diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-01-24 22:38:04 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-01-24 22:38:04 +0000 |
commit | 229f438bede61cf09c0e83a91465b8185242836c (patch) | |
tree | 787c9df7cb41ead1e14f404d9db424dd1ebd5920 /sys/dev/eisa/bha_eisa.c | |
parent | 7a84d429fb74a2b7280f088d6db6689b057661bc (diff) |
bussified and bus-split bustec scsi ha driver.
original port done by chris@ in '98 and pounded into
-current by me, plus support for wide mode.
tested on pci in both modes by me, on eisa (w/
half success, thus not enabled yet) by jason@.
niklas@, jason@, millert@ ok.
Diffstat (limited to 'sys/dev/eisa/bha_eisa.c')
-rw-r--r-- | sys/dev/eisa/bha_eisa.c | 146 |
1 files changed, 107 insertions, 39 deletions
diff --git a/sys/dev/eisa/bha_eisa.c b/sys/dev/eisa/bha_eisa.c index 78794a80f0e..397081d77c8 100644 --- a/sys/dev/eisa/bha_eisa.c +++ b/sys/dev/eisa/bha_eisa.c @@ -1,8 +1,12 @@ -/* $OpenBSD: bha_eisa.c,v 1.1 1996/11/28 23:27:37 niklas Exp $ */ -/* $NetBSD: bha_eisa.c,v 1.5 1996/10/21 22:31:00 thorpej Exp $ */ +/* $OpenBSD: bha_eisa.c,v 1.2 2002/01/24 22:38:03 mickey Exp $ */ +/* $NetBSD: bha_eisa.c,v 1.16 1998/08/15 10:10:49 mycroft Exp $ */ -/* - * Copyright (c) 1994, 1996 Charles M. Hannum. All rights reserved. +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -14,20 +18,23 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Charles M. Hannum. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. */ #include <sys/types.h> @@ -47,9 +54,13 @@ #include <dev/ic/bhareg.h> #include <dev/ic/bhavar.h> -#define BHA_EISA_SLOT_OFFSET 0xc00 -#define BHA_EISA_IOSIZE 0x100 +#define BHA_EISA_SLOT_OFFSET 0x0c80 +#define BHA_EISA_IOSIZE 0x0010 +#define BHA_ISA_IOSIZE 0x0004 + +#define BHA_EISA_IOCONF 0x0c +int bha_eisa_address __P((bus_space_tag_t, bus_space_handle_t, int *)); int bha_eisa_match __P((struct device *, void *, void *)); void bha_eisa_attach __P((struct device *, struct device *, void *)); @@ -57,6 +68,41 @@ struct cfattach bha_eisa_ca = { sizeof(struct bha_softc), bha_eisa_match, bha_eisa_attach }; +int +bha_eisa_address(iot, ioh, portp) + bus_space_tag_t iot; + bus_space_handle_t ioh; + int *portp; +{ + int port; + + switch (bus_space_read_1(iot, ioh, BHA_EISA_IOCONF) & 0x07) { + case 0x00: + port = 0x330; + break; + case 0x01: + port = 0x334; + break; + case 0x02: + port = 0x230; + break; + case 0x03: + port = 0x234; + break; + case 0x04: + port = 0x130; + break; + case 0x05: + port = 0x134; + break; + default: + return (1); + } + + *portp = port; + return (0); +} + /* * Check the slots looking for a board we recognise * If we find one, note it's address (slot) and call @@ -65,11 +111,12 @@ struct cfattach bha_eisa_ca = { int bha_eisa_match(parent, match, aux) struct device *parent; - void *match, *aux; + void *aux, *match; { struct eisa_attach_args *ea = aux; bus_space_tag_t iot = ea->ea_iot; - bus_space_handle_t ioh; + bus_space_handle_t ioh, ioh2; + int port; int rv; /* must match one of our known ID strings */ @@ -77,12 +124,20 @@ bha_eisa_match(parent, match, aux) strcmp(ea->ea_idstring, "BUS4202")) return (0); - if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) + - BHA_EISA_SLOT_OFFSET, BHA_EISA_IOSIZE, 0, &ioh)) + if (bus_space_map(iot, + EISA_SLOT_ADDR(ea->ea_slot) + BHA_EISA_SLOT_OFFSET, BHA_EISA_IOSIZE, + 0, &ioh)) return (0); - rv = bha_find(iot, ioh, NULL); + if (bha_eisa_address(iot, ioh, &port) || + bus_space_map(iot, port, BHA_ISA_IOSIZE, 0, &ioh2)) { + bus_space_unmap(iot, ioh, BHA_EISA_IOSIZE); + return (0); + } + + rv = bha_find(iot, ioh2, NULL); + bus_space_unmap(iot, ioh2, BHA_ISA_IOSIZE); bus_space_unmap(iot, ioh, BHA_EISA_IOSIZE); return (rv); @@ -99,7 +154,9 @@ bha_eisa_attach(parent, self, aux) struct eisa_attach_args *ea = aux; struct bha_softc *sc = (void *)self; bus_space_tag_t iot = ea->ea_iot; - bus_space_handle_t ioh; + bus_space_handle_t ioh, ioh2; + int port; + struct bha_probe_data bpd; eisa_chipset_tag_t ec = ea->ea_ec; eisa_intr_handle_t ih; const char *model, *intrstr; @@ -110,34 +167,45 @@ bha_eisa_attach(parent, self, aux) model = EISA_PRODUCT_BUS4202; else model = "unknown model!"; - printf(": %s\n", model); - if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) + - BHA_EISA_SLOT_OFFSET, BHA_EISA_IOSIZE, 0, &ioh)) - panic("bha_attach: could not map I/O addresses"); + if (bus_space_map(iot, + EISA_SLOT_ADDR(ea->ea_slot) + BHA_EISA_SLOT_OFFSET, BHA_EISA_IOSIZE, + 0, &ioh)) { + printf(": could not map EISA slot\n"); + return; + } + + if (bha_eisa_address(iot, ioh, &port) || + bus_space_map(iot, port, BHA_ISA_IOSIZE, 0, &ioh2)) { + printf(": could not map ISA address\n"); + return; + } sc->sc_iot = iot; - sc->sc_ioh = ioh; - if (!bha_find(iot, ioh, sc)) - panic("bha_attach: bha_find failed!"); + sc->sc_ioh = ioh2; + sc->sc_dmat = ea->ea_dmat; + if (!bha_find(iot, ioh2, &bpd)) { + printf(": bha_find failed\n"); + return; + } + + sc->sc_dmaflags = 0; - if (eisa_intr_map(ec, sc->sc_irq, &ih)) { - printf("%s: couldn't map interrupt (%d)\n", - sc->sc_dev.dv_xname, sc->sc_irq); + if (eisa_intr_map(ec, bpd.sc_irq, &ih)) { + printf(": couldn't map interrupt (%d)\n", bpd.sc_irq); return; } intrstr = eisa_intr_string(ec, ih); sc->sc_ih = eisa_intr_establish(ec, ih, IST_LEVEL, IPL_BIO, bha_intr, sc, sc->sc_dev.dv_xname); if (sc->sc_ih == NULL) { - printf("%s: couldn't establish interrupt", - sc->sc_dev.dv_xname); + printf(": couldn't establish interrupt"); if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); return; } - printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr); + printf(": %s, %s\n", intrstr, model); - bha_attach(sc); + bha_attach(sc, &bpd); } |