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/pci/viapm.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: viapm.c,v 1.9 2003/01/01 00:10:23 thorpej Exp $        */
    2 
    3 /*
    4  * Copyright (c) 2000 Johan Danielsson
    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  *
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  *
   14  * 2. Redistributions in binary form must reproduce the above copyright
   15  *    notice, this list of conditions and the following disclaimer in the
   16  *    documentation and/or other materials provided with the distribution.
   17  *
   18  * 3. Neither the name of author nor the names of any contributors may
   19  *    be used to endorse or promote products derived from this
   20  *    software without specific prior written permission.
   21  *
   22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
   23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   24  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   25  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   26  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   32  * POSSIBILITY OF SUCH DAMAGE.
   33  */
   34 
   35 /*
   36  * frontend for the power management device in the VIA VT82C686a South
   37  * Bridge. It (the chip) has three functions, power management, hardware
   38  * monitoring, and an SMBus controller. A driver for the hardware monitoring
   39  * is provided by the viaenv driver
   40  */
   41 
   42 #include <sys/cdefs.h>
   43 __KERNEL_RCSID(0, "$NetBSD: viapm.c,v 1.9 2003/01/01 00:10:23 thorpej Exp $");
   44 
   45 #include <sys/param.h>
   46 #include <sys/systm.h>
   47 #include <sys/kernel.h>
   48 #include <sys/device.h>
   49 
   50 #include <dev/pci/pcivar.h>
   51 #include <dev/pci/pcireg.h>
   52 #include <dev/pci/pcidevs.h>
   53 
   54 #include <dev/pci/viapmvar.h>
   55 
   56 struct viapm_softc {
   57         struct device sc_dev;
   58 
   59         pci_chipset_tag_t sc_pc;
   60         pcitag_t sc_tag;
   61         bus_space_tag_t sc_iot;
   62 };
   63 
   64 static int
   65 viapm_match(struct device * parent, struct cfdata * match, void *aux)
   66 {
   67         struct pci_attach_args *pa = aux;
   68 
   69         if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_VIATECH &&
   70             PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_VIATECH_VT82C686A_SMB)
   71                 return 1;
   72         return 0;
   73 }
   74 
   75 static const char *
   76 viapm_device_name(enum vapm_devtype type)
   77 {
   78 
   79         switch (type) {
   80         case VIAPM_POWER:
   81                 return "power management";
   82         case VIAPM_HWMON:
   83                 return "hardware monitor";
   84         case VIAPM_SMBUS:
   85                 return "SMBus controller";
   86         default:
   87                 panic("viapm_device_name: unknown type");
   88         }
   89 }
   90 
   91 static int
   92 viapm_print(void *aux, const char *pnp)
   93 {
   94         struct viapm_attach_args *vaa = aux;
   95 
   96         if (pnp)
   97                 aprint_normal("%s at %s", viapm_device_name(vaa->va_type), pnp);
   98         return UNCONF;
   99 }
  100 
  101 static int
  102 viapm_submatch(struct device * parent, struct cfdata * cf, void *aux)
  103 {
  104 
  105         return config_match(parent, cf, aux);
  106 }
  107 
  108 static void
  109 viapm_attach(struct device * parent, struct device * self, void *aux)
  110 {
  111         struct viapm_softc *sc = (struct viapm_softc *) self;
  112         struct pci_attach_args *pa = aux;
  113         struct viapm_attach_args vaa;
  114 
  115         printf("\n");
  116 
  117         sc->sc_pc = pa->pa_pc;
  118         sc->sc_tag = pa->pa_tag;
  119         sc->sc_iot = pa->pa_iot;
  120 
  121         vaa.va_pc = sc->sc_pc;
  122         vaa.va_tag = sc->sc_tag;
  123         vaa.va_iot = sc->sc_iot;
  124 
  125 #if 0
  126         /*
  127          * no point in confusing people with these until there are drivers for
  128          * them
  129          */
  130         vaa.va_type = VIAPM_POWER;
  131         vaa.va_offset = 0x40;
  132         config_found_sm(self, &vaa, viapm_print, viapm_submatch);
  133 #endif
  134 
  135         vaa.va_type = VIAPM_HWMON;
  136         vaa.va_offset = 0x70;
  137         config_found_sm(self, &vaa, viapm_print, viapm_submatch);
  138 
  139 #if 0
  140         vaa.va_type = VIAPM_SMBUS;
  141         vaa.va_offset = 0x93;
  142         config_found_sm(self, &vaa, viapm_print, viapm_submatch);
  143 #endif
  144 }
  145 
  146 CFATTACH_DECL(viapm, sizeof(struct viapm_softc),
  147     viapm_match, viapm_attach, NULL, NULL);

Cache object: 4c4232f0e9d734bbdf86be2b25012f81


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