summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/pccard/i82365.h8
-rw-r--r--sys/pccard/pcic.c13
-rw-r--r--sys/pccard/pcic_isa.c20
-rw-r--r--sys/pccard/pcic_pci.c2
-rw-r--r--sys/pccard/pcicvar.h5
5 files changed, 28 insertions, 20 deletions
diff --git a/sys/pccard/i82365.h b/sys/pccard/i82365.h
index fedb5b0..004bd544 100644
--- a/sys/pccard/i82365.h
+++ b/sys/pccard/i82365.h
@@ -60,10 +60,10 @@
* identify the port number, and the lower 6 bits
* select one of the 64 possible data registers.
*/
-#define PCIC_INDEX_0 0x3e0 /* index reg, chips 0 and 1 */
-#define PCIC_DATA_0 (PCIC_INDEX_0 + 1) /* data reg, chips 0 and 1 */
-#define PCIC_INDEX_1 (PCIC_INDEX_0 + 2) /* index reg, chips 2 and 3 */
-#define PCIC_DATA_1 (PCIC_INDEX_1 + 1) /* data reg, chips 2 and 3 */
+#define PCIC_INDEX 0 /* Index register */
+#define PCIC_DATA 1 /* Data register */
+#define PCIC_NPORT 2 /* Number of ports */
+#define PCIC_PORT_0 0x3e0 /* index reg, chips 0 and 1 */
/*
* Register index addresses.
diff --git a/sys/pccard/pcic.c b/sys/pccard/pcic.c
index 995600a..409c59e 100644
--- a/sys/pccard/pcic.c
+++ b/sys/pccard/pcic.c
@@ -83,8 +83,8 @@ static struct slot_ctrl pcic_cinfo = {
unsigned char
pcic_getb_io(struct pcic_slot *sp, int reg)
{
- outb(sp->index, sp->offset + reg);
- return (inb(sp->data));
+ bus_space_write_1(sp->bst, sp->bsh, PCIC_INDEX, sp->offset + reg);
+ return (bus_space_read_1(sp->bst, sp->bsh, PCIC_DATA));
}
/*
@@ -93,8 +93,13 @@ pcic_getb_io(struct pcic_slot *sp, int reg)
void
pcic_putb_io(struct pcic_slot *sp, int reg, unsigned char val)
{
- outb(sp->index, sp->offset + reg);
- outb(sp->data, val);
+ /*
+ * Many datasheets recommend using outw rather than outb to save
+ * a microsecond. Maybe we should do this, but we'd likely only
+ * save 20-30us on card activation.
+ */
+ bus_space_write_1(sp->bst, sp->bsh, PCIC_INDEX, sp->offset + reg);
+ bus_space_write_1(sp->bst, sp->bsh, PCIC_DATA, val);
}
/*
diff --git a/sys/pccard/pcic_isa.c b/sys/pccard/pcic_isa.c
index d1df7ce..5f82180 100644
--- a/sys/pccard/pcic_isa.c
+++ b/sys/pccard/pcic_isa.c
@@ -96,7 +96,8 @@ pcic_isa_probe(device_t dev)
return (ENXIO);
if (bus_get_resource_start(dev, SYS_RES_IOPORT, 0) == 0)
- bus_set_resource(dev, SYS_RES_IOPORT, 0, PCIC_INDEX0, 2);
+ bus_set_resource(dev, SYS_RES_IOPORT, 0, PCIC_PORT_0,
+ PCIC_NPORT);
rid = 0;
r = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE);
if (!r) {
@@ -114,8 +115,8 @@ pcic_isa_probe(device_t dev)
*/
sp->getb = pcic_getb_io;
sp->putb = pcic_putb_io;
- sp->index = rman_get_start(r);
- sp->data = sp->index + 1;
+ sp->bst = rman_get_bustag(r);
+ sp->bsh = rman_get_bushandle(r);
sp->offset = slotnum * PCIC_SLOT_SIZE;
sp->controller = -1;
}
@@ -138,8 +139,7 @@ pcic_isa_probe(device_t dev)
if (sp0->getb(sp0, PCIC_ID_REV) == PCIC_VLSI82C146 &&
sp1->getb(sp1, PCIC_ID_REV) != PCIC_VLSI82C146) {
spsave = *sp1;
- sp1->index += 4;
- sp1->data += 4;
+ sp1->bsh += 4;
sp1->offset = PCIC_SLOT_SIZE << 1;
if (sp1->getb(sp1, PCIC_ID_REV) != PCIC_VLSI82C146) {
*sp1 = spsave;
@@ -170,10 +170,14 @@ pcic_isa_probe(device_t dev)
sp->controller = PCIC_I82365;
sp->revision = c & 1;
/*
- * Now check for VADEM chips.
+ * Check for Vadem chips by unlocking their extra
+ * registers and looking for valid ID. Bit 3 in
+ * the ID register is normally 0, except when
+ * PCIC_VADEMREV is set. Other bridges appear
+ * to ignore this frobbing.
*/
- outb(sp->index, 0x0E); /* Unlock VADEM's extra regs */
- outb(sp->index, 0x37);
+ bus_space_write_1(sp->bst, sp->bsh, PCIC_INDEX, 0x0E);
+ bus_space_write_1(sp->bst, sp->bsh, PCIC_INDEX, 0x37);
pcic_setb(sp, PCIC_VMISC, PCIC_VADEMREV);
c = sp->getb(sp, PCIC_ID_REV);
if (c & 0x08) {
diff --git a/sys/pccard/pcic_pci.c b/sys/pccard/pcic_pci.c
index 3b74304..dde8971 100644
--- a/sys/pccard/pcic_pci.c
+++ b/sys/pccard/pcic_pci.c
@@ -64,7 +64,7 @@ pd6832_legacy_init(device_t dev)
* sequentially. We only initialize the first socket's legacy port,
* the other is a dummy.
*/
- io_port = PCIC_INDEX_0 + num6832 * CLPD6832_NUM_REGS;
+ io_port = PCIC_PORT_0 + num6832 * CLPD6832_NUM_REGS;
if (unit == 0)
pci_write_config(dev, CLPD6832_LEGACY_16BIT_IOADDR,
io_port & ~CLPD6832_LEGACY_16BIT_IOENABLE, 4);
diff --git a/sys/pccard/pcicvar.h b/sys/pccard/pcicvar.h
index c02cffe..57bbb1e 100644
--- a/sys/pccard/pcicvar.h
+++ b/sys/pccard/pcicvar.h
@@ -28,8 +28,6 @@
* Per-slot data table.
*/
struct pcic_slot {
- int index; /* Index register */
- int data; /* Data register */
int offset; /* Offset value for index */
char controller; /* Device type */
char revision; /* Device Revision */
@@ -37,7 +35,8 @@ struct pcic_slot {
struct pcic_softc *sc; /* Back pointer to softc */
u_char (*getb)(struct pcic_slot *, int);
void (*putb)(struct pcic_slot *, int, u_char);
- u_char *regs; /* Pointer to regs in mem */
+ bus_space_tag_t bst;
+ bus_space_handle_t bsh;
};
struct pcic_softc
OpenPOWER on IntegriCloud