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-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: ahc_eisa.c,v 1.42 2021/01/27 04:35:15 thorpej 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.42 2021/01/27 04:35:15 thorpej 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 <sys/bus.h>
   44 #include <sys/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(device_t, cfdata_t, void *);
   60 static void     ahc_eisa_attach(device_t, device_t, void *);
   61 
   62 
   63 CFATTACH_DECL_NEW(ahc_eisa, sizeof(struct ahc_softc),
   64     ahc_eisa_match, ahc_eisa_attach, NULL, NULL);
   65 
   66 static const struct device_compatible_entry compat_data[] = {
   67         { .compat = "ADP7770",  .data = EISA_PRODUCT_ADP7770 },
   68         { .compat = "ADP7771",  .data = EISA_PRODUCT_ADP7771 },
   69         DEVICE_COMPAT_EOL
   70 };
   71 
   72 /*
   73  * Check the slots looking for a board we recognise
   74  * If we find one, note its address (slot) and call
   75  * the actual probe routine to check it out.
   76  */
   77 static int
   78 ahc_eisa_match(device_t parent, cfdata_t match, void *aux)
   79 {
   80         struct eisa_attach_args *ea = aux;
   81         bus_space_tag_t iot = ea->ea_iot;
   82         bus_space_handle_t ioh;
   83         int irq;
   84 
   85         if (!eisa_compatible_match(ea, compat_data))
   86                 return (0);
   87 
   88         if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
   89             AHC_EISA_SLOT_OFFSET, AHC_EISA_IOSIZE, 0, &ioh))
   90                 return (0);
   91 
   92         irq = ahc_aic77xx_irq(iot, ioh);
   93 
   94         bus_space_unmap(iot, ioh, AHC_EISA_IOSIZE);
   95 
   96         return (irq >= 0);
   97 }
   98 
   99 static void
  100 ahc_eisa_attach(device_t parent, device_t self, void *aux)
  101 {
  102         struct ahc_softc *ahc = device_private(self);
  103         struct eisa_attach_args *ea = aux;
  104         const struct device_compatible_entry *dce;
  105         eisa_chipset_tag_t ec = ea->ea_ec;
  106         eisa_intr_handle_t ih;
  107         bus_space_tag_t iot = ea->ea_iot;
  108         bus_space_handle_t ioh;
  109         int irq, intrtype;
  110         const char *intrstr, *intrtypestr;
  111         u_int biosctrl;
  112         u_int scsiconf;
  113         u_int scsiconf1;
  114         u_char intdef;
  115 #ifdef AHC_DEBUG
  116         int i;
  117 #endif
  118         char intrbuf[EISA_INTRSTR_LEN];
  119 
  120         ahc->sc_dev = self;
  121 
  122         dce = eisa_compatible_lookup(ea, compat_data);
  123         KASSERT(dce != NULL);
  124 
  125         if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
  126             AHC_EISA_SLOT_OFFSET, AHC_EISA_IOSIZE, 0, &ioh)) {
  127                 aprint_error_dev(ahc->sc_dev, "could not map I/O addresses");
  128                 return;
  129         }
  130         if ((irq = ahc_aic77xx_irq(iot, ioh)) < 0) {
  131                 aprint_error_dev(ahc->sc_dev, "ahc_aic77xx_irq failed!");
  132                 goto free_io;
  133         }
  134 
  135         printf(": %s\n", (const char *)dce->data);
  136 
  137         ahc_set_name(ahc, device_xname(ahc->sc_dev));
  138         ahc->parent_dmat = ea->ea_dmat;
  139         ahc->chip = AHC_AIC7770|AHC_EISA;
  140         ahc->features = AHC_AIC7770_FE;
  141         ahc->flags = AHC_PAGESCBS;
  142         ahc->bugs = AHC_TMODE_WIDEODD_BUG;
  143         ahc->tag = iot;
  144         ahc->bsh = ioh;
  145         ahc->channel = 'A';
  146 
  147         if (ahc_softc_init(ahc) != 0)
  148                 goto free_io;
  149 
  150         ahc_intr_enable(ahc, FALSE);
  151 
  152         if (ahc_reset(ahc) != 0)
  153                 goto free_io;
  154 
  155         if (eisa_intr_map(ec, irq, &ih)) {
  156                 aprint_error_dev(ahc->sc_dev, "couldn't map interrupt (%d)\n",
  157                     irq);
  158                 goto free_io;
  159         }
  160 
  161         intdef = bus_space_read_1(iot, ioh, INTDEF);
  162 
  163         if (intdef & EDGE_TRIG) {
  164                 intrtype = IST_EDGE;
  165                 intrtypestr = "edge triggered";
  166         } else {
  167                 intrtype = IST_LEVEL;
  168                 intrtypestr = "level sensitive";
  169         }
  170         intrstr = eisa_intr_string(ec, ih, intrbuf, sizeof(intrbuf));
  171         ahc->ih = eisa_intr_establish(ec, ih,
  172             intrtype, IPL_BIO, ahc_intr, ahc);
  173         if (ahc->ih == NULL) {
  174                 aprint_error_dev(ahc->sc_dev,
  175                     "couldn't establish %s interrupt", intrtypestr);
  176                 if (intrstr != NULL)
  177                         aprint_error(" at %s", intrstr);
  178                 aprint_error("\n");
  179                 goto free_io;
  180         }
  181         if (intrstr != NULL)
  182                 aprint_normal_dev(ahc->sc_dev, "%s interrupting at %s\n",
  183                        intrtypestr, intrstr);
  184 
  185         /*
  186          * Now that we know we own the resources we need, do the
  187          * card initialization.
  188          *
  189          * First, the aic7770 card specific setup.
  190          */
  191         biosctrl = ahc_inb(ahc, HA_274_BIOSCTRL);
  192         scsiconf = ahc_inb(ahc, SCSICONF);
  193         scsiconf1 = ahc_inb(ahc, SCSICONF + 1);
  194 
  195 #ifdef AHC_DEBUG
  196         for (i = TARG_SCSIRATE; i <= HA_274_BIOSCTRL; i+=8) {
  197                 printf("0x%x, 0x%x, 0x%x, 0x%x, "
  198                        "0x%x, 0x%x, 0x%x, 0x%x\n",
  199                        ahc_inb(ahc, i),
  200                        ahc_inb(ahc, i+1),
  201                        ahc_inb(ahc, i+2),
  202                        ahc_inb(ahc, i+3),
  203                        ahc_inb(ahc, i+4),
  204                        ahc_inb(ahc, i+5),
  205                        ahc_inb(ahc, i+6),
  206                        ahc_inb(ahc, i+7));
  207         }
  208 #endif
  209 
  210         /* Get the primary channel information */
  211         if ((biosctrl & CHANNEL_B_PRIMARY) != 0)
  212                 ahc->flags |= AHC_PRIMARY_CHANNEL;
  213 
  214         if ((biosctrl & BIOSMODE) == BIOSDISABLED) {
  215                 ahc->flags |= AHC_USEDEFAULTS;
  216         } else if ((ahc->features & AHC_WIDE) != 0) {
  217                 ahc->our_id = scsiconf1 & HWSCSIID;
  218                 if (scsiconf & TERM_ENB)
  219                         ahc->flags |= AHC_TERM_ENB_A;
  220         } else {
  221                 ahc->our_id = scsiconf & HSCSIID;
  222                 ahc->our_id_b = scsiconf1 & HSCSIID;
  223                 if (scsiconf & TERM_ENB)
  224                         ahc->flags |= AHC_TERM_ENB_A;
  225                 if (scsiconf1 & TERM_ENB)
  226                         ahc->flags |= AHC_TERM_ENB_B;
  227         }
  228         if ((ahc_inb(ahc, HA_274_BIOSGLOBAL) & HA_274_EXTENDED_TRANS))
  229                 ahc->flags |= AHC_EXTENDED_TRANS_A|AHC_EXTENDED_TRANS_B;
  230 
  231         /* Attach sub-devices */
  232         if (ahc_aic77xx_attach(ahc) == 0)
  233                 return; /* succeed */
  234 
  235         /* failed */
  236         eisa_intr_disestablish(ec, ahc->ih);
  237 free_io:
  238         bus_space_unmap(iot, ioh, AHC_EISA_IOSIZE);
  239 }

Cache object: 2a288ce3b3a7eaf1fbcb534fff89d11c


[ 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.