summaryrefslogtreecommitdiffstats
path: root/sys/pccard
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1997-04-20 07:21:12 +0000
committerphk <phk@FreeBSD.org>1997-04-20 07:21:12 +0000
commit8f01634fd18fbc0abdbe3f2186b89f67998ffd0f (patch)
treedaa98ba282f80feba3d6e385196c44b71e398a79 /sys/pccard
parent1be613d0b3ea5dd90581c66eab4a08a0f51a12d8 (diff)
downloadFreeBSD-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')
-rw-r--r--sys/pccard/i82365.h4
-rw-r--r--sys/pccard/pccard.c17
-rw-r--r--sys/pccard/pcic.c100
3 files changed, 76 insertions, 45 deletions
diff --git a/sys/pccard/i82365.h b/sys/pccard/i82365.h
index f6140ef..5940f1f 100644
--- a/sys/pccard/i82365.h
+++ b/sys/pccard/i82365.h
@@ -43,9 +43,9 @@
#define PCIC_VG469 7
#define PCIC_RF5C396 8 /* Ricoh RF5C396 */
#define PCIC_IBM_KING 9 /* IBM KING PCMCIA Controller */
-#ifdef PC98
#define PCIC_PC98 10
-#endif
+#define PCIC_TI1130 11 /* TI PCI1130 CardBus */
+
/*
* Address of the controllers. Each controller can manage
* two PCMCIA slots. Up to 8 slots are supported in total.
diff --git a/sys/pccard/pccard.c b/sys/pccard/pccard.c
index 17a9757..541b4af 100644
--- a/sys/pccard/pccard.c
+++ b/sys/pccard/pccard.c
@@ -35,6 +35,7 @@
#include <sys/fcntl.h>
#include <sys/proc.h>
#include <sys/malloc.h>
+#include <sys/sysctl.h>
#include <sys/conf.h>
#ifdef DEVFS
#include <sys/devfsext.h>
@@ -56,6 +57,17 @@
#include <machine/clock.h>
#include <machine/md_var.h>
+SYSCTL_NODE(_machdep, OID_AUTO, pccard, CTLFLAG_RW, 0, "pccard");
+
+static int pcic_resume_reset =
+#ifdef PCIC_RESUME_RESET
+ 1;
+#else
+ 0;
+#endif
+
+SYSCTL_INT(_machdep_pccard, OID_AUTO, pcic_resume_reset, CTLFLAG_RW,
+ &pcic_resume_reset, 0, "");
#define PCCARD_MEMSIZE (4*1024)
@@ -344,9 +356,8 @@ slot_resume(void *arg)
struct slot *sp = arg;
struct pccard_dev *dp;
-#ifdef PCIC_RESUME_RESET
- sp->ctrl->resume(sp);
-#endif
+ if (pcic_resume_reset)
+ sp->ctrl->resume(sp);
if (!sp->suspend_power)
sp->ctrl->power(sp);
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);
}
OpenPOWER on IntegriCloud