Home | History | Annotate | Line # | Download | only in pci
geode.c revision 1.6.8.1
      1  1.6.8.1       ad /*	$NetBSD: geode.c,v 1.6.8.1 2006/11/18 21:29:19 ad Exp $	*/
      2      1.1   dyoung 
      3      1.1   dyoung /*-
      4      1.1   dyoung  * Copyright (c) 2005 David Young.  All rights reserved.
      5      1.1   dyoung  *
      6      1.6   kardel  * This code was written by David Young and merged with geodecntr code
      7      1.6   kardel  * by Frank Kardel.
      8      1.1   dyoung  *
      9      1.1   dyoung  * Redistribution and use in source and binary forms, with or without
     10      1.1   dyoung  * modification, are permitted provided that the following conditions
     11      1.1   dyoung  * are met:
     12      1.1   dyoung  * 1. Redistributions of source code must retain the above copyright
     13      1.1   dyoung  *    notice, this list of conditions and the following disclaimer.
     14      1.1   dyoung  * 2. Redistributions in binary form must reproduce the above copyright
     15      1.1   dyoung  *    notice, this list of conditions and the following disclaimer in the
     16      1.1   dyoung  *    documentation and/or other materials provided with the distribution.
     17      1.1   dyoung  * 3. All advertising materials mentioning features or use of this software
     18      1.1   dyoung  *    must display the following acknowledgement:
     19      1.1   dyoung  *	This product includes software developed by David Young.
     20      1.1   dyoung  * 4. The name of David Young may not be used to endorse or promote
     21      1.1   dyoung  *    products derived from this software without specific prior
     22      1.1   dyoung  *    written permission.
     23      1.1   dyoung  *
     24      1.1   dyoung  * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
     25      1.1   dyoung  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     26      1.1   dyoung  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
     27      1.1   dyoung  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DAVID
     28      1.1   dyoung  * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     29      1.1   dyoung  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
     30      1.1   dyoung  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     31      1.1   dyoung  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     32      1.1   dyoung  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     33      1.1   dyoung  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     34      1.1   dyoung  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
     35      1.1   dyoung  * OF SUCH DAMAGE.
     36      1.1   dyoung  */
     37      1.1   dyoung /*-
     38      1.1   dyoung  * Copyright (c) 2002 The NetBSD Foundation, Inc.
     39      1.1   dyoung  * All rights reserved.
     40      1.1   dyoung  *
     41      1.1   dyoung  * This code is derived from software contributed to The NetBSD Foundation
     42      1.1   dyoung  * by Jason R. Thorpe.
     43      1.1   dyoung  *
     44      1.1   dyoung  * Redistribution and use in source and binary forms, with or without
     45      1.1   dyoung  * modification, are permitted provided that the following conditions
     46      1.1   dyoung  * are met:
     47      1.1   dyoung  * 1. Redistributions of source code must retain the above copyright
     48      1.1   dyoung  *    notice, this list of conditions and the following disclaimer.
     49      1.1   dyoung  * 2. Redistributions in binary form must reproduce the above copyright
     50      1.1   dyoung  *    notice, this list of conditions and the following disclaimer in the
     51      1.1   dyoung  *    documentation and/or other materials provided with the distribution.
     52      1.1   dyoung  * 3. All advertising materials mentioning features or use of this software
     53      1.1   dyoung  *    must display the following acknowledgement:
     54      1.1   dyoung  *	This product includes software developed by the NetBSD
     55      1.1   dyoung  *	Foundation, Inc. and its contributors.
     56      1.1   dyoung  * 4. Neither the name of The NetBSD Foundation nor the names of its
     57      1.1   dyoung  *    contributors may be used to endorse or promote products derived
     58      1.1   dyoung  *    from this software without specific prior written permission.
     59      1.1   dyoung  *
     60      1.1   dyoung  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     61      1.1   dyoung  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     62      1.1   dyoung  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     63      1.1   dyoung  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     64      1.1   dyoung  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     65      1.1   dyoung  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     66      1.1   dyoung  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     67      1.1   dyoung  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     68      1.1   dyoung  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     69      1.1   dyoung  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     70      1.1   dyoung  * POSSIBILITY OF SUCH DAMAGE.
     71      1.1   dyoung  */
     72      1.1   dyoung 
     73      1.1   dyoung /*
     74      1.6   kardel  * Device driver for the special devices attached to the GBA (watchdog, high
     75      1.6   kardel  * resolution counter, ...) in the AMD Geode SC1100 processor.
     76      1.1   dyoung  */
     77      1.1   dyoung 
     78      1.1   dyoung #include <sys/cdefs.h>
     79      1.1   dyoung 
     80  1.6.8.1       ad __KERNEL_RCSID(0, "$NetBSD: geode.c,v 1.6.8.1 2006/11/18 21:29:19 ad Exp $");
     81      1.1   dyoung 
     82      1.1   dyoung #include <sys/param.h>
     83      1.1   dyoung #include <sys/systm.h>
     84      1.1   dyoung #include <sys/device.h>
     85      1.1   dyoung #include <sys/wdog.h>
     86      1.1   dyoung #include <uvm/uvm_extern.h>
     87      1.1   dyoung #include <machine/bus.h>
     88      1.1   dyoung #include <dev/pci/pcivar.h>
     89      1.1   dyoung #include <dev/pci/pcidevs.h>
     90      1.6   kardel #include <arch/i386/pci/geodevar.h>
     91      1.1   dyoung #include <arch/i386/pci/geodereg.h>
     92      1.1   dyoung #include <dev/sysmon/sysmonvar.h>
     93      1.1   dyoung 
     94      1.1   dyoung #ifdef GEODE_DEBUG
     95      1.1   dyoung #define	GEODE_DPRINTF(__x) printf __x
     96      1.1   dyoung #else /* GEODE_DEBUG */
     97      1.1   dyoung #define	GEODE_DPRINTF(__x) /* nothing */
     98      1.1   dyoung #endif
     99      1.1   dyoung 
    100      1.1   dyoung static int
    101  1.6.8.1       ad geode_gcb_match(struct device *parent, struct cfdata *match,
    102  1.6.8.1       ad     void *aux)
    103      1.1   dyoung {
    104      1.1   dyoung 	struct pci_attach_args *pa = aux;
    105      1.1   dyoung 
    106      1.1   dyoung 	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_NS &&
    107      1.1   dyoung 	    PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_NS_SC1100_XBUS)
    108      1.1   dyoung 		return (10);	/* XXX beat pchb? -dyoung */
    109      1.1   dyoung 
    110      1.1   dyoung 	return (0);
    111      1.1   dyoung }
    112      1.1   dyoung 
    113      1.1   dyoung static void
    114      1.6   kardel geode_gcb_attach(struct device *parent, struct device *self, void *aux)
    115      1.1   dyoung {
    116      1.6   kardel 	struct geode_gcb_softc *sc = (void *) self;
    117      1.1   dyoung 	struct pci_attach_args *pa = aux;
    118      1.1   dyoung 	uint32_t cba;
    119      1.6   kardel 	u_int rev;
    120      1.1   dyoung 
    121      1.1   dyoung 	cba = pci_conf_read(pa->pa_pc, pa->pa_tag, SC1100_XBUS_CBA_SCRATCHPAD);
    122      1.1   dyoung 	sc->sc_iot = pa->pa_iot;
    123      1.1   dyoung 	if (bus_space_map(sc->sc_iot, (bus_addr_t)cba, SC1100_GCB_SIZE, 0,
    124      1.1   dyoung 	    &sc->sc_ioh) != 0) {
    125      1.4  thorpej 		aprint_error("%s: unable to map registers\n",
    126      1.4  thorpej 		    sc->sc_dev.dv_xname);
    127      1.1   dyoung 		return;
    128      1.1   dyoung 	}
    129      1.1   dyoung 
    130      1.1   dyoung 	GEODE_DPRINTF(("%s: mapped %u bytes at %#08" PRIx32 "\n",
    131      1.1   dyoung 	    sc->sc_dev.dv_xname, SC1100_GCB_SIZE, cba));
    132      1.1   dyoung 
    133      1.6   kardel 	rev = bus_space_read_1(sc->sc_iot, sc->sc_ioh, SC1100_GCB_REV_B);
    134      1.1   dyoung 
    135      1.6   kardel 	aprint_normal(": AMD Geode GCB (rev. 0x%02x)\n", rev);
    136      1.1   dyoung 
    137      1.6   kardel 	while (config_found(self, NULL, NULL) != NULL)
    138      1.6   kardel 		/* empty */;
    139      1.1   dyoung }
    140      1.1   dyoung 
    141      1.6   kardel CFATTACH_DECL(geodegcb, sizeof(struct geode_gcb_softc),
    142      1.6   kardel     geode_gcb_match, geode_gcb_attach, NULL, NULL);
    143