diff options
author | John Hay <jhay@FreeBSD.org> | 2003-04-23 20:22:32 +0000 |
---|---|---|
committer | John Hay <jhay@FreeBSD.org> | 2003-04-23 20:22:32 +0000 |
commit | d8422795faa627ef27b37a547e84c2e89820d655 (patch) | |
tree | e8333241fbb892962eddb2eb6255ed21247de587 /sys/dev/sr/if_sr_isa.c | |
parent | 9ab3ea7841109a046d906d40a1808042c471c4d2 (diff) | |
download | src-d8422795faa627ef27b37a547e84c2e89820d655.tar.gz src-d8422795faa627ef27b37a547e84c2e89820d655.zip |
Use bus_space*() instead of in*() and out*().
Notes
Notes:
svn path=/head/; revision=113931
Diffstat (limited to 'sys/dev/sr/if_sr_isa.c')
-rw-r--r-- | sys/dev/sr/if_sr_isa.c | 119 |
1 files changed, 51 insertions, 68 deletions
diff --git a/sys/dev/sr/if_sr_isa.c b/sys/dev/sr/if_sr_isa.c index e0f59cce5cd6..3610de098c33 100644 --- a/sys/dev/sr/if_sr_isa.c +++ b/sys/dev/sr/if_sr_isa.c @@ -96,10 +96,10 @@ static driver_t sr_isa_driver = { DRIVER_MODULE(sr, isa, sr_isa_driver, sr_devclass, 0, 0); MODULE_DEPEND(sr, isa, 1, 1, 1); -static u_int src_get8_io(u_int base, u_int off); -static u_int src_get16_io(u_int base, u_int off); -static void src_put8_io(u_int base, u_int off, u_int val); -static void src_put16_io(u_int base, u_int off, u_int val); +static u_int src_get8_io(struct sr_hardc *hc, u_int off); +static u_int src_get16_io(struct sr_hardc *hc, u_int off); +static void src_put8_io(struct sr_hardc *hc, u_int off, u_int val); +static void src_put16_io(struct sr_hardc *hc, u_int off, u_int val); static u_int src_dpram_size(device_t device); /* @@ -113,8 +113,7 @@ sr_isa_probe (device_t device) int error; u_int32_t flags; u_int i, tmp; - u_short port; - u_long irq, junk, membase, memsize, port_start, port_count; + u_long irq, junk, membase, memsize; sca_regs *sca = 0; error = ISA_PNP_PROBE(device_get_parent(device), device, sr_ids); @@ -131,13 +130,8 @@ sr_isa_probe (device_t device) /* * Now see if the card is realy there. */ - error = bus_get_resource(device, SYS_RES_IOPORT, 0, &port_start, - &port_count); - port = port_start; - hc->cardtype = SR_CRD_N2; hc->cunit = device_get_unit(device); - hc->iobase = port_start; /* * We have to fill these in early because the SRC_PUT* and SRC_GET* * macros use them. @@ -154,16 +148,16 @@ sr_isa_probe (device_t device) if (flags & SR_FLAGS_NCHAN_MSK) hc->numports = flags & SR_FLAGS_NCHAN_MSK; - outb(port + SR_PCR, 0); /* turn off the card */ + sr_outb(hc, SR_PCR, 0); /* turn off the card */ /* * Next, we'll test the Base Address Register to retension of * data... ... seeing if we're *really* talking to an N2. */ for (i = 0; i < 0x100; i++) { - outb(port + SR_BAR, i); - inb(port + SR_PCR); - tmp = inb(port + SR_BAR); + sr_outb(hc, SR_BAR, i); + sr_inb(hc, SR_PCR); + tmp = sr_inb(hc, SR_BAR); if (tmp != i) { printf("sr%d: probe failed BAR %x, %x.\n", hc->cunit, i, tmp); @@ -174,39 +168,39 @@ sr_isa_probe (device_t device) /* * Now see if we can see the SCA. */ - outb(port + SR_PCR, SR_PCR_SCARUN | inb(port + SR_PCR)); - SRC_PUT8(port, sca->wcrl, 0); - SRC_PUT8(port, sca->wcrm, 0); - SRC_PUT8(port, sca->wcrh, 0); - SRC_PUT8(port, sca->pcr, 0); - SRC_PUT8(port, sca->msci[0].tmc, 0); - inb(port); - - tmp = SRC_GET8(port, sca->msci[0].tmc); + sr_outb(hc, SR_PCR, SR_PCR_SCARUN | sr_inb(hc, SR_PCR)); + SRC_PUT8(hc, sca->wcrl, 0); + SRC_PUT8(hc, sca->wcrm, 0); + SRC_PUT8(hc, sca->wcrh, 0); + SRC_PUT8(hc, sca->pcr, 0); + SRC_PUT8(hc, sca->msci[0].tmc, 0); + sr_inb(hc, 0); + + tmp = SRC_GET8(hc, sca->msci[0].tmc); if (tmp != 0) { printf("sr%d: Error reading SCA 0, %x\n", hc->cunit, tmp); goto errexit; } - SRC_PUT8(port, sca->msci[0].tmc, 0x5A); - inb(port); + SRC_PUT8(hc, sca->msci[0].tmc, 0x5A); + sr_inb(hc, 0); - tmp = SRC_GET8(port, sca->msci[0].tmc); + tmp = SRC_GET8(hc, sca->msci[0].tmc); if (tmp != 0x5A) { printf("sr%d: Error reading SCA 0x5A, %x\n", hc->cunit, tmp); goto errexit; } - SRC_PUT16(port, sca->dmac[0].cda, 0); - inb(port); + SRC_PUT16(hc, sca->dmac[0].cda, 0); + sr_inb(hc, 0); - tmp = SRC_GET16(port, sca->dmac[0].cda); + tmp = SRC_GET16(hc, sca->dmac[0].cda); if (tmp != 0) { printf("sr%d: Error reading SCA 0, %x\n", hc->cunit, tmp); goto errexit; } - SRC_PUT16(port, sca->dmac[0].cda, 0x55AA); - inb(port); + SRC_PUT16(hc, sca->dmac[0].cda, 0x55AA); + sr_inb(hc, 0); - tmp = SRC_GET16(port, sca->dmac[0].cda); + tmp = SRC_GET16(hc, sca->dmac[0].cda); if (tmp != 0x55AA) { printf("sr%d: Error reading SCA 0x55AA, %x\n", hc->cunit, tmp); @@ -291,8 +285,6 @@ sr_isa_attach (device_t device) if (flags & SR_FLAGS_NCHAN_MSK) hc->numports = flags & SR_FLAGS_NCHAN_MSK; - hc->iobase = rman_get_start(hc->res_ioport); - hc->sca_base = hc->iobase; hc->mem_start = (caddr_t)rman_get_virtual(hc->res_memory); hc->mem_end = hc->mem_start + SRC_WIN_SIZ; hc->mem_pstart = 0; @@ -301,21 +293,20 @@ sr_isa_attach (device_t device) hc->mempages = src_dpram_size(device); hc->memsize = hc->mempages * SRC_WIN_SIZ; - outb(hc->iobase + SR_PCR, inb(hc->iobase + SR_PCR) | SR_PCR_SCARUN); - outb(hc->iobase + SR_PSR, inb(hc->iobase + SR_PSR) | SR_PSR_EN_SCA_DMA); - outb(hc->iobase + SR_MCR, + sr_outb(hc, SR_PCR, sr_inb(hc, SR_PCR) | SR_PCR_SCARUN); + sr_outb(hc, SR_PSR, sr_inb(hc, SR_PSR) | SR_PSR_EN_SCA_DMA); + sr_outb(hc, SR_MCR, SR_MCR_DTR0 | SR_MCR_DTR1 | SR_MCR_TE0 | SR_MCR_TE1); - SRC_SET_ON(hc->iobase); + SRC_SET_ON(hc); /* * Configure the card. Mem address, irq, */ mar = (rman_get_start(hc->res_memory) >> 16) & SR_PCR_16M_SEL; - outb(hc->iobase + SR_PCR, - mar | (inb(hc->iobase + SR_PCR) & ~SR_PCR_16M_SEL)); + sr_outb(hc, SR_PCR, mar | (sr_inb(hc, SR_PCR) & ~SR_PCR_16M_SEL)); mar = rman_get_start(hc->res_memory) >> 12; - outb(hc->iobase + SR_BAR, mar); + sr_outb(hc, SR_BAR, mar); return sr_attach(device); @@ -327,52 +318,49 @@ errexit: /* * I/O for ISA N2 card(s) */ -#define SRC_REG(iobase,y) ((((y) & 0xf) + (((y) & 0xf0) << 6) + \ - (iobase)) | 0x8000) +#define SRC_REG(y) ((((y) & 0xf) + (((y) & 0xf0) << 6)) | 0x8000) static u_int -src_get8_io(u_int base, u_int off) +src_get8_io(struct sr_hardc *hc, u_int off) { - return inb(SRC_REG(base, off)); + return bus_space_read_1(hc->bt_ioport, hc->bh_ioport, SRC_REG(off)); } static u_int -src_get16_io(u_int base, u_int off) +src_get16_io(struct sr_hardc *hc, u_int off) { - return inw(SRC_REG(base, off)); + return bus_space_read_2(hc->bt_ioport, hc->bh_ioport, SRC_REG(off)); } static void -src_put8_io(u_int base, u_int off, u_int val) +src_put8_io(struct sr_hardc *hc, u_int off, u_int val) { - outb(SRC_REG(base, off), val); + bus_space_write_1(hc->bt_ioport, hc->bh_ioport, SRC_REG(off), val); } static void -src_put16_io(u_int base, u_int off, u_int val) +src_put16_io(struct sr_hardc *hc, u_int off, u_int val) { - outw(SRC_REG(base, off), val); + bus_space_write_2(hc->bt_ioport, hc->bh_ioport, SRC_REG(off), val); } static u_int src_dpram_size(device_t device) { u_int pgs, i; - u_short port; u_short *smem; u_char mar; u_long membase; struct sr_hardc *hc; hc = device_get_softc(device); - port = hc->iobase; /* * OK, the board's interface registers seem to work. Now we'll see * if the Dual-Ported RAM is fully accessible... */ - outb(port + SR_PCR, SR_PCR_EN_VPM | SR_PCR_ISA16); - outb(port + SR_PSR, SR_PSR_WIN_16K); + sr_outb(hc, SR_PCR, SR_PCR_EN_VPM | SR_PCR_ISA16); + sr_outb(hc, SR_PSR, SR_PSR_WIN_16K); /* * Take the kernel "virtual" address supplied to us and convert @@ -380,10 +368,10 @@ src_dpram_size(device_t device) */ membase = rman_get_start(hc->res_memory); mar = (membase >> 16) & SR_PCR_16M_SEL; - outb(port + SR_PCR, mar | inb(port + SR_PCR)); + sr_outb(hc, SR_PCR, mar | sr_inb(hc, SR_PCR)); mar = membase >> 12; - outb(port + SR_BAR, mar); - outb(port + SR_PCR, inb(port + SR_PCR) | SR_PCR_MEM_WIN); + sr_outb(hc, SR_BAR, mar); + sr_outb(hc, SR_PCR, sr_inb(hc, SR_PCR) | SR_PCR_MEM_WIN); smem = (u_short *)rman_get_virtual(hc->res_memory);/* DP RAM Address */ /* * Here we will perform the memory scan to size the device. @@ -397,16 +385,12 @@ src_dpram_size(device_t device) * Note: We're sizing 16K memory granules. */ for (i = 0; i <= SR_PSR_PG_SEL; i++) { - outb(port + SR_PSR, - (inb(port + SR_PSR) & ~SR_PSR_PG_SEL) | i); - + sr_outb(hc, SR_PSR, (sr_inb(hc, SR_PSR) & ~SR_PSR_PG_SEL) | i); *smem = 0xAA55; } for (i = 0; i <= SR_PSR_PG_SEL; i++) { - outb(port + SR_PSR, - (inb(port + SR_PSR) & ~SR_PSR_PG_SEL) | i); - + sr_outb(hc, SR_PSR, (sr_inb(hc, SR_PSR) & ~SR_PSR_PG_SEL) | i); if (*smem != 0xAA55) { /* * If we have less than 64k of memory, give up. That @@ -431,11 +415,10 @@ src_dpram_size(device_t device) * This next loop erases the contents of that page in DPRAM */ for (i = 0; i <= pgs; i++) { - outb(port + SR_PSR, - (inb(port + SR_PSR) & ~SR_PSR_PG_SEL) | i); + sr_outb(hc, SR_PSR, (sr_inb(hc, SR_PSR) & ~SR_PSR_PG_SEL) | i); bzero(smem, SRC_WIN_SIZ); } - SRC_SET_OFF(port); + SRC_SET_OFF(hc); return (pgs); } |