summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1998-07-05 07:20:03 +0000
committerJason Downs <downsj@cvs.openbsd.org>1998-07-05 07:20:03 +0000
commit6bf015290608a019d3615c7366ce2df39c5c0d66 (patch)
treec548f53565e172d67af1494a8deee0ae1155168f /sys/dev
parent51b0bce5527fe3016e8f66bb91a5c1bfc5ca184c (diff)
Add support for ISA PnP to wdc and associated config goo. This does NOT work
with the Soundblaster; documentation is needed. Also changes wdcprobe method slightly.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/isa/files.isa6
-rw-r--r--sys/dev/isa/files.isapnp4
-rw-r--r--sys/dev/isa/wdc.c61
3 files changed, 52 insertions, 19 deletions
diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa
index ba476852ccd..60d5e0c5bdc 100644
--- a/sys/dev/isa/files.isa
+++ b/sys/dev/isa/files.isa
@@ -1,4 +1,4 @@
-# $OpenBSD: files.isa,v 1.40 1998/04/26 21:02:40 provos Exp $
+# $OpenBSD: files.isa,v 1.41 1998/07/05 07:20:00 downsj Exp $
# $NetBSD: files.isa,v 1.21 1996/05/16 03:45:55 mycroft Exp $
#
# Config.new file and device description for machine-independent ISA code.
@@ -125,10 +125,10 @@ file dev/isa/pcd.c pcd needs-flag
# ISA "wd" (ESDI/IDE/etc.) controllers, ATAPI bus
define ata {drive = -1}
device wdc {drive = -1}: atapi, ata
-attach wdc at isa
+attach wdc at isa with wdc_isa
device wd: disk
attach wd at wdc
-file dev/isa/wdc.c wdc needs-flag
+file dev/isa/wdc.c wdc & (wdc_isa | wdc_isapnp) needs-flag
file dev/isa/wd.c wd needs-flag
# Wangtek- and Archive-compatible tape controller boards
diff --git a/sys/dev/isa/files.isapnp b/sys/dev/isa/files.isapnp
index cf39e611b9b..923a73772dc 100644
--- a/sys/dev/isa/files.isapnp
+++ b/sys/dev/isa/files.isapnp
@@ -1,4 +1,4 @@
-# $OpenBSD: files.isapnp,v 1.6 1998/05/08 18:39:36 csapuntz Exp $
+# $OpenBSD: files.isapnp,v 1.7 1998/07/05 07:20:01 downsj Exp $
# $NetBSD: files.isapnp,v 1.7 1997/10/16 17:16:36 matt Exp $
#
# Config file and device description for machine-independent ISAPnP code.
@@ -19,6 +19,8 @@ file dev/isa/isapnpres.c isapnp
#attach com at isapnp with com_isapnp
+attach wdc at isapnp with wdc_isapnp
+
attach sb at isapnp with sb_isapnp
file dev/isa/sb_isapnp.c sb & (sb_isa | sb_isapnp) needs-flag
diff --git a/sys/dev/isa/wdc.c b/sys/dev/isa/wdc.c
index 18f8bb88363..0e359a17baa 100644
--- a/sys/dev/isa/wdc.c
+++ b/sys/dev/isa/wdc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wdc.c,v 1.28 1998/04/28 05:41:08 angelos Exp $ */
+/* $OpenBSD: wdc.c,v 1.29 1998/07/05 07:20:02 downsj Exp $ */
/* $NetBSD: wd.c,v 1.150 1996/05/12 23:54:03 mycroft Exp $ */
/*
@@ -68,6 +68,8 @@
#include <dev/isa/wdreg.h>
#include <dev/isa/wdlink.h>
+#include "wdc.h"
+
#include "atapibus.h"
#if NATAPIBUS > 0
#include <dev/atapi/atapilink.h>
@@ -94,9 +96,17 @@ int wdcprint __P((void *, const char *));
void wdcattach __P((struct device *, struct device *, void *));
int wdcintr __P((void *));
-struct cfattach wdc_ca = {
+#if NWDC_ISA
+struct cfattach wdc_isa_ca = {
+ sizeof(struct wdc_softc), wdcprobe, wdcattach
+};
+#endif
+
+#if NWDC_ISAPNP
+struct cfattach wdc_isapnp_ca = {
sizeof(struct wdc_softc), wdcprobe, wdcattach
};
+#endif
struct cfdriver wdc_cd = {
NULL, "wdc", DV_DULL
@@ -137,6 +147,14 @@ static int wdc_nxfer;
#define WDDEBUG_PRINT(args)
#endif
+/* Macro for determining bus type. */
+#if NWDC_ISAPNP
+#define IS_ISAPNP(parent) \
+ !strcmp((parent)->dv_cfdata->cf_driver->cd_name, "isapnp")
+#else
+#define IS_ISAPNP(parent) 0
+#endif
+
int
wdcprobe(parent, match, aux)
struct device *parent;
@@ -146,6 +164,7 @@ wdcprobe(parent, match, aux)
bus_space_handle_t ioh;
struct wdc_softc *wdc = match;
struct isa_attach_args *ia = aux;
+ int err;
#if NISADMA == 0
if (ia->ia_drq != DRQUNK) {
@@ -155,33 +174,31 @@ wdcprobe(parent, match, aux)
#endif
wdc->sc_iot = iot = ia->ia_iot;
- if (bus_space_map(iot, ia->ia_iobase, 8, 0, &ioh))
- return 0;
+ if (IS_ISAPNP(parent)) {
+ ioh = ia->ia_ioh;
+ } else {
+ if (bus_space_map(iot, ia->ia_iobase, 8, 0, &ioh))
+ return 0;
+ }
wdc->sc_ioh = ioh;
/* Check if we have registers that work. */
- /* Error register not writable, */
- bus_space_write_1(iot, ioh, wd_error, 0x5a);
- /* but all of cyl_lo are. */
bus_space_write_1(iot, ioh, wd_cyl_lo, 0xa5);
- if (bus_space_read_1(iot, ioh, wd_error) == 0x5a ||
- bus_space_read_1(iot, ioh, wd_cyl_lo) != 0xa5) {
+ if (bus_space_read_1(iot, ioh, wd_cyl_lo) == 0xff) {
/*
* Test for a controller with no IDE master, just one
* ATAPI device. Select drive 1, and try again.
*/
bus_space_write_1(iot, ioh, wd_sdh, WDSD_IBM | 0x10);
- bus_space_write_1(iot, ioh, wd_error, 0x5a);
bus_space_write_1(iot, ioh, wd_cyl_lo, 0xa5);
- if (bus_space_read_1(iot, ioh, wd_error) == 0x5a ||
- bus_space_read_1(iot, ioh, wd_cyl_lo) != 0xa5)
+ if (bus_space_read_1(iot, ioh, wd_cyl_lo) == 0xff)
goto nomatch;
wdc->sc_flags |= WDCF_ONESLAVE;
}
if (wdcreset(wdc, WDCRESET_SILENT) != 0) {
/*
- * if the reset failed,, there is no master. test for ATAPI
+ * If the reset failed, there is no master. test for ATAPI
* signature on the slave device. If no ATAPI slave, wait 5s
* and retry a reset.
*/
@@ -212,6 +229,21 @@ wdcprobe(parent, match, aux)
if (wait_for_unbusy(wdc) < 0)
goto nomatch;
+ /* See if the drive(s) are alive. */
+ err = bus_space_read_1(iot, ioh, wd_error);
+ if (err && (err != 0x01)) {
+ if (err & 0x80) {
+ /* Select drive 1. */
+ bus_space_write_1(iot, ioh, wd_sdh, WDSD_IBM | 0x10);
+ (void) wait_for_unbusy(wdc);
+
+ err = bus_space_read_1(iot, ioh, wd_error);
+ if ((err != 0x01) && (err != 0x81))
+ goto nomatch;
+ } else
+ goto nomatch;
+ }
+
ia->ia_iosize = 8;
ia->ia_msize = 0;
#ifdef notyet
@@ -1191,7 +1223,7 @@ wdc_atapi_get_params(ab_link, drive, id)
wdcbit_bucket(wdc, excess);
end: /* Restart the queue. */
- WDDEBUG_PRINT(("wdcstart from wdc_atapi_get_parms flags %d\n",
+ WDDEBUG_PRINT(("wdcstart from wdc_atapi_get_params flags %d\n",
wdc->sc_flags));
wdc->sc_flags &= ~WDCF_ACTIVE;
wdcstart(wdc);
@@ -1650,7 +1682,6 @@ wdcwait(wdc, mask)
wdc->sc_status = status = bus_space_read_1(iot, ioh,
wd_status);
/*
- * XXX
* If a single slave ATAPI device is attached, it may
* have released the bus. Select it and try again.
*/