1 /* $NetBSD: geode.c,v 1.13 2008/05/10 13:38:34 jmcneill Exp $ */
4 * Copyright (c) 2005 David Young. All rights reserved.
6 * This code was written by David Young and merged with geodecntr code
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
18 * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
22 * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32 * Copyright (c) 2002 The NetBSD Foundation, Inc.
33 * All rights reserved.
35 * This code is derived from software contributed to The NetBSD Foundation
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
47 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
48 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
49 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
50 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
51 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
52 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
53 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
54 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
55 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
56 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
57 * POSSIBILITY OF SUCH DAMAGE.
61 * Device driver for the special devices attached to the GBA (watchdog, high
62 * resolution counter, ...) in the AMD Geode SC1100 processor.
65 #include <sys/cdefs.h>
67 __KERNEL_RCSID(0, "$NetBSD: geode.c,v 1.13 2008/05/10 13:38:34 jmcneill Exp $");
69 #include <sys/param.h>
70 #include <sys/systm.h>
71 #include <sys/device.h>
73 #include <uvm/uvm_extern.h>
74 #include <machine/bus.h>
75 #include <dev/pci/pcivar.h>
76 #include <dev/pci/pcidevs.h>
77 #include <arch/i386/pci/geodevar.h>
78 #include <arch/i386/pci/geodereg.h>
79 #include <dev/sysmon/sysmonvar.h>
82 #define GEODE_DPRINTF(__x) printf __x
83 #else /* GEODE_DEBUG */
84 #define GEODE_DPRINTF(__x) /* nothing */
88 geode_gcb_match(device_t parent
, cfdata_t match
, void *aux
)
90 struct pci_attach_args
*pa
= aux
;
92 if (PCI_VENDOR(pa
->pa_id
) == PCI_VENDOR_NS
&&
93 PCI_PRODUCT(pa
->pa_id
) == PCI_PRODUCT_NS_SC1100_XBUS
)
94 return (10); /* XXX beat pchb? -dyoung */
100 geode_gcb_attach(device_t parent
, device_t self
, void *aux
)
102 struct geode_gcb_softc
*sc
= device_private(self
);
103 struct pci_attach_args
*pa
= aux
;
107 cba
= pci_conf_read(pa
->pa_pc
, pa
->pa_tag
, SC1100_XBUS_CBA_SCRATCHPAD
);
108 sc
->sc_iot
= pa
->pa_iot
;
109 if (bus_space_map(sc
->sc_iot
, (bus_addr_t
)cba
, SC1100_GCB_SIZE
, 0,
111 aprint_error(": unable to map registers\n");
115 GEODE_DPRINTF(("%s: mapped %u bytes at %#08" PRIx32
"\n",
116 device_xname(self
), SC1100_GCB_SIZE
, cba
));
118 rev
= bus_space_read_1(sc
->sc_iot
, sc
->sc_ioh
, SC1100_GCB_REV_B
);
121 aprint_normal(": AMD Geode GCB (rev. 0x%02x)\n", rev
);
123 while (config_found(self
, NULL
, NULL
) != NULL
)
127 geode_gcb_detach(device_t self
, int flags
)
130 struct geode_gcb_softc
*sc
= device_private(self
);
132 if ((rc
= config_detach_children(self
, flags
)) != 0)
135 bus_space_unmap(sc
->sc_iot
, sc
->sc_ioh
, SC1100_GCB_SIZE
);
140 geode_gcb_childdetached(device_t parent
, device_t child
)
142 /* We hold no references to child devices, so there is nothing
147 CFATTACH_DECL2_NEW(geodegcb
, sizeof(struct geode_gcb_softc
),
148 geode_gcb_match
, geode_gcb_attach
, geode_gcb_detach
, NULL
, NULL
,
149 geode_gcb_childdetached
);