From 2ecdd552dce7f4813e6119f94fc07d1a7b6459fb Mon Sep 17 00:00:00 2001 From: thorpej Date: Tue, 25 May 2004 20:42:40 +0000 Subject: [PATCH] Add the notion of "shadow registers" to the wdc driver. These shadow registers are registers that overlap with others on many controllers, but which may actually be distinct on some controllers. Right now, the two shadows are: - wd_status (usually overlaps wd_command) - wd_features (usually overlaps wd_error) Add a new helper function, wdc_init_shadow_regs(), used to initialize the shadow register handles on controllers where they do actually overlap. Partially from Jordan Rhody @ Wasabi Systems, Inc. --- sys/arch/acorn32/eb7500atx/rside.c | 5 +++-- sys/arch/acorn32/mainbus/wdc_pioc.c | 8 +++++--- sys/arch/acorn32/podulebus/icside.c | 5 +++-- sys/arch/acorn32/podulebus/rapide.c | 5 +++-- sys/arch/acorn32/podulebus/simide.c | 5 +++-- sys/arch/amiga/dev/wdc_amiga.c | 5 +++-- sys/arch/i386/pnpbios/pciide_pnpbios.c | 5 +++-- sys/arch/mac68k/obio/wdc_obio.c | 6 ++++-- sys/arch/macppc/dev/kauai.c | 5 +++-- sys/arch/macppc/dev/wdc_obio.c | 5 +++-- sys/arch/playstation2/dev/wdc_spd.c | 5 +++-- sys/arch/prep/dev/wdc_obio.c | 6 ++++-- sys/dev/ic/wdc.c | 15 +++++++++++++-- sys/dev/ic/wdc_upc.c | 5 +++-- sys/dev/ic/wdcreg.h | 8 +++++--- sys/dev/ic/wdcvar.h | 11 ++++++++--- sys/dev/isa/wdc_isa.c | 6 ++++-- sys/dev/isapnp/wdc_isapnp.c | 5 +++-- sys/dev/ofisa/wdc_ofisa.c | 6 +++--- sys/dev/pci/pciide_common.c | 6 ++++-- sys/dev/pci/satalink.c | 3 ++- sys/dev/pcmcia/wdc_pcmcia.c | 5 +++-- sys/dev/podulebus/dtide.c | 5 +++-- sys/dev/podulebus/hcide.c | 5 +++-- 24 files changed, 94 insertions(+), 51 deletions(-) diff --git a/sys/arch/acorn32/eb7500atx/rside.c b/sys/arch/acorn32/eb7500atx/rside.c index 74bf6cfc9a9c..d532c3334549 100644 --- a/sys/arch/acorn32/eb7500atx/rside.c +++ b/sys/arch/acorn32/eb7500atx/rside.c @@ -1,4 +1,4 @@ -/* $NetBSD: rside.c,v 1.2 2004/01/04 13:49:49 chris Exp $ */ +/* $NetBSD: rside.c,v 1.3 2004/05/25 20:42:40 thorpej Exp $ */ /* * Copyright (c) 2004 Christopher Gilbert @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rside.c,v 1.2 2004/01/04 13:49:49 chris Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rside.c,v 1.3 2004/05/25 20:42:40 thorpej Exp $"); #include #include @@ -213,6 +213,7 @@ rside_attach(struct device *parent, struct device *self, void *aux) continue; } } + wdc_init_shadow_regs(cp); if (bus_space_map(cp->ctl_iot, rside_info[channel].aux_register, 0x4, 0, &cp->ctl_ioh)) diff --git a/sys/arch/acorn32/mainbus/wdc_pioc.c b/sys/arch/acorn32/mainbus/wdc_pioc.c index c8dbf6a2fc07..9d3f4ba8d717 100644 --- a/sys/arch/acorn32/mainbus/wdc_pioc.c +++ b/sys/arch/acorn32/mainbus/wdc_pioc.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_pioc.c,v 1.15 2004/01/03 22:56:52 thorpej Exp $ */ +/* $NetBSD: wdc_pioc.c,v 1.16 2004/05/25 20:42:40 thorpej Exp $ */ /* * Copyright (c) 1997-1998 Mark Brinicombe. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc_pioc.c,v 1.15 2004/01/03 22:56:52 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_pioc.c,v 1.16 2004/05/25 20:42:40 thorpej Exp $"); #include #include @@ -114,6 +114,7 @@ wdc_pioc_probe(parent, cf, aux) return 0; } } + wdc_init_shadow_regs(&ch); if (bus_space_map(ch.ctl_iot, iobase + WDC_PIOC_AUXREG_OFFSET, WDC_PIOC_AUXREG_NPORTS, 0, &ch.ctl_ioh)) { @@ -163,7 +164,8 @@ wdc_pioc_attach(parent, self, aux) panic("%s: couldn't submap drive registers", self->dv_xname); } - + wdc_init_shadow_regs(&sc->wdc_channel); + if (bus_space_map(sc->wdc_channel.ctl_iot, iobase + WDC_PIOC_AUXREG_OFFSET, WDC_PIOC_AUXREG_NPORTS, 0, &sc->wdc_channel.ctl_ioh)) diff --git a/sys/arch/acorn32/podulebus/icside.c b/sys/arch/acorn32/podulebus/icside.c index c6c0f4dc0294..2b75a57c2868 100644 --- a/sys/arch/acorn32/podulebus/icside.c +++ b/sys/arch/acorn32/podulebus/icside.c @@ -1,4 +1,4 @@ -/* $NetBSD: icside.c,v 1.20 2004/01/03 22:56:52 thorpej Exp $ */ +/* $NetBSD: icside.c,v 1.21 2004/05/25 20:42:40 thorpej Exp $ */ /* * Copyright (c) 1997-1998 Mark Brinicombe @@ -42,7 +42,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: icside.c,v 1.20 2004/01/03 22:56:52 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: icside.c,v 1.21 2004/05/25 20:42:40 thorpej Exp $"); #include #include @@ -279,6 +279,7 @@ icside_attach(struct device *parent, struct device *self, void *aux) i, i == 0 ? 4 : 1, &cp->cmd_iohs[i]) != 0) return; } + wdc_init_shadow_regs(cp); if (bus_space_map(iot, iobase + ide->auxregs[channel], AUX_REGISTER_SPACE, 0, &cp->ctl_ioh)) return; diff --git a/sys/arch/acorn32/podulebus/rapide.c b/sys/arch/acorn32/podulebus/rapide.c index 1379567572b7..383ed4601d9c 100644 --- a/sys/arch/acorn32/podulebus/rapide.c +++ b/sys/arch/acorn32/podulebus/rapide.c @@ -1,4 +1,4 @@ -/* $NetBSD: rapide.c,v 1.19 2004/01/03 22:56:52 thorpej Exp $ */ +/* $NetBSD: rapide.c,v 1.20 2004/05/25 20:42:40 thorpej Exp $ */ /* * Copyright (c) 1997-1998 Mark Brinicombe @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rapide.c,v 1.19 2004/01/03 22:56:52 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rapide.c,v 1.20 2004/05/25 20:42:40 thorpej Exp $"); #include #include @@ -273,6 +273,7 @@ rapide_attach(parent, self, aux) continue; } } + wdc_init_shadow_regs(cp); if (bus_space_map(iot, iobase + rapide_info[channel].aux_register, 4, 0, &cp->ctl_ioh)) { bus_space_unmap(iot, cp->cmd_baseioh, diff --git a/sys/arch/acorn32/podulebus/simide.c b/sys/arch/acorn32/podulebus/simide.c index 12f2255560d6..930446db884c 100644 --- a/sys/arch/acorn32/podulebus/simide.c +++ b/sys/arch/acorn32/podulebus/simide.c @@ -1,4 +1,4 @@ -/* $NetBSD: simide.c,v 1.18 2004/01/03 22:56:52 thorpej Exp $ */ +/* $NetBSD: simide.c,v 1.19 2004/05/25 20:42:40 thorpej Exp $ */ /* * Copyright (c) 1997-1998 Mark Brinicombe @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: simide.c,v 1.18 2004/01/03 22:56:52 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: simide.c,v 1.19 2004/05/25 20:42:40 thorpej Exp $"); #include #include @@ -270,6 +270,7 @@ simide_attach(parent, self, aux) continue; } } + wdc_init_shadow_regs(cp); if (bus_space_map(cp->ctl_iot, iobase + simide_info[channel].aux_register, 4, 0, &cp->ctl_ioh)) { bus_space_unmap(cp->cmd_iot, cp->cmd_baseioh, diff --git a/sys/arch/amiga/dev/wdc_amiga.c b/sys/arch/amiga/dev/wdc_amiga.c index dc99b6d514f9..5bead3b05476 100644 --- a/sys/arch/amiga/dev/wdc_amiga.c +++ b/sys/arch/amiga/dev/wdc_amiga.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_amiga.c,v 1.20 2004/01/06 18:46:07 he Exp $ */ +/* $NetBSD: wdc_amiga.c,v 1.21 2004/05/25 20:42:40 thorpej Exp $ */ /*- * Copyright (c) 2000, 2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc_amiga.c,v 1.20 2004/01/06 18:46:07 he Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_amiga.c,v 1.21 2004/05/25 20:42:40 thorpej Exp $"); #include #include @@ -128,6 +128,7 @@ wdc_amiga_attach(struct device *parent, struct device *self, void *aux) return; } } + wdc_init_shadow_regs(&sc->wdc_channel); if (sc->sc_a1200) sc->wdc_channel.ctl_ioh = sc->ctl_iot.base; diff --git a/sys/arch/i386/pnpbios/pciide_pnpbios.c b/sys/arch/i386/pnpbios/pciide_pnpbios.c index 808f757df0fb..4b34536310ff 100644 --- a/sys/arch/i386/pnpbios/pciide_pnpbios.c +++ b/sys/arch/i386/pnpbios/pciide_pnpbios.c @@ -1,4 +1,4 @@ -/* $NetBSD: pciide_pnpbios.c,v 1.14 2004/01/03 22:56:53 thorpej Exp $ */ +/* $NetBSD: pciide_pnpbios.c,v 1.15 2004/05/25 20:42:40 thorpej Exp $ */ /* * Copyright (c) 1999 Soren S. Jorvang. All rights reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pciide_pnpbios.c,v 1.14 2004/01/03 22:56:53 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pciide_pnpbios.c,v 1.15 2004/05/25 20:42:40 thorpej Exp $"); #include #include @@ -156,6 +156,7 @@ pciide_pnpbios_attach(parent, self, aux) return; } } + wdc_init_shadow_regs(wdc_cp); wdc_cp->ctl_iot = wdc_cp->data32iot = compat_iot; wdc_cp->ctl_ioh = wdc_cp->data32ioh = ctl_ioh; diff --git a/sys/arch/mac68k/obio/wdc_obio.c b/sys/arch/mac68k/obio/wdc_obio.c index 0e07d18a3e21..3fa35c68a634 100644 --- a/sys/arch/mac68k/obio/wdc_obio.c +++ b/sys/arch/mac68k/obio/wdc_obio.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_obio.c,v 1.14 2004/01/09 17:00:02 fredb Exp $ */ +/* $NetBSD: wdc_obio.c,v 1.15 2004/05/25 20:42:40 thorpej Exp $ */ /* * Copyright (c) 2002 Takeshi Shibagaki All rights reserved. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.14 2004/01/09 17:00:02 fredb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.15 2004/05/25 20:42:40 thorpej Exp $"); #include #include @@ -112,6 +112,7 @@ wdc_obio_match(parent, match, aux) return 0; } } + wdc_init_shadow_regs(&ch); if (bus_space_subregion(ch.cmd_iot, ch.cmd_baseioh, @@ -183,6 +184,7 @@ wdc_obio_attach(parent, self, aux) return; } } + wdc_init_shadow_regs(&sc->wdc_channel); if (bus_space_subregion(sc->wdc_channel.cmd_iot, sc->wdc_channel.cmd_baseioh, diff --git a/sys/arch/macppc/dev/kauai.c b/sys/arch/macppc/dev/kauai.c index acea9820afc8..dad1ef70fa47 100644 --- a/sys/arch/macppc/dev/kauai.c +++ b/sys/arch/macppc/dev/kauai.c @@ -1,4 +1,4 @@ -/* $NetBSD: kauai.c,v 1.12 2004/01/04 07:08:13 dbj Exp $ */ +/* $NetBSD: kauai.c,v 1.13 2004/05/25 20:42:41 thorpej Exp $ */ /*- * Copyright (c) 2003 Tsubai Masanari. All rights reserved. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kauai.c,v 1.12 2004/01/04 07:08:13 dbj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kauai.c,v 1.13 2004/05/25 20:42:41 thorpej Exp $"); #include #include @@ -164,6 +164,7 @@ kauai_attach(parent, self, aux) return; } } + wdc_init_shadow_regs(chp); if (pci_intr_establish(pa->pa_pc, ih, IPL_BIO, wdcintr, chp) == NULL) { printf("%s: unable to establish interrupt\n", self->dv_xname); diff --git a/sys/arch/macppc/dev/wdc_obio.c b/sys/arch/macppc/dev/wdc_obio.c index 5664fc5d8771..338780c4ec1d 100644 --- a/sys/arch/macppc/dev/wdc_obio.c +++ b/sys/arch/macppc/dev/wdc_obio.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_obio.c,v 1.36 2004/01/04 07:08:13 dbj Exp $ */ +/* $NetBSD: wdc_obio.c,v 1.37 2004/05/25 20:42:41 thorpej Exp $ */ /*- * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.36 2004/01/04 07:08:13 dbj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.37 2004/05/25 20:42:41 thorpej Exp $"); #include #include @@ -172,6 +172,7 @@ wdc_obio_attach(parent, self, aux) return; } } + wdc_init_shadow_regs(chp); #if 0 chp->data32iot = chp->cmd_iot; chp->data32ioh = chp->cmd_ioh; diff --git a/sys/arch/playstation2/dev/wdc_spd.c b/sys/arch/playstation2/dev/wdc_spd.c index 4ae5c5d224e5..b9026a11f7cc 100644 --- a/sys/arch/playstation2/dev/wdc_spd.c +++ b/sys/arch/playstation2/dev/wdc_spd.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_spd.c,v 1.13 2004/01/06 18:46:07 he Exp $ */ +/* $NetBSD: wdc_spd.c,v 1.14 2004/05/25 20:42:41 thorpej Exp $ */ /*- * Copyright (c) 2001, 2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc_spd.c,v 1.13 2004/01/06 18:46:07 he Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_spd.c,v 1.14 2004/05/25 20:42:41 thorpej Exp $"); #include #include @@ -227,6 +227,7 @@ __wdc_spd_bus_space(struct wdc_channel *ch) ch->cmd_iot = &_wdc_spd_space; for (i = 0; i < 8; i++) ch->cmd_iohs[i] = SPD_HDD_IO_BASE + i * 2; /* wdc register is 16 bit wide. */ + wdc_init_shadow_regs(ch); ch->ctl_iot = &_wdc_spd_space; ch->ctl_ioh = SPD_HDD_IO_BASE + WDC_SPD_HDD_AUXREG_OFFSET; ch->data32iot = ch->cmd_iot; diff --git a/sys/arch/prep/dev/wdc_obio.c b/sys/arch/prep/dev/wdc_obio.c index 758200ad70ea..8638af84d83d 100644 --- a/sys/arch/prep/dev/wdc_obio.c +++ b/sys/arch/prep/dev/wdc_obio.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_obio.c,v 1.15 2004/03/10 15:14:49 nonaka Exp $ */ +/* $NetBSD: wdc_obio.c,v 1.16 2004/05/25 20:42:41 thorpej Exp $ */ /*- * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.15 2004/03/10 15:14:49 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.16 2004/05/25 20:42:41 thorpej Exp $"); #include #include @@ -93,6 +93,7 @@ wdc_obio_probe(struct device *parent, struct cfdata *match, void *aux) i == 0 ? 4 : 1, &ch.cmd_iohs[i]) != 0) goto outunmap; } + wdc_init_shadow_regs(&ch); ch.ctl_iot = oa->oa_iot; if (bus_space_map(ch.ctl_iot, oa->oa_iobase + WDC_OBIO_AUXREG_OFFSET, @@ -140,6 +141,7 @@ wdc_obio_attach(struct device *parent, struct device *self, void *aux) return; } } + wdc_init_shadow_regs(&sc->wdc_channel); sc->wdc_channel.data32iot = sc->wdc_channel.cmd_iot; sc->wdc_channel.data32ioh = sc->wdc_channel.cmd_iohs[0]; diff --git a/sys/dev/ic/wdc.c b/sys/dev/ic/wdc.c index 0ebacd8b312a..f52543b8514c 100644 --- a/sys/dev/ic/wdc.c +++ b/sys/dev/ic/wdc.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc.c,v 1.175 2004/05/24 20:45:30 bouyer Exp $ */ +/* $NetBSD: wdc.c,v 1.176 2004/05/25 20:42:41 thorpej Exp $ */ /* * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.175 2004/05/24 20:45:30 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.176 2004/05/25 20:42:41 thorpej Exp $"); #ifndef WDCDEBUG #define WDCDEBUG @@ -175,6 +175,17 @@ struct atabus_initq_head atabus_initq_head = TAILQ_HEAD_INITIALIZER(atabus_initq_head); struct simplelock atabus_interlock = SIMPLELOCK_INITIALIZER; +/* + * Initialize the "shadow register" handles for a standard wdc controller. + */ +void +wdc_init_shadow_regs(struct wdc_channel *chp) +{ + + chp->cmd_iohs[wd_status] = chp->cmd_iohs[wd_command]; + chp->cmd_iohs[wd_features] = chp->cmd_iohs[wd_error]; +} + /* Test to see controller with at last one attached drive is there. * Returns a bit for each possible drive found (0x01 for drive 0, * 0x02 for drive 1). diff --git a/sys/dev/ic/wdc_upc.c b/sys/dev/ic/wdc_upc.c index 2d27e17855fd..dc41ce68c8bb 100644 --- a/sys/dev/ic/wdc_upc.c +++ b/sys/dev/ic/wdc_upc.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_upc.c,v 1.15 2004/01/03 22:56:53 thorpej Exp $ */ +/* $NetBSD: wdc_upc.c,v 1.16 2004/05/25 20:42:41 thorpej Exp $ */ /*- * Copyright (c) 2000 Ben Harris * All rights reserved. @@ -28,7 +28,7 @@ /* This file is part of NetBSD/arm26 -- a port of NetBSD to ARM2/3 machines. */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc_upc.c,v 1.15 2004/01/03 22:56:53 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_upc.c,v 1.16 2004/05/25 20:42:41 thorpej Exp $"); #include #include @@ -94,6 +94,7 @@ wdc_upc_attach(struct device *parent, struct device *self, void *aux) return; } } + wdc_init_shadow_regs(&sc->sc_channel); upc_intr_establish(ua->ua_irqhandle, IPL_BIO, wdcintr, &sc->sc_channel); diff --git a/sys/dev/ic/wdcreg.h b/sys/dev/ic/wdcreg.h index 0082f2737235..f7d5f1301448 100644 --- a/sys/dev/ic/wdcreg.h +++ b/sys/dev/ic/wdcreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: wdcreg.h,v 1.32 2003/12/30 19:30:13 thorpej Exp $ */ +/* $NetBSD: wdcreg.h,v 1.33 2004/05/25 20:42:41 thorpej Exp $ */ /*- * Copyright (c) 1991 The Regents of the University of California. @@ -45,7 +45,6 @@ #define wd_data 0 /* data register (R/W - 16 bits) */ #define wd_error 1 /* error register (R) */ #define wd_precomp 1 /* write precompensation (W) */ -#define wd_features 1 /* features (W), same as wd_precomp */ #define wd_seccnt 2 /* sector count (R/W) */ #define wd_ireason 2 /* interrupt reason (R/W) (for atapi) */ #define wd_sector 3 /* first sector number (R/W) */ @@ -53,11 +52,14 @@ #define wd_cyl_hi 5 /* cylinder address, high byte (R/W) */ #define wd_sdh 6 /* sector size/drive/head (R/W) */ #define wd_command 7 /* command register (W) */ -#define wd_status 7 /* immediate status (R) */ #define wd_lba_lo 3 /* lba address, low byte (RW) */ #define wd_lba_mi 4 /* lba address, middle byte (RW) */ #define wd_lba_hi 5 /* lba address, high byte (RW) */ +/* "shadow" registers; these may or may not overlap regular registers */ +#define wd_status 8 /* immediate status (R) */ +#define wd_features 9 /* features (W) */ + /* offsets of registers in the auxiliary register region */ #define wd_aux_altsts 0 /* alternate fixed disk status (R) */ #define wd_aux_ctlr 0 /* fixed disk controller control (W) */ diff --git a/sys/dev/ic/wdcvar.h b/sys/dev/ic/wdcvar.h index e3d252281987..937e76df206b 100644 --- a/sys/dev/ic/wdcvar.h +++ b/sys/dev/ic/wdcvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: wdcvar.h,v 1.56 2004/04/13 19:51:06 bouyer Exp $ */ +/* $NetBSD: wdcvar.h,v 1.57 2004/05/25 20:42:41 thorpej Exp $ */ /*- * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. @@ -39,16 +39,19 @@ #ifndef _DEV_IC_WDCVAR_H_ #define _DEV_IC_WDCVAR_H_ +#include + /* XXX For scsipi_adapter and scsipi_channel. */ #include #include -#include +#include #define WAITTIME (10 * hz) /* time to wait for a completion */ /* this is a lot for hard drives, but not for cdroms */ #define WDC_NREG 8 /* number of command registers */ +#define WDC_NSHADOWREG 2 /* number of command "shadow" registers */ /* * Per-channel data @@ -61,7 +64,7 @@ struct wdc_channel { /* Our registers */ bus_space_tag_t cmd_iot; bus_space_handle_t cmd_baseioh; - bus_space_handle_t cmd_iohs[WDC_NREG]; + bus_space_handle_t cmd_iohs[WDC_NREG+WDC_NSHADOWREG]; bus_space_tag_t ctl_iot; bus_space_handle_t ctl_ioh; @@ -172,6 +175,8 @@ struct wdc_softc { * or bus-specific backends. */ +void wdc_init_shadow_regs(struct wdc_channel *); + int wdcprobe(struct wdc_channel *); void wdcattach(struct wdc_channel *); int wdcdetach(struct device *, int); diff --git a/sys/dev/isa/wdc_isa.c b/sys/dev/isa/wdc_isa.c index ee19822ffe08..c9a2bce9077b 100644 --- a/sys/dev/isa/wdc_isa.c +++ b/sys/dev/isa/wdc_isa.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_isa.c,v 1.40 2004/01/03 22:56:53 thorpej Exp $ */ +/* $NetBSD: wdc_isa.c,v 1.41 2004/05/25 20:42:41 thorpej Exp $ */ /*- * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc_isa.c,v 1.40 2004/01/03 22:56:53 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_isa.c,v 1.41 2004/05/25 20:42:41 thorpej Exp $"); #include #include @@ -124,6 +124,7 @@ wdc_isa_probe(parent, match, aux) i == 0 ? 4 : 1, &ch.cmd_iohs[i]) != 0) goto outunmap; } + wdc_init_shadow_regs(&ch); ch.ctl_iot = ia->ia_iot; if (bus_space_map(ch.ctl_iot, ia->ia_io[0].ir_addr + @@ -177,6 +178,7 @@ wdc_isa_attach(parent, self, aux) return; } } + wdc_init_shadow_regs(&sc->wdc_channel); sc->wdc_channel.data32iot = sc->wdc_channel.cmd_iot; sc->wdc_channel.data32ioh = sc->wdc_channel.cmd_iohs[0]; diff --git a/sys/dev/isapnp/wdc_isapnp.c b/sys/dev/isapnp/wdc_isapnp.c index 69083dfd5d18..9de2104502bc 100644 --- a/sys/dev/isapnp/wdc_isapnp.c +++ b/sys/dev/isapnp/wdc_isapnp.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_isapnp.c,v 1.26 2004/01/03 22:56:53 thorpej Exp $ */ +/* $NetBSD: wdc_isapnp.c,v 1.27 2004/05/25 20:42:41 thorpej Exp $ */ /*- * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc_isapnp.c,v 1.26 2004/01/03 22:56:53 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_isapnp.c,v 1.27 2004/05/25 20:42:41 thorpej Exp $"); #include #include @@ -142,6 +142,7 @@ wdc_isapnp_attach(parent, self, aux) return; } } + wdc_init_shadow_regs(&sc->wdc_channel); sc->wdc_channel.data32iot = sc->wdc_channel.cmd_iot; sc->wdc_channel.data32ioh = sc->wdc_channel.cmd_iohs[0]; diff --git a/sys/dev/ofisa/wdc_ofisa.c b/sys/dev/ofisa/wdc_ofisa.c index 0f3aa2d7ed73..3fa2b4dd51be 100644 --- a/sys/dev/ofisa/wdc_ofisa.c +++ b/sys/dev/ofisa/wdc_ofisa.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_ofisa.c,v 1.19 2004/01/03 22:56:53 thorpej Exp $ */ +/* $NetBSD: wdc_ofisa.c,v 1.20 2004/05/25 20:42:41 thorpej Exp $ */ /* * Copyright 1997, 1998 @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc_ofisa.c,v 1.19 2004/01/03 22:56:53 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_ofisa.c,v 1.20 2004/05/25 20:42:41 thorpej Exp $"); #include #include @@ -151,7 +151,7 @@ wdc_ofisa_attach(parent, self, aux) return; } } - + wdc_init_shadow_regs(&sc->wdc_channel); sc->sc_ih = isa_intr_establish(aa->ic, intr.irq, intr.share, IPL_BIO, wdcintr, &sc->wdc_channel); diff --git a/sys/dev/pci/pciide_common.c b/sys/dev/pci/pciide_common.c index 0efe86952fff..de4057ccf84f 100644 --- a/sys/dev/pci/pciide_common.c +++ b/sys/dev/pci/pciide_common.c @@ -1,4 +1,4 @@ -/* $NetBSD: pciide_common.c,v 1.10 2004/05/05 17:56:14 bouyer Exp $ */ +/* $NetBSD: pciide_common.c,v 1.11 2004/05/25 20:42:41 thorpej Exp $ */ /* @@ -76,7 +76,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pciide_common.c,v 1.10 2004/05/05 17:56:14 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pciide_common.c,v 1.11 2004/05/25 20:42:41 thorpej Exp $"); #include #include @@ -236,6 +236,7 @@ pciide_mapregs_compat(pa, cp, compatchan, cmdsizep, ctlsizep) goto bad; } } + wdc_init_shadow_regs(wdc_cp); wdc_cp->data32iot = wdc_cp->cmd_iot; wdc_cp->data32ioh = wdc_cp->cmd_iohs[0]; pciide_map_compat_intr(pa, cp, compatchan); @@ -326,6 +327,7 @@ pciide_mapregs_native(pa, cp, cmdsizep, ctlsizep, pci_intr) goto bad; } } + wdc_init_shadow_regs(wdc_cp); wdc_cp->data32iot = wdc_cp->cmd_iot; wdc_cp->data32ioh = wdc_cp->cmd_iohs[0]; return; diff --git a/sys/dev/pci/satalink.c b/sys/dev/pci/satalink.c index 0df5fd0dd833..a13dba1407cb 100644 --- a/sys/dev/pci/satalink.c +++ b/sys/dev/pci/satalink.c @@ -1,4 +1,4 @@ -/* $NetBSD: satalink.c,v 1.13 2004/05/07 13:01:49 sekiya Exp $ */ +/* $NetBSD: satalink.c,v 1.14 2004/05/25 20:42:41 thorpej Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -596,6 +596,7 @@ sii3114_mapchan(struct pciide_channel *cp) goto bad; } } + wdc_init_shadow_regs(wdc_cp); wdc_cp->data32iot = wdc_cp->cmd_iot; wdc_cp->data32ioh = wdc_cp->cmd_iohs[0]; wdcattach(wdc_cp); diff --git a/sys/dev/pcmcia/wdc_pcmcia.c b/sys/dev/pcmcia/wdc_pcmcia.c index 1ee1283b3193..66307da6ef9c 100644 --- a/sys/dev/pcmcia/wdc_pcmcia.c +++ b/sys/dev/pcmcia/wdc_pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_pcmcia.c,v 1.67 2004/01/03 22:56:53 thorpej Exp $ */ +/* $NetBSD: wdc_pcmcia.c,v 1.68 2004/05/25 20:42:41 thorpej Exp $ */ /*- * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdc_pcmcia.c,v 1.67 2004/01/03 22:56:53 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_pcmcia.c,v 1.68 2004/05/25 20:42:41 thorpej Exp $"); #include #include @@ -361,6 +361,7 @@ wdc_pcmcia_attach(parent, self, aux) goto mapaux_failed; } } + wdc_init_shadow_regs(&sc->wdc_channel); sc->wdc_channel.data32iot = sc->wdc_channel.cmd_iot; sc->wdc_channel.data32ioh = sc->wdc_channel.cmd_iohs[0]; sc->sc_wdcdev.PIO_cap = 0; diff --git a/sys/dev/podulebus/dtide.c b/sys/dev/podulebus/dtide.c index 06dbeff7c535..31c20ffaec7c 100644 --- a/sys/dev/podulebus/dtide.c +++ b/sys/dev/podulebus/dtide.c @@ -1,4 +1,4 @@ -/* $NetBSD: dtide.c,v 1.15 2004/01/03 22:56:53 thorpej Exp $ */ +/* $NetBSD: dtide.c,v 1.16 2004/05/25 20:42:41 thorpej Exp $ */ /*- * Copyright (c) 2000, 2001 Ben Harris @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dtide.c,v 1.15 2004/01/03 22:56:53 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dtide.c,v 1.16 2004/05/25 20:42:41 thorpej Exp $"); #include @@ -108,6 +108,7 @@ dtide_attach(struct device *parent, struct device *self, void *aux) for (j = 0; j < WDC_NREG; j++) bus_space_subregion(ch->cmd_iot, ch->cmd_baseioh, j, j == 0 ? 4 : 1, &ch->cmd_iohs[j]); + wdc_init_shadow_regs(ch); bus_space_map(pa->pa_fast_t, pa->pa_fast_base + dtide_ctloffsets[i], 0, 8, &ch->ctl_ioh); diff --git a/sys/dev/podulebus/hcide.c b/sys/dev/podulebus/hcide.c index 21949999bb6a..7e2cd75eb29d 100644 --- a/sys/dev/podulebus/hcide.c +++ b/sys/dev/podulebus/hcide.c @@ -1,4 +1,4 @@ -/* $NetBSD: hcide.c,v 1.12 2004/01/03 22:56:53 thorpej Exp $ */ +/* $NetBSD: hcide.c,v 1.13 2004/05/25 20:42:41 thorpej Exp $ */ /*- * Copyright (c) 2000, 2001 Ben Harris @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hcide.c,v 1.12 2004/01/03 22:56:53 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hcide.c,v 1.13 2004/05/25 20:42:41 thorpej Exp $"); #include @@ -103,6 +103,7 @@ hcide_attach(struct device *parent, struct device *self, void *aux) for (j = 0; j < WDC_NREG; j++) bus_space_subregion(ch->cmd_iot, ch->cmd_baseioh, j, j == 0 ? 4 : 1, &ch->cmd_iohs[j]); + wdc_init_shadow_regs(ch); bus_space_map(pa->pa_fast_t, pa->pa_fast_base + hcide_ctloffsets[i], 0, 8, &ch->ctl_ioh);