1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Intel PCIC or compatible Controller driver
|
|
|
|
* May be built using LKM to make a loadable module.
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Copyright (c) 1995 Andrew McRae. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1996-06-14 11:02:28 +00:00
|
|
|
/*
|
|
|
|
* pcic98 : PC9801 original PCMCIA controller code for NS/A,Ne,NX/C,NR/L.
|
|
|
|
* by Noriyuki Hosobuchi <yj8n-hsbc@asahi-net.or.jp>
|
|
|
|
*/
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
1997-01-13 21:51:13 +00:00
|
|
|
#include <sys/select.h>
|
1997-06-01 05:04:39 +00:00
|
|
|
#include <sys/interrupt.h>
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
#include <machine/clock.h>
|
|
|
|
|
1997-01-14 16:29:05 +00:00
|
|
|
#include <i386/isa/icu.h>
|
|
|
|
#include <i386/isa/isa_device.h>
|
|
|
|
|
1995-11-21 08:27:00 +00:00
|
|
|
#include <pccard/i82365.h>
|
1997-07-21 16:55:28 +00:00
|
|
|
#ifdef PC98
|
|
|
|
#include <pccard/pcic98reg.h>
|
|
|
|
#endif
|
1997-01-13 21:51:13 +00:00
|
|
|
|
1997-11-18 21:04:01 +00:00
|
|
|
#include <pccard/cardinfo.h>
|
1995-12-16 00:11:11 +00:00
|
|
|
#include <pccard/driver.h>
|
1995-11-21 08:27:00 +00:00
|
|
|
#include <pccard/slot.h>
|
1995-10-21 00:55:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Prototypes for interrupt handler.
|
|
|
|
*/
|
1995-11-09 20:44:36 +00:00
|
|
|
static void pcicintr __P((int unit));
|
|
|
|
static int pcic_ioctl __P((struct slot *, int, caddr_t));
|
|
|
|
static int pcic_power __P((struct slot *));
|
1995-11-13 08:39:44 +00:00
|
|
|
static timeout_t pcic_reset;
|
1997-01-08 00:22:58 +00:00
|
|
|
static void pcic_resume(struct slot *);
|
1995-11-09 20:44:36 +00:00
|
|
|
static void pcic_disable __P((struct slot *));
|
|
|
|
static void pcic_mapirq __P((struct slot *, int));
|
|
|
|
static timeout_t pcictimeout;
|
1997-09-21 22:02:25 +00:00
|
|
|
static struct callout_handle pcictimeout_ch
|
|
|
|
= CALLOUT_HANDLE_INITIALIZER(&pcictimeout_ch);
|
1996-04-06 01:16:19 +00:00
|
|
|
#ifdef LKM
|
1995-12-16 00:11:11 +00:00
|
|
|
static int pcic_handle __P((struct lkm_table *lkmtp, int cmd));
|
1996-04-06 01:16:19 +00:00
|
|
|
#endif
|
1995-11-09 20:44:36 +00:00
|
|
|
static int pcic_memory(struct slot *, int);
|
|
|
|
static int pcic_io(struct slot *, int);
|
1997-01-11 17:54:57 +00:00
|
|
|
static u_int build_freelist(u_int);
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Per-slot data table.
|
|
|
|
*/
|
1995-11-09 20:44:36 +00:00
|
|
|
static struct pcic_slot {
|
1997-10-26 04:36:24 +00:00
|
|
|
int slotnum; /* My slot number */
|
1995-08-24 08:56:20 +00:00
|
|
|
int index; /* Index register */
|
|
|
|
int data; /* Data register */
|
|
|
|
int offset; /* Offset value for index */
|
1995-11-09 20:44:36 +00:00
|
|
|
char controller; /* Device type */
|
|
|
|
char revision; /* Device Revision */
|
1997-10-26 04:36:24 +00:00
|
|
|
struct slot *slt; /* Back ptr to slot */
|
|
|
|
u_char (*getb)(struct pcic_slot *, int);
|
|
|
|
void (*putb)(struct pcic_slot *, int, u_char);
|
1997-04-20 07:21:12 +00:00
|
|
|
u_char *regs; /* Pointer to regs in mem */
|
1995-11-09 20:44:36 +00:00
|
|
|
} pcic_slots[PCIC_MAX_SLOTS];
|
|
|
|
|
|
|
|
static int pcic_irq;
|
|
|
|
static unsigned pcic_imask;
|
|
|
|
static struct slot_ctrl cinfo;
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Internal inline functions for accessing the PCIC.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Read a register from the PCIC.
|
|
|
|
*/
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline unsigned char
|
1997-10-06 02:46:38 +00:00
|
|
|
getb1(struct pcic_slot *sp, int reg)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-06 02:46:38 +00:00
|
|
|
outb(sp->index, sp->offset + reg);
|
|
|
|
return inb(sp->data);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
|
|
|
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline unsigned char
|
1997-10-06 02:46:38 +00:00
|
|
|
getb2(struct pcic_slot *sp, int reg)
|
1997-04-20 07:21:12 +00:00
|
|
|
{
|
|
|
|
return (sp->regs[reg]);
|
|
|
|
}
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Write a register on the PCIC
|
|
|
|
*/
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline void
|
1997-10-06 02:46:38 +00:00
|
|
|
putb1(struct pcic_slot *sp, int reg, unsigned char val)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-06 02:46:38 +00:00
|
|
|
outb(sp->index, sp->offset + reg);
|
|
|
|
outb(sp->data, val);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1997-01-08 00:22:58 +00:00
|
|
|
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline void
|
1997-10-06 02:46:38 +00:00
|
|
|
putb2(struct pcic_slot *sp, int reg, unsigned char val)
|
1997-04-20 07:21:12 +00:00
|
|
|
{
|
|
|
|
sp->regs[reg] = val;
|
|
|
|
}
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Clear bit(s) of a register.
|
|
|
|
*/
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline void
|
1995-08-24 08:56:20 +00:00
|
|
|
clrb(struct pcic_slot *sp, int reg, unsigned char mask)
|
|
|
|
{
|
1997-10-06 02:46:38 +00:00
|
|
|
sp->putb(sp, reg, sp->getb(sp, reg) & ~mask);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1997-01-08 00:22:58 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Set bit(s) of a register
|
|
|
|
*/
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline void
|
1995-08-24 08:56:20 +00:00
|
|
|
setb(struct pcic_slot *sp, int reg, unsigned char mask)
|
|
|
|
{
|
1997-10-06 02:46:38 +00:00
|
|
|
sp->putb(sp, reg, sp->getb(sp, reg) | mask);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write a 16 bit value to 2 adjacent PCIC registers
|
|
|
|
*/
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline void
|
1997-10-06 03:17:36 +00:00
|
|
|
putw(struct pcic_slot *sp, int reg, unsigned short word)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-06 02:46:38 +00:00
|
|
|
sp->putb(sp, reg, word & 0xFF);
|
|
|
|
sp->putb(sp, reg + 1, (word >> 8) & 0xff);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loadable kernel module interface.
|
|
|
|
*/
|
|
|
|
#ifdef LKM
|
|
|
|
/*
|
|
|
|
* This defines the lkm_misc module use by modload
|
|
|
|
* to define the module name.
|
|
|
|
*/
|
1995-11-14 07:35:57 +00:00
|
|
|
MOD_MISC(pcic);
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Module handler that processes loads and unloads.
|
|
|
|
* Once the module is loaded, the probe routine
|
|
|
|
* is called to install the slots (if any).
|
|
|
|
*/
|
|
|
|
static int
|
1995-11-09 20:44:36 +00:00
|
|
|
pcic_handle(struct lkm_table *lkmtp, int cmd)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1995-11-09 20:44:36 +00:00
|
|
|
int err = 0; /* default = success*/
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1997-11-04 17:50:23 +00:00
|
|
|
switch(cmd) {
|
1995-08-24 08:56:20 +00:00
|
|
|
case LKM_E_LOAD:
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't load twice! (lkmexists() is exported by kern_lkm.c)
|
|
|
|
*/
|
1997-12-02 21:31:35 +00:00
|
|
|
if (lkmexists(lkmtp))
|
1997-11-04 17:50:23 +00:00
|
|
|
return(EEXIST);
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Call the probe routine to find the slots. If
|
|
|
|
* no slots exist, then don't bother loading the module.
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
if (pcic_probe() == 0)
|
|
|
|
return(ENODEV);
|
|
|
|
break; /* Success*/
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Attempt to unload the slot driver.
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
case LKM_E_UNLOAD:
|
|
|
|
printf("Unloading PCIC driver\n");
|
1995-11-13 08:39:44 +00:00
|
|
|
err = pcic_unload(lkmtp, cmd);
|
1995-08-24 08:56:20 +00:00
|
|
|
break; /* Success*/
|
|
|
|
|
|
|
|
default: /* we only understand load/unload*/
|
|
|
|
err = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1997-11-04 17:50:23 +00:00
|
|
|
return(err);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* External entry point; should generally match name of .o file. The
|
|
|
|
* arguments are always the same for all loaded modules. The "load",
|
|
|
|
* "unload", and "stat" functions in "DISPATCH" will be called under
|
1995-11-13 08:39:44 +00:00
|
|
|
* their respective circumstances unless their value is "lkm_nullcmd".
|
|
|
|
* If called, they are called with the same arguments (cmd is included to
|
1995-08-24 08:56:20 +00:00
|
|
|
* allow the use of a single function, ver is included for version
|
|
|
|
* matching between modules and the kernel loader for the modules).
|
|
|
|
*
|
|
|
|
* Since we expect to link in the kernel and add external symbols to
|
|
|
|
* the kernel symbol name space in a future version, generally all
|
|
|
|
* functions used in the implementation of a particular module should
|
|
|
|
* be static unless they are expected to be seen in other modules or
|
|
|
|
* to resolve unresolved symbols alread existing in the kernel (the
|
|
|
|
* second case is not likely to ever occur).
|
|
|
|
*
|
|
|
|
* The entry point should return 0 unless it is refusing load (in which
|
|
|
|
* case it should return an errno from errno.h).
|
|
|
|
*/
|
|
|
|
int
|
1995-11-09 20:44:36 +00:00
|
|
|
pcic_mod(struct lkm_table *lkmtp, int cmd, int ver)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-04-06 11:14:13 +00:00
|
|
|
MOD_DISPATCH(pcic, lkmtp, cmd, ver,
|
|
|
|
pcic_handle, pcic_handle, lkm_nullcmd);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* pcic_unload - Called when unloading a LKM.
|
|
|
|
* Disables interrupts and resets PCIC.
|
|
|
|
*/
|
|
|
|
static int
|
1995-11-13 08:39:44 +00:00
|
|
|
pcic_unload(struct lkm_table *lkmtp, int cmd)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1995-11-09 20:44:36 +00:00
|
|
|
int slot;
|
|
|
|
struct pcic_slot *sp = pcic_slots;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1997-12-02 21:31:35 +00:00
|
|
|
untimeout(pcictimeout, 0, pcictimeout_ch);
|
1995-11-09 20:44:36 +00:00
|
|
|
if (pcic_irq) {
|
|
|
|
for (slot = 0; slot < PCIC_MAX_SLOTS; slot++, sp++) {
|
1997-10-26 04:36:24 +00:00
|
|
|
if (sp->slt)
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->putb(sp, PCIC_STAT_INT, 0);
|
1995-10-21 00:55:36 +00:00
|
|
|
}
|
1995-08-24 08:56:20 +00:00
|
|
|
unregister_intr(pcic_irq, pcicintr);
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
1995-08-24 08:56:20 +00:00
|
|
|
pccard_remove_controller(&cinfo);
|
|
|
|
return(0);
|
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
|
|
|
#endif /* LKM */
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
static void
|
1997-10-28 20:58:53 +00:00
|
|
|
pcic_dump_attributes(unsigned char *scratch, int maxlen)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
|
|
|
int i,j,k;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (scratch[i] != 0xff && i < maxlen) {
|
1995-11-09 20:44:36 +00:00
|
|
|
unsigned char link = scratch[i+2];
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Dump attribute memory
|
|
|
|
*/
|
|
|
|
if (scratch[i]) {
|
1997-10-28 20:58:53 +00:00
|
|
|
printf("[%02x] ", i);
|
1995-11-09 20:44:36 +00:00
|
|
|
for (j = 0; j < 2 * link + 4 && j < 128; j += 2)
|
1997-10-28 20:58:53 +00:00
|
|
|
printf("%02x ", scratch[j + i]);
|
|
|
|
printf("\n");
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
i += 4 + 2 * link;
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-03-19 16:19:16 +00:00
|
|
|
static void
|
|
|
|
nullfunc(int unit)
|
|
|
|
{
|
|
|
|
/* empty */
|
|
|
|
}
|
|
|
|
|
1997-01-11 17:54:57 +00:00
|
|
|
static u_int
|
|
|
|
build_freelist(u_int pcic_mask)
|
|
|
|
{
|
|
|
|
int irq;
|
|
|
|
u_int mask, freemask;
|
|
|
|
|
|
|
|
/* No free IRQs (yet). */
|
|
|
|
freemask = 0;
|
|
|
|
|
|
|
|
/* Walk through all of the IRQ's and find any that aren't allocated. */
|
1997-10-06 02:54:19 +00:00
|
|
|
for (irq = 1; irq < ICU_LEN; irq++) {
|
1997-01-11 17:54:57 +00:00
|
|
|
/*
|
|
|
|
* If the PCIC controller can't generate it, don't
|
|
|
|
* bother checking to see if it it's free.
|
|
|
|
*/
|
|
|
|
mask = 1 << irq;
|
|
|
|
if (!(mask & pcic_mask)) continue;
|
|
|
|
|
|
|
|
/* See if the IRQ is free. */
|
|
|
|
if (register_intr(irq, 0, 0, nullfunc, NULL, irq) == 0) {
|
|
|
|
/* Give it back, but add it to the mask */
|
|
|
|
INTRMASK(freemask, mask);
|
|
|
|
unregister_intr(irq, nullfunc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef PCIC_DEBUG
|
|
|
|
printf("Freelist of IRQ's <0x%x>\n", freemask);
|
|
|
|
#endif
|
|
|
|
return freemask;
|
|
|
|
}
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* entry point from main code to map/unmap memory context.
|
|
|
|
*/
|
|
|
|
static int
|
1997-10-26 04:36:24 +00:00
|
|
|
pcic_memory(struct slot *slt, int win)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pcic_slot *sp = slt->cdata;
|
|
|
|
struct mem_desc *mp = &slt->mem[win];
|
1995-11-09 20:44:36 +00:00
|
|
|
int reg = mp->window * PCIC_MEMSIZE + PCIC_MEMBASE;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1996-06-14 11:02:28 +00:00
|
|
|
#ifdef PC98
|
1997-10-28 20:50:58 +00:00
|
|
|
if (sp->controller == PCIC_PC98) {
|
|
|
|
if (mp->flags & MDF_ACTIVE) {
|
1996-06-14 11:02:28 +00:00
|
|
|
/* slot = 0, window = 0, sys_addr = 0xda000, length = 8KB */
|
|
|
|
unsigned char x;
|
|
|
|
|
1997-10-28 20:50:58 +00:00
|
|
|
if ((unsigned long)mp->start != 0xda000) {
|
1996-06-14 11:02:28 +00:00
|
|
|
printf("sys_addr must be 0xda000. requested address = 0x%x\n",
|
|
|
|
mp->start);
|
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* omajinai ??? */
|
|
|
|
outb(PCIC98_REG0, 0);
|
|
|
|
x = inb(PCIC98_REG1);
|
|
|
|
x &= 0xfc;
|
|
|
|
x |= 0x02;
|
|
|
|
outb(PCIC98_REG1, x);
|
|
|
|
|
|
|
|
outw(PCIC98_REG_PAGOFS, 0);
|
|
|
|
|
1997-10-28 20:50:58 +00:00
|
|
|
if (mp->flags & MDF_ATTR) {
|
1996-06-14 11:02:28 +00:00
|
|
|
outb(PCIC98_REG6, inb(PCIC98_REG6) | PCIC98_ATTRMEM);
|
|
|
|
}else{
|
|
|
|
outb(PCIC98_REG6, inb(PCIC98_REG6) & (~PCIC98_ATTRMEM));
|
|
|
|
}
|
|
|
|
|
|
|
|
outb(PCIC98_REG_WINSEL, PCIC98_MAPWIN);
|
|
|
|
|
|
|
|
#if 0
|
1997-10-28 20:50:58 +00:00
|
|
|
if (mp->flags & MDF_16BITS == 1) { /* 16bit */
|
1996-06-14 11:02:28 +00:00
|
|
|
outb(PCIC98_REG2, inb(PCIC98_REG2) & (~PCIC98_8BIT));
|
|
|
|
}else{ /* 8bit */
|
|
|
|
outb(PCIC98_REG2, inb(PCIC98_REG2) | PCIC98_8BIT);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}else{
|
|
|
|
outb(PCIC98_REG_WINSEL, PCIC98_UNMAPWIN);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* PC98 */
|
|
|
|
|
1997-01-08 00:22:58 +00:00
|
|
|
if (mp->flags & MDF_ACTIVE) {
|
1995-08-24 08:56:20 +00:00
|
|
|
unsigned long sys_addr = (unsigned long)mp->start >> 12;
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Write the addresses, card offsets and length.
|
|
|
|
* The values are all stored as the upper 12 bits of the
|
|
|
|
* 24 bit address i.e everything is allocated as 4 Kb chunks.
|
|
|
|
*/
|
1997-10-06 03:17:36 +00:00
|
|
|
putw(sp, reg, sys_addr & 0xFFF);
|
|
|
|
putw(sp, reg+2, (sys_addr + (mp->size >> 12) - 1) & 0xFFF);
|
|
|
|
putw(sp, reg+4, ((mp->card >> 12) - sys_addr) & 0x3FFF);
|
1995-10-10 09:52:55 +00:00
|
|
|
#if 0
|
|
|
|
printf("card offs = card_adr = 0x%x 0x%x, sys_addr = 0x%x\n",
|
|
|
|
mp->card, ((mp->card >> 12) - sys_addr) & 0x3FFF,
|
|
|
|
sys_addr);
|
1995-08-24 08:56:20 +00:00
|
|
|
#endif
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Each 16 bit register has some flags in the upper bits.
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
if (mp->flags & MDF_16BITS)
|
1995-11-09 20:44:36 +00:00
|
|
|
setb(sp, reg+1, PCIC_DATA16);
|
1995-08-24 08:56:20 +00:00
|
|
|
if (mp->flags & MDF_ZEROWS)
|
1995-11-09 20:44:36 +00:00
|
|
|
setb(sp, reg+1, PCIC_ZEROWS);
|
1995-08-24 08:56:20 +00:00
|
|
|
if (mp->flags & MDF_WS0)
|
1995-11-09 20:44:36 +00:00
|
|
|
setb(sp, reg+3, PCIC_MW0);
|
1995-08-24 08:56:20 +00:00
|
|
|
if (mp->flags & MDF_WS1)
|
1995-11-09 20:44:36 +00:00
|
|
|
setb(sp, reg+3, PCIC_MW1);
|
1995-08-24 08:56:20 +00:00
|
|
|
if (mp->flags & MDF_ATTR)
|
1995-11-09 20:44:36 +00:00
|
|
|
setb(sp, reg+5, PCIC_REG);
|
1995-08-24 08:56:20 +00:00
|
|
|
if (mp->flags & MDF_WP)
|
1995-11-09 20:44:36 +00:00
|
|
|
setb(sp, reg+5, PCIC_WP);
|
1995-08-24 08:56:20 +00:00
|
|
|
#if 0
|
|
|
|
printf("Slot number %d, reg 0x%x, offs 0x%x\n",
|
1997-10-26 04:36:24 +00:00
|
|
|
sp->slotnum, reg, sp->offset);
|
1995-08-24 08:56:20 +00:00
|
|
|
printf("Map window to sys addr 0x%x for %d bytes, card 0x%x\n",
|
|
|
|
mp->start, mp->size, mp->card);
|
|
|
|
printf("regs are: 0x%02x%02x 0x%02x%02x 0x%02x%02x flags 0x%x\n",
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->getb(sp, reg), sp->getb(sp, reg+1),
|
|
|
|
sp->getb(sp, reg+2), sp->getb(sp, reg+3),
|
|
|
|
sp->getb(sp, reg+4), sp->getb(sp, reg+5),
|
1995-08-24 08:56:20 +00:00
|
|
|
mp->flags);
|
|
|
|
#endif
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Enable the memory window. By experiment, we need a delay.
|
|
|
|
*/
|
1997-10-06 03:17:36 +00:00
|
|
|
setb(sp, PCIC_ADDRWINE, (1<<win) | PCIC_MEMCS16);
|
1995-08-24 08:56:20 +00:00
|
|
|
DELAY(50);
|
1997-01-08 00:22:58 +00:00
|
|
|
} else {
|
1995-08-24 08:56:20 +00:00
|
|
|
#if 0
|
|
|
|
printf("Unmapping window %d\n", win);
|
|
|
|
#endif
|
1997-10-06 03:17:36 +00:00
|
|
|
clrb(sp, PCIC_ADDRWINE, 1<<win);
|
|
|
|
putw(sp, reg, 0);
|
|
|
|
putw(sp, reg+2, 0);
|
|
|
|
putw(sp, reg+4, 0);
|
1997-01-08 00:22:58 +00:00
|
|
|
}
|
1995-08-24 08:56:20 +00:00
|
|
|
return(0);
|
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* pcic_io - map or unmap I/O context
|
|
|
|
*/
|
|
|
|
static int
|
1997-10-26 04:36:24 +00:00
|
|
|
pcic_io(struct slot *slt, int win)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1995-11-09 20:44:36 +00:00
|
|
|
int mask, reg;
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pcic_slot *sp = slt->cdata;
|
|
|
|
struct io_desc *ip = &slt->io[win];
|
1996-06-14 11:02:28 +00:00
|
|
|
#ifdef PC98
|
1997-10-28 20:50:58 +00:00
|
|
|
if (sp->controller == PCIC_PC98) {
|
1996-06-14 11:02:28 +00:00
|
|
|
unsigned char x;
|
|
|
|
|
|
|
|
#if 0
|
1997-10-28 20:50:58 +00:00
|
|
|
if (win =! 0) {
|
1996-06-14 11:02:28 +00:00
|
|
|
printf("pcic98:Illegal PCIC I/O window request(%d)!", win);
|
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
#endif
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1997-10-28 20:50:58 +00:00
|
|
|
if (ip->flags & IODF_ACTIVE) {
|
1996-06-14 11:02:28 +00:00
|
|
|
unsigned short base;
|
|
|
|
|
|
|
|
x = inb(PCIC98_REG2) & 0x0f;
|
|
|
|
if (! (ip->flags & IODF_16BIT))
|
|
|
|
x |= PCIC98_8BIT;
|
|
|
|
|
|
|
|
if (ip->size > 16) /* 128bytes mapping */
|
|
|
|
x |= PCIC98_MAP128;
|
|
|
|
|
|
|
|
x |= PCIC98_IOMEMORY;
|
|
|
|
outb(PCIC98_REG2, x);
|
|
|
|
|
|
|
|
base = 0x80d0;
|
|
|
|
outw(PCIC98_REG4, base); /* 98side IO base */
|
|
|
|
outw(PCIC98_REG5, ip->start); /* card side IO base */
|
|
|
|
|
|
|
|
#ifdef PCIC_DEBUG
|
|
|
|
printf("pcic98: IO mapped 0x%04x(98) -> 0x%04x(Card) and width %d bytes\n",
|
|
|
|
base, ip->start, ip->size);
|
|
|
|
#endif
|
|
|
|
ip->start = base;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
outb(PCIC98_REG2, inb(PCIC98_REG2) & (~PCIC98_IOMEMORY));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
1996-02-21 23:20:21 +00:00
|
|
|
switch (win) {
|
|
|
|
case 0:
|
1995-08-24 08:56:20 +00:00
|
|
|
mask = PCIC_IO0_EN;
|
|
|
|
reg = PCIC_IO0;
|
1996-02-21 23:20:21 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
1995-08-24 08:56:20 +00:00
|
|
|
mask = PCIC_IO1_EN;
|
|
|
|
reg = PCIC_IO1;
|
1996-02-21 23:20:21 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
panic("Illegal PCIC I/O window request!");
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
|
|
|
if (ip->flags & IODF_ACTIVE) {
|
1996-02-21 23:20:21 +00:00
|
|
|
unsigned char x, ioctlv;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1996-02-21 23:20:21 +00:00
|
|
|
#ifdef PCIC_DEBUG
|
|
|
|
printf("Map I/O 0x%x (size 0x%x) on Window %d\n", ip->start, ip->size, win);
|
|
|
|
#endif /* PCIC_DEBUG */
|
1997-10-06 03:17:36 +00:00
|
|
|
putw(sp, reg, ip->start);
|
|
|
|
putw(sp, reg+2, ip->start+ip->size-1);
|
1996-02-21 23:20:21 +00:00
|
|
|
x = 0;
|
1995-08-24 08:56:20 +00:00
|
|
|
if (ip->flags & IODF_ZEROWS)
|
1996-02-21 23:20:21 +00:00
|
|
|
x |= PCIC_IO_0WS;
|
1995-08-24 08:56:20 +00:00
|
|
|
if (ip->flags & IODF_WS)
|
|
|
|
x |= PCIC_IO_WS;
|
|
|
|
if (ip->flags & IODF_CS16)
|
|
|
|
x |= PCIC_IO_CS16;
|
1996-02-21 23:20:21 +00:00
|
|
|
if (ip->flags & IODF_16BIT)
|
1995-08-24 08:56:20 +00:00
|
|
|
x |= PCIC_IO_16BIT;
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Extract the current flags and merge with new flags.
|
|
|
|
* Flags for window 0 in lower nybble, and in upper nybble
|
|
|
|
* for window 1.
|
|
|
|
*/
|
1997-04-20 07:21:12 +00:00
|
|
|
ioctlv = sp->getb(sp, PCIC_IOCTL);
|
1996-02-21 23:20:21 +00:00
|
|
|
DELAY(100);
|
|
|
|
switch (win) {
|
|
|
|
case 0:
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->putb(sp, PCIC_IOCTL, x | (ioctlv & 0xf0));
|
1996-02-21 23:20:21 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->putb(sp, PCIC_IOCTL, (x << 4) | (ioctlv & 0xf));
|
1996-02-21 23:20:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
DELAY(100);
|
1997-10-06 03:17:36 +00:00
|
|
|
setb(sp, PCIC_ADDRWINE, mask);
|
1995-08-24 08:56:20 +00:00
|
|
|
DELAY(100);
|
1995-11-09 20:44:36 +00:00
|
|
|
} else {
|
1997-10-06 03:17:36 +00:00
|
|
|
clrb(sp, PCIC_ADDRWINE, mask);
|
1996-02-21 23:20:21 +00:00
|
|
|
DELAY(100);
|
1997-10-06 03:17:36 +00:00
|
|
|
putw(sp, reg, 0);
|
|
|
|
putw(sp, reg + 2, 0);
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
1995-08-24 08:56:20 +00:00
|
|
|
return(0);
|
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Look for an Intel PCIC (or compatible).
|
|
|
|
* For each available slot, allocate a PC-CARD slot.
|
|
|
|
*/
|
|
|
|
|
1996-02-21 23:20:21 +00:00
|
|
|
/*
|
|
|
|
* VLSI 82C146 has incompatibilities about the I/O address
|
1997-01-08 00:22:58 +00:00
|
|
|
* of slot 1. Assume it's the only PCIC whose vendor ID is 0x84,
|
|
|
|
* contact Nate Williams <nate@FreeBSD.org> if incorrect.
|
1996-02-21 23:20:21 +00:00
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
int
|
1997-01-08 00:22:58 +00:00
|
|
|
pcic_probe(void)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
int slotnum, i, validslots = 0;
|
1997-01-11 17:54:57 +00:00
|
|
|
u_int free_irqs;
|
1997-10-26 04:36:24 +00:00
|
|
|
struct slot *slt;
|
1995-11-09 20:44:36 +00:00
|
|
|
struct pcic_slot *sp;
|
|
|
|
unsigned char c;
|
1997-02-21 05:46:57 +00:00
|
|
|
static int maybe_vlsi = 0;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1997-01-11 17:54:57 +00:00
|
|
|
/* Determine the list of free interrupts */
|
|
|
|
free_irqs = build_freelist(PCIC_INT_MASK_ALLOWED);
|
|
|
|
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Initialise controller information structure.
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
cinfo.mapmem = pcic_memory;
|
|
|
|
cinfo.mapio = pcic_io;
|
|
|
|
cinfo.ioctl = pcic_ioctl;
|
|
|
|
cinfo.power = pcic_power;
|
|
|
|
cinfo.mapirq = pcic_mapirq;
|
|
|
|
cinfo.reset = pcic_reset;
|
|
|
|
cinfo.disable = pcic_disable;
|
1997-01-08 00:22:58 +00:00
|
|
|
cinfo.resume = pcic_resume;
|
1995-08-24 08:56:20 +00:00
|
|
|
cinfo.maxmem = PCIC_MEM_WIN;
|
|
|
|
cinfo.maxio = PCIC_IO_WIN;
|
1997-01-11 17:54:57 +00:00
|
|
|
cinfo.irqs = free_irqs;
|
1997-01-11 18:32:27 +00:00
|
|
|
cinfo.imask = &pcic_imask;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
#ifdef LKM
|
|
|
|
bzero(pcic_slots, sizeof(pcic_slots));
|
|
|
|
#endif
|
1995-11-09 20:44:36 +00:00
|
|
|
sp = pcic_slots;
|
1997-10-26 04:36:24 +00:00
|
|
|
for (slotnum = 0; slotnum < PCIC_MAX_SLOTS; slotnum++, sp++) {
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Initialise the PCIC slot table.
|
|
|
|
*/
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->getb = getb1;
|
|
|
|
sp->putb = putb1;
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slotnum < 4) {
|
1995-11-09 20:44:36 +00:00
|
|
|
sp->index = PCIC_INDEX_0;
|
|
|
|
sp->data = PCIC_DATA_0;
|
1997-10-26 04:36:24 +00:00
|
|
|
sp->offset = slotnum * PCIC_SLOT_SIZE;
|
1995-11-09 20:44:36 +00:00
|
|
|
} else {
|
|
|
|
sp->index = PCIC_INDEX_1;
|
|
|
|
sp->data = PCIC_DATA_1;
|
1997-10-26 04:36:24 +00:00
|
|
|
sp->offset = (slotnum - 4) * PCIC_SLOT_SIZE;
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1997-02-18 19:20:52 +00:00
|
|
|
/*
|
|
|
|
* XXX - Screwed up slot 1 on the VLSI chips. According to
|
|
|
|
* the Linux PCMCIA code from David Hinds, working chipsets
|
|
|
|
* return 0x84 from their (correct) ID ports, while the broken
|
|
|
|
* ones would need to be probed at the new offset we set after
|
|
|
|
* we assume it's broken.
|
|
|
|
*/
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slotnum == 1 && maybe_vlsi && sp->getb(sp, PCIC_ID_REV) != 0x84) {
|
1997-01-08 00:22:58 +00:00
|
|
|
sp->index += 4;
|
|
|
|
sp->data += 4;
|
|
|
|
sp->offset = PCIC_SLOT_SIZE << 1;
|
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* see if there's a PCMCIA controller here
|
|
|
|
* Intel PCMCIA controllers use 0x82 and 0x83
|
|
|
|
* IBM clone chips use 0x88 and 0x89, apparently
|
|
|
|
*/
|
1997-10-06 02:46:38 +00:00
|
|
|
c = sp->getb(sp, PCIC_ID_REV);
|
1995-11-09 20:44:36 +00:00
|
|
|
sp->revision = -1;
|
|
|
|
switch(c) {
|
|
|
|
/*
|
|
|
|
* 82365 or clones.
|
|
|
|
*/
|
|
|
|
case 0x82:
|
|
|
|
case 0x83:
|
|
|
|
sp->controller = PCIC_I82365;
|
|
|
|
sp->revision = c & 1;
|
|
|
|
/*
|
|
|
|
* Now check for VADEM chips.
|
|
|
|
*/
|
|
|
|
outb(sp->index, 0x0E);
|
|
|
|
outb(sp->index, 0x37);
|
|
|
|
setb(sp, 0x3A, 0x40);
|
1997-10-06 02:46:38 +00:00
|
|
|
c = sp->getb(sp, PCIC_ID_REV);
|
1995-11-09 20:44:36 +00:00
|
|
|
if (c & 0x08) {
|
|
|
|
sp->controller = ((sp->revision = c & 7) == 4) ?
|
|
|
|
PCIC_VG469 : PCIC_VG468 ;
|
|
|
|
clrb(sp, 0x3A, 0x40);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1996-02-21 23:20:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for RICOH RF5C396 PCMCIA Controller
|
|
|
|
*/
|
1997-10-06 02:46:38 +00:00
|
|
|
c = sp->getb(sp, 0x3a);
|
1996-02-21 23:20:21 +00:00
|
|
|
if (c == 0xb2) {
|
|
|
|
sp->controller = PCIC_RF5C396;
|
|
|
|
}
|
|
|
|
|
1995-11-09 20:44:36 +00:00
|
|
|
break;
|
|
|
|
/*
|
|
|
|
* VLSI chips.
|
|
|
|
*/
|
|
|
|
case 0x84:
|
|
|
|
sp->controller = PCIC_VLSI;
|
1997-02-21 05:46:57 +00:00
|
|
|
maybe_vlsi = 1;
|
1995-11-09 20:44:36 +00:00
|
|
|
break;
|
|
|
|
case 0x88:
|
|
|
|
case 0x89:
|
|
|
|
sp->controller = PCIC_IBM;
|
|
|
|
sp->revision = c & 1;
|
|
|
|
break;
|
1996-02-21 23:20:21 +00:00
|
|
|
case 0x8a:
|
|
|
|
sp->controller = PCIC_IBM_KING;
|
|
|
|
sp->revision = c & 1;
|
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
default:
|
|
|
|
continue;
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Check for Cirrus logic chips.
|
|
|
|
*/
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->putb(sp, 0x1F, 0);
|
|
|
|
c = sp->getb(sp, 0x1F);
|
1995-11-09 20:44:36 +00:00
|
|
|
if ((c & 0xC0) == 0xC0) {
|
1997-04-20 07:21:12 +00:00
|
|
|
c = sp->getb(sp, 0x1F);
|
1995-11-09 20:44:36 +00:00
|
|
|
if ((c & 0xC0) == 0) {
|
|
|
|
if (c & 0x20)
|
|
|
|
sp->controller = PCIC_PD672X;
|
|
|
|
else
|
|
|
|
sp->controller = PCIC_PD6710;
|
|
|
|
sp->revision = 8 - ((c & 0x1F) >> 2);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
switch(sp->controller) {
|
|
|
|
case PCIC_I82365:
|
|
|
|
cinfo.name = "Intel 82365";
|
|
|
|
break;
|
|
|
|
case PCIC_IBM:
|
|
|
|
cinfo.name = "IBM PCIC";
|
|
|
|
break;
|
1996-02-21 23:20:21 +00:00
|
|
|
case PCIC_IBM_KING:
|
|
|
|
cinfo.name = "IBM KING PCMCIA Controller";
|
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
case PCIC_PD672X:
|
|
|
|
cinfo.name = "Cirrus Logic PD672X";
|
|
|
|
break;
|
|
|
|
case PCIC_PD6710:
|
|
|
|
cinfo.name = "Cirrus Logic PD6710";
|
|
|
|
break;
|
|
|
|
case PCIC_VG468:
|
|
|
|
cinfo.name = "Vadem 468";
|
|
|
|
break;
|
|
|
|
case PCIC_VG469:
|
|
|
|
cinfo.name = "Vadem 469";
|
|
|
|
break;
|
1996-02-21 23:20:21 +00:00
|
|
|
case PCIC_RF5C396:
|
|
|
|
cinfo.name = "Ricoh RF5C396";
|
|
|
|
break;
|
|
|
|
case PCIC_VLSI:
|
|
|
|
cinfo.name = "VLSI 82C146";
|
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
default:
|
|
|
|
cinfo.name = "Unknown!";
|
|
|
|
break;
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* OK it seems we have a PCIC or lookalike.
|
|
|
|
* Allocate a slot and initialise the data structures.
|
|
|
|
*/
|
|
|
|
validslots++;
|
1997-10-26 04:36:24 +00:00
|
|
|
sp->slotnum = slotnum;
|
|
|
|
slt = pccard_alloc_slot(&cinfo);
|
|
|
|
if (slt == 0)
|
1995-11-09 20:44:36 +00:00
|
|
|
continue;
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->cdata = sp;
|
|
|
|
sp->slt = slt;
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* If we haven't allocated an interrupt for the controller,
|
|
|
|
* then attempt to get one.
|
|
|
|
*/
|
|
|
|
if (pcic_irq == 0) {
|
1997-07-21 16:50:46 +00:00
|
|
|
pcic_imask = soft_imask;
|
1997-01-11 17:54:57 +00:00
|
|
|
pcic_irq = pccard_alloc_intr(free_irqs,
|
1997-11-15 14:20:31 +00:00
|
|
|
pcicintr, 0, &pcic_imask, NULL);
|
1995-11-09 20:44:36 +00:00
|
|
|
if (pcic_irq < 0)
|
|
|
|
printf("pcic: failed to allocate IRQ\n");
|
1996-04-23 16:03:08 +00:00
|
|
|
else
|
|
|
|
printf("pcic: controller irq %d\n", pcic_irq);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1997-10-06 03:17:36 +00:00
|
|
|
/*
|
|
|
|
* Modem cards send the speaker audio (dialing noises)
|
|
|
|
* to the host's speaker. Cirrus Logic PCIC chips must
|
|
|
|
* enable this. There is also a Low Power Dynamic Mode bit
|
|
|
|
* that claims to reduce power consumption by 30%, so
|
|
|
|
* enable it and hope for the best.
|
|
|
|
*/
|
|
|
|
if (sp->controller == PCIC_PD672X) {
|
|
|
|
setb(sp, PCIC_MISC1, PCIC_SPKR_EN);
|
|
|
|
setb(sp, PCIC_MISC2, PCIC_LPDM_EN);
|
1997-10-06 04:02:42 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Check for a card in this slot.
|
|
|
|
*/
|
1997-10-06 03:17:36 +00:00
|
|
|
setb(sp, PCIC_POWER, PCIC_PCPWRE| PCIC_DISRST);
|
1997-10-06 02:46:38 +00:00
|
|
|
if ((sp->getb(sp, PCIC_STATUS) & PCIC_CD) != PCIC_CD) {
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->laststate = slt->state = empty;
|
1995-11-09 20:44:36 +00:00
|
|
|
} else {
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->laststate = slt->state = filled;
|
|
|
|
pccard_event(sp->slt, card_inserted);
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Assign IRQ for slot changes
|
|
|
|
*/
|
|
|
|
if (pcic_irq > 0)
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->putb(sp, PCIC_STAT_INT, (pcic_irq << 4) | 0xF);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1996-06-14 11:02:28 +00:00
|
|
|
#ifdef PC98
|
1997-10-28 20:50:58 +00:00
|
|
|
if (validslots == 0) {
|
1997-10-26 04:36:24 +00:00
|
|
|
sp = pcic_slots;
|
|
|
|
slotnum = 0;
|
1997-10-28 20:50:58 +00:00
|
|
|
if (inb(PCIC98_REG0) != 0xff) {
|
1996-06-14 11:02:28 +00:00
|
|
|
sp->controller = PCIC_PC98;
|
|
|
|
sp->revision = 0;
|
|
|
|
cinfo.name = "PC98 Original";
|
|
|
|
cinfo.maxmem = 1;
|
|
|
|
cinfo.maxio = 1;
|
|
|
|
/* cinfo.irqs = PCIC_INT_MASK_ALLOWED;*/
|
|
|
|
cinfo.irqs = 0x1468;
|
|
|
|
validslots++;
|
1997-10-26 04:36:24 +00:00
|
|
|
sp->slotnum = slotnum;
|
1996-06-14 11:02:28 +00:00
|
|
|
|
1997-10-26 04:36:24 +00:00
|
|
|
slt = pccard_alloc_slot(&cinfo);
|
1997-10-28 20:50:58 +00:00
|
|
|
if (slt == 0) {
|
1997-10-26 04:36:24 +00:00
|
|
|
printf("pcic98: slt == NULL\n");
|
1996-06-14 11:02:28 +00:00
|
|
|
goto pcic98_probe_end;
|
|
|
|
}
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->cdata = sp;
|
|
|
|
sp->slt = slt;
|
1996-06-14 11:02:28 +00:00
|
|
|
|
|
|
|
/* Check for a card in this slot */
|
1997-10-28 20:50:58 +00:00
|
|
|
if (inb(PCIC98_REG1) & PCIC98_CARDEXIST) {
|
1996-06-14 11:02:28 +00:00
|
|
|
/* PCMCIA card exist */
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->laststate = slt->state = filled;
|
|
|
|
pccard_event(sp->slt, card_inserted);
|
1996-06-14 11:02:28 +00:00
|
|
|
} else {
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->laststate = slt->state = empty;
|
1996-06-14 11:02:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pcic98_probe_end:
|
|
|
|
}
|
|
|
|
#endif /* PC98 */
|
1998-04-20 15:15:20 +00:00
|
|
|
if (validslots && pcic_irq <= 0)
|
1997-11-04 17:50:23 +00:00
|
|
|
pcictimeout_ch = timeout(pcictimeout, 0, hz/2);
|
1995-08-24 08:56:20 +00:00
|
|
|
return(validslots);
|
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* ioctl calls - Controller specific ioctls
|
|
|
|
*/
|
|
|
|
static int
|
1997-10-26 04:36:24 +00:00
|
|
|
pcic_ioctl(struct slot *slt, int cmd, caddr_t data)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pcic_slot *sp = slt->cdata;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1995-11-09 20:44:36 +00:00
|
|
|
switch(cmd) {
|
1995-08-24 08:56:20 +00:00
|
|
|
default:
|
|
|
|
return(EINVAL);
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Get/set PCIC registers
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
case PIOCGREG:
|
|
|
|
((struct pcic_reg *)data)->value =
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->getb(sp, ((struct pcic_reg *)data)->reg);
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
|
|
|
case PIOCSREG:
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->putb(sp, ((struct pcic_reg *)data)->reg,
|
1995-08-24 08:56:20 +00:00
|
|
|
((struct pcic_reg *)data)->value);
|
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
1995-08-24 08:56:20 +00:00
|
|
|
return(0);
|
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* pcic_power - Enable the power of the slot according to
|
|
|
|
* the parameters in the power structure(s).
|
|
|
|
*/
|
|
|
|
static int
|
1997-10-26 04:36:24 +00:00
|
|
|
pcic_power(struct slot *slt)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1996-01-06 07:49:43 +00:00
|
|
|
unsigned char reg = PCIC_DISRST|PCIC_PCPWRE;
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pcic_slot *sp = slt->cdata;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1995-11-09 20:44:36 +00:00
|
|
|
switch(sp->controller) {
|
1996-06-14 11:02:28 +00:00
|
|
|
#ifdef PC98
|
|
|
|
case PCIC_PC98:
|
|
|
|
reg = inb(PCIC98_REG6) & (~PCIC98_VPP12V);
|
1997-10-26 04:36:24 +00:00
|
|
|
switch(slt->pwr.vpp) {
|
1996-06-14 11:02:28 +00:00
|
|
|
default:
|
|
|
|
return(EINVAL);
|
|
|
|
case 50:
|
|
|
|
break;
|
|
|
|
case 120:
|
|
|
|
reg |= PCIC98_VPP12V;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
outb(PCIC98_REG6, reg);
|
1997-10-28 20:58:53 +00:00
|
|
|
DELAY(100*1000);
|
1996-06-14 11:02:28 +00:00
|
|
|
|
|
|
|
reg = inb(PCIC98_REG2) & (~PCIC98_VCC3P3V);
|
1997-10-26 04:36:24 +00:00
|
|
|
switch(slt->pwr.vcc) {
|
1996-06-14 11:02:28 +00:00
|
|
|
default:
|
|
|
|
return(EINVAL);
|
|
|
|
case 33:
|
|
|
|
reg |= PCIC98_VCC3P3V;
|
|
|
|
break;
|
|
|
|
case 50:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
outb(PCIC98_REG2, reg);
|
1997-10-28 20:58:53 +00:00
|
|
|
DELAY(100*1000);
|
1996-06-14 11:02:28 +00:00
|
|
|
return (0);
|
|
|
|
#endif
|
1995-08-24 08:56:20 +00:00
|
|
|
case PCIC_PD672X:
|
|
|
|
case PCIC_PD6710:
|
1996-02-21 23:20:21 +00:00
|
|
|
case PCIC_VG468:
|
1995-11-09 20:44:36 +00:00
|
|
|
case PCIC_VG469:
|
1996-02-21 23:20:21 +00:00
|
|
|
case PCIC_RF5C396:
|
|
|
|
case PCIC_VLSI:
|
|
|
|
case PCIC_IBM_KING:
|
1997-10-26 04:36:24 +00:00
|
|
|
switch(slt->pwr.vpp) {
|
1995-08-24 08:56:20 +00:00
|
|
|
default:
|
|
|
|
return(EINVAL);
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 50:
|
|
|
|
case 33:
|
|
|
|
reg |= PCIC_VPP_5V;
|
|
|
|
break;
|
|
|
|
case 120:
|
|
|
|
reg |= PCIC_VPP_12V;
|
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
1997-10-26 04:36:24 +00:00
|
|
|
switch(slt->pwr.vcc) {
|
1995-08-24 08:56:20 +00:00
|
|
|
default:
|
|
|
|
return(EINVAL);
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 33:
|
1996-02-21 23:20:21 +00:00
|
|
|
if (sp->controller == PCIC_IBM_KING) {
|
|
|
|
reg |= PCIC_VCC_5V_KING;
|
|
|
|
break;
|
|
|
|
}
|
1997-05-22 07:29:24 +00:00
|
|
|
reg |= PCIC_VCC_3V;
|
1996-02-21 23:20:21 +00:00
|
|
|
if ((sp->controller == PCIC_VG468)||
|
|
|
|
(sp->controller == PCIC_VG469))
|
1995-11-09 20:44:36 +00:00
|
|
|
setb(sp, 0x2f, 0x03) ;
|
|
|
|
else
|
|
|
|
setb(sp, 0x16, 0x02);
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
|
|
|
case 50:
|
1996-02-21 23:20:21 +00:00
|
|
|
if (sp->controller == PCIC_IBM_KING) {
|
|
|
|
reg |= PCIC_VCC_5V_KING;
|
|
|
|
break;
|
|
|
|
}
|
1995-08-24 08:56:20 +00:00
|
|
|
reg |= PCIC_VCC_5V;
|
1996-02-21 23:20:21 +00:00
|
|
|
if ((sp->controller == PCIC_VG468)||
|
|
|
|
(sp->controller == PCIC_VG469))
|
1995-11-09 20:44:36 +00:00
|
|
|
clrb(sp, 0x2f, 0x03) ;
|
|
|
|
else
|
|
|
|
clrb(sp, 0x16, 0x02);
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
|
|
|
}
|
1996-02-21 23:20:21 +00:00
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
1997-10-06 02:46:38 +00:00
|
|
|
sp->putb(sp, PCIC_POWER, reg);
|
1995-08-24 08:56:20 +00:00
|
|
|
DELAY(300*1000);
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slt->pwr.vcc) {
|
1995-08-24 08:56:20 +00:00
|
|
|
reg |= PCIC_OUTENA;
|
1997-10-06 02:46:38 +00:00
|
|
|
sp->putb(sp, PCIC_POWER, reg);
|
|
|
|
DELAY(100*1000);
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
1997-05-22 07:29:24 +00:00
|
|
|
/* Some chips are smarter than us it seems, so if we weren't
|
|
|
|
* allowed to use 5V, try 3.3 instead
|
|
|
|
*/
|
1997-10-26 04:36:24 +00:00
|
|
|
if (!(sp->getb(sp, PCIC_STATUS) & 0x40) && slt->pwr.vcc == 50) {
|
|
|
|
slt->pwr.vcc = 33;
|
|
|
|
slt->pwr.vpp = 0;
|
|
|
|
return (pcic_power(slt));
|
1997-05-22 07:29:24 +00:00
|
|
|
}
|
1995-08-24 08:56:20 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* tell the PCIC which irq we want to use. only the following are legal:
|
|
|
|
* 3, 4, 5, 7, 9, 10, 11, 12, 14, 15
|
|
|
|
*/
|
|
|
|
static void
|
1997-10-28 20:58:53 +00:00
|
|
|
pcic_mapirq(struct slot *slt, int irq)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pcic_slot *sp = slt->cdata;
|
1996-06-14 11:02:28 +00:00
|
|
|
#ifdef PC98
|
1997-10-28 20:50:58 +00:00
|
|
|
if (sp->controller == PCIC_PC98) {
|
1996-06-14 11:02:28 +00:00
|
|
|
unsigned char x;
|
1997-10-28 20:50:58 +00:00
|
|
|
switch (irq) {
|
1996-06-14 11:02:28 +00:00
|
|
|
case 3:
|
|
|
|
x = PCIC98_INT0; break;
|
|
|
|
case 5:
|
|
|
|
x = PCIC98_INT1; break;
|
|
|
|
case 6:
|
|
|
|
x = PCIC98_INT2; break;
|
|
|
|
case 10:
|
|
|
|
x = PCIC98_INT4; break;
|
|
|
|
case 12:
|
|
|
|
x = PCIC98_INT5; break;
|
|
|
|
case 0: /* disable */
|
|
|
|
x = PCIC98_INTDISABLE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("pcic98: illegal irq %d\n", irq);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#ifdef PCIC_DEBUG
|
|
|
|
printf("pcic98: irq=%d mapped.\n", irq);
|
|
|
|
#endif
|
|
|
|
outb(PCIC98_REG3, x);
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1996-06-14 11:02:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
1995-08-24 08:56:20 +00:00
|
|
|
if (irq == 0)
|
|
|
|
clrb(sp, PCIC_INT_GEN, 0xF);
|
|
|
|
else
|
1997-10-06 02:46:38 +00:00
|
|
|
sp->putb(sp, PCIC_INT_GEN,
|
|
|
|
(sp->getb(sp, PCIC_INT_GEN) & 0xF0) | irq);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* pcic_reset - Reset the card and enable initial power.
|
|
|
|
*/
|
|
|
|
static void
|
1995-11-13 08:39:44 +00:00
|
|
|
pcic_reset(void *chan)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct slot *slt = chan;
|
|
|
|
struct pcic_slot *sp = slt->cdata;
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1996-06-14 11:02:28 +00:00
|
|
|
#ifdef PC98
|
1997-10-28 20:50:58 +00:00
|
|
|
if (sp->controller == PCIC_PC98) {
|
1996-06-14 11:02:28 +00:00
|
|
|
outb(PCIC98_REG0, 0);
|
|
|
|
outb(PCIC98_REG2, inb(PCIC98_REG2) & (~PCIC98_IOMEMORY));
|
|
|
|
outb(PCIC98_REG3, PCIC98_INTDISABLE);
|
|
|
|
outb(PCIC98_REG2, inb(PCIC98_REG2) & (~PCIC98_VCC3P3V));
|
|
|
|
outb(PCIC98_REG6, inb(PCIC98_REG6) & (~PCIC98_VPP12V));
|
|
|
|
outb(PCIC98_REG1, 0);
|
|
|
|
|
1997-10-26 04:36:24 +00:00
|
|
|
selwakeup(&slt->selp);
|
1996-06-14 11:02:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
1997-10-26 04:36:24 +00:00
|
|
|
switch (slt->insert_seq) {
|
1995-11-09 20:44:36 +00:00
|
|
|
case 0: /* Something funny happended on the way to the pub... */
|
|
|
|
return;
|
|
|
|
case 1: /* Assert reset */
|
1997-10-06 03:17:36 +00:00
|
|
|
clrb(sp, PCIC_INT_GEN, PCIC_CARDRESET);
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->insert_seq = 2;
|
1997-12-02 21:31:35 +00:00
|
|
|
timeout(pcic_reset, (void *)slt, hz/4);
|
1995-11-09 20:44:36 +00:00
|
|
|
return;
|
|
|
|
case 2: /* Deassert it again */
|
1997-10-06 03:17:36 +00:00
|
|
|
setb(sp, PCIC_INT_GEN, PCIC_CARDRESET|PCIC_IOCARD);
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->insert_seq = 3;
|
1997-12-02 21:31:35 +00:00
|
|
|
timeout(pcic_reset, (void *)slt, hz/4);
|
1995-11-09 20:44:36 +00:00
|
|
|
return;
|
|
|
|
case 3: /* Wait if card needs more time */
|
1997-04-20 07:21:12 +00:00
|
|
|
if (!sp->getb(sp, PCIC_STATUS) & PCIC_READY) {
|
1997-12-02 21:31:35 +00:00
|
|
|
timeout(pcic_reset, (void *)slt, hz/10);
|
1995-11-09 20:44:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->insert_seq = 0;
|
1995-11-09 20:44:36 +00:00
|
|
|
if (sp->controller == PCIC_PD672X || sp->controller == PCIC_PD6710) {
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->putb(sp, PCIC_TIME_SETUP0, 0x1);
|
|
|
|
sp->putb(sp, PCIC_TIME_CMD0, 0x6);
|
|
|
|
sp->putb(sp, PCIC_TIME_RECOV0, 0x0);
|
|
|
|
sp->putb(sp, PCIC_TIME_SETUP1, 1);
|
|
|
|
sp->putb(sp, PCIC_TIME_CMD1, 0xf);
|
|
|
|
sp->putb(sp, PCIC_TIME_RECOV1, 0);
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
1997-10-26 04:36:24 +00:00
|
|
|
selwakeup(&slt->selp);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* pcic_disable - Disable the slot.
|
|
|
|
*/
|
|
|
|
static void
|
1997-10-26 04:36:24 +00:00
|
|
|
pcic_disable(struct slot *slt)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pcic_slot *sp = slt->cdata;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1996-06-14 11:02:28 +00:00
|
|
|
#ifdef PC98
|
1997-10-28 20:50:58 +00:00
|
|
|
if (sp->controller == PCIC_PC98) {
|
1996-06-14 11:02:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->putb(sp, PCIC_INT_GEN, 0);
|
|
|
|
sp->putb(sp, PCIC_POWER, 0);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
|
|
|
|
1995-10-21 00:55:36 +00:00
|
|
|
/*
|
1998-04-20 15:15:20 +00:00
|
|
|
* PCIC timer. If the controller doesn't have a free IRQ to use
|
|
|
|
* or if interrupt steering doesn't work, poll the controller for
|
|
|
|
* insertion/removal events.
|
1995-10-21 00:55:36 +00:00
|
|
|
*/
|
|
|
|
static void
|
1995-11-09 08:58:20 +00:00
|
|
|
pcictimeout(void *chan)
|
1995-10-21 00:55:36 +00:00
|
|
|
{
|
|
|
|
pcicintr(0);
|
1997-11-04 17:50:23 +00:00
|
|
|
pcictimeout_ch = timeout(pcictimeout, 0, hz/2);
|
1995-10-21 00:55:36 +00:00
|
|
|
}
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* PCIC Interrupt handler.
|
|
|
|
* Check each slot in turn, and read the card status change
|
|
|
|
* register. If this is non-zero, then a change has occurred
|
|
|
|
* on this card, so send an event to the main code.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
pcicintr(int unit)
|
|
|
|
{
|
1995-11-09 20:44:36 +00:00
|
|
|
int slot, s;
|
|
|
|
unsigned char chg;
|
|
|
|
struct pcic_slot *sp = pcic_slots;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1996-06-14 11:02:28 +00:00
|
|
|
#ifdef PC98
|
1997-10-28 20:50:58 +00:00
|
|
|
if (sp->controller == PCIC_PC98) {
|
1996-06-14 11:02:28 +00:00
|
|
|
slot = 0;
|
|
|
|
s = splhigh();
|
|
|
|
/* Check for a card in this slot */
|
1997-10-28 20:50:58 +00:00
|
|
|
if (inb(PCIC98_REG1) & PCIC98_CARDEXIST) {
|
|
|
|
if (sp->slt->laststate != filled) {
|
1997-10-26 04:36:24 +00:00
|
|
|
pccard_event(sp->slt, card_inserted);
|
1996-06-14 11:02:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
1997-10-28 20:50:58 +00:00
|
|
|
if (sp->slt->laststate != empty) {
|
1997-10-26 04:36:24 +00:00
|
|
|
pccard_event(sp->slt, card_removed);
|
1996-06-14 11:02:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif /* PC98 */
|
1995-08-24 08:56:20 +00:00
|
|
|
s = splhigh();
|
1995-11-09 20:44:36 +00:00
|
|
|
for (slot = 0; slot < PCIC_MAX_SLOTS; slot++, sp++)
|
1997-10-26 04:36:24 +00:00
|
|
|
if (sp->slt && (chg = sp->getb(sp, PCIC_STAT_CHG)) != 0)
|
1995-10-21 00:55:36 +00:00
|
|
|
if (chg & PCIC_CDTCH) {
|
1997-04-20 07:21:12 +00:00
|
|
|
if ((sp->getb(sp, PCIC_STATUS) & PCIC_CD) ==
|
1995-10-21 00:55:36 +00:00
|
|
|
PCIC_CD) {
|
1997-10-26 04:36:24 +00:00
|
|
|
pccard_event(sp->slt, card_inserted);
|
1995-10-21 00:55:36 +00:00
|
|
|
} else {
|
1997-10-26 04:36:24 +00:00
|
|
|
pccard_event(sp->slt, card_removed);
|
1995-10-21 00:55:36 +00:00
|
|
|
}
|
|
|
|
}
|
1995-08-24 08:56:20 +00:00
|
|
|
splx(s);
|
|
|
|
}
|
1997-01-08 00:22:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* pcic_resume - Suspend/resume support for PCIC
|
|
|
|
*/
|
|
|
|
static void
|
1997-10-26 04:36:24 +00:00
|
|
|
pcic_resume(struct slot *slt)
|
1997-01-08 00:22:58 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pcic_slot *sp = slt->cdata;
|
1997-01-08 00:22:58 +00:00
|
|
|
if (pcic_irq > 0)
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->putb(sp, PCIC_STAT_INT, (pcic_irq << 4) | 0xF);
|
1997-10-06 03:17:36 +00:00
|
|
|
if (sp->controller == PCIC_PD672X) {
|
1997-10-06 04:02:42 +00:00
|
|
|
setb(sp, PCIC_MISC1, PCIC_SPKR_EN);
|
|
|
|
setb(sp, PCIC_MISC2, PCIC_LPDM_EN);
|
1997-10-06 03:17:36 +00:00
|
|
|
}
|
1997-01-08 00:22:58 +00:00
|
|
|
}
|