Home | History | Annotate | Line # | Download | only in pci
amdpcib.c revision 1.1.12.2
      1  1.1.12.2  ad /* $NetBSD: amdpcib.c,v 1.1.12.2 2007/12/03 19:04:24 ad Exp $ */
      2  1.1.12.2  ad 
      3  1.1.12.2  ad /*
      4  1.1.12.2  ad  * Copyright (c) 2006 Nicolas Joly
      5  1.1.12.2  ad  * All rights reserved.
      6  1.1.12.2  ad  *
      7  1.1.12.2  ad  * Redistribution and use in source and binary forms, with or without
      8  1.1.12.2  ad  * modification, are permitted provided that the following conditions
      9  1.1.12.2  ad  * are met:
     10  1.1.12.2  ad  * 1. Redistributions of source code must retain the above copyright
     11  1.1.12.2  ad  *    notice, this list of conditions and the following disclaimer.
     12  1.1.12.2  ad  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1.12.2  ad  *    notice, this list of conditions and the following disclaimer in the
     14  1.1.12.2  ad  *    documentation and/or other materials provided with the distribution.
     15  1.1.12.2  ad  * 3. The name of the author may not be used to endorse or promote products
     16  1.1.12.2  ad  *    derived from this software without specific prior written permission.
     17  1.1.12.2  ad  *
     18  1.1.12.2  ad  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
     19  1.1.12.2  ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     20  1.1.12.2  ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     21  1.1.12.2  ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     22  1.1.12.2  ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     23  1.1.12.2  ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     24  1.1.12.2  ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     25  1.1.12.2  ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     26  1.1.12.2  ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     27  1.1.12.2  ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     28  1.1.12.2  ad  * POSSIBILITY OF SUCH DAMAGE.
     29  1.1.12.2  ad  */
     30  1.1.12.2  ad 
     31  1.1.12.2  ad #include <sys/cdefs.h>
     32  1.1.12.2  ad __KERNEL_RCSID(0, "$NetBSD: amdpcib.c,v 1.1.12.2 2007/12/03 19:04:24 ad Exp $");
     33  1.1.12.2  ad 
     34  1.1.12.2  ad #include <sys/systm.h>
     35  1.1.12.2  ad #include <sys/device.h>
     36  1.1.12.2  ad 
     37  1.1.12.2  ad #include <dev/pci/pcivar.h>
     38  1.1.12.2  ad #include <dev/pci/pcireg.h>
     39  1.1.12.2  ad #include <dev/pci/pcidevs.h>
     40  1.1.12.2  ad 
     41  1.1.12.2  ad struct amdpcib_softc {
     42  1.1.12.2  ad 	struct device		sc_dev;
     43  1.1.12.2  ad 
     44  1.1.12.2  ad 	bus_space_tag_t		sc_memt;
     45  1.1.12.2  ad 	bus_space_handle_t	sc_memh;
     46  1.1.12.2  ad };
     47  1.1.12.2  ad 
     48  1.1.12.2  ad static int	amdpcib_match(struct device *, struct cfdata *, void *);
     49  1.1.12.2  ad static void	amdpcib_attach(struct device *, struct device *, void *);
     50  1.1.12.2  ad static int	amdpcib_search(device_t, cfdata_t, const int *, void *);
     51  1.1.12.2  ad 
     52  1.1.12.2  ad 
     53  1.1.12.2  ad extern void	pcibattach(struct device *, struct device *, void *);
     54  1.1.12.2  ad 
     55  1.1.12.2  ad CFATTACH_DECL(amdpcib, sizeof(struct amdpcib_softc), amdpcib_match,
     56  1.1.12.2  ad     amdpcib_attach, NULL, NULL);
     57  1.1.12.2  ad 
     58  1.1.12.2  ad static int
     59  1.1.12.2  ad amdpcib_match(struct device *parent, struct cfdata *match, void *aux)
     60  1.1.12.2  ad {
     61  1.1.12.2  ad 	struct pci_attach_args *pa = aux;
     62  1.1.12.2  ad 
     63  1.1.12.2  ad 	if ((PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD) &&
     64  1.1.12.2  ad 	    (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_PBC8111_LPC))
     65  1.1.12.2  ad 		return 2;
     66  1.1.12.2  ad 
     67  1.1.12.2  ad 	return 0;
     68  1.1.12.2  ad }
     69  1.1.12.2  ad 
     70  1.1.12.2  ad static void
     71  1.1.12.2  ad amdpcib_attach(struct device *parent, struct device *self, void *aux)
     72  1.1.12.2  ad {
     73  1.1.12.2  ad 	struct amdpcib_softc *sc;
     74  1.1.12.2  ad 	struct pci_attach_args *pa;
     75  1.1.12.2  ad 
     76  1.1.12.2  ad 	sc = (struct amdpcib_softc *)self;
     77  1.1.12.2  ad 	pa = (struct pci_attach_args *)aux;
     78  1.1.12.2  ad 
     79  1.1.12.2  ad 	pcibattach(parent, self, aux);
     80  1.1.12.2  ad 
     81  1.1.12.2  ad 	config_search_loc(amdpcib_search, &sc->sc_dev, "amdpcib", NULL, pa);
     82  1.1.12.2  ad }
     83  1.1.12.2  ad 
     84  1.1.12.2  ad static int
     85  1.1.12.2  ad amdpcib_search(device_t parent, cfdata_t cf, const int *locs, void *aux)
     86  1.1.12.2  ad {
     87  1.1.12.2  ad 
     88  1.1.12.2  ad 	if (config_match(parent, cf, aux))
     89  1.1.12.2  ad 		config_attach_loc(parent, cf, locs, aux, NULL);
     90  1.1.12.2  ad 
     91  1.1.12.2  ad 	return 0;
     92  1.1.12.2  ad }
     93  1.1.12.2  ad /* $NetBSD: amdpcib.c,v 1.1.12.2 2007/12/03 19:04:24 ad Exp $ */
     94  1.1.12.2  ad 
     95  1.1.12.2  ad /*
     96  1.1.12.2  ad  * Copyright (c) 2006 Nicolas Joly
     97  1.1.12.2  ad  * All rights reserved.
     98  1.1.12.2  ad  *
     99  1.1.12.2  ad  * Redistribution and use in source and binary forms, with or without
    100  1.1.12.2  ad  * modification, are permitted provided that the following conditions
    101  1.1.12.2  ad  * are met:
    102  1.1.12.2  ad  * 1. Redistributions of source code must retain the above copyright
    103  1.1.12.2  ad  *    notice, this list of conditions and the following disclaimer.
    104  1.1.12.2  ad  * 2. Redistributions in binary form must reproduce the above copyright
    105  1.1.12.2  ad  *    notice, this list of conditions and the following disclaimer in the
    106  1.1.12.2  ad  *    documentation and/or other materials provided with the distribution.
    107  1.1.12.2  ad  * 3. The name of the author may not be used to endorse or promote products
    108  1.1.12.2  ad  *    derived from this software without specific prior written permission.
    109  1.1.12.2  ad  *
    110  1.1.12.2  ad  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
    111  1.1.12.2  ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
    112  1.1.12.2  ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    113  1.1.12.2  ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
    114  1.1.12.2  ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    115  1.1.12.2  ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    116  1.1.12.2  ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    117  1.1.12.2  ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    118  1.1.12.2  ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    119  1.1.12.2  ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    120  1.1.12.2  ad  * POSSIBILITY OF SUCH DAMAGE.
    121  1.1.12.2  ad  */
    122  1.1.12.2  ad 
    123  1.1.12.2  ad #include <sys/cdefs.h>
    124  1.1.12.2  ad __KERNEL_RCSID(0, "$NetBSD: amdpcib.c,v 1.1.12.2 2007/12/03 19:04:24 ad Exp $");
    125  1.1.12.2  ad 
    126  1.1.12.2  ad #include <sys/systm.h>
    127  1.1.12.2  ad #include <sys/device.h>
    128  1.1.12.2  ad 
    129  1.1.12.2  ad #include <dev/pci/pcivar.h>
    130  1.1.12.2  ad #include <dev/pci/pcireg.h>
    131  1.1.12.2  ad #include <dev/pci/pcidevs.h>
    132  1.1.12.2  ad 
    133  1.1.12.2  ad struct amdpcib_softc {
    134  1.1.12.2  ad 	struct device		sc_dev;
    135  1.1.12.2  ad 
    136  1.1.12.2  ad 	bus_space_tag_t		sc_memt;
    137  1.1.12.2  ad 	bus_space_handle_t	sc_memh;
    138  1.1.12.2  ad };
    139  1.1.12.2  ad 
    140  1.1.12.2  ad static int	amdpcib_match(struct device *, struct cfdata *, void *);
    141  1.1.12.2  ad static void	amdpcib_attach(struct device *, struct device *, void *);
    142  1.1.12.2  ad static int	amdpcib_search(device_t, cfdata_t, const int *, void *);
    143  1.1.12.2  ad 
    144  1.1.12.2  ad 
    145  1.1.12.2  ad extern void	pcibattach(struct device *, struct device *, void *);
    146  1.1.12.2  ad 
    147  1.1.12.2  ad CFATTACH_DECL(amdpcib, sizeof(struct amdpcib_softc), amdpcib_match,
    148  1.1.12.2  ad     amdpcib_attach, NULL, NULL);
    149  1.1.12.2  ad 
    150  1.1.12.2  ad static int
    151  1.1.12.2  ad amdpcib_match(struct device *parent, struct cfdata *match, void *aux)
    152  1.1.12.2  ad {
    153  1.1.12.2  ad 	struct pci_attach_args *pa = aux;
    154  1.1.12.2  ad 
    155  1.1.12.2  ad 	if ((PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD) &&
    156  1.1.12.2  ad 	    (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_PBC8111_LPC))
    157  1.1.12.2  ad 		return 2;
    158  1.1.12.2  ad 
    159  1.1.12.2  ad 	return 0;
    160  1.1.12.2  ad }
    161  1.1.12.2  ad 
    162  1.1.12.2  ad static void
    163  1.1.12.2  ad amdpcib_attach(struct device *parent, struct device *self, void *aux)
    164  1.1.12.2  ad {
    165  1.1.12.2  ad 	struct amdpcib_softc *sc;
    166  1.1.12.2  ad 	struct pci_attach_args *pa;
    167  1.1.12.2  ad 
    168  1.1.12.2  ad 	sc = (struct amdpcib_softc *)self;
    169  1.1.12.2  ad 	pa = (struct pci_attach_args *)aux;
    170  1.1.12.2  ad 
    171  1.1.12.2  ad 	pcibattach(parent, self, aux);
    172  1.1.12.2  ad 
    173  1.1.12.2  ad 	config_search_loc(amdpcib_search, &sc->sc_dev, "amdpcib", NULL, pa);
    174  1.1.12.2  ad }
    175  1.1.12.2  ad 
    176  1.1.12.2  ad static int
    177  1.1.12.2  ad amdpcib_search(device_t parent, cfdata_t cf, const int *locs, void *aux)
    178  1.1.12.2  ad {
    179  1.1.12.2  ad 
    180  1.1.12.2  ad 	if (config_match(parent, cf, aux))
    181  1.1.12.2  ad 		config_attach_loc(parent, cf, locs, aux, NULL);
    182  1.1.12.2  ad 
    183  1.1.12.2  ad 	return 0;
    184  1.1.12.2  ad }
    185