diff options
author | mdodd <mdodd@FreeBSD.org> | 1999-10-09 03:39:47 +0000 |
---|---|---|
committer | mdodd <mdodd@FreeBSD.org> | 1999-10-09 03:39:47 +0000 |
commit | 7b08684353b61d72f62f872ffeae28a25233f9dc (patch) | |
tree | a3b7b100cbd8abc8c4427d324915a0aff52eefdb /sys/dev/dpt | |
parent | 6af4cfa2bb9d7defdaa391b26c3b0636fdcb8927 (diff) | |
download | FreeBSD-src-7b08684353b61d72f62f872ffeae28a25233f9dc.zip FreeBSD-src-7b08684353b61d72f62f872ffeae28a25233f9dc.tar.gz |
- Implement a simple PIO driven function for retreiving the onboard
configuration information from a DPT card at a given port.
This is needed by the ISA bus front end (still to come) and the EISA
bus front end (which hasn't ever worked).
- Blow away dpt_eisa.h as the information it contains does not justify
an additional file.
- Convert dpt_eisa.c to use the onboard config instead of trying to
read the EISA configuration registers.
Diffstat (limited to 'sys/dev/dpt')
-rw-r--r-- | sys/dev/dpt/dpt.h | 2 | ||||
-rw-r--r-- | sys/dev/dpt/dpt_eisa.c | 64 | ||||
-rw-r--r-- | sys/dev/dpt/dpt_eisa.h | 66 | ||||
-rw-r--r-- | sys/dev/dpt/dpt_scsi.c | 106 |
4 files changed, 137 insertions, 101 deletions
diff --git a/sys/dev/dpt/dpt.h b/sys/dev/dpt/dpt.h index 6202f5a..4d151eb 100644 --- a/sys/dev/dpt/dpt.h +++ b/sys/dev/dpt/dpt.h @@ -1277,6 +1277,8 @@ int dpt_init(struct dpt_softc *dpt); int dpt_attach(dpt_softc_t * dpt); void dpt_intr(void *arg); +dpt_conf_t * dpt_pio_get_conf(u_int32_t); + #if 0 extern void hex_dump(u_char * data, int length, char *name, int no); diff --git a/sys/dev/dpt/dpt_eisa.c b/sys/dev/dpt/dpt_eisa.c index 8518214..67b77d1 100644 --- a/sys/dev/dpt/dpt_eisa.c +++ b/sys/dev/dpt/dpt_eisa.c @@ -59,7 +59,6 @@ #include <dev/dpt/dpt.h> #include <i386/eisa/eisaconf.h> -#include <i386/eisa/dpt_eisa.h> #include <machine/clock.h> @@ -67,6 +66,24 @@ #include <vm/vm_param.h> #include <vm/pmap.h> +#define DPT_EISA_IOSIZE 0x100 +#define DPT_EISA_SLOT_OFFSET 0x0c00 +#define DPT_EISA_EATA_REG_OFFSET 0x0088 + +#define DPT_EISA_DPT2402 0x12142402 +#define DPT_EISA_DPTA401 0x1214A401 +#define DPT_EISA_DPTA402 0x1214A402 +#define DPT_EISA_DPTA410 0x1214A410 +#define DPT_EISA_DPTA411 0x1214A411 +#define DPT_EISA_DPTA412 0x1214A412 +#define DPT_EISA_DPTA420 0x1214A420 +#define DPT_EISA_DPTA501 0x1214A501 +#define DPT_EISA_DPTA502 0x1214A502 +#define DPT_EISA_DPTA701 0x1214A701 +#define DPT_EISA_DPTBC01 0x1214BC01 +#define DPT_EISA_NEC8200 0x12148200 +#define DPT_EISA_ATT2408 0x12142408 + /* Function Prototypes */ static const char *dpt_eisa_match(eisa_id_t); @@ -74,49 +91,26 @@ static const char *dpt_eisa_match(eisa_id_t); static int dpt_eisa_probe(device_t dev) { - const char *desc; - u_int32_t io_base; - u_int intdef; - u_int irq; - int shared; + const char * desc; + u_int32_t io_base; + dpt_conf_t * conf; desc = dpt_eisa_match(eisa_get_id(dev)); if (!desc) return (ENXIO); device_set_desc(dev, desc); - io_base = (eisa_get_slot(dev) * EISA_SLOT_SIZE) - + DPT_EISA_SLOT_OFFSET; - - eisa_add_iospace(dev, io_base, DPT_EISA_IOSIZE, RESVADDR_NONE); + io_base = (eisa_get_slot(dev) * EISA_SLOT_SIZE) + DPT_EISA_SLOT_OFFSET; - outb((DPT_EISA_CFENABLE + io_base), 0xf8); - - intdef = inb(DPT_EISA_INTDEF + io_base); - - irq = intdef & DPT_EISA_INT_NUM_MASK; - shared = (intdef & DPT_EISA_INT_LEVEL) - ? EISA_TRIGGER_LEVEL : EISA_TRIGGER_EDGE; - switch (irq) { - case DPT_EISA_INT_NUM_11: - irq = 11; - break; - case DPT_EISA_INT_NUM_15: - irq = 15; - break; - case DPT_EISA_INT_NUM_14: - irq = 14; - break; - default: - device_printf(dev, "dpt at slot %d: illegal irq setting %d\n", - eisa_get_slot(dev), irq); - irq = 0; - break; + conf = dpt_pio_get_conf(io_base + DPT_EISA_EATA_REG_OFFSET); + if (!conf) { + printf("dpt: dpt_pio_get_conf() failed.\n"); + return (ENXIO); } - if (irq == 0) - return (ENXIO); - eisa_add_intr(dev, irq, shared); + eisa_add_iospace(dev, io_base, DPT_EISA_IOSIZE, RESVADDR_NONE); + eisa_add_intr(dev, conf->IRQ, + (conf->IRQ_TR ? EISA_TRIGGER_LEVEL : EISA_TRIGGER_EDGE)); return 0; } diff --git a/sys/dev/dpt/dpt_eisa.h b/sys/dev/dpt/dpt_eisa.h deleted file mode 100644 index 683ff65..0000000 --- a/sys/dev/dpt/dpt_eisa.h +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 1997 by Matthew N. Dodd <winter@jurai.net> - * All Rights Reserved - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification, immediately at the beginning of the file. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* Credits: Based on and part of the DPT driver for FreeBSD written and - * maintained by Simon Shapiro <shimon@simon-shapiro.org> - */ - -/* - * $FreeBSD$ - */ - -#define DPT_EISA_SLOT_OFFSET 0xc00 -#define DPT_EISA_IOSIZE 0x100 - -#define DPT_EISA_CFENABLE 0x8f - -#define DPT_EISA_INTDEF 0x90 -#define DPT_EISA_INT_LEVEL 0x04 -#define DPT_EISA_INT_NUM_MASK 0x38 -#define DPT_EISA_INT_NUM_11 0x08 -#define DPT_EISA_INT_NUM_15 0x10 -#define DPT_EISA_INT_NUM_14 0x20 - -#define DPT_EISA_EATA_REG_OFFSET 0x88 - -#define ISA_PRIMARY_WD_ADDRESS 0x1f8 - -#define DPT_EISA_DPT2402 0x12142402 -#define DPT_EISA_DPTA401 0x1214A401 -#define DPT_EISA_DPTA402 0x1214A402 -#define DPT_EISA_DPTA410 0x1214A410 -#define DPT_EISA_DPTA411 0x1214A411 -#define DPT_EISA_DPTA412 0x1214A412 -#define DPT_EISA_DPTA420 0x1214A420 -#define DPT_EISA_DPTA501 0x1214A501 -#define DPT_EISA_DPTA502 0x1214A502 -#define DPT_EISA_DPTA701 0x1214A701 -#define DPT_EISA_DPTBC01 0x1214BC01 -#define DPT_EISA_NEC8200 0x12148200 -#define DPT_EISA_ATT2408 0x12142408 diff --git a/sys/dev/dpt/dpt_scsi.c b/sys/dev/dpt/dpt_scsi.c index 5858ee2..86449f0 100644 --- a/sys/dev/dpt/dpt_scsi.c +++ b/sys/dev/dpt/dpt_scsi.c @@ -108,6 +108,7 @@ struct dpt_softc_list dpt_softcs = TAILQ_HEAD_INITIALIZER(dpt_softcs); /* ================= Private Inline Function declarations ===================*/ static __inline int dpt_just_reset(dpt_softc_t * dpt); static __inline int dpt_raid_busy(dpt_softc_t * dpt); +static __inline int dpt_pio_wait (u_int32_t, u_int, u_int, u_int); static __inline int dpt_wait(dpt_softc_t *dpt, u_int bits, u_int state); static __inline struct dpt_ccb* dptgetccb(struct dpt_softc *dpt); @@ -183,6 +184,22 @@ dpt_raid_busy(dpt_softc_t * dpt) } static __inline int +dpt_pio_wait (u_int32_t base, u_int reg, u_int bits, u_int state) +{ + int i; + u_int c; + + for (i = 0; i < 20000; i++) { /* wait 20ms for not busy */ + c = inb(base + reg) & bits; + if (!(c == state)) + return (0); + else + DELAY(50); + } + return (-1); +} + +static __inline int dpt_wait(dpt_softc_t *dpt, u_int bits, u_int state) { int i; @@ -371,6 +388,95 @@ dptallocccbs(dpt_softc_t *dpt) return (i); } +dpt_conf_t * +dpt_pio_get_conf (u_int32_t base) +{ + static dpt_conf_t * conf; + u_int16_t * p; + int i; + + /* + * Allocate a dpt_conf_t + */ + if (!conf) { + conf = (dpt_conf_t *)malloc(sizeof(dpt_conf_t), + M_DEVBUF, M_NOWAIT); + } + + /* + * If we didn't get one then we probably won't ever get one. + */ + if (!conf) { + printf("dpt: unable to allocate dpt_conf_t\n"); + return (NULL); + } + + /* + * If we have one, clean it up. + */ + bzero(conf, sizeof(dpt_conf_t)); + + /* + * Reset the controller. + */ + outb((base + HA_WCOMMAND), EATA_CMD_RESET); + + /* + * Wait for the controller to become ready. + */ + if (dpt_pio_wait(base, HA_RSTATUS, HA_SBUSY, 0)) { + printf("dpt: timeout waiting for controller to become ready\n"); + return (NULL); + } + + if (dpt_pio_wait(base, HA_RAUXSTAT, HA_ABUSY, 0)) { + printf("dpt: timetout waiting for adapter ready.\n"); + return (NULL); + } + + /* + * Send the PIO_READ_CONFIG command. + */ + outb((base + HA_WCOMMAND), EATA_CMD_PIO_READ_CONFIG); + + /* + * Read the data into the struct. + */ + p = (u_int16_t *)conf; + for (i = 0; i < (sizeof(dpt_conf_t) / 2); i++) { + + if (dpt_pio_wait(base, HA_RSTATUS, HA_SDRQ, 0)) { + printf("dpt: timeout in data read.\n"); + return (NULL); + } + + *p = inw(base + HA_RDATA); + p++; + } + + if (inb(base + HA_RSTATUS) & HA_SERROR) { + printf("dpt: error reading configuration data.\n"); + return (NULL); + } + +#define BE_EATA_SIGNATURE 0x45415441 +#define LE_EATA_SIGNATURE 0x41544145 + + /* + * Test to see if we have a valid card. + */ + if ((conf->signature == BE_EATA_SIGNATURE) || + (conf->signature == LE_EATA_SIGNATURE)) { + + while (inb(base + HA_RSTATUS) & HA_SDRQ) { + inw(base + HA_RDATA); + } + + return (conf); + } + return (NULL); +} + /* * Read a configuration page into the supplied dpt_cont_t buffer. */ |