diff options
author | phk <phk@FreeBSD.org> | 1997-04-20 07:21:12 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1997-04-20 07:21:12 +0000 |
commit | 8f01634fd18fbc0abdbe3f2186b89f67998ffd0f (patch) | |
tree | daa98ba282f80feba3d6e385196c44b71e398a79 /sys/pccard/pcic.c | |
parent | 1be613d0b3ea5dd90581c66eab4a08a0f51a12d8 (diff) | |
download | FreeBSD-src-8f01634fd18fbc0abdbe3f2186b89f67998ffd0f.zip FreeBSD-src-8f01634fd18fbc0abdbe3f2186b89f67998ffd0f.tar.gz |
1. i82365.h: Chip identifiers should not be #ifdef PC98. Add identifier
(pt. unused) for TI PCI1130.
2. pccard.c: PCIC_RESUME_RESET is now (also) a sysctl. (Never make it
a #ifdef if it can be made a sysctl!)
3. pcic.c: make getb() and putb() proper member functions of struct
pcic_slot. Add a couple of missing casts.
Diffstat (limited to 'sys/pccard/pcic.c')
-rw-r--r-- | sys/pccard/pcic.c | 100 |
1 files changed, 60 insertions, 40 deletions
diff --git a/sys/pccard/pcic.c b/sys/pccard/pcic.c index 27f934b..6ddc18c 100644 --- a/sys/pccard/pcic.c +++ b/sys/pccard/pcic.c @@ -81,6 +81,9 @@ static struct pcic_slot { char controller; /* Device type */ char revision; /* Device Revision */ struct slot *slotp; /* Back ptr to slot */ + u_char (*getb)(struct pcic_slot *sp, int reg); + void (*putb)(struct pcic_slot *sp, int reg, u_char val); + u_char *regs; /* Pointer to regs in mem */ } pcic_slots[PCIC_MAX_SLOTS]; static int pcic_irq; @@ -95,29 +98,41 @@ static struct slot_ctrl cinfo; * Read a register from the PCIC. */ static inline unsigned char -getb (struct pcic_slot *sp, int reg) +getb1 (struct pcic_slot *sp, int reg) { outb (sp->index, sp->offset + reg); return inb (sp->data); } +static inline unsigned char +getb2 (struct pcic_slot *sp, int reg) +{ + return (sp->regs[reg]); +} + /* * Write a register on the PCIC */ static inline void -putb (struct pcic_slot *sp, int reg, unsigned char val) +putb1 (struct pcic_slot *sp, int reg, unsigned char val) { outb (sp->index, sp->offset + reg); outb (sp->data, val); } +static inline void +putb2 (struct pcic_slot *sp, int reg, unsigned char val) +{ + sp->regs[reg] = val; +} + /* * Clear bit(s) of a register. */ static inline void clrb(struct pcic_slot *sp, int reg, unsigned char mask) { - putb (sp, reg, getb (sp, reg) & ~mask); + sp->putb (sp, reg, sp->getb (sp, reg) & ~mask); } /* @@ -126,7 +141,7 @@ clrb(struct pcic_slot *sp, int reg, unsigned char mask) static inline void setb(struct pcic_slot *sp, int reg, unsigned char mask) { - putb (sp, reg, getb (sp, reg) | mask); + sp->putb (sp, reg, sp->getb (sp, reg) | mask); } /* @@ -135,8 +150,8 @@ setb(struct pcic_slot *sp, int reg, unsigned char mask) static inline void putw (struct pcic_slot *sp, int reg, unsigned short word) { - putb (sp, reg, word & 0xFF); - putb (sp, reg + 1, (word >> 8) & 0xff); + sp->putb (sp, reg, word & 0xFF); + sp->putb (sp, reg + 1, (word >> 8) & 0xff); } @@ -231,7 +246,7 @@ pcic_unload(struct lkm_table *lkmtp, int cmd) if (pcic_irq) { for (slot = 0; slot < PCIC_MAX_SLOTS; slot++, sp++) { if (sp->slotp) - putb(sp, PCIC_STAT_INT, 0); + sp->putb(sp, PCIC_STAT_INT, 0); } unregister_intr(pcic_irq, pcicintr); } @@ -386,9 +401,9 @@ pcic_memory(struct slot *slotp, int win) 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", - getb(sp, reg), getb(sp, reg+1), - getb(sp, reg+2), getb(sp, reg+3), - getb(sp, reg+4), getb(sp, reg+5), + 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), mp->flags); #endif /* @@ -491,14 +506,14 @@ printf("Map I/O 0x%x (size 0x%x) on Window %d\n", ip->start, ip->size, win); * Flags for window 0 in lower nybble, and in upper nybble * for window 1. */ - ioctlv = getb(sp, PCIC_IOCTL); + ioctlv = sp->getb(sp, PCIC_IOCTL); DELAY(100); switch (win) { case 0: - putb(sp, PCIC_IOCTL, x | (ioctlv & 0xf0)); + sp->putb(sp, PCIC_IOCTL, x | (ioctlv & 0xf0)); break; case 1: - putb(sp, PCIC_IOCTL, (x << 4) | (ioctlv & 0xf)); + sp->putb(sp, PCIC_IOCTL, (x << 4) | (ioctlv & 0xf)); break; } DELAY(100); @@ -560,6 +575,8 @@ pcic_probe(void) /* * Initialise the PCIC slot table. */ + sp->getb = getb1; + sp->putb = putb1; if (slot < 4) { sp->index = PCIC_INDEX_0; sp->data = PCIC_DATA_0; @@ -576,7 +593,7 @@ pcic_probe(void) * ones would need to be probed at the new offset we set after * we assume it's broken. */ - if (slot == 1 && maybe_vlsi && getb(sp, PCIC_ID_REV) != 0x84) { + if (slot == 1 && maybe_vlsi && sp->getb(sp, PCIC_ID_REV) != 0x84) { sp->index += 4; sp->data += 4; sp->offset = PCIC_SLOT_SIZE << 1; @@ -586,7 +603,7 @@ pcic_probe(void) * Intel PCMCIA controllers use 0x82 and 0x83 * IBM clone chips use 0x88 and 0x89, apparently */ - c = getb (sp, PCIC_ID_REV); + c = sp->getb (sp, PCIC_ID_REV); sp->revision = -1; switch(c) { /* @@ -602,7 +619,7 @@ pcic_probe(void) outb(sp->index, 0x0E); outb(sp->index, 0x37); setb(sp, 0x3A, 0x40); - c = getb (sp, PCIC_ID_REV); + c = sp->getb (sp, PCIC_ID_REV); if (c & 0x08) { sp->controller = ((sp->revision = c & 7) == 4) ? PCIC_VG469 : PCIC_VG468 ; @@ -612,7 +629,7 @@ pcic_probe(void) /* * Check for RICOH RF5C396 PCMCIA Controller */ - c = getb (sp, 0x3a); + c = sp->getb (sp, 0x3a); if (c == 0xb2) { sp->controller = PCIC_RF5C396; } @@ -640,10 +657,10 @@ pcic_probe(void) /* * Check for Cirrus logic chips. */ - putb(sp, 0x1F, 0); - c = getb(sp, 0x1F); + sp->putb(sp, 0x1F, 0); + c = sp->getb(sp, 0x1F); if ((c & 0xC0) == 0xC0) { - c = getb(sp, 0x1F); + c = sp->getb(sp, 0x1F); if ((c & 0xC0) == 0) { if (c & 0x20) sp->controller = PCIC_PD672X; @@ -689,7 +706,7 @@ pcic_probe(void) * clear out the registers. */ for (i = 2; i < 0x40; i++) - putb(sp, i, 0); + sp->putb(sp, i, 0); #endif /* PCIC_NOCLRREGS */ /* * OK it seems we have a PCIC or lookalike. @@ -719,7 +736,7 @@ pcic_probe(void) * Check for a card in this slot. */ setb (sp, PCIC_POWER, PCIC_PCPWRE| PCIC_DISRST); - if ((getb (sp, PCIC_STATUS) & PCIC_CD) != PCIC_CD) { + if ((sp->getb (sp, PCIC_STATUS) & PCIC_CD) != PCIC_CD) { slotp->laststate = slotp->state = empty; } else { slotp->laststate = slotp->state = filled; @@ -729,7 +746,7 @@ pcic_probe(void) * Assign IRQ for slot changes */ if (pcic_irq > 0) - putb(sp, PCIC_STAT_INT, (pcic_irq << 4) | 0xF); + sp->putb(sp, PCIC_STAT_INT, (pcic_irq << 4) | 0xF); } #ifdef PC98 if (validslots == 0){ @@ -776,6 +793,7 @@ pcic_probe(void) static int pcic_ioctl(struct slot *slotp, int cmd, caddr_t data) { + struct pcic_slot *sp = slotp->cdata; switch(cmd) { default: @@ -785,10 +803,10 @@ pcic_ioctl(struct slot *slotp, int cmd, caddr_t data) */ case PIOCGREG: ((struct pcic_reg *)data)->value = - getb(slotp->cdata, ((struct pcic_reg *)data)->reg); + sp->getb(sp, ((struct pcic_reg *)data)->reg); break; case PIOCSREG: - putb(slotp->cdata, ((struct pcic_reg *)data)->reg, + sp->putb(sp, ((struct pcic_reg *)data)->reg, ((struct pcic_reg *)data)->value); break; } @@ -887,11 +905,11 @@ pcic_power(struct slot *slotp) } break; } - putb (sp, PCIC_POWER, reg); + sp->putb (sp, PCIC_POWER, reg); DELAY(300*1000); if (slotp->pwr.vcc) { reg |= PCIC_OUTENA; - putb (sp, PCIC_POWER, reg); + sp->putb (sp, PCIC_POWER, reg); DELAY (100*1000); } return(0); @@ -937,7 +955,8 @@ pcic_mapirq (struct slot *slotp, int irq) if (irq == 0) clrb(sp, PCIC_INT_GEN, 0xF); else - putb (sp, PCIC_INT_GEN, (getb (sp, PCIC_INT_GEN) & 0xF0) | irq); + sp->putb (sp, PCIC_INT_GEN, + (sp->getb (sp, PCIC_INT_GEN) & 0xF0) | irq); } /* @@ -976,19 +995,19 @@ pcic_reset(void *chan) timeout(pcic_reset, (void*) slotp, hz/4); return; case 3: /* Wait if card needs more time */ - if (!getb(sp, PCIC_STATUS) & PCIC_READY) { + if (!sp->getb(sp, PCIC_STATUS) & PCIC_READY) { timeout(pcic_reset, (void*) slotp, hz/10); return; } } slotp->insert_seq = 0; if (sp->controller == PCIC_PD672X || sp->controller == PCIC_PD6710) { - putb(sp, PCIC_TIME_SETUP0, 0x1); - putb(sp, PCIC_TIME_CMD0, 0x6); - putb(sp, PCIC_TIME_RECOV0, 0x0); - putb(sp, PCIC_TIME_SETUP1, 1); - putb(sp, PCIC_TIME_CMD1, 0xf); - putb(sp, PCIC_TIME_RECOV1, 0); + 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); } selwakeup(&slotp->selp); } @@ -1006,8 +1025,8 @@ pcic_disable(struct slot *slotp) return; } #endif - putb(sp, PCIC_INT_GEN, 0); - putb(sp, PCIC_POWER, 0); + sp->putb(sp, PCIC_INT_GEN, 0); + sp->putb(sp, PCIC_POWER, 0); } /* @@ -1054,9 +1073,9 @@ pcicintr(int unit) #endif /* PC98 */ s = splhigh(); for (slot = 0; slot < PCIC_MAX_SLOTS; slot++, sp++) - if (sp->slotp && (chg = getb(sp, PCIC_STAT_CHG)) != 0) + if (sp->slotp && (chg = sp->getb(sp, PCIC_STAT_CHG)) != 0) if (chg & PCIC_CDTCH) { - if ((getb(sp, PCIC_STATUS) & PCIC_CD) == + if ((sp->getb(sp, PCIC_STATUS) & PCIC_CD) == PCIC_CD) { pccard_event(sp->slotp, card_inserted); @@ -1074,6 +1093,7 @@ pcicintr(int unit) static void pcic_resume(struct slot *slotp) { + struct pcic_slot *sp = slotp->cdata; if (pcic_irq > 0) - putb(slotp->cdata, PCIC_STAT_INT, (pcic_irq << 4) | 0xF); + sp->putb(sp, PCIC_STAT_INT, (pcic_irq << 4) | 0xF); } |