diff options
| author | fvdl <fvdl@NetBSD.org> | 2000-03-15 02:04:43 +0000 |
|---|---|---|
| committer | fvdl <fvdl@NetBSD.org> | 2000-03-15 02:04:43 +0000 |
| commit | 7df6153163e4fc2345ae9eab0f903e0450e33ca2 (patch) | |
| tree | f80f3104703d4ecabe78e905480fcaec2306ec15 /sys/dev | |
| parent | 2da1f00fcd5f2e4a55f21aacec53311a97b2470b (diff) | |
Update EISA frontend for new ahc driver (done by Noriyuki Soda).
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/eisa/ahc_eisa.c | 290 | ||||
| -rw-r--r-- | sys/dev/eisa/files.eisa | 4 |
2 files changed, 110 insertions, 184 deletions
diff --git a/sys/dev/eisa/ahc_eisa.c b/sys/dev/eisa/ahc_eisa.c index 7d78a7b8eba..ca674ad0c0a 100644 --- a/sys/dev/eisa/ahc_eisa.c +++ b/sys/dev/eisa/ahc_eisa.c @@ -1,10 +1,10 @@ -/* $NetBSD: ahc_eisa.c,v 1.17 2000/01/26 06:41:11 thorpej Exp $ */ +/* $NetBSD: ahc_eisa.c,v 1.18 2000/03/15 02:04:43 fvdl Exp $ */ /* * Product specific probe and attach routines for: - * 27/284X and aic7770 motherboard SCSI controllers + * 274X and aic7770 motherboard SCSI controllers * - * Copyright (c) 1994, 1995, 1996 Justin T. Gibbs. + * Copyright (c) 1994, 1995, 1996, 1997, 1998 Justin T. Gibbs. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -13,10 +13,7 @@ * 1. Redistributions of source code must retain the above copyright * notice immediately at the beginning of the file, without modification, * this list of conditions, and the following disclaimer. - * 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 + * 2. 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 @@ -31,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from Id: aic7770.c,v 1.29 1996/05/30 07:18:52 gibbs Exp + * $FreeBSD: src/sys/dev/aic7xxx/ahc_eisa.c,v 1.15 2000/01/29 14:22:19 peter Exp $ */ #include <sys/param.h> @@ -50,12 +47,10 @@ #include <dev/eisa/eisavar.h> #include <dev/eisa/eisadevs.h> -#include <dev/ic/aic7xxxreg.h> +#include <dev/microcode/aic7xxx/aic7xxx_reg.h> #include <dev/ic/aic7xxxvar.h> - -#define AHC_EISA_SLOT_OFFSET 0xc00 -#define AHC_EISA_IOSIZE 0x100 -#define INTDEF 0x5cul /* Interrupt Definition Register */ +#include <dev/ic/aic77xxreg.h> +#include <dev/ic/aic77xxvar.h> /* * Under normal circumstances, these messages are unnecessary @@ -64,49 +59,18 @@ #ifdef DEBUG #define bootverbose 1 #else -#define bootverbose 0 +#define bootverbose 1 #endif -int ahc_eisa_irq __P((bus_space_tag_t, bus_space_handle_t)); int ahc_eisa_match __P((struct device *, struct cfdata *, void *)); void ahc_eisa_attach __P((struct device *, struct device *, void *)); struct cfattach ahc_eisa_ca = { - sizeof(struct ahc_data), ahc_eisa_match, ahc_eisa_attach + sizeof(struct ahc_softc), ahc_eisa_match, ahc_eisa_attach }; /* - * Return irq setting of the board, otherwise -1. - */ -int -ahc_eisa_irq(iot, ioh) - bus_space_tag_t iot; - bus_space_handle_t ioh; -{ - int irq; - u_char intdef; - - ahc_reset("ahc_eisa", iot, ioh); - intdef = bus_space_read_1(iot, ioh, INTDEF); - switch (irq = (intdef & 0xf)) { - case 9: - case 10: - case 11: - case 12: - case 14: - case 15: - break; - default: - printf("ahc_eisa_irq: illegal irq setting %d\n", intdef); - return -1; - } - - /* Note that we are going and return (to probe) */ - return irq; -} - -/* * Check the slots looking for a board we recognise * If we find one, note it's address (slot) and call * the actual probe routine to check it out. @@ -124,19 +88,14 @@ ahc_eisa_match(parent, match, aux) /* must match one of our known ID strings */ if (strcmp(ea->ea_idstring, "ADP7770") && - strcmp(ea->ea_idstring, "ADP7771") -#if 0 - && strcmp(ea->ea_idstring, "ADP7756") /* not EISA, but VL */ - && strcmp(ea->ea_idstring, "ADP7757") /* not EISA, but VL */ -#endif - ) + strcmp(ea->ea_idstring, "ADP7771")) return (0); if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) + AHC_EISA_SLOT_OFFSET, AHC_EISA_IOSIZE, 0, &ioh)) return (0); - irq = ahc_eisa_irq(iot, ioh); + irq = ahc_aic77xx_irq(iot, ioh); bus_space_unmap(iot, ioh, AHC_EISA_IOSIZE); @@ -148,58 +107,79 @@ ahc_eisa_attach(parent, self, aux) struct device *parent, *self; void *aux; { - ahc_type type; - struct ahc_data *ahc = (void *)self; + struct ahc_softc *ahc = (void *)self; struct eisa_attach_args *ea = aux; - bus_space_tag_t iot = ea->ea_iot; - bus_space_handle_t ioh; - int irq; eisa_chipset_tag_t ec = ea->ea_ec; eisa_intr_handle_t ih; - const char *model, *intrstr; + bus_space_tag_t iot = ea->ea_iot; + bus_space_handle_t ioh; + int irq, intrtype; + const char *intrstr, *intrtypestr; + u_int biosctrl; + u_int scsiconf; + u_int scsiconf1; +#if DEBUG + int i; +#endif if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) + AHC_EISA_SLOT_OFFSET, AHC_EISA_IOSIZE, 0, &ioh)) - panic("ahc_eisa_attach: could not map I/O addresses"); - if ((irq = ahc_eisa_irq(iot, ioh)) < 0) - panic("ahc_eisa_attach: ahc_eisa_irq failed!"); + panic("%s: could not map I/O addresses", ahc->sc_dev.dv_xname); + if ((irq = ahc_aic77xx_irq(iot, ioh)) < 0) + panic("%s: ahc_aic77xx_irq failed!", ahc->sc_dev.dv_xname); if (strcmp(ea->ea_idstring, "ADP7770") == 0) { - model = EISA_PRODUCT_ADP7770; - type = AHC_AIC7770; + printf(": %s\n", EISA_PRODUCT_ADP7770); } else if (strcmp(ea->ea_idstring, "ADP7771") == 0) { - model = EISA_PRODUCT_ADP7771; - type = AHC_274; -#if 0 - } else if (strcmp(ea->ea_idstring, "ADP7756") == 0) { - model = EISA_PRODUCT_ADP7756; - type = AHC_284; - } else if (strcmp(ea->ea_idstring, "ADP7757") == 0) { - model = EISA_PRODUCT_ADP7757; - type = AHC_284; -#endif + printf(": %s\n", EISA_PRODUCT_ADP7771); } else { - panic("ahc_eisa_attach: Unknown device type %s\n", - ea->ea_idstring); + panic(": Unknown device type %s\n", ea->ea_idstring); } - printf(": %s\n", model); - ahc_construct(ahc, iot, ioh, ea->ea_dmat, type, AHC_FNONE); + if (ahc_alloc(ahc, ioh, iot, ea->ea_dmat, + AHC_AIC7770|AHC_EISA, AHC_AIC7770_FE, AHC_FNONE) < 0) + goto free_io; + + ahc->channel = 'A'; + ahc->channel_b = 'B'; + if (ahc_reset(ahc) != 0) + goto free_ahc; + if (eisa_intr_map(ec, irq, &ih)) { printf("%s: couldn't map interrupt (%d)\n", ahc->sc_dev.dv_xname, irq); - return; + goto free_ahc; } /* + * The IRQMS bit enables level sensitive interrupts. Only allow + * IRQ sharing if it's set. + * NOTE: ahc->pause is initialized in ahc_alloc(). + * * Tell the user what type of interrupts we're using. * usefull for debugging irq problems */ - if(bootverbose) { - printf("%s: Using %s Interrupts\n", - ahc_name(ahc), - ahc->pause & IRQMS ? "Level Sensitive" : "Edge Triggered"); + if (ahc->pause & IRQMS) { + intrtype = IST_LEVEL; + intrtypestr = "level sensitive"; + } else { + intrtype = IST_EDGE; + intrtypestr = "edge triggered"; } + intrstr = eisa_intr_string(ec, ih); + ahc->ih = eisa_intr_establish(ec, ih, + intrtype, IPL_BIO, ahc_intr, ahc); + if (ahc->ih == NULL) { + printf("%s: couldn't establish %s interrupt", + ahc->sc_dev.dv_xname, intrtypestr); + if (intrstr != NULL) + printf(" at %s", intrstr); + printf("\n"); + goto free_ahc; + } + if (intrstr != NULL) + printf("%s: %s interrupting at %s\n", ahc->sc_dev.dv_xname, + intrtypestr, intrstr); /* * Now that we know we own the resources we need, do the @@ -207,111 +187,57 @@ ahc_eisa_attach(parent, self, aux) * * First, the aic7770 card specific setup. */ - switch( ahc->type ) { - case AHC_AIC7770: - case AHC_274: - { - u_char biosctrl = AHC_INB(ahc, HA_274_BIOSCTRL); - - /* Get the primary channel information */ - ahc->flags |= (biosctrl & CHANNEL_B_PRIMARY); - - if((biosctrl & BIOSMODE) == BIOSDISABLED) - ahc->flags |= AHC_USEDEFAULTS; - break; - } - case AHC_284: - { - /* XXX - * All values are automagically intialized at - * POST for these cards, so we can always rely - * on the Scratch Ram values. However, we should - * read the SEEPROM here (Dan has the code to do - * it) so we can say what kind of translation the - * BIOS is using. Printing out the geometry could - * save a lot of users the grief of failed installs. - */ - break; - } - default: - break; - } - - /* - * See if we have a Rev E or higher aic7770. Anything below a - * Rev E will have a R/O autoflush disable configuration bit. - * It's still not clear exactly what is differenent about the Rev E. - * We think it allows 8 bit entries in the QOUTFIFO to support - * "paging" SCBs so you can have more than 4 commands active at - * once. - */ - { - char *id_string; - u_char sblkctl; - u_char sblkctl_orig; - - sblkctl_orig = AHC_INB(ahc, SBLKCTL); - sblkctl = sblkctl_orig ^ AUTOFLUSHDIS; - AHC_OUTB(ahc, SBLKCTL, sblkctl); - sblkctl = AHC_INB(ahc, SBLKCTL); - if(sblkctl != sblkctl_orig) - { - id_string = "aic7770 >= Rev E, "; - /* - * Ensure autoflush is enabled - */ - sblkctl &= ~AUTOFLUSHDIS; - AHC_OUTB(ahc, SBLKCTL, sblkctl); - - /* Allow paging on this adapter */ - ahc->flags |= AHC_PAGESCBS; - } - else - id_string = "aic7770 <= Rev C, "; - - printf("%s: %s", ahc_name(ahc), id_string); + biosctrl = ahc_inb(ahc, HA_274_BIOSCTRL); + scsiconf = ahc_inb(ahc, SCSICONF); + scsiconf1 = ahc_inb(ahc, SCSICONF + 1); + +#if DEBUG + for (i = TARG_SCSIRATE; i <= HA_274_BIOSCTRL; i+=8) { + printf("0x%x, 0x%x, 0x%x, 0x%x, " + "0x%x, 0x%x, 0x%x, 0x%x\n", + ahc_inb(ahc, i), + ahc_inb(ahc, i+1), + ahc_inb(ahc, i+2), + ahc_inb(ahc, i+3), + ahc_inb(ahc, i+4), + ahc_inb(ahc, i+5), + ahc_inb(ahc, i+6), + ahc_inb(ahc, i+7)); } +#endif - /* Setup the FIFO threshold and the bus off time */ - { - u_char hostconf = AHC_INB(ahc, HOSTCONF); - AHC_OUTB(ahc, BUSSPD, hostconf & DFTHRSH); - AHC_OUTB(ahc, BUSTIME, (hostconf << 2) & BOFF); - } + /* Get the primary channel information */ + if ((biosctrl & CHANNEL_B_PRIMARY) != 0) + ahc->flags |= AHC_CHANNEL_B_PRIMARY; - /* - * Generic aic7xxx initialization. - */ - if(ahc_init(ahc)){ - ahc_free(ahc); - return; + if ((biosctrl & BIOSMODE) == BIOSDISABLED) { + ahc->flags |= AHC_USEDEFAULTS; + } else if ((ahc->features & AHC_WIDE) != 0) { + ahc->our_id = scsiconf1 & HWSCSIID; + if (scsiconf & TERM_ENB) + ahc->flags |= AHC_TERM_ENB_A; + } else { + ahc->our_id = scsiconf & HSCSIID; + ahc->our_id_b = scsiconf1 & HSCSIID; + if (scsiconf & TERM_ENB) + ahc->flags |= AHC_TERM_ENB_A; + if (scsiconf1 & TERM_ENB) + ahc->flags |= AHC_TERM_ENB_B; } - /* - * Enable the board's BUS drivers + * We have no way to tell, so assume extended + * translation is enabled. */ - AHC_OUTB(ahc, BCTL, ENABLE); + ahc->flags |= AHC_EXTENDED_TRANS_A|AHC_EXTENDED_TRANS_B; - intrstr = eisa_intr_string(ec, ih); - /* - * The IRQMS bit enables level sensitive interrupts only allow - * IRQ sharing if its set. - */ - ahc->sc_ih = eisa_intr_establish(ec, ih, - ahc->pause & IRQMS ? IST_LEVEL : IST_EDGE, IPL_BIO, ahc_intr, ahc); - if (ahc->sc_ih == NULL) { - printf("%s: couldn't establish interrupt", - ahc->sc_dev.dv_xname); - if (intrstr != NULL) - printf(" at %s", intrstr); - printf("\n"); - ahc_free(ahc); - return; - } - if (intrstr != NULL) - printf("%s: interrupting at %s\n", ahc->sc_dev.dv_xname, - intrstr); + /* Attach sub-devices */ + if (ahc_aic77xx_attach(ahc) == 0) + return; /* succeed */ - /* Attach sub-devices - always succeeds */ - ahc_attach(ahc); + /* failed */ + eisa_intr_disestablish(ec, ahc->ih); +free_ahc: + ahc_free(ahc); +free_io: + bus_space_unmap(iot, ioh, AHC_EISA_IOSIZE); } diff --git a/sys/dev/eisa/files.eisa b/sys/dev/eisa/files.eisa index 69d9975172d..704e4b4998c 100644 --- a/sys/dev/eisa/files.eisa +++ b/sys/dev/eisa/files.eisa @@ -1,4 +1,4 @@ -# $NetBSD: files.eisa,v 1.19 1999/09/29 20:38:51 ad Exp $ +# $NetBSD: files.eisa,v 1.20 2000/03/15 02:04:43 fvdl Exp $ # # Config file and device description for machine-independent EISA code. # Included by ports that need it. Requires that the SCSI files be @@ -17,7 +17,7 @@ file dev/eisa/ahb.c ahb # Adaptec AHA-274x and aic7770 motherboard SCSI controllers # device declaration in sys/conf/files -attach ahc at eisa with ahc_eisa +attach ahc at eisa with ahc_eisa: ahc_aic77xx file dev/eisa/ahc_eisa.c ahc_eisa # BusLogic BT-7xx EISA family |
