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/powermng/ichsmb/ichsmb_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  * ichsmb_pci.c
    3  *
    4  * Author: Archie Cobbs <archie@freebsd.org>
    5  * Copyright (c) 2000 Whistle Communications, Inc.
    6  * All rights reserved.
    7  * Author: Archie Cobbs <archie@freebsd.org>
    8  *
    9  * Subject to the following obligations and disclaimer of warranty, use and
   10  * redistribution of this software, in source or object code forms, with or
   11  * without modifications are expressly permitted by Whistle Communications;
   12  * provided, however, that:
   13  * 1. Any and all reproductions of the source or object code must include the
   14  *    copyright notice above and the following disclaimer of warranties; and
   15  * 2. No rights are granted, in any manner or form, to use Whistle
   16  *    Communications, Inc. trademarks, including the mark "WHISTLE
   17  *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
   18  *    such appears in the above copyright notice or in the software.
   19  *
   20  * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
   21  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
   22  * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
   23  * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
   24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
   25  * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
   26  * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
   27  * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
   28  * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
   29  * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
   30  * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
   31  * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
   32  * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
   33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   35  * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
   36  * OF SUCH DAMAGE.
   37  *
   38  * $FreeBSD: src/sys/dev/ichsmb/ichsmb_pci.c,v 1.25 2009/12/16 12:25:27 avg Exp $
   39  */
   40 
   41 /*
   42  * Support for the SMBus controller logical device which is part of the
   43  * Intel 81801AA/AB/BA/CA/DC/EB (ICH/ICH[02345]) I/O controller hub chips.
   44  */
   45 
   46 #include <sys/param.h>
   47 #include <sys/systm.h>
   48 #include <sys/kernel.h>
   49 #include <sys/module.h>
   50 #include <sys/errno.h>
   51 #include <sys/lock.h>
   52 #include <sys/mutex.h>
   53 #include <sys/syslog.h>
   54 #include <sys/bus.h>
   55 
   56 #include <sys/rman.h>
   57 
   58 #include <bus/pci/pcivar.h>
   59 #include <bus/pci/pcireg.h>
   60 
   61 #include <bus/smbus/smbconf.h>
   62 
   63 #include <dev/powermng/ichsmb/ichsmb_var.h>
   64 #include <dev/powermng/ichsmb/ichsmb_reg.h>
   65 
   66 /* PCI unique identifiers */
   67 #define ID_82801AA                      0x24138086
   68 #define ID_82801AB                      0x24238086
   69 #define ID_82801BA                      0x24438086
   70 #define ID_82801CA                      0x24838086
   71 #define ID_82801DC                      0x24C38086
   72 #define ID_82801E                       0x24538086
   73 #define ID_82801EB                      0x24D38086
   74 #define ID_82801FB                      0x266A8086
   75 #define ID_82801GB                      0x27da8086
   76 #define ID_82801H                       0x283e8086
   77 #define ID_82801I                       0x29308086
   78 #define ID_82801JI                      0x3a308086
   79 #define ID_PCH                          0x3b308086
   80 #define ID_6300ESB                      0x25a48086
   81 #define ID_631xESB                      0x269b8086
   82 
   83 #define PCIS_SERIALBUS_SMBUS_PROGIF     0x00
   84 
   85 /* Internal functions */
   86 static int      ichsmb_pci_probe(device_t dev);
   87 static int      ichsmb_pci_attach(device_t dev);
   88 /*Use generic one for now*/
   89 #if 0
   90 static int      ichsmb_pci_detach(device_t dev);
   91 #endif
   92 
   93 /* Device methods */
   94 static device_method_t ichsmb_pci_methods[] = {
   95         /* Device interface */
   96         DEVMETHOD(device_probe, ichsmb_pci_probe),
   97         DEVMETHOD(device_attach, ichsmb_pci_attach),
   98         DEVMETHOD(device_detach, ichsmb_detach),
   99 
  100         /* Bus methods */
  101         DEVMETHOD(bus_print_child, bus_generic_print_child),
  102 
  103         /* SMBus methods */
  104         DEVMETHOD(smbus_callback, ichsmb_callback),
  105         DEVMETHOD(smbus_quick, ichsmb_quick),
  106         DEVMETHOD(smbus_sendb, ichsmb_sendb),
  107         DEVMETHOD(smbus_recvb, ichsmb_recvb),
  108         DEVMETHOD(smbus_writeb, ichsmb_writeb),
  109         DEVMETHOD(smbus_writew, ichsmb_writew),
  110         DEVMETHOD(smbus_readb, ichsmb_readb),
  111         DEVMETHOD(smbus_readw, ichsmb_readw),
  112         DEVMETHOD(smbus_pcall, ichsmb_pcall),
  113         DEVMETHOD(smbus_bwrite, ichsmb_bwrite),
  114         DEVMETHOD(smbus_bread, ichsmb_bread),
  115         DEVMETHOD_END
  116 };
  117 
  118 static driver_t ichsmb_pci_driver = {
  119         "ichsmb",
  120         ichsmb_pci_methods,
  121         sizeof(struct ichsmb_softc)
  122 };
  123 
  124 static devclass_t ichsmb_pci_devclass;
  125 
  126 DRIVER_MODULE(ichsmb, pci, ichsmb_pci_driver, ichsmb_pci_devclass, NULL, NULL);
  127 
  128 static int
  129 ichsmb_pci_probe(device_t dev)
  130 {
  131         /* Check PCI identifier */
  132         switch (pci_get_devid(dev)) {
  133         case ID_82801AA:
  134                 device_set_desc(dev, "Intel 82801AA (ICH) SMBus controller");
  135                 break;
  136         case ID_82801AB:
  137                 device_set_desc(dev, "Intel 82801AB (ICH0) SMBus controller");
  138                 break;
  139         case ID_82801BA:
  140                 device_set_desc(dev, "Intel 82801BA (ICH2) SMBus controller");
  141                 break;
  142         case ID_82801CA:
  143                 device_set_desc(dev, "Intel 82801CA (ICH3) SMBus controller");
  144                 break;
  145         case ID_82801DC:
  146                 device_set_desc(dev, "Intel 82801DC (ICH4) SMBus controller");
  147                 break;
  148         case ID_82801E:
  149                 device_set_desc(dev, "Intel 82801E (C-ICH) SMBus controller");
  150                 break;
  151         case ID_82801EB:
  152                 device_set_desc(dev, "Intel 82801EB (ICH5) SMBus controller");
  153                 break;
  154         case ID_82801FB:
  155                 device_set_desc(dev, "Intel 82801FB (ICH6) SMBus controller");
  156                 break;
  157         case ID_82801GB:
  158                 device_set_desc(dev, "Intel 82801GB (ICH7) SMBus controller");
  159                 break;
  160         case ID_82801H:
  161                 device_set_desc(dev, "Intel 82801H (ICH8) SMBus controller");
  162                 break;
  163         case ID_82801I:
  164                 device_set_desc(dev, "Intel 82801I (ICH9) SMBus controller");
  165                 break;
  166         case ID_82801JI:
  167                 device_set_desc(dev, "Intel 82801JI (ICH10) SMBus controller");
  168                 break;
  169         case ID_PCH:
  170                 device_set_desc(dev, "Intel PCH SMBus controller");
  171                 break;
  172         case ID_6300ESB:
  173                 device_set_desc(dev, "Intel 6300ESB (ICH) SMBus controller");
  174                 break;
  175         case ID_631xESB:
  176                 device_set_desc(dev, "Intel 631xESB/6321ESB (ESB2) SMBus controller");
  177                 break;
  178         default:
  179                 return (ENXIO);
  180         }
  181 
  182         /* Done */
  183         return (ichsmb_probe(dev));
  184 }
  185 
  186 static int
  187 ichsmb_pci_attach(device_t dev)
  188 {
  189         const sc_p sc = device_get_softc(dev);
  190         int error;
  191 
  192         /* Initialize private state */
  193         bzero(sc, sizeof(*sc));
  194         sc->ich_cmd = -1;
  195         sc->dev = dev;
  196 
  197         /* Allocate an I/O range */
  198         sc->io_rid = ICH_SMB_BASE;
  199         sc->io_res = bus_alloc_resource(dev, SYS_RES_IOPORT,
  200             &sc->io_rid, 0, ~0, 16, RF_ACTIVE);
  201         if (sc->io_res == NULL)
  202                 sc->io_res = bus_alloc_resource(dev, SYS_RES_IOPORT,
  203                     &sc->io_rid, 0ul, ~0ul, 32, RF_ACTIVE);
  204         if (sc->io_res == NULL) {
  205                 device_printf(dev, "can't map I/O\n");
  206                 error = ENXIO;
  207                 goto fail;
  208         }
  209 
  210         /* Allocate interrupt */
  211         sc->irq_rid = 0;
  212         sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ,
  213             &sc->irq_rid, RF_ACTIVE | RF_SHAREABLE);
  214         if (sc->irq_res == NULL) {
  215                 device_printf(dev, "can't get IRQ\n");
  216                 error = ENXIO;
  217                 goto fail;
  218         }
  219 
  220         /* Enable device */
  221         pci_write_config(dev, ICH_HOSTC, ICH_HOSTC_HST_EN, 1);
  222 
  223         /* Done */
  224         error = ichsmb_attach(dev);
  225         if (error)
  226                 goto fail;
  227         return (0);
  228 
  229 fail:
  230         /* Attach failed, release resources */
  231         ichsmb_release_resources(sc);
  232         return (error);
  233 }
  234 
  235 
  236 MODULE_DEPEND(ichsmb, pci, 1, 1, 1);
  237 MODULE_DEPEND(ichsmb, smbus, SMBUS_MINVER, SMBUS_PREFVER, SMBUS_MAXVER);
  238 MODULE_VERSION(ichsmb, 1);

Cache object: 4fb0b944d8a93fb88a5b55cb3087aed7


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