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