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/ar/if_ar_pci.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 /*
    2  * Copyright (c) 1999 - 2001 John Hay.
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  * 3. Neither the name of the author nor the names of any co-contributors
   14  *    may be used to endorse or promote products derived from this software
   15  *    without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  * $FreeBSD: releng/5.0/sys/dev/ar/if_ar_pci.c 71825 2001-01-30 10:01:15Z jhay $
   30  */
   31 
   32 #include <sys/param.h>
   33 #include <sys/systm.h>
   34 #include <sys/kernel.h>
   35 #include <sys/malloc.h>
   36 #include <sys/bus.h>
   37 #include <machine/bus.h>
   38 #include <machine/resource.h>
   39 #include <machine/bus_pio.h>
   40 #include <machine/bus_memio.h>
   41 #include <sys/rman.h>
   42 
   43 #include <pci/pcireg.h>
   44 #include <pci/pcivar.h>
   45 
   46 #include <dev/ic/hd64570.h>
   47 #include <dev/ar/if_arregs.h>
   48 
   49 #ifdef TRACE
   50 #define TRC(x)               x
   51 #else
   52 #define TRC(x)
   53 #endif
   54 
   55 #define TRCL(x)              x
   56 
   57 static int      ar_pci_probe(device_t);
   58 static int      ar_pci_attach(device_t);
   59 
   60 static device_method_t ar_pci_methods[] = {
   61         /* Device interface */
   62         DEVMETHOD(device_probe,         ar_pci_probe),
   63         DEVMETHOD(device_attach,        ar_pci_attach),
   64         DEVMETHOD(device_detach,        ar_detach),
   65         { 0, 0 }
   66 };
   67 
   68 static driver_t ar_pci_driver = {
   69         "ar",
   70         ar_pci_methods,
   71         sizeof(struct ar_hardc),
   72 };
   73 
   74 DRIVER_MODULE(if_ar, pci, ar_pci_driver, ar_devclass, 0, 0);
   75 
   76 static int
   77 ar_pci_probe(device_t device)
   78 {
   79         u_int32_t       type = pci_get_devid(device);
   80 
   81         switch(type) {
   82         case 0x5012114f:
   83                 device_set_desc(device, "Digi SYNC/570i-PCI 2 port");
   84                 return (0);
   85                 break;
   86         case 0x5010114f:
   87                 printf("Digi SYNC/570i-PCI 2 port (mapped below 1M)\n");
   88                 printf("Please change the jumper to select linear mode.\n");
   89                 break;
   90         case 0x5013114f:
   91                 device_set_desc(device, "Digi SYNC/570i-PCI 4 port");
   92                 return (0);
   93                 break;
   94         case 0x5011114f:
   95                 printf("Digi SYNC/570i-PCI 4 port (mapped below 1M)\n");
   96                 printf("Please change the jumper to select linear mode.\n");
   97                 break;
   98         default:
   99                 break;
  100         }
  101         return (ENXIO);
  102 }
  103 
  104 static int
  105 ar_pci_attach(device_t device)
  106 {
  107         int error;
  108         u_int i, tmp;
  109         u_char *inten;
  110         struct ar_hardc *hc;
  111 
  112         hc = (struct ar_hardc *)device_get_softc(device);
  113         bzero(hc, sizeof(struct ar_hardc));
  114 
  115         error = ar_allocate_plx_memory(device, 0x10, 1);
  116         if(error)
  117                 goto errexit;
  118 
  119         error = ar_allocate_memory(device, 0x18, 1);
  120         if(error)
  121                 goto errexit;
  122 
  123         error = ar_allocate_irq(device, 0, 1);
  124         if(error)
  125                 goto errexit;
  126 
  127         hc->plx_mem = rman_get_virtual(hc->res_plx_memory);
  128         hc->mem_start = rman_get_virtual(hc->res_memory);
  129 
  130         hc->cunit = device_get_unit(device);
  131         hc->sca[0] = (sca_regs *)(hc->mem_start + AR_PCI_SCA_1_OFFSET);
  132         hc->sca[1] = (sca_regs *)(hc->mem_start + AR_PCI_SCA_2_OFFSET);
  133         hc->iobase = 0;
  134         hc->orbase = (u_char *)(hc->mem_start + AR_PCI_ORBASE_OFFSET);
  135 
  136         tmp = hc->orbase[AR_BMI * 4];
  137         hc->bustype = tmp & AR_BUS_MSK;
  138         hc->memsize = (tmp & AR_MEM_MSK) >> AR_MEM_SHFT;
  139         hc->memsize = 1 << hc->memsize;
  140         hc->memsize <<= 16;
  141         hc->interface[0] = (tmp & AR_IFACE_MSK);
  142         tmp = hc->orbase[AR_REV * 4];
  143         hc->revision = tmp & AR_REV_MSK;
  144         hc->winsize = (1 << ((tmp & AR_WSIZ_MSK) >> AR_WSIZ_SHFT)) * 16 * 1024;
  145         hc->mem_end = (caddr_t)(hc->mem_start + hc->winsize);
  146         hc->winmsk = hc->winsize - 1;
  147         hc->numports = hc->orbase[AR_PNUM * 4];
  148         hc->handshake = hc->orbase[AR_HNDSH * 4];
  149 
  150         for(i = 1; i < hc->numports; i++)
  151                 hc->interface[i] = hc->interface[0];
  152 
  153         TRC(printf("arp%d: bus %x, rev %d, memstart %p, winsize %d, "
  154             "winmsk %x, interface %x\n",
  155             unit, hc->bustype, hc->revision, hc->mem_start, hc->winsize,
  156             hc->winmsk, hc->interface[0]));
  157 
  158         ar_attach(device);
  159 
  160         /* Magic to enable the card to generate interrupts. */
  161         inten = (u_char *)hc->plx_mem;
  162         inten[0x69] = 0x09;
  163 
  164         return (0);
  165 
  166 errexit:
  167         ar_deallocate_resources(device);
  168         return (ENXIO);
  169 }
  170 

Cache object: 3102abd6ae7a2e35e8c0439705b564b7


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