The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/eisa/ahc_eisa.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: ahc_eisa.c,v 1.33 2006/11/16 01:32:50 christos Exp $   */
    2 
    3 /*
    4  * Product specific probe and attach routines for:
    5  *      274X and aic7770 motherboard SCSI controllers
    6  *
    7  * Copyright (c) 1994, 1995, 1996, 1997, 1998 Justin T. Gibbs.
    8  * All rights reserved.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice immediately at the beginning of the file, without modification,
   15  *    this list of conditions, and the following disclaimer.
   16  * 2. The name of the author may not be used to endorse or promote products
   17  *    derived from this software without specific prior written permission.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
   23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  *
   31  * $FreeBSD: src/sys/dev/aic7xxx/ahc_eisa.c,v 1.15 2000/01/29 14:22:19 peter Exp $
   32  */
   33 
   34 #include <sys/cdefs.h>
   35 __KERNEL_RCSID(0, "$NetBSD: ahc_eisa.c,v 1.33 2006/11/16 01:32:50 christos Exp $");
   36 
   37 #include <sys/param.h>
   38 #include <sys/systm.h>
   39 #include <sys/kernel.h>
   40 #include <sys/device.h>
   41 #include <sys/reboot.h>
   42 
   43 #include <machine/bus.h>
   44 #include <machine/intr.h>
   45 
   46 #include <dev/scsipi/scsi_all.h>
   47 #include <dev/scsipi/scsipi_all.h>
   48 #include <dev/scsipi/scsiconf.h>
   49 
   50 #include <dev/eisa/eisareg.h>
   51 #include <dev/eisa/eisavar.h>
   52 #include <dev/eisa/eisadevs.h>
   53 
   54 #include <dev/ic/aic7xxx_osm.h>
   55 #include <dev/ic/aic7xxx_inline.h>
   56 #include <dev/ic/aic77xxreg.h>
   57 #include <dev/ic/aic77xxvar.h>
   58 
   59 static int      ahc_eisa_match(struct device *, struct cfdata *, void *);
   60 static void     ahc_eisa_attach(struct device *, struct device *, void *);
   61 
   62 
   63 CFATTACH_DECL(ahc_eisa, sizeof(struct ahc_softc),
   64     ahc_eisa_match, ahc_eisa_attach, NULL, NULL);
   65 
   66 /*
   67  * Check the slots looking for a board we recognise
   68  * If we find one, note it's address (slot) and call
   69  * the actual probe routine to check it out.
   70  */
   71 static int
   72 ahc_eisa_match(struct device *parent, struct cfdata *match,
   73     void *aux)
   74 {
   75         struct eisa_attach_args *ea = aux;
   76         bus_space_tag_t iot = ea->ea_iot;
   77         bus_space_handle_t ioh;
   78         int irq;
   79 
   80         /* must match one of our known ID strings */
   81         if (strcmp(ea->ea_idstring, "ADP7770") &&
   82             strcmp(ea->ea_idstring, "ADP7771"))
   83                 return (0);
   84 
   85         if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
   86             AHC_EISA_SLOT_OFFSET, AHC_EISA_IOSIZE, 0, &ioh))
   87                 return (0);
   88 
   89         irq = ahc_aic77xx_irq(iot, ioh);
   90 
   91         bus_space_unmap(iot, ioh, AHC_EISA_IOSIZE);
   92 
   93         return (irq >= 0);
   94 }
   95 
   96 static void
   97 ahc_eisa_attach(struct device *parent, struct device *self, void *aux)
   98 {
   99         struct ahc_softc *ahc = device_private(self);
  100         struct eisa_attach_args *ea = aux;
  101         eisa_chipset_tag_t ec = ea->ea_ec;
  102         eisa_intr_handle_t ih;
  103         bus_space_tag_t iot = ea->ea_iot;
  104         bus_space_handle_t ioh;
  105         int irq, intrtype;
  106         const char *intrstr, *intrtypestr;
  107         u_int biosctrl;
  108         u_int scsiconf;
  109         u_int scsiconf1;
  110         u_char intdef;
  111 #ifdef AHC_DEBUG
  112         int i;
  113 #endif
  114 
  115         if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
  116             AHC_EISA_SLOT_OFFSET, AHC_EISA_IOSIZE, 0, &ioh)) {
  117                 printf("%s: could not map I/O addresses", ahc->sc_dev.dv_xname);
  118                 return;
  119         }
  120         if ((irq = ahc_aic77xx_irq(iot, ioh)) < 0) {
  121                 printf("%s: ahc_aic77xx_irq failed!", ahc->sc_dev.dv_xname);
  122                 goto free_io;
  123         }
  124 
  125         if (strcmp(ea->ea_idstring, "ADP7770") == 0) {
  126                 printf(": %s\n", EISA_PRODUCT_ADP7770);
  127         } else if (strcmp(ea->ea_idstring, "ADP7771") == 0) {
  128                 printf(": %s\n", EISA_PRODUCT_ADP7771);
  129         } else {
  130                 printf(": Unknown device type %s", ea->ea_idstring);
  131                 goto free_io;
  132         }
  133 
  134         ahc_set_name(ahc, ahc->sc_dev.dv_xname);
  135         ahc->parent_dmat = ea->ea_dmat;
  136         ahc->chip = AHC_AIC7770|AHC_EISA;
  137         ahc->features = AHC_AIC7770_FE;
  138         ahc->flags = AHC_PAGESCBS;
  139         ahc->bugs = AHC_TMODE_WIDEODD_BUG;
  140         ahc->tag = iot;
  141         ahc->bsh = ioh;
  142         ahc->channel = 'A';
  143 
  144         if (ahc_softc_init(ahc) != 0)
  145                 goto free_io;
  146 
  147         ahc_intr_enable(ahc, FALSE);
  148 
  149         if (ahc_reset(ahc) != 0)
  150                 goto free_io;
  151 
  152         if (eisa_intr_map(ec, irq, &ih)) {
  153                 printf("%s: couldn't map interrupt (%d)\n",
  154                     ahc->sc_dev.dv_xname, irq);
  155                 goto free_io;
  156         }
  157 
  158         intdef = bus_space_read_1(iot, ioh, INTDEF);
  159 
  160         if (intdef & EDGE_TRIG) {
  161                 intrtype = IST_EDGE;
  162                 intrtypestr = "edge triggered";
  163         } else {
  164                 intrtype = IST_LEVEL;
  165                 intrtypestr = "level sensitive";
  166         }
  167         intrstr = eisa_intr_string(ec, ih);
  168         ahc->ih = eisa_intr_establish(ec, ih,
  169             intrtype, IPL_BIO, ahc_intr, ahc);
  170         if (ahc->ih == NULL) {
  171                 printf("%s: couldn't establish %s interrupt",
  172                     ahc->sc_dev.dv_xname, intrtypestr);
  173                 if (intrstr != NULL)
  174                         printf(" at %s", intrstr);
  175                 printf("\n");
  176                 goto free_io;
  177         }
  178         if (intrstr != NULL)
  179                 printf("%s: %s interrupting at %s\n", ahc->sc_dev.dv_xname,
  180                        intrtypestr, intrstr);
  181 
  182         /*
  183          * Now that we know we own the resources we need, do the
  184          * card initialization.
  185          *
  186          * First, the aic7770 card specific setup.
  187          */
  188         biosctrl = ahc_inb(ahc, HA_274_BIOSCTRL);
  189         scsiconf = ahc_inb(ahc, SCSICONF);
  190         scsiconf1 = ahc_inb(ahc, SCSICONF + 1);
  191 
  192 #ifdef AHC_DEBUG
  193         for (i = TARG_SCSIRATE; i <= HA_274_BIOSCTRL; i+=8) {
  194                 printf("0x%x, 0x%x, 0x%x, 0x%x, "
  195                        "0x%x, 0x%x, 0x%x, 0x%x\n",
  196                        ahc_inb(ahc, i),
  197                        ahc_inb(ahc, i+1),
  198                        ahc_inb(ahc, i+2),
  199                        ahc_inb(ahc, i+3),
  200                        ahc_inb(ahc, i+4),
  201                        ahc_inb(ahc, i+5),
  202                        ahc_inb(ahc, i+6),
  203                        ahc_inb(ahc, i+7));
  204         }
  205 #endif
  206 
  207         /* Get the primary channel information */
  208         if ((biosctrl & CHANNEL_B_PRIMARY) != 0)
  209                 ahc->flags |= AHC_PRIMARY_CHANNEL;
  210 
  211         if ((biosctrl & BIOSMODE) == BIOSDISABLED) {
  212                 ahc->flags |= AHC_USEDEFAULTS;
  213         } else if ((ahc->features & AHC_WIDE) != 0) {
  214                 ahc->our_id = scsiconf1 & HWSCSIID;
  215                 if (scsiconf & TERM_ENB)
  216                         ahc->flags |= AHC_TERM_ENB_A;
  217         } else {
  218                 ahc->our_id = scsiconf & HSCSIID;
  219                 ahc->our_id_b = scsiconf1 & HSCSIID;
  220                 if (scsiconf & TERM_ENB)
  221                         ahc->flags |= AHC_TERM_ENB_A;
  222                 if (scsiconf1 & TERM_ENB)
  223                         ahc->flags |= AHC_TERM_ENB_B;
  224         }
  225         if ((ahc_inb(ahc, HA_274_BIOSGLOBAL) & HA_274_EXTENDED_TRANS))
  226                 ahc->flags |= AHC_EXTENDED_TRANS_A|AHC_EXTENDED_TRANS_B;
  227 
  228         /* Attach sub-devices */
  229         if (ahc_aic77xx_attach(ahc) == 0)
  230                 return; /* succeed */
  231 
  232         /* failed */
  233         eisa_intr_disestablish(ec, ahc->ih);
  234 free_io:
  235         bus_space_unmap(iot, ioh, AHC_EISA_IOSIZE);
  236 }

Cache object: b61b284bd757646dde600d89bbf09e78


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.