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/dpt_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: dpt_eisa.c,v 1.16 2006/11/16 01:32:50 christos Exp $   */
    2 
    3 /*
    4  * Copyright (c) 1999, 2000, 2001 Andrew Doran <ad@NetBSD.org>
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  *
   28  */
   29 
   30 /*
   31  * EISA front-end for DPT EATA SCSI driver.
   32  */
   33 
   34 #include <sys/cdefs.h>
   35 __KERNEL_RCSID(0, "$NetBSD: dpt_eisa.c,v 1.16 2006/11/16 01:32:50 christos Exp $");
   36 
   37 #include <sys/param.h>
   38 #include <sys/systm.h>
   39 #include <sys/device.h>
   40 #include <sys/queue.h>
   41 
   42 #include <machine/bus.h>
   43 #include <machine/intr.h>
   44 
   45 #include <dev/scsipi/scsipi_all.h>
   46 #include <dev/scsipi/scsiconf.h>
   47 
   48 #include <dev/eisa/eisavar.h>
   49 
   50 #include <dev/ic/dptreg.h>
   51 #include <dev/ic/dptvar.h>
   52 
   53 #include <dev/i2o/dptivar.h>
   54 
   55 #define DPT_EISA_SLOT_OFFSET            0x0c00
   56 #define DPT_EISA_IOSIZE                 0x0100
   57 #define DPT_EISA_IOCONF                 0x90
   58 #define DPT_EISA_EATA_REG_OFFSET        0x88
   59 
   60 static void     dpt_eisa_attach(struct device *, struct device *, void *);
   61 static int      dpt_eisa_irq(bus_space_tag_t, bus_space_handle_t, int *);
   62 static int      dpt_eisa_match(struct device *, struct cfdata *, void *);
   63 
   64 CFATTACH_DECL(dpt_eisa, sizeof(struct dpt_softc),
   65     dpt_eisa_match, dpt_eisa_attach, NULL, NULL);
   66 
   67 static const char * const dpt_eisa_boards[] = {
   68         "DPT2402",
   69         "DPTA401",
   70         "DPTA402",
   71         "DPTA410",
   72         "DPTA411",
   73         "DPTA412",
   74         "DPTA420",
   75         "DPTA501",
   76         "DPTA502",
   77         "DPTA701",
   78         "DPTBC01",
   79         "NEC8200",      /* OEM */
   80         "ATT2408",      /* OEM */
   81         NULL
   82 };
   83 
   84 static int
   85 dpt_eisa_irq(bus_space_tag_t iot, bus_space_handle_t ioh, int *irq)
   86 {
   87 
   88         switch (bus_space_read_1(iot, ioh, DPT_EISA_IOCONF) & 0x38) {
   89         case 0x08:
   90                 *irq = 11;
   91                 break;
   92         case 0x10:
   93                 *irq = 15;
   94                 break;
   95         case 0x20:
   96                 *irq = 14;
   97                 break;
   98         default:
   99                 return (-1);
  100         }
  101 
  102         return (0);
  103 }
  104 
  105 static int
  106 dpt_eisa_match(struct device *parent, struct cfdata *match,
  107     void *aux)
  108 {
  109         struct eisa_attach_args *ea;
  110         int i;
  111 
  112         ea = aux;
  113 
  114         for (i = 0; dpt_eisa_boards[i] != NULL; i++)
  115                 if (strcmp(ea->ea_idstring, dpt_eisa_boards[i]) == 0)
  116                         break;
  117 
  118         return (dpt_eisa_boards[i] != NULL);
  119 }
  120 
  121 static void
  122 dpt_eisa_attach(struct device *parent, struct device *self, void *aux)
  123 {
  124         struct eisa_attach_args *ea;
  125         bus_space_handle_t ioh;
  126         eisa_chipset_tag_t ec;
  127         eisa_intr_handle_t ih;
  128         struct dpt_softc *sc;
  129         bus_space_tag_t iot;
  130         const char *intrstr;
  131         int irq;
  132 
  133         ea = aux;
  134         sc = device_private(self);
  135         iot = ea->ea_iot;
  136         ec = ea->ea_ec;
  137 
  138         printf(": ");
  139 
  140         if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
  141             DPT_EISA_SLOT_OFFSET, DPT_EISA_IOSIZE, 0, &ioh)) {
  142                 printf("can't map i/o space\n");
  143                 return;
  144         }
  145 
  146         sc->sc_iot = iot;
  147         sc->sc_ioh = ioh;
  148         sc->sc_dmat = ea->ea_dmat;
  149 
  150         /* Map and establish the interrupt. */
  151         if (dpt_eisa_irq(iot, ioh, &irq)) {
  152                 printf("HBA on invalid IRQ\n");
  153                 return;
  154         }
  155 
  156         if (eisa_intr_map(ec, irq, &ih)) {
  157                 printf("can't map interrupt (%d)\n", irq);
  158                 return;
  159         }
  160 
  161         intrstr = eisa_intr_string(ec, ih);
  162         sc->sc_ih = eisa_intr_establish(ec, ih, IST_LEVEL, IPL_BIO,
  163             dpt_intr, sc);
  164         if (sc->sc_ih == NULL) {
  165                 printf("can't establish interrupt");
  166                 if (intrstr != NULL)
  167                         printf(" at %s", intrstr);
  168                 printf("\n");
  169                 return;
  170         }
  171 
  172         /* Read the EATA configuration. */
  173         if (dpt_readcfg(sc)) {
  174                 printf("%s: readcfg failed - see dpt(4)\n",
  175                     sc->sc_dv.dv_xname);
  176                 return;
  177         }
  178 
  179         sc->sc_bustype = SI_EISA_BUS;
  180         sc->sc_isaport =  EISA_SLOT_ADDR(ea->ea_slot) + DPT_EISA_SLOT_OFFSET;
  181         sc->sc_isairq = irq;
  182 
  183         /* Now attach to the bus-independent code. */
  184         dpt_init(sc, intrstr);
  185 }

Cache object: 9cb7cae03da33715e2c53b942752620f


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