Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev There are some cards that map the ATA control and ID...
details: https://anonhg.NetBSD.org/src/rev/c57b7e1e489a
branches: trunk
changeset: 555778:c57b7e1e489a
user: fvdl <fvdl%NetBSD.org@localhost>
date: Thu Nov 27 23:02:40 2003 +0000
description:
There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.
To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.
bus_space_write_4(tag, handle, offset, value)
becomes
bus_space_write_4(tag, handles[offset], 0, value)
Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
diffstat:
sys/dev/ata/ata_wdc.c | 20 +-
sys/dev/ic/wdc.c | 294 +++++++++++++++++++++++-------------------
sys/dev/ic/wdc_upc.c | 16 +-
sys/dev/ic/wdcreg.h | 4 +-
sys/dev/ic/wdcvar.h | 7 +-
sys/dev/isa/wdc_isa.c | 32 +++-
sys/dev/isapnp/wdc_isapnp.c | 20 ++-
sys/dev/ofisa/wdc_ofisa.c | 18 ++-
sys/dev/pci/acardide.c | 16 +-
sys/dev/pci/aceride.c | 5 +-
sys/dev/pci/cmdide.c | 11 +-
sys/dev/pci/cypide.c | 6 +-
sys/dev/pci/hptide.c | 15 +-
sys/dev/pci/pciide_common.c | 123 +++++++++++------
sys/dev/pci/pciide_opti_reg.h | 22 +-
sys/dev/pci/pciidereg.h | 3 +-
sys/dev/pci/pciidevar.h | 10 +-
sys/dev/pci/pdcide.c | 18 +-
sys/dev/pci/piixide.c | 8 +-
sys/dev/pci/rccide.c | 18 +-
sys/dev/pci/siside.c | 8 +-
sys/dev/pci/stpcide.c | 6 +-
sys/dev/pci/viaide.c | 5 +-
sys/dev/pcmcia/wdc_pcmcia.c | 35 ++--
sys/dev/scsipi/atapi_wdc.c | 46 +++---
25 files changed, 442 insertions(+), 324 deletions(-)
diffs (truncated from 1922 to 300 lines):
diff -r b795f56f1a9a -r c57b7e1e489a sys/dev/ata/ata_wdc.c
--- a/sys/dev/ata/ata_wdc.c Thu Nov 27 21:43:22 2003 +0000
+++ b/sys/dev/ata/ata_wdc.c Thu Nov 27 23:02:40 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_wdc.c,v 1.42 2003/10/29 22:05:15 bouyer Exp $ */
+/* $NetBSD: ata_wdc.c,v 1.43 2003/11/27 23:02:40 fvdl Exp $ */
/*
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.42 2003/10/29 22:05:15 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.43 2003/11/27 23:02:40 fvdl Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@@ -236,7 +236,7 @@
WDCTL_4BIT | WDCTL_IDS);
if (chp->wdc->cap & WDC_CAPABILITY_SELECT)
chp->wdc->select(chp,xfer->drive);
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
WDSD_IBM | (xfer->drive << 4));
errstring = "wait";
if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY, wait_flags))
@@ -430,8 +430,8 @@
/* Initiate command */
if (chp->wdc->cap & WDC_CAPABILITY_SELECT)
chp->wdc->select(chp,xfer->drive);
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
- WDSD_IBM | (xfer->drive << 4));
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh],
+ 0, WDSD_IBM | (xfer->drive << 4));
switch(wait_for_ready(chp, ATA_DELAY, wait_flags)) {
case WDCWAIT_OK:
break;
@@ -470,7 +470,7 @@
/* Initiate command! */
if (chp->wdc->cap & WDC_CAPABILITY_SELECT)
chp->wdc->select(chp,xfer->drive);
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
WDSD_IBM | (xfer->drive << 4));
switch(wait_for_ready(chp, ATA_DELAY, wait_flags)) {
case WDCWAIT_OK:
@@ -530,7 +530,7 @@
ata_bio->nbytes >> 2);
} else {
bus_space_write_multi_2(chp->cmd_iot,
- chp->cmd_ioh, wd_data,
+ chp->cmd_iohs[wd_data], 0,
(u_int16_t *)((char *)xfer->databuf +
xfer->c_skip),
ata_bio->nbytes >> 1);
@@ -544,7 +544,7 @@
ata_bio->nbytes >> 2);
} else {
bus_space_write_multi_stream_2(chp->cmd_iot,
- chp->cmd_ioh, wd_data,
+ chp->cmd_iohs[wd_data], 0,
(u_int16_t *)((char *)xfer->databuf +
xfer->c_skip),
ata_bio->nbytes >> 1);
@@ -694,7 +694,7 @@
ata_bio->nbytes >> 2);
} else {
bus_space_read_multi_2(chp->cmd_iot,
- chp->cmd_ioh, wd_data,
+ chp->cmd_iohs[wd_data], 0,
(u_int16_t *)((char *)xfer->databuf +
xfer->c_skip),
ata_bio->nbytes >> 1);
@@ -708,7 +708,7 @@
ata_bio->nbytes >> 2);
} else {
bus_space_read_multi_stream_2(chp->cmd_iot,
- chp->cmd_ioh, wd_data,
+ chp->cmd_iohs[wd_data], 0,
(u_int16_t *)((char *)xfer->databuf +
xfer->c_skip),
ata_bio->nbytes >> 1);
diff -r b795f56f1a9a -r c57b7e1e489a sys/dev/ic/wdc.c
--- a/sys/dev/ic/wdc.c Thu Nov 27 21:43:22 2003 +0000
+++ b/sys/dev/ic/wdc.c Thu Nov 27 23:02:40 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wdc.c,v 1.156 2003/11/25 21:03:15 bouyer Exp $ */
+/* $NetBSD: wdc.c,v 1.157 2003/11/27 23:02:40 fvdl Exp $ */
/*
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.156 2003/11/25 21:03:15 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.157 2003/11/27 23:02:40 fvdl Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@@ -338,17 +338,19 @@
for (i = 0; i < mstohz(3000); i++) {
if (chp->wdc && (chp->wdc->cap & WDC_CAPABILITY_SELECT))
chp->wdc->select(chp,0);
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
WDSD_IBM);
delay(10); /* 400ns delay */
- st0 = bus_space_read_1(chp->cmd_iot, chp->cmd_ioh, wd_status);
+ st0 = bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_status], 0);
if (chp->wdc && (chp->wdc->cap & WDC_CAPABILITY_SELECT))
chp->wdc->select(chp,1);
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
WDSD_IBM | 0x10);
delay(10); /* 400ns delay */
- st1 = bus_space_read_1(chp->cmd_iot, chp->cmd_ioh, wd_status);
+ st1 = bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_status], 0);
if (((chp->ch_drive[0].drive_flags & (DRIVE_ATA|DRIVE_OLD))
== 0 ||
@@ -424,17 +426,17 @@
*/
if (chp->wdc->cap & WDC_CAPABILITY_SELECT)
chp->wdc->select(chp,i);
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
- WDSD_IBM | (i << 4));
+ bus_space_write_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_sdh], 0, WDSD_IBM | (i << 4));
delay(10); /* 400ns delay */
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh,
- wd_error, 0x58);
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh,
- wd_cyl_lo, 0xa5);
- if (bus_space_read_1(chp->cmd_iot, chp->cmd_ioh,
- wd_error) == 0x58 ||
- bus_space_read_1(chp->cmd_iot, chp->cmd_ioh,
- wd_cyl_lo) != 0xa5) {
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_error],
+ 0, 0x58);
+ bus_space_write_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_cyl_lo], 0, 0xa5);
+ if (bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_error], 0) == 0x58 ||
+ bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_cyl_lo], 0) != 0xa5) {
WDCDEBUG_PRINT(("%s:%d:%d: register "
"writability failed\n",
chp->wdc->sc_dev.dv_xname,
@@ -449,8 +451,8 @@
chp->ch_drive[i].drive_flags &= ~DRIVE_OLD;
continue;
}
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh,
- wd_command, WDCC_RECAL);
+ bus_space_write_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_command], 0, WDCC_RECAL);
delay(10); /* 400ns delay */
if (wait_for_ready(chp, 10000, 0) == WDCWAIT_TOUT) {
WDCDEBUG_PRINT(("%s:%d:%d: WDCC_RECAL failed\n",
@@ -626,18 +628,20 @@
if (chp->wdc && (chp->wdc->cap & WDC_CAPABILITY_SELECT))
chp->wdc->select(chp,0);
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
WDSD_IBM);
delay(10); /* 400ns delay */
- st0 = bus_space_read_1(chp->cmd_iot, chp->cmd_ioh, wd_status);
+ st0 = bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_status], 0);
if (chp->wdc && (chp->wdc->cap & WDC_CAPABILITY_SELECT))
chp->wdc->select(chp,1);
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
WDSD_IBM | 0x10);
delay(10); /* 400ns delay */
- st1 = bus_space_read_1(chp->cmd_iot, chp->cmd_ioh, wd_status);
+ st1 = bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_status], 0);
WDCDEBUG_PRINT(("%s:%d: before reset, st0=0x%x, st1=0x%x\n",
chp->wdc ? chp->wdc->sc_dev.dv_xname : "wdcprobe",
@@ -651,59 +655,60 @@
if (ret_value & 0x01) {
if (chp->wdc && (chp->wdc->cap & WDC_CAPABILITY_SELECT))
chp->wdc->select(chp,0);
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
- WDSD_IBM);
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_cyl_lo, 0x02);
- if (bus_space_read_1(chp->cmd_iot, chp->cmd_ioh,
- wd_cyl_lo) != 0x02)
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh],
+ 0, WDSD_IBM);
+ bus_space_write_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_cyl_lo], 0, 0x02);
+ if (bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_cyl_lo], 0) != 0x02)
ret_value &= ~0x01;
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_cyl_lo,
- 0x01);
- if (bus_space_read_1(chp->cmd_iot, chp->cmd_ioh,
- wd_cyl_lo) != 0x01)
+ bus_space_write_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_cyl_lo], 0, 0x01);
+ if (bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_cyl_lo], 0) != 0x01)
ret_value &= ~0x01;
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sector,
- 0x01);
- if (bus_space_read_1(chp->cmd_iot, chp->cmd_ioh,
- wd_sector) != 0x01)
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sector],
+ 0, 0x01);
+ if (bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_sector], 0) != 0x01)
ret_value &= ~0x01;
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sector,
- 0x02);
- if (bus_space_read_1(chp->cmd_iot, chp->cmd_ioh,
- wd_sector) != 0x02)
+ bus_space_write_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_sector], 0, 0x02);
+ if (bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_sector], 0) != 0x02)
ret_value &= ~0x01;
- if (bus_space_read_1(chp->cmd_iot, chp->cmd_ioh,
- wd_cyl_lo) != 0x01)
+ if (bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_cyl_lo], 0) != 0x01)
ret_value &= ~0x01;
}
/* Register writability test, drive 1. */
if (ret_value & 0x02) {
if (chp->wdc && (chp->wdc->cap & WDC_CAPABILITY_SELECT))
chp->wdc->select(chp,1);
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
- WDSD_IBM | 0x10);
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_cyl_lo,
- 0x02);
- if (bus_space_read_1(chp->cmd_iot, chp->cmd_ioh,
- wd_cyl_lo) != 0x02)
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh],
+ 0, WDSD_IBM | 0x10);
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_cyl_lo],
+ 0, 0x02);
+ if (bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_cyl_lo], 0) != 0x02)
ret_value &= ~0x02;
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_cyl_lo,
- 0x01);
- if (bus_space_read_1(chp->cmd_iot, chp->cmd_ioh,
- wd_cyl_lo) != 0x01)
+ bus_space_write_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_cyl_lo], 0, 0x01);
+ if (bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_cyl_lo], 0) != 0x01)
ret_value &= ~0x02;
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sector,
- 0x01);
- if (bus_space_read_1(chp->cmd_iot, chp->cmd_ioh,
- wd_sector) != 0x01)
+ bus_space_write_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_sector], 0, 0x01);
+ if (bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_sector], 0) != 0x01)
ret_value &= ~0x02;
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sector,
- 0x02);
- if (bus_space_read_1(chp->cmd_iot, chp->cmd_ioh,
- wd_sector) != 0x02)
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sector],
+ 0, 0x02);
+ if (bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_sector], 0) != 0x02)
ret_value &= ~0x02;
- if (bus_space_read_1(chp->cmd_iot, chp->cmd_ioh,
- wd_cyl_lo) != 0x01)
+ if (bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_cyl_lo], 0) != 0x01)
ret_value &= ~0x02;
}
@@ -716,13 +721,12 @@
if (chp->wdc && (chp->wdc->cap & WDC_CAPABILITY_SELECT))
chp->wdc->select(chp,0);
/* assert SRST, wait for reset to complete */
- bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
- WDSD_IBM);
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0, WDSD_IBM);
delay(10); /* 400ns delay */
bus_space_write_1(chp->ctl_iot, chp->ctl_ioh, wd_aux_ctlr,
WDCTL_RST | WDCTL_IDS | WDCTL_4BIT);
DELAY(2000);
Home |
Main Index |
Thread Index |
Old Index