device_t/softc split. Compiled, but never run.diff -r1.22 -r1.23 src/sys/arch/evbarm/ifpga/ifpga.c
(dyoung)
--- src/sys/arch/evbarm/ifpga/ifpga.c 2008/04/27 18:58:46 1.22
+++ src/sys/arch/evbarm/ifpga/ifpga.c 2009/07/21 16:04:16 1.23
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ifpga.c,v 1.22 2008/04/27 18:58:46 matt Exp $ */ | 1 | /* $NetBSD: ifpga.c,v 1.23 2009/07/21 16:04:16 dyoung Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001 ARM Ltd | 4 | * Copyright (c) 2001 ARM Ltd | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -28,27 +28,27 @@ | @@ -28,27 +28,27 @@ | |||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * Integrator FPGA core logic support. | 33 | * Integrator FPGA core logic support. | |
34 | * | 34 | * | |
35 | * The integrator board supports the core logic in an FPGA which is loaded | 35 | * The integrator board supports the core logic in an FPGA which is loaded | |
36 | * at POR with a custom design. This code supports the default logic as the | 36 | * at POR with a custom design. This code supports the default logic as the | |
37 | * board is shipped. | 37 | * board is shipped. | |
38 | */ | 38 | */ | |
39 | 39 | |||
40 | #include <sys/cdefs.h> | 40 | #include <sys/cdefs.h> | |
41 | __KERNEL_RCSID(0, "$NetBSD: ifpga.c,v 1.22 2008/04/27 18:58:46 matt Exp $"); | 41 | __KERNEL_RCSID(0, "$NetBSD: ifpga.c,v 1.23 2009/07/21 16:04:16 dyoung Exp $"); | |
42 | 42 | |||
43 | #include <sys/param.h> | 43 | #include <sys/param.h> | |
44 | #include <sys/types.h> | 44 | #include <sys/types.h> | |
45 | #include <sys/device.h> | 45 | #include <sys/device.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | #include <sys/extent.h> | 47 | #include <sys/extent.h> | |
48 | #include <sys/malloc.h> | 48 | #include <sys/malloc.h> | |
49 | #include <sys/null.h> | 49 | #include <sys/null.h> | |
50 | 50 | |||
51 | #include <dev/pci/pcivar.h> | 51 | #include <dev/pci/pcivar.h> | |
52 | #include <dev/pci/pciconf.h> | 52 | #include <dev/pci/pciconf.h> | |
53 | 53 | |||
54 | #include <arm/cpufunc.h> | 54 | #include <arm/cpufunc.h> | |
@@ -56,143 +56,145 @@ __KERNEL_RCSID(0, "$NetBSD: ifpga.c,v 1. | @@ -56,143 +56,145 @@ __KERNEL_RCSID(0, "$NetBSD: ifpga.c,v 1. | |||
56 | #include "opt_pci.h" | 56 | #include "opt_pci.h" | |
57 | #include "pci.h" | 57 | #include "pci.h" | |
58 | 58 | |||
59 | #include <evbarm/ifpga/ifpgamem.h> | 59 | #include <evbarm/ifpga/ifpgamem.h> | |
60 | #include <evbarm/ifpga/ifpgavar.h> | 60 | #include <evbarm/ifpga/ifpgavar.h> | |
61 | #include <evbarm/ifpga/ifpgareg.h> | 61 | #include <evbarm/ifpga/ifpgareg.h> | |
62 | #include <evbarm/ifpga/ifpga_pcivar.h> | 62 | #include <evbarm/ifpga/ifpga_pcivar.h> | |
63 | #include <evbarm/dev/v360reg.h> | 63 | #include <evbarm/dev/v360reg.h> | |
64 | 64 | |||
65 | #include <evbarm/integrator/int_bus_dma.h> | 65 | #include <evbarm/integrator/int_bus_dma.h> | |
66 | #include "locators.h" | 66 | #include "locators.h" | |
67 | 67 | |||
68 | /* Prototypes */ | 68 | /* Prototypes */ | |
69 | static int ifpga_match (struct device *, struct cfdata *, void *); | 69 | static int ifpga_match (device_t, cfdata_t, void *); | |
70 | static void ifpga_attach (struct device *, struct device *, void *); | 70 | static void ifpga_attach (device_t, device_t, void *); | |
71 | static int ifpga_print (void *, const char *); | 71 | static int ifpga_print (void *, const char *); | |
72 | 72 | |||
73 | /* Drive and attach structures */ | 73 | /* Drive and attach structures */ | |
74 | CFATTACH_DECL(ifpga, sizeof(struct ifpga_softc), | 74 | CFATTACH_DECL_NEW(ifpga, sizeof(struct ifpga_softc), | |
75 | ifpga_match, ifpga_attach, NULL, NULL); | 75 | ifpga_match, ifpga_attach, NULL, NULL); | |
76 | 76 | |||
77 | int ifpga_found; | 77 | int ifpga_found; | |
78 | 78 | |||
79 | /* Default UART clock speed (we should make this a boot option). */ | 79 | /* Default UART clock speed (we should make this a boot option). */ | |
80 | int ifpga_uart_clk = IFPGA_UART_CLK; | 80 | int ifpga_uart_clk = IFPGA_UART_CLK; | |
81 | 81 | |||
82 | #if NPCI > 0 | 82 | #if NPCI > 0 | |
83 | /* PCI handles */ | 83 | /* PCI handles */ | |
84 | extern struct arm32_pci_chipset ifpga_pci_chipset; | 84 | extern struct arm32_pci_chipset ifpga_pci_chipset; | |
85 | extern struct arm32_bus_dma_tag ifpga_pci_bus_dma_tag; | 85 | extern struct arm32_bus_dma_tag ifpga_pci_bus_dma_tag; | |
86 | 86 | |||
87 | static struct bus_space ifpga_pci_io_tag; | 87 | static struct bus_space ifpga_pci_io_tag; | |
88 | static struct bus_space ifpga_pci_mem_tag; | 88 | static struct bus_space ifpga_pci_mem_tag; | |
89 | #endif /* NPCI > 0 */ | 89 | #endif /* NPCI > 0 */ | |
90 | 90 | |||
91 | static struct bus_space ifpga_bs_tag; | 91 | static struct bus_space ifpga_bs_tag; | |
92 | 92 | |||
93 | struct ifpga_softc *ifpga_sc; | 93 | struct ifpga_softc *ifpga_sc; | |
94 | device_t ifpga_dev; | |||
95 | ||||
94 | /* | 96 | /* | |
95 | * Print the configuration information for children | 97 | * Print the configuration information for children | |
96 | */ | 98 | */ | |
97 | 99 | |||
98 | static int | 100 | static int | |
99 | ifpga_print(void *aux, const char *pnp) | 101 | ifpga_print(void *aux, const char *pnp) | |
100 | { | 102 | { | |
101 | struct ifpga_attach_args *ifa = aux; | 103 | struct ifpga_attach_args *ifa = aux; | |
102 | 104 | |||
103 | if (ifa->ifa_addr != -1) | 105 | if (ifa->ifa_addr != -1) | |
104 | aprint_normal(" addr 0x%lx", (unsigned long)ifa->ifa_addr); | 106 | aprint_normal(" addr 0x%lx", (unsigned long)ifa->ifa_addr); | |
105 | if (ifa->ifa_irq != -1) | 107 | if (ifa->ifa_irq != -1) | |
106 | aprint_normal(" irq %d", ifa->ifa_irq); | 108 | aprint_normal(" irq %d", ifa->ifa_irq); | |
107 | 109 | |||
108 | return UNCONF; | 110 | return UNCONF; | |
109 | } | 111 | } | |
110 | 112 | |||
111 | static int | 113 | static int | |
112 | ifpga_search(struct device *parent, struct cfdata *cf, | 114 | ifpga_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux) | |
113 | const int *ldesc, void *aux) | |||
114 | { | 115 | { | |
115 | struct ifpga_softc *sc = (struct ifpga_softc *)parent; | 116 | struct ifpga_softc *sc = device_private(parent); | |
116 | struct ifpga_attach_args ifa; | 117 | struct ifpga_attach_args ifa; | |
117 | int tryagain; | 118 | int tryagain; | |
118 | 119 | |||
119 | do { | 120 | do { | |
120 | ifa.ifa_iot = sc->sc_iot; | 121 | ifa.ifa_iot = sc->sc_iot; | |
121 | ifa.ifa_addr = cf->cf_iobase; | 122 | ifa.ifa_addr = cf->cf_iobase; | |
122 | ifa.ifa_irq = cf->cf_irq; | 123 | ifa.ifa_irq = cf->cf_irq; | |
123 | ifa.ifa_sc_ioh = sc->sc_sc_ioh; | 124 | ifa.ifa_sc_ioh = sc->sc_sc_ioh; | |
124 | 125 | |||
125 | tryagain = 0; | 126 | tryagain = 0; | |
126 | if (config_match(parent, cf, &ifa) > 0) { | 127 | if (config_match(parent, cf, &ifa) > 0) { | |
127 | config_attach(parent, cf, &ifa, ifpga_print); | 128 | config_attach(parent, cf, &ifa, ifpga_print); | |
128 | tryagain = (cf->cf_fstate == FSTATE_STAR); | 129 | tryagain = (cf->cf_fstate == FSTATE_STAR); | |
129 | } | 130 | } | |
130 | } while (tryagain); | 131 | } while (tryagain); | |
131 | 132 | |||
132 | return 0; | 133 | return 0; | |
133 | } | 134 | } | |
134 | 135 | |||
135 | static int | 136 | static int | |
136 | ifpga_match(struct device *parent, struct cfdata *cf, void *aux) | 137 | ifpga_match(device_t parent, cfdata_t cf, void *aux) | |
137 | { | 138 | { | |
138 | #if 0 | 139 | #if 0 | |
139 | struct mainbus_attach_args *ma = aux; | 140 | struct mainbus_attach_args *ma = aux; | |
140 | 141 | |||
141 | /* Make sure that we're looking for the IFPGA. */ | 142 | /* Make sure that we're looking for the IFPGA. */ | |
142 | if (strcmp(ma->ma_name, ifpga_md.md_name)) | 143 | if (strcmp(ma->ma_name, ifpga_md.md_name)) | |
143 | return 0; | 144 | return 0; | |
144 | #endif | 145 | #endif | |
145 | 146 | |||
146 | /* We can only have one instance of the IFPGA. */ | 147 | /* We can only have one instance of the IFPGA. */ | |
147 | if (ifpga_found) | 148 | if (ifpga_found) | |
148 | return 0; | 149 | return 0; | |
149 | 150 | |||
150 | return 1; | 151 | return 1; | |
151 | } | 152 | } | |
152 | 153 | |||
153 | static void | 154 | static void | |
154 | ifpga_attach(struct device *parent, struct device *self, void *aux) | 155 | ifpga_attach(device_t parent, device_t self, void *aux) | |
155 | { | 156 | { | |
156 | struct ifpga_softc *sc = (struct ifpga_softc *)self; | 157 | struct ifpga_softc *sc = device_private(self); | |
157 | u_int id, sysclk; | 158 | u_int id, sysclk; | |
158 | #if defined(PCI_NETBSD_CONFIGURE) && NPCI > 0 | 159 | #if defined(PCI_NETBSD_CONFIGURE) && NPCI > 0 | |
159 | struct extent *ioext, *memext, *pmemext; | 160 | struct extent *ioext, *memext, *pmemext; | |
160 | struct ifpga_pci_softc *pci_sc; | 161 | struct ifpga_pci_softc *pci_sc; | |
161 | struct pcibus_attach_args pci_pba; | 162 | struct pcibus_attach_args pci_pba; | |
162 | #endif | 163 | #endif | |
163 | 164 | |||
164 | ifpga_found = 1; | 165 | ifpga_found = 1; | |
165 | 166 | |||
166 | /* We want a memory-mapped bus space, since the I/O space is sparse. */ | 167 | /* We want a memory-mapped bus space, since the I/O space is sparse. */ | |
167 | ifpga_create_mem_bs_tag(&ifpga_bs_tag, (void *)IFPGA_IO_BASE); | 168 | ifpga_create_mem_bs_tag(&ifpga_bs_tag, (void *)IFPGA_IO_BASE); | |
168 | 169 | |||
169 | #if NPCI > 0 | 170 | #if NPCI > 0 | |
170 | /* But the PCI config space is quite large, so we have a linear region | 171 | /* But the PCI config space is quite large, so we have a linear region | |
171 | for that pre-allocated. */ | 172 | for that pre-allocated. */ | |
172 | 173 | |||
173 | ifpga_create_io_bs_tag(&ifpga_pci_io_tag, (void *)IFPGA_PCI_IO_VBASE); | 174 | ifpga_create_io_bs_tag(&ifpga_pci_io_tag, (void *)IFPGA_PCI_IO_VBASE); | |
174 | ifpga_create_mem_bs_tag(&ifpga_pci_mem_tag, (void *)0); | 175 | ifpga_create_mem_bs_tag(&ifpga_pci_mem_tag, (void *)0); | |
175 | #endif | 176 | #endif | |
176 | 177 | |||
177 | sc->sc_iot = &ifpga_bs_tag; | 178 | sc->sc_iot = &ifpga_bs_tag; | |
178 | 179 | |||
180 | ifpga_dev = self; | |||
179 | ifpga_sc = sc; | 181 | ifpga_sc = sc; | |
180 | 182 | |||
181 | /* Now map in the IFPGA motherboard registers. */ | 183 | /* Now map in the IFPGA motherboard registers. */ | |
182 | if (bus_space_map(sc->sc_iot, IFPGA_IO_SC_BASE, IFPGA_IO_SC_SIZE, 0, | 184 | if (bus_space_map(sc->sc_iot, IFPGA_IO_SC_BASE, IFPGA_IO_SC_SIZE, 0, | |
183 | &sc->sc_sc_ioh)) | 185 | &sc->sc_sc_ioh)) | |
184 | panic("%s: Cannot map system controller registers", | 186 | panic("%s: Cannot map system controller registers", | |
185 | self->dv_xname); | 187 | device_xname(self)); | |
186 | 188 | |||
187 | id = bus_space_read_4(sc->sc_iot, sc->sc_sc_ioh, IFPGA_SC_ID); | 189 | id = bus_space_read_4(sc->sc_iot, sc->sc_sc_ioh, IFPGA_SC_ID); | |
188 | 190 | |||
189 | printf(": Build %d, ", (id & IFPGA_SC_ID_BUILD_MASK) >> | 191 | printf(": Build %d, ", (id & IFPGA_SC_ID_BUILD_MASK) >> | |
190 | IFPGA_SC_ID_BUILD_SHIFT); | 192 | IFPGA_SC_ID_BUILD_SHIFT); | |
191 | switch (id & IFPGA_SC_ID_REV_MASK) | 193 | switch (id & IFPGA_SC_ID_REV_MASK) | |
192 | { | 194 | { | |
193 | case IFPGA_SC_ID_REV_A: | 195 | case IFPGA_SC_ID_REV_A: | |
194 | printf("Rev A, "); | 196 | printf("Rev A, "); | |
195 | break; | 197 | break; | |
196 | case IFPGA_SC_ID_REV_B: | 198 | case IFPGA_SC_ID_REV_B: | |
197 | printf("Rev B, "); | 199 | printf("Rev B, "); | |
198 | break; | 200 | break; | |
@@ -211,93 +213,95 @@ ifpga_attach(struct device *parent, stru | @@ -211,93 +213,95 @@ ifpga_attach(struct device *parent, stru | |||
211 | 213 | |||
212 | switch (id & IFPGA_SC_ID_ARCH_MASK) | 214 | switch (id & IFPGA_SC_ID_ARCH_MASK) | |
213 | { | 215 | { | |
214 | case IFPGA_SC_ID_ARCH_ASBLE: | 216 | case IFPGA_SC_ID_ARCH_ASBLE: | |
215 | printf(" ASB, Little-endian,"); | 217 | printf(" ASB, Little-endian,"); | |
216 | break; | 218 | break; | |
217 | case IFPGA_SC_ID_ARCH_AHBLE: | 219 | case IFPGA_SC_ID_ARCH_AHBLE: | |
218 | printf(" AHB, Little-endian,"); | 220 | printf(" AHB, Little-endian,"); | |
219 | break; | 221 | break; | |
220 | default: | 222 | default: | |
221 | panic(" Unsupported bus"); | 223 | panic(" Unsupported bus"); | |
222 | } | 224 | } | |
223 | 225 | |||
224 | printf("\n%s: FPGA ", self->dv_xname); | 226 | printf("\n%s: FPGA ", device_xname(self)); | |
225 | 227 | |||
226 | switch (id & IFPGA_SC_ID_FPGA_MASK) | 228 | switch (id & IFPGA_SC_ID_FPGA_MASK) | |
227 | { | 229 | { | |
228 | case IFPGA_SC_ID_FPGA_XC4062: | 230 | case IFPGA_SC_ID_FPGA_XC4062: | |
229 | printf("XC4062"); | 231 | printf("XC4062"); | |
230 | break; | 232 | break; | |
231 | case IFPGA_SC_ID_FPGA_XC4085: | 233 | case IFPGA_SC_ID_FPGA_XC4085: | |
232 | printf("XC4085"); | 234 | printf("XC4085"); | |
233 | break; | 235 | break; | |
234 | default: | 236 | default: | |
235 | printf("unknown"); | 237 | printf("unknown"); | |
236 | break; | 238 | break; | |
237 | } | 239 | } | |
238 | 240 | |||
239 | sysclk = bus_space_read_1(sc->sc_iot, sc->sc_sc_ioh, IFPGA_SC_OSC); | 241 | sysclk = bus_space_read_1(sc->sc_iot, sc->sc_sc_ioh, IFPGA_SC_OSC); | |
240 | sysclk &= IFPGA_SC_OSC_S_VDW; | 242 | sysclk &= IFPGA_SC_OSC_S_VDW; | |
241 | sysclk += 8; | 243 | sysclk += 8; | |
242 | 244 | |||
243 | printf(", SYSCLK %d.%02dMHz", sysclk >> 2, (sysclk & 3) * 25); | 245 | printf(", SYSCLK %d.%02dMHz", sysclk >> 2, (sysclk & 3) * 25); | |
244 | 246 | |||
245 | /* Map the Interrupt controller */ | 247 | /* Map the Interrupt controller */ | |
246 | if (bus_space_map(sc->sc_iot, IFPGA_IO_IRQ_BASE, IFPGA_IO_IRQ_SIZE, | 248 | if (bus_space_map(sc->sc_iot, IFPGA_IO_IRQ_BASE, IFPGA_IO_IRQ_SIZE, | |
247 | BUS_SPACE_MAP_LINEAR, &sc->sc_irq_ioh)) | 249 | BUS_SPACE_MAP_LINEAR, &sc->sc_irq_ioh)) | |
248 | panic("%s: Cannot map irq controller registers", | 250 | panic("%s: Cannot map irq controller registers", | |
249 | self->dv_xname); | 251 | device_xname(self)); | |
250 | 252 | |||
251 | /* We can write to the IRQ/FIQ controller now. */ | 253 | /* We can write to the IRQ/FIQ controller now. */ | |
252 | ifpga_intr_postinit(); | 254 | ifpga_intr_postinit(); | |
253 | 255 | |||
254 | /* Map the core module */ | 256 | /* Map the core module */ | |
255 | if (bus_space_map(sc->sc_iot, IFPGA_IO_CM_BASE, IFPGA_IO_CM_SIZE, 0, | 257 | if (bus_space_map(sc->sc_iot, IFPGA_IO_CM_BASE, IFPGA_IO_CM_SIZE, 0, | |
256 | &sc->sc_cm_ioh)) | 258 | &sc->sc_cm_ioh)) { | |
257 | panic("%s: Cannot map core module registers", self->dv_xname); | 259 | panic("%s: Cannot map core module registers", | |
260 | device_xname(self)); | |||
261 | } | |||
258 | 262 | |||
259 | /* Map the timers */ | 263 | /* Map the timers */ | |
260 | if (bus_space_map(sc->sc_iot, IFPGA_IO_TMR_BASE, IFPGA_IO_TMR_SIZE, 0, | 264 | if (bus_space_map(sc->sc_iot, IFPGA_IO_TMR_BASE, IFPGA_IO_TMR_SIZE, 0, | |
261 | &sc->sc_tmr_ioh)) | 265 | &sc->sc_tmr_ioh)) | |
262 | panic("%s: Cannot map timer registers", self->dv_xname); | 266 | panic("%s: Cannot map timer registers", device_xname(self)); | |
263 | 267 | |||
264 | printf("\n"); | 268 | printf("\n"); | |
265 | 269 | |||
266 | #if NPCI > 0 | 270 | #if NPCI > 0 | |
267 | pci_sc = malloc(sizeof(struct ifpga_pci_softc), M_DEVBUF, M_WAITOK); | 271 | pci_sc = malloc(sizeof(struct ifpga_pci_softc), M_DEVBUF, M_WAITOK); | |
268 | pci_sc->sc_iot = &ifpga_pci_io_tag; | 272 | pci_sc->sc_iot = &ifpga_pci_io_tag; | |
269 | pci_sc->sc_memt = &ifpga_pci_mem_tag; | 273 | pci_sc->sc_memt = &ifpga_pci_mem_tag; | |
270 | 274 | |||
271 | if (bus_space_map(pci_sc->sc_iot, 0, IFPGA_PCI_IO_VSIZE, 0, | 275 | if (bus_space_map(pci_sc->sc_iot, 0, IFPGA_PCI_IO_VSIZE, 0, | |
272 | &pci_sc->sc_io_ioh) | 276 | &pci_sc->sc_io_ioh) | |
273 | || bus_space_map(pci_sc->sc_iot, | 277 | || bus_space_map(pci_sc->sc_iot, | |
274 | IFPGA_PCI_CONF_VBASE - IFPGA_PCI_IO_VBASE, IFPGA_PCI_CONF_VSIZE, 0, | 278 | IFPGA_PCI_CONF_VBASE - IFPGA_PCI_IO_VBASE, IFPGA_PCI_CONF_VSIZE, 0, | |
275 | &pci_sc->sc_conf_ioh) | 279 | &pci_sc->sc_conf_ioh) | |
276 | || bus_space_map(pci_sc->sc_memt, IFPGA_V360_REG_BASE, | 280 | || bus_space_map(pci_sc->sc_memt, IFPGA_V360_REG_BASE, | |
277 | IFPGA_V360_REG_SIZE, 0, &pci_sc->sc_reg_ioh)) | 281 | IFPGA_V360_REG_SIZE, 0, &pci_sc->sc_reg_ioh)) | |
278 | panic("%s: Cannot map pci memory", self->dv_xname); | 282 | panic("%s: Cannot map pci memory", device_xname(self)); | |
279 | 283 | |||
280 | { | 284 | { | |
281 | pcireg_t id_reg, class_reg; | 285 | pcireg_t id_reg, class_reg; | |
282 | char buf[1000]; | 286 | char buf[1000]; | |
283 | 287 | |||
284 | id_reg = bus_space_read_4(pci_sc->sc_memt, pci_sc->sc_reg_ioh, | 288 | id_reg = bus_space_read_4(pci_sc->sc_memt, pci_sc->sc_reg_ioh, | |
285 | V360_PCI_VENDOR); | 289 | V360_PCI_VENDOR); | |
286 | class_reg = bus_space_read_4(pci_sc->sc_memt, | 290 | class_reg = bus_space_read_4(pci_sc->sc_memt, | |
287 | pci_sc->sc_reg_ioh, V360_PCI_CC_REV); | 291 | pci_sc->sc_reg_ioh, V360_PCI_CC_REV); | |
288 | 292 | |||
289 | pci_devinfo(id_reg, class_reg, 1, buf, sizeof(buf)); | 293 | pci_devinfo(id_reg, class_reg, 1, buf, sizeof(buf)); | |
290 | printf("%s: %s\n", self->dv_xname, buf); | 294 | printf("%s: %s\n", device_xname(self), buf); | |
291 | } | 295 | } | |
292 | 296 | |||
293 | #if defined(PCI_NETBSD_CONFIGURE) | 297 | #if defined(PCI_NETBSD_CONFIGURE) | |
294 | ioext = extent_create("pciio", 0x00000000, | 298 | ioext = extent_create("pciio", 0x00000000, | |
295 | 0x00000000 + IFPGA_PCI_IO_VSIZE, M_DEVBUF, NULL, 0, EX_NOWAIT); | 299 | 0x00000000 + IFPGA_PCI_IO_VSIZE, M_DEVBUF, NULL, 0, EX_NOWAIT); | |
296 | memext = extent_create("pcimem", IFPGA_PCI_APP0_BASE, | 300 | memext = extent_create("pcimem", IFPGA_PCI_APP0_BASE, | |
297 | IFPGA_PCI_APP0_BASE + IFPGA_PCI_APP0_SIZE, | 301 | IFPGA_PCI_APP0_BASE + IFPGA_PCI_APP0_SIZE, | |
298 | M_DEVBUF, NULL, 0, EX_NOWAIT); | 302 | M_DEVBUF, NULL, 0, EX_NOWAIT); | |
299 | pmemext = extent_create("pcipmem", IFPGA_PCI_APP1_BASE, | 303 | pmemext = extent_create("pcipmem", IFPGA_PCI_APP1_BASE, | |
300 | IFPGA_PCI_APP1_BASE + IFPGA_PCI_APP1_SIZE, | 304 | IFPGA_PCI_APP1_BASE + IFPGA_PCI_APP1_SIZE, | |
301 | M_DEVBUF, NULL, 0, EX_NOWAIT); | 305 | M_DEVBUF, NULL, 0, EX_NOWAIT); | |
302 | ifpga_pci_chipset.pc_conf_v = (void *)pci_sc; | 306 | ifpga_pci_chipset.pc_conf_v = (void *)pci_sc; | |
303 | pci_configure_bus(&ifpga_pci_chipset, ioext, memext, pmemext, 0, | 307 | pci_configure_bus(&ifpga_pci_chipset, ioext, memext, pmemext, 0, |
--- src/sys/arch/evbarm/ifpga/ifpga_clock.c 2009/03/18 10:22:27 1.13
+++ src/sys/arch/evbarm/ifpga/ifpga_clock.c 2009/07/21 16:04:16 1.14
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ifpga_clock.c,v 1.13 2009/03/18 10:22:27 cegger Exp $ */ | 1 | /* $NetBSD: ifpga_clock.c,v 1.14 2009/07/21 16:04:16 dyoung Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001 ARM Ltd | 4 | * Copyright (c) 2001 ARM Ltd | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -29,27 +29,27 @@ | @@ -29,27 +29,27 @@ | |||
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * The IFPGA has three timers. Timer 0 is clocked by the system bus clock, | 33 | * The IFPGA has three timers. Timer 0 is clocked by the system bus clock, | |
34 | * while timers 1 and 2 are clocked at 24MHz. To keep things simple here, | 34 | * while timers 1 and 2 are clocked at 24MHz. To keep things simple here, | |
35 | * we use timers 1 and 2 only. All three timers are 16-bit counters that | 35 | * we use timers 1 and 2 only. All three timers are 16-bit counters that | |
36 | * are programmable in either periodic mode or in one-shot mode. | 36 | * are programmable in either periodic mode or in one-shot mode. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | /* Include header files */ | 39 | /* Include header files */ | |
40 | 40 | |||
41 | #include <sys/cdefs.h> | 41 | #include <sys/cdefs.h> | |
42 | __KERNEL_RCSID(0, "$NetBSD: ifpga_clock.c,v 1.13 2009/03/18 10:22:27 cegger Exp $"); | 42 | __KERNEL_RCSID(0, "$NetBSD: ifpga_clock.c,v 1.14 2009/07/21 16:04:16 dyoung Exp $"); | |
43 | 43 | |||
44 | #include <sys/types.h> | 44 | #include <sys/types.h> | |
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | #include <sys/kernel.h> | 47 | #include <sys/kernel.h> | |
48 | #include <sys/atomic.h> | 48 | #include <sys/atomic.h> | |
49 | #include <sys/time.h> | 49 | #include <sys/time.h> | |
50 | #include <sys/timetc.h> | 50 | #include <sys/timetc.h> | |
51 | #include <sys/device.h> | 51 | #include <sys/device.h> | |
52 | 52 | |||
53 | #include <arm/cpufunc.h> | 53 | #include <arm/cpufunc.h> | |
54 | #include <machine/intr.h> | 54 | #include <machine/intr.h> | |
55 | 55 | |||
@@ -89,26 +89,27 @@ static struct timecounter ifpga_timecoun | @@ -89,26 +89,27 @@ static struct timecounter ifpga_timecoun | |||
89 | ifpga_get_timecount, /* get_timecount */ | 89 | ifpga_get_timecount, /* get_timecount */ | |
90 | 0, /* no poll_pps */ | 90 | 0, /* no poll_pps */ | |
91 | 0xffffffff, /* counter_mask */ | 91 | 0xffffffff, /* counter_mask */ | |
92 | COUNTS_PER_SEC, /* frequency */ | 92 | COUNTS_PER_SEC, /* frequency */ | |
93 | "ifpga", /* name */ | 93 | "ifpga", /* name */ | |
94 | 100, /* quality */ | 94 | 100, /* quality */ | |
95 | NULL, /* prev */ | 95 | NULL, /* prev */ | |
96 | NULL, /* next */ | 96 | NULL, /* next */ | |
97 | }; | 97 | }; | |
98 | 98 | |||
99 | static volatile uint32_t ifpga_base; | 99 | static volatile uint32_t ifpga_base; | |
100 | 100 | |||
101 | extern struct ifpga_softc *ifpga_sc; | 101 | extern struct ifpga_softc *ifpga_sc; | |
102 | extern device_t ifpga_dev; | |||
102 | 103 | |||
103 | static int clock_started = 0; | 104 | static int clock_started = 0; | |
104 | 105 | |||
105 | static int load_timer(int, int); | 106 | static int load_timer(int, int); | |
106 | 107 | |||
107 | static inline u_int | 108 | static inline u_int | |
108 | getclock(void) | 109 | getclock(void) | |
109 | { | 110 | { | |
110 | return bus_space_read_4(ifpga_sc->sc_iot, ifpga_sc->sc_tmr_ioh, | 111 | return bus_space_read_4(ifpga_sc->sc_iot, ifpga_sc->sc_tmr_ioh, | |
111 | TIMER_1_VALUE); | 112 | TIMER_1_VALUE); | |
112 | } | 113 | } | |
113 | 114 | |||
114 | static inline u_int | 115 | static inline u_int | |
@@ -277,46 +278,46 @@ cpu_initclocks(void) | @@ -277,46 +278,46 @@ cpu_initclocks(void) | |||
277 | statmin = statint - (statvar >> 1); | 278 | statmin = statint - (statvar >> 1); | |
278 | profmin = profint - (statvar >> 1); | 279 | profmin = profint - (statvar >> 1); | |
279 | timer2min = statmin; | 280 | timer2min = statmin; | |
280 | statprev = statint; | 281 | statprev = statint; | |
281 | 282 | |||
282 | /* Report the clock frequencies */ | 283 | /* Report the clock frequencies */ | |
283 | printf("clock: hz=%d stathz = %d profhz = %d\n", hz, stathz, profhz); | 284 | printf("clock: hz=%d stathz = %d profhz = %d\n", hz, stathz, profhz); | |
284 | 285 | |||
285 | /* Setup timer 1 and claim interrupt */ | 286 | /* Setup timer 1 and claim interrupt */ | |
286 | ifpga_sc->sc_clockintr = ifpga_intr_establish(IFPGA_TIMER1_IRQ, | 287 | ifpga_sc->sc_clockintr = ifpga_intr_establish(IFPGA_TIMER1_IRQ, | |
287 | IPL_CLOCK, clockhandler, 0); | 288 | IPL_CLOCK, clockhandler, 0); | |
288 | if (ifpga_sc->sc_clockintr == NULL) | 289 | if (ifpga_sc->sc_clockintr == NULL) | |
289 | panic("%s: Cannot install timer 1 interrupt handler", | 290 | panic("%s: Cannot install timer 1 interrupt handler", | |
290 | ifpga_sc->sc_dev.dv_xname); | 291 | device_xname(ifpga_dev)); | |
291 | 292 | |||
292 | ifpga_sc->sc_clock_count | 293 | ifpga_sc->sc_clock_count | |
293 | = load_timer(IFPGA_TIMER1_BASE, intvl); | 294 | = load_timer(IFPGA_TIMER1_BASE, intvl); | |
294 | 295 | |||
295 | /* | 296 | /* | |
296 | * Use ticks per 256us for accuracy since ticks per us is often | 297 | * Use ticks per 256us for accuracy since ticks per us is often | |
297 | * fractional e.g. @ 66MHz | 298 | * fractional e.g. @ 66MHz | |
298 | */ | 299 | */ | |
299 | ifpga_sc->sc_clock_ticks_per_256us = | 300 | ifpga_sc->sc_clock_ticks_per_256us = | |
300 | ((((ifpga_sc->sc_clock_count * hz) / 1000) * 256) / 1000); | 301 | ((((ifpga_sc->sc_clock_count * hz) / 1000) * 256) / 1000); | |
301 | 302 | |||
302 | clock_started = 1; | 303 | clock_started = 1; | |
303 | 304 | |||
304 | /* Set up timer 2 as statclk/profclk. */ | 305 | /* Set up timer 2 as statclk/profclk. */ | |
305 | ifpga_sc->sc_statclockintr = ifpga_intr_establish(IFPGA_TIMER2_IRQ, | 306 | ifpga_sc->sc_statclockintr = ifpga_intr_establish(IFPGA_TIMER2_IRQ, | |
306 | IPL_HIGH, statclockhandler, 0); | 307 | IPL_HIGH, statclockhandler, 0); | |
307 | if (ifpga_sc->sc_statclockintr == NULL) | 308 | if (ifpga_sc->sc_statclockintr == NULL) | |
308 | panic("%s: Cannot install timer 2 interrupt handler", | 309 | panic("%s: Cannot install timer 2 interrupt handler", | |
309 | ifpga_sc->sc_dev.dv_xname); | 310 | device_xname(ifpga_dev)); | |
310 | load_timer(IFPGA_TIMER2_BASE, statint); | 311 | load_timer(IFPGA_TIMER2_BASE, statint); | |
311 | 312 | |||
312 | tc_init(&ifpga_timecounter); | 313 | tc_init(&ifpga_timecounter); | |
313 | } | 314 | } | |
314 | 315 | |||
315 | static u_int | 316 | static u_int | |
316 | ifpga_get_timecount(struct timecounter *tc) | 317 | ifpga_get_timecount(struct timecounter *tc) | |
317 | { | 318 | { | |
318 | u_int base, counter; | 319 | u_int base, counter; | |
319 | 320 | |||
320 | do { | 321 | do { | |
321 | base = ifpga_base; | 322 | base = ifpga_base; | |
322 | counter = getclock(); | 323 | counter = getclock(); |
--- src/sys/arch/evbarm/ifpga/ifpga_pci.c 2005/12/11 12:17:09 1.12
+++ src/sys/arch/evbarm/ifpga/ifpga_pci.c 2009/07/21 16:04:16 1.13
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ifpga_pci.c,v 1.12 2005/12/11 12:17:09 christos Exp $ */ | 1 | /* $NetBSD: ifpga_pci.c,v 1.13 2009/07/21 16:04:16 dyoung Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001 ARM Ltd | 4 | * Copyright (c) 2001 ARM Ltd | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -54,48 +54,48 @@ | @@ -54,48 +54,48 @@ | |||
54 | * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | 54 | * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
55 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 55 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
56 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 56 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
57 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 57 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
58 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 58 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
59 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 59 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
60 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 60 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
61 | * SUCH DAMAGE. | 61 | * SUCH DAMAGE. | |
62 | */ | 62 | */ | |
63 | 63 | |||
64 | #define _ARM32_BUS_DMA_PRIVATE | 64 | #define _ARM32_BUS_DMA_PRIVATE | |
65 | 65 | |||
66 | #include <sys/cdefs.h> | 66 | #include <sys/cdefs.h> | |
67 | __KERNEL_RCSID(0, "$NetBSD: ifpga_pci.c,v 1.12 2005/12/11 12:17:09 christos Exp $"); | 67 | __KERNEL_RCSID(0, "$NetBSD: ifpga_pci.c,v 1.13 2009/07/21 16:04:16 dyoung Exp $"); | |
68 | 68 | |||
69 | #include <sys/param.h> | 69 | #include <sys/param.h> | |
70 | #include <sys/systm.h> | 70 | #include <sys/systm.h> | |
71 | #include <sys/conf.h> | 71 | #include <sys/conf.h> | |
72 | #include <sys/malloc.h> | 72 | #include <sys/malloc.h> | |
73 | #include <sys/device.h> | 73 | #include <sys/device.h> | |
74 | 74 | |||
75 | #include <evbarm/integrator/int_bus_dma.h> | 75 | #include <evbarm/integrator/int_bus_dma.h> | |
76 | 76 | |||
77 | #include <machine/intr.h> | 77 | #include <machine/intr.h> | |
78 | 78 | |||
79 | #include <dev/pci/pcireg.h> | 79 | #include <dev/pci/pcireg.h> | |
80 | #include <dev/pci/pcivar.h> | 80 | #include <dev/pci/pcivar.h> | |
81 | 81 | |||
82 | #include <evbarm/ifpga/ifpgareg.h> | 82 | #include <evbarm/ifpga/ifpgareg.h> | |
83 | #include <evbarm/ifpga/ifpgamem.h> | 83 | #include <evbarm/ifpga/ifpgamem.h> | |
84 | #include <evbarm/ifpga/ifpga_pcivar.h> | 84 | #include <evbarm/ifpga/ifpga_pcivar.h> | |
85 | #include <evbarm/dev/v360reg.h> | 85 | #include <evbarm/dev/v360reg.h> | |
86 | 86 | |||
87 | 87 | |||
88 | void ifpga_pci_attach_hook (struct device *, struct device *, | 88 | void ifpga_pci_attach_hook (device_t, device_t, | |
89 | struct pcibus_attach_args *); | 89 | struct pcibus_attach_args *); | |
90 | int ifpga_pci_bus_maxdevs (void *, int); | 90 | int ifpga_pci_bus_maxdevs (void *, int); | |
91 | pcitag_t ifpga_pci_make_tag (void *, int, int, int); | 91 | pcitag_t ifpga_pci_make_tag (void *, int, int, int); | |
92 | void ifpga_pci_decompose_tag (void *, pcitag_t, int *, int *, | 92 | void ifpga_pci_decompose_tag (void *, pcitag_t, int *, int *, | |
93 | int *); | 93 | int *); | |
94 | pcireg_t ifpga_pci_conf_read (void *, pcitag_t, int); | 94 | pcireg_t ifpga_pci_conf_read (void *, pcitag_t, int); | |
95 | void ifpga_pci_conf_write (void *, pcitag_t, int, pcireg_t); | 95 | void ifpga_pci_conf_write (void *, pcitag_t, int, pcireg_t); | |
96 | int ifpga_pci_intr_map (struct pci_attach_args *, | 96 | int ifpga_pci_intr_map (struct pci_attach_args *, | |
97 | pci_intr_handle_t *); | 97 | pci_intr_handle_t *); | |
98 | const char *ifpga_pci_intr_string (void *, pci_intr_handle_t); | 98 | const char *ifpga_pci_intr_string (void *, pci_intr_handle_t); | |
99 | const struct evcnt *ifpga_pci_intr_evcnt (void *, pci_intr_handle_t); | 99 | const struct evcnt *ifpga_pci_intr_evcnt (void *, pci_intr_handle_t); | |
100 | void *ifpga_pci_intr_establish (void *, pci_intr_handle_t, int, | 100 | void *ifpga_pci_intr_establish (void *, pci_intr_handle_t, int, | |
101 | int (*)(void *), void *); | 101 | int (*)(void *), void *); | |
@@ -146,27 +146,27 @@ struct arm32_bus_dma_tag ifpga_pci_bus_d | @@ -146,27 +146,27 @@ struct arm32_bus_dma_tag ifpga_pci_bus_d | |||
146 | * (See conf_{read,write} for more detail | 146 | * (See conf_{read,write} for more detail | |
147 | */ | 147 | */ | |
148 | #define MAX_PCI_DEVICES 21 | 148 | #define MAX_PCI_DEVICES 21 | |
149 | 149 | |||
150 | /*static int | 150 | /*static int | |
151 | pci_intr(void *arg) | 151 | pci_intr(void *arg) | |
152 | { | 152 | { | |
153 | printf("pci int %x\n", (int)arg); | 153 | printf("pci int %x\n", (int)arg); | |
154 | return 0; | 154 | return 0; | |
155 | }*/ | 155 | }*/ | |
156 | 156 | |||
157 | 157 | |||
158 | void | 158 | void | |
159 | ifpga_pci_attach_hook(struct device *parent, struct device *self, | 159 | ifpga_pci_attach_hook(device_t parent, device_t self, | |
160 | struct pcibus_attach_args *pba) | 160 | struct pcibus_attach_args *pba) | |
161 | { | 161 | { | |
162 | #ifdef PCI_DEBUG | 162 | #ifdef PCI_DEBUG | |
163 | printf("ifpga_pci_attach_hook()\n"); | 163 | printf("ifpga_pci_attach_hook()\n"); | |
164 | #endif | 164 | #endif | |
165 | } | 165 | } | |
166 | 166 | |||
167 | int | 167 | int | |
168 | ifpga_pci_bus_maxdevs(void *pcv, int busno) | 168 | ifpga_pci_bus_maxdevs(void *pcv, int busno) | |
169 | { | 169 | { | |
170 | #ifdef PCI_DEBUG | 170 | #ifdef PCI_DEBUG | |
171 | printf("ifpga_pci_bus_maxdevs(pcv=%p, busno=%d)\n", pcv, busno); | 171 | printf("ifpga_pci_bus_maxdevs(pcv=%p, busno=%d)\n", pcv, busno); | |
172 | #endif | 172 | #endif |
--- src/sys/arch/evbarm/ifpga/ifpga_pcivar.h 2001/10/27 16:19:09 1.1
+++ src/sys/arch/evbarm/ifpga/ifpga_pcivar.h 2009/07/21 16:04:16 1.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ifpga_pcivar.h,v 1.1 2001/10/27 16:19:09 rearnsha Exp $ */ | 1 | /* $NetBSD: ifpga_pcivar.h,v 1.2 2009/07/21 16:04:16 dyoung Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001 ARM Ltd | 4 | * Copyright (c) 2001 ARM Ltd | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -20,28 +20,26 @@ | @@ -20,28 +20,26 @@ | |||
20 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 20 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
22 | * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | 22 | * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
23 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 23 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | struct ifpga_pci_softc { | 32 | struct ifpga_pci_softc { | |
33 | struct device sc_dev; | |||
34 | ||||
35 | bus_space_tag_t sc_iot; | 33 | bus_space_tag_t sc_iot; | |
36 | bus_space_handle_t sc_io_ioh; | 34 | bus_space_handle_t sc_io_ioh; | |
37 | bus_space_handle_t sc_conf_ioh; | 35 | bus_space_handle_t sc_conf_ioh; | |
38 | 36 | |||
39 | bus_space_tag_t sc_memt; | 37 | bus_space_tag_t sc_memt; | |
40 | bus_space_handle_t sc_app0_ioh; | 38 | bus_space_handle_t sc_app0_ioh; | |
41 | bus_space_handle_t sc_app1_ioh; | 39 | bus_space_handle_t sc_app1_ioh; | |
42 | bus_space_handle_t sc_reg_ioh; | 40 | bus_space_handle_t sc_reg_ioh; | |
43 | }; | 41 | }; | |
44 | 42 | |||
45 | /* Apperture 0, 256MB normal cycles. */ | 43 | /* Apperture 0, 256MB normal cycles. */ | |
46 | #define IFPGA_PCI_APP0_256MB_BASE 0x40000081 | 44 | #define IFPGA_PCI_APP0_256MB_BASE 0x40000081 | |
47 | #define IFPGA_PCI_APP0_512MB_BASE 0x40000091 | 45 | #define IFPGA_PCI_APP0_512MB_BASE 0x40000091 |
--- src/sys/arch/evbarm/ifpga/ifpgavar.h 2005/12/11 12:17:09 1.4
+++ src/sys/arch/evbarm/ifpga/ifpgavar.h 2009/07/21 16:04:16 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ifpgavar.h,v 1.4 2005/12/11 12:17:09 christos Exp $ */ | 1 | /* $NetBSD: ifpgavar.h,v 1.5 2009/07/21 16:04:16 dyoung Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001 ARM Ltd | 4 | * Copyright (c) 2001 ARM Ltd | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -35,27 +35,26 @@ | @@ -35,27 +35,26 @@ | |||
35 | #include <machine/bus.h> | 35 | #include <machine/bus.h> | |
36 | 36 | |||
37 | /* We statically map the UARTS at boot so that we can access the console | 37 | /* We statically map the UARTS at boot so that we can access the console | |
38 | before we've probed for the IFPGA. */ | 38 | before we've probed for the IFPGA. */ | |
39 | #define UART0_BOOT_BASE 0xfde00000 | 39 | #define UART0_BOOT_BASE 0xfde00000 | |
40 | #define UART1_BOOT_BASE 0xfdf00000 | 40 | #define UART1_BOOT_BASE 0xfdf00000 | |
41 | 41 | |||
42 | #define IFPGA_UART0 0x06000000 /* Uart 0 */ | 42 | #define IFPGA_UART0 0x06000000 /* Uart 0 */ | |
43 | #define IFPGA_UART1 0x07000000 /* Uart 1 */ | 43 | #define IFPGA_UART1 0x07000000 /* Uart 1 */ | |
44 | 44 | |||
45 | typedef paddr_t ifpga_addr_t; | 45 | typedef paddr_t ifpga_addr_t; | |
46 | 46 | |||
47 | struct ifpga_softc { | 47 | struct ifpga_softc { | |
48 | struct device sc_dev; /* Device node */ | |||
49 | bus_space_tag_t sc_iot; /* Bus tag */ | 48 | bus_space_tag_t sc_iot; /* Bus tag */ | |
50 | bus_space_handle_t sc_sc_ioh; /* System Controller handle */ | 49 | bus_space_handle_t sc_sc_ioh; /* System Controller handle */ | |
51 | bus_space_handle_t sc_cm_ioh; /* Core Module handle */ | 50 | bus_space_handle_t sc_cm_ioh; /* Core Module handle */ | |
52 | bus_space_handle_t sc_tmr_ioh; /* Timers handle */ | 51 | bus_space_handle_t sc_tmr_ioh; /* Timers handle */ | |
53 | bus_space_handle_t sc_irq_ioh; /* IRQ controller handle */ | 52 | bus_space_handle_t sc_irq_ioh; /* IRQ controller handle */ | |
54 | 53 | |||
55 | /* Clock variables. */ | 54 | /* Clock variables. */ | |
56 | int sc_statclock_count; | 55 | int sc_statclock_count; | |
57 | int sc_clock_count; | 56 | int sc_clock_count; | |
58 | int sc_clock_ticks_per_256us; | 57 | int sc_clock_ticks_per_256us; | |
59 | void * sc_clockintr; | 58 | void * sc_clockintr; | |
60 | void * sc_statclockintr; | 59 | void * sc_statclockintr; | |
61 | }; | 60 | }; |
--- src/sys/arch/evbarm/ifpga/pl030_rtc.c 2007/02/19 02:08:12 1.8
+++ src/sys/arch/evbarm/ifpga/pl030_rtc.c 2009/07/21 16:04:16 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pl030_rtc.c,v 1.8 2007/02/19 02:08:12 briggs Exp $ */ | 1 | /* $NetBSD: pl030_rtc.c,v 1.9 2009/07/21 16:04:16 dyoung Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001 ARM Ltd | 4 | * Copyright (c) 2001 ARM Ltd | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -22,94 +22,93 @@ | @@ -22,94 +22,93 @@ | |||
22 | * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | 22 | * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
23 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 23 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* Include header files */ | 32 | /* Include header files */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, "$NetBSD: pl030_rtc.c,v 1.8 2007/02/19 02:08:12 briggs Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: pl030_rtc.c,v 1.9 2009/07/21 16:04:16 dyoung Exp $"); | |
36 | 36 | |||
37 | #include <sys/types.h> | 37 | #include <sys/types.h> | |
38 | #include <sys/param.h> | 38 | #include <sys/param.h> | |
39 | #include <sys/systm.h> | 39 | #include <sys/systm.h> | |
40 | #include <sys/kernel.h> | 40 | #include <sys/kernel.h> | |
41 | #include <sys/time.h> | 41 | #include <sys/time.h> | |
42 | #include <sys/device.h> | 42 | #include <sys/device.h> | |
43 | 43 | |||
44 | #include <dev/clock_subr.h> | 44 | #include <dev/clock_subr.h> | |
45 | 45 | |||
46 | #include <arm/cpufunc.h> | 46 | #include <arm/cpufunc.h> | |
47 | #include <machine/intr.h> | 47 | #include <machine/intr.h> | |
48 | #include <evbarm/ifpga/ifpgavar.h> | 48 | #include <evbarm/ifpga/ifpgavar.h> | |
49 | #include <evbarm/ifpga/ifpgamem.h> | 49 | #include <evbarm/ifpga/ifpgamem.h> | |
50 | #include <evbarm/ifpga/ifpgareg.h> | 50 | #include <evbarm/ifpga/ifpgareg.h> | |
51 | 51 | |||
52 | #define PL030_RTC_SIZE 0x14 | 52 | #define PL030_RTC_SIZE 0x14 | |
53 | 53 | |||
54 | struct plrtc_softc { | 54 | struct plrtc_softc { | |
55 | struct device sc_dev; | |||
56 | bus_space_tag_t sc_iot; | 55 | bus_space_tag_t sc_iot; | |
57 | bus_space_handle_t sc_ioh; | 56 | bus_space_handle_t sc_ioh; | |
58 | struct todr_chip_handle sc_todr; | 57 | struct todr_chip_handle sc_todr; | |
59 | }; | 58 | }; | |
60 | 59 | |||
61 | static int plrtc_probe (struct device *, struct cfdata *, void *); | 60 | static int plrtc_probe (device_t, cfdata_t, void *); | |
62 | static void plrtc_attach (struct device *, struct device *, void *); | 61 | static void plrtc_attach (device_t, device_t, void *); | |
63 | 62 | |||
64 | CFATTACH_DECL(plrtc, sizeof(struct plrtc_softc), | 63 | CFATTACH_DECL_NEW(plrtc, sizeof(struct plrtc_softc), | |
65 | plrtc_probe, plrtc_attach, NULL, NULL); | 64 | plrtc_probe, plrtc_attach, NULL, NULL); | |
66 | 65 | |||
67 | static int | 66 | static int | |
68 | plrtc_gettime(todr_chip_handle_t todr, volatile struct timeval *tv) | 67 | plrtc_gettime(todr_chip_handle_t todr, volatile struct timeval *tv) | |
69 | { | 68 | { | |
70 | struct plrtc_softc *sc; | 69 | struct plrtc_softc *sc; | |
71 | 70 | |||
72 | sc = (struct plrtc_softc *)todr->cookie; | 71 | sc = (struct plrtc_softc *)todr->cookie; | |
73 | tv->tv_sec = bus_space_read_4(sc->sc_iot, sc->sc_ioh, IFPGA_RTC_DR); | 72 | tv->tv_sec = bus_space_read_4(sc->sc_iot, sc->sc_ioh, IFPGA_RTC_DR); | |
74 | /* initialize tv_usec? */ | 73 | /* initialize tv_usec? */ | |
75 | return 0; | 74 | return 0; | |
76 | } | 75 | } | |
77 | 76 | |||
78 | static int | 77 | static int | |
79 | plrtc_settime(todr_chip_handle_t todr, volatile struct timeval *tv) | 78 | plrtc_settime(todr_chip_handle_t todr, volatile struct timeval *tv) | |
80 | { | 79 | { | |
81 | struct plrtc_softc *sc; | 80 | struct plrtc_softc *sc; | |
82 | 81 | |||
83 | sc = (struct plrtc_softc *)todr->cookie; | 82 | sc = (struct plrtc_softc *)todr->cookie; | |
84 | bus_space_write_4(sc->sc_iot, sc->sc_ioh, IFPGA_RTC_LR, tv->tv_sec); | 83 | bus_space_write_4(sc->sc_iot, sc->sc_ioh, IFPGA_RTC_LR, tv->tv_sec); | |
85 | return 0; | 84 | return 0; | |
86 | } | 85 | } | |
87 | 86 | |||
88 | static int | 87 | static int | |
89 | plrtc_probe(struct device *parent, struct cfdata *cf, void *aux) | 88 | plrtc_probe(device_t parent, cfdata_t cf, void *aux) | |
90 | { | 89 | { | |
91 | return 1; | 90 | return 1; | |
92 | } | 91 | } | |
93 | 92 | |||
94 | static void | 93 | static void | |
95 | plrtc_attach(struct device *parent, struct device *self, void *aux) | 94 | plrtc_attach(device_t parent, device_t self, void *aux) | |
96 | { | 95 | { | |
97 | struct ifpga_attach_args *ifa = aux; | 96 | struct ifpga_attach_args *ifa = aux; | |
98 | struct plrtc_softc *sc = (struct plrtc_softc *)self; | 97 | struct plrtc_softc *sc = device_private(self); | |
99 | 98 | |||
100 | sc->sc_iot = ifa->ifa_iot; | 99 | sc->sc_iot = ifa->ifa_iot; | |
101 | if (bus_space_map(ifa->ifa_iot, ifa->ifa_addr, PL030_RTC_SIZE, 0, | 100 | if (bus_space_map(ifa->ifa_iot, ifa->ifa_addr, PL030_RTC_SIZE, 0, | |
102 | &sc->sc_ioh)) { | 101 | &sc->sc_ioh)) { | |
103 | printf("%s: unable to map device\n", sc->sc_dev.dv_xname); | 102 | printf("%s: unable to map device\n", device_xname(self)); | |
104 | return; | 103 | return; | |
105 | } | 104 | } | |
106 | 105 | |||
107 | memset(&sc->sc_todr, 0, sizeof(struct todr_chip_handle)); | 106 | memset(&sc->sc_todr, 0, sizeof(struct todr_chip_handle)); | |
108 | sc->sc_todr.cookie = sc; | 107 | sc->sc_todr.cookie = sc; | |
109 | sc->sc_todr.todr_gettime = plrtc_gettime; | 108 | sc->sc_todr.todr_gettime = plrtc_gettime; | |
110 | sc->sc_todr.todr_settime = plrtc_settime; | 109 | sc->sc_todr.todr_settime = plrtc_settime; | |
111 | 110 | |||
112 | todr_attach( &sc->sc_todr ); | 111 | todr_attach( &sc->sc_todr ); | |
113 | 112 | |||
114 | printf("\n"); | 113 | printf("\n"); | |
115 | } | 114 | } |