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/si/si_pci.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 /*-
    2  * Device driver for Specialix range (SI/XIO) of serial line multiplexors.
    3  *
    4  * Copyright (C) 2000, Peter Wemm <peter@netplex.com.au>
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notices, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notices, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED
   16  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
   17  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
   18  * NO EVENT SHALL THE AUTHORS BE LIABLE.
   19  */
   20 
   21 #include <sys/cdefs.h>
   22 __FBSDID("$FreeBSD$");
   23 
   24 #include <sys/param.h>
   25 #include <sys/systm.h>
   26 #include <sys/kernel.h>
   27 #include <sys/module.h>
   28 #include <sys/bus.h>
   29 #include <machine/bus.h>
   30 #include <sys/rman.h>
   31 #include <machine/resource.h>
   32 
   33 #include <dev/si/sireg.h>
   34 #include <dev/si/sivar.h>
   35 
   36 #include <dev/pci/pcivar.h>
   37 
   38 static int
   39 si_pci_probe(device_t dev)
   40 {
   41         const char *desc = NULL;
   42 
   43         switch (pci_get_devid(dev)) {
   44         case 0x400011cb:
   45                 desc = "Specialix SI/XIO PCI host card";
   46                 break;
   47         case 0x200011cb:
   48                 if (pci_read_config(dev, SIJETSSIDREG, 4) == 0x020011cb)
   49                         desc = "Specialix SX PCI host card";
   50                 break;
   51         }
   52         if (desc) {
   53                 device_set_desc(dev, desc);
   54                 return 0;
   55         }
   56         return ENXIO;
   57 }
   58 
   59 static int
   60 si_pci_attach(device_t dev)
   61 {
   62         struct si_softc *sc;
   63         void *ih;
   64         int error;
   65 
   66         error = 0;
   67         ih = NULL;
   68         sc = device_get_softc(dev);
   69 
   70         switch (pci_get_devid(dev)) {
   71         case 0x400011cb:
   72                 sc->sc_type = SIPCI;
   73                 sc->sc_mem_rid = SIPCIBADR;
   74                 break;
   75         case 0x200011cb:
   76                 sc->sc_type = SIJETPCI;
   77                 sc->sc_mem_rid = SIJETBADR;
   78                 break;
   79         }
   80 
   81         sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
   82                                                 &sc->sc_mem_rid,
   83                                                 RF_ACTIVE);
   84         if (!sc->sc_mem_res) {
   85                 device_printf(dev, "couldn't map memory\n");
   86                 goto fail;
   87         }
   88         sc->sc_paddr = (caddr_t)rman_get_start(sc->sc_mem_res);
   89         sc->sc_maddr = rman_get_virtual(sc->sc_mem_res);
   90 
   91         sc->sc_irq_rid = 0;
   92         sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ,
   93                                                 &sc->sc_irq_rid,
   94                                                 RF_ACTIVE | RF_SHAREABLE);
   95         if (!sc->sc_irq_res) {
   96                 device_printf(dev, "couldn't map interrupt\n");
   97                 goto fail;
   98         }
   99         sc->sc_irq = rman_get_start(sc->sc_irq_res);
  100         error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY,
  101                                si_intr, sc, &ih);
  102         if (error) {
  103                 device_printf(dev, "could not activate interrupt\n");
  104                 goto fail;
  105         }
  106 
  107         error = siattach(dev);
  108         if (error)
  109                 goto fail;
  110         return (0);             /* success */
  111 
  112 fail:
  113         if (error == 0)
  114                 error = ENXIO;
  115         if (sc->sc_irq_res) {
  116                 if (ih)
  117                         bus_teardown_intr(dev, sc->sc_irq_res, ih);
  118                 bus_release_resource(dev, SYS_RES_IRQ,
  119                                      sc->sc_irq_rid, sc->sc_irq_res);
  120                 sc->sc_irq_res = 0;
  121         }
  122         if (sc->sc_mem_res) {
  123                 bus_release_resource(dev, SYS_RES_MEMORY,
  124                                      sc->sc_mem_rid, sc->sc_mem_res);
  125                 sc->sc_mem_res = 0;
  126         }
  127         return (error);
  128 }
  129 
  130 static device_method_t si_pci_methods[] = {
  131         /* Device interface */
  132         DEVMETHOD(device_probe,         si_pci_probe),
  133         DEVMETHOD(device_attach,        si_pci_attach),
  134 
  135         { 0, 0 }
  136 };
  137 
  138 static driver_t si_pci_driver = {
  139         "si",
  140         si_pci_methods,
  141         sizeof(struct si_softc),
  142 };
  143 
  144 DRIVER_MODULE(si, pci, si_pci_driver, si_devclass, 0, 0);

Cache object: d9c3f0273dd7f6df1736b7d4ac6b5097


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