| @@ -1,330 +1,345 @@ | | | @@ -1,330 +1,345 @@ |
1 | /* $Id: omap2_gpmc.c,v 1.9 2011/07/01 20:30:21 dyoung Exp $ */ | | 1 | /* $Id: omap2_gpmc.c,v 1.10 2016/10/04 15:23:40 kiyohara Exp $ */ |
2 | | | 2 | |
3 | /* adapted from: */ | | 3 | /* adapted from: */ |
4 | /* $NetBSD: omap2_gpmc.c,v 1.9 2011/07/01 20:30:21 dyoung Exp $ */ | | 4 | /* $NetBSD: omap2_gpmc.c,v 1.10 2016/10/04 15:23:40 kiyohara Exp $ */ |
5 | | | 5 | |
6 | | | 6 | |
7 | /* | | 7 | /* |
8 | * Autoconfiguration support for the Texas Instruments OMAP GPMC bus. | | 8 | * Autoconfiguration support for the Texas Instruments OMAP GPMC bus. |
9 | * Based on arm/omap/omap_emifs.c which in turn was derived | | 9 | * Based on arm/omap/omap_emifs.c which in turn was derived |
10 | * Based on arm/xscale/pxa2x0.c which in turn was derived | | 10 | * Based on arm/xscale/pxa2x0.c which in turn was derived |
11 | * from arm/sa11x0/sa11x0.c | | 11 | * from arm/sa11x0/sa11x0.c |
12 | * | | 12 | * |
13 | * Copyright (c) 2002, 2005 Genetec Corporation. All rights reserved. | | 13 | * Copyright (c) 2002, 2005 Genetec Corporation. All rights reserved. |
14 | * Written by Hiroyuki Bessho for Genetec Corporation. | | 14 | * Written by Hiroyuki Bessho for Genetec Corporation. |
15 | * | | 15 | * |
16 | * Redistribution and use in source and binary forms, with or without | | 16 | * Redistribution and use in source and binary forms, with or without |
17 | * modification, are permitted provided that the following conditions | | 17 | * modification, are permitted provided that the following conditions |
18 | * are met: | | 18 | * are met: |
19 | * 1. Redistributions of source code must retain the above copyright | | 19 | * 1. Redistributions of source code must retain the above copyright |
20 | * notice, this list of conditions and the following disclaimer. | | 20 | * notice, this list of conditions and the following disclaimer. |
21 | * 2. Redistributions in binary form must reproduce the above copyright | | 21 | * 2. Redistributions in binary form must reproduce the above copyright |
22 | * notice, this list of conditions and the following disclaimer in the | | 22 | * notice, this list of conditions and the following disclaimer in the |
23 | * documentation and/or other materials provided with the distribution. | | 23 | * documentation and/or other materials provided with the distribution. |
24 | * 3. All advertising materials mentioning features or use of this software | | 24 | * 3. All advertising materials mentioning features or use of this software |
25 | * must display the following acknowledgement: | | 25 | * must display the following acknowledgement: |
26 | * This product includes software developed for the NetBSD Project by | | 26 | * This product includes software developed for the NetBSD Project by |
27 | * Genetec Corporation. | | 27 | * Genetec Corporation. |
28 | * 4. The name of Genetec Corporation may not be used to endorse or | | 28 | * 4. The name of Genetec Corporation may not be used to endorse or |
29 | * promote products derived from this software without specific prior | | 29 | * promote products derived from this software without specific prior |
30 | * written permission. | | 30 | * written permission. |
31 | * | | 31 | * |
32 | * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND | | 32 | * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND |
33 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 33 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
34 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 34 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
35 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION | | 35 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION |
36 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 36 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
37 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 37 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
38 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 38 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
39 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 39 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
40 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 40 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
41 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 41 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
42 | * POSSIBILITY OF SUCH DAMAGE. | | 42 | * POSSIBILITY OF SUCH DAMAGE. |
43 | * | | 43 | * |
44 | * Copyright (c) 1997,1998, 2001, The NetBSD Foundation, Inc. | | 44 | * Copyright (c) 1997,1998, 2001, The NetBSD Foundation, Inc. |
45 | * All rights reserved. | | 45 | * All rights reserved. |
46 | * | | 46 | * |
47 | * This code is derived from software contributed to The NetBSD Foundation | | 47 | * This code is derived from software contributed to The NetBSD Foundation |
48 | * by IWAMOTO Toshihiro, Ichiro FUKUHARA and Paul Kranenburg. | | 48 | * by IWAMOTO Toshihiro, Ichiro FUKUHARA and Paul Kranenburg. |
49 | * | | 49 | * |
50 | * Redistribution and use in source and binary forms, with or without | | 50 | * Redistribution and use in source and binary forms, with or without |
51 | * modification, are permitted provided that the following conditions | | 51 | * modification, are permitted provided that the following conditions |
52 | * are met: | | 52 | * are met: |
53 | * 1. Redistributions of source code must retain the above copyright | | 53 | * 1. Redistributions of source code must retain the above copyright |
54 | * notice, this list of conditions and the following disclaimer. | | 54 | * notice, this list of conditions and the following disclaimer. |
55 | * 2. Redistributions in binary form must reproduce the above copyright | | 55 | * 2. Redistributions in binary form must reproduce the above copyright |
56 | * notice, this list of conditions and the following disclaimer in the | | 56 | * notice, this list of conditions and the following disclaimer in the |
57 | * documentation and/or other materials provided with the distribution. | | 57 | * documentation and/or other materials provided with the distribution. |
58 | * | | 58 | * |
59 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 59 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
60 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 60 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
61 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 61 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
62 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 62 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
63 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 63 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
64 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 64 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
65 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 65 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
66 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 66 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
67 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 67 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
68 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 68 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
69 | * POSSIBILITY OF SUCH DAMAGE. | | 69 | * POSSIBILITY OF SUCH DAMAGE. |
70 | * | | 70 | * |
71 | * Copyright (c) 1999 | | 71 | * Copyright (c) 1999 |
72 | * Shin Takemura and PocketBSD Project. All rights reserved. | | 72 | * Shin Takemura and PocketBSD Project. All rights reserved. |
73 | * | | 73 | * |
74 | * Redistribution and use in source and binary forms, with or without | | 74 | * Redistribution and use in source and binary forms, with or without |
75 | * modification, are permitted provided that the following conditions | | 75 | * modification, are permitted provided that the following conditions |
76 | * are met: | | 76 | * are met: |
77 | * 1. Redistributions of source code must retain the above copyright | | 77 | * 1. Redistributions of source code must retain the above copyright |
78 | * notice, this list of conditions and the following disclaimer. | | 78 | * notice, this list of conditions and the following disclaimer. |
79 | * 2. Redistributions in binary form must reproduce the above copyright | | 79 | * 2. Redistributions in binary form must reproduce the above copyright |
80 | * notice, this list of conditions and the following disclaimer in the | | 80 | * notice, this list of conditions and the following disclaimer in the |
81 | * documentation and/or other materials provided with the distribution. | | 81 | * documentation and/or other materials provided with the distribution. |
82 | * 3. All advertising materials mentioning features or use of this software | | 82 | * 3. All advertising materials mentioning features or use of this software |
83 | * must display the following acknowledgement: | | 83 | * must display the following acknowledgement: |
84 | * This product includes software developed by the PocketBSD project | | 84 | * This product includes software developed by the PocketBSD project |
85 | * and its contributors. | | 85 | * and its contributors. |
86 | * 4. Neither the name of the project nor the names of its contributors | | 86 | * 4. Neither the name of the project nor the names of its contributors |
87 | * may be used to endorse or promote products derived from this software | | 87 | * may be used to endorse or promote products derived from this software |
88 | * without specific prior written permission. | | 88 | * without specific prior written permission. |
89 | * | | 89 | * |
90 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 90 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
91 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 91 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
92 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 92 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
93 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 93 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
94 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 94 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
95 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 95 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
96 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 96 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
97 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 97 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
98 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 98 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
99 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 99 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
100 | * SUCH DAMAGE. | | 100 | * SUCH DAMAGE. |
101 | */ | | 101 | */ |
102 | | | 102 | |
103 | #include "opt_omap.h" | | 103 | #include "opt_omap.h" |
104 | #include <sys/cdefs.h> | | 104 | #include <sys/cdefs.h> |
105 | __KERNEL_RCSID(0, "$NetBSD: omap2_gpmc.c,v 1.9 2011/07/01 20:30:21 dyoung Exp $"); | | 105 | __KERNEL_RCSID(0, "$NetBSD: omap2_gpmc.c,v 1.10 2016/10/04 15:23:40 kiyohara Exp $"); |
106 | | | 106 | |
107 | #include "locators.h" | | 107 | #include "locators.h" |
108 | | | 108 | |
109 | #include <sys/param.h> | | 109 | #include <sys/param.h> |
110 | #include <sys/systm.h> | | 110 | #include <sys/systm.h> |
111 | #include <sys/device.h> | | 111 | #include <sys/device.h> |
112 | #include <sys/kernel.h> | | 112 | #include <sys/kernel.h> |
113 | #include <sys/reboot.h> | | 113 | #include <sys/reboot.h> |
114 | | | 114 | |
115 | #include <machine/cpu.h> | | 115 | #include <machine/cpu.h> |
116 | #include <sys/bus.h> | | 116 | #include <sys/bus.h> |
117 | | | 117 | |
118 | #include <arm/cpufunc.h> | | 118 | #include <arm/cpufunc.h> |
119 | #include <arm/mainbus/mainbus.h> | | 119 | #include <arm/mainbus/mainbus.h> |
120 | #include <arm/omap/omap_var.h> | | 120 | #include <arm/omap/omap_var.h> |
121 | | | 121 | |
122 | #include <arm/omap/omap2_gpmcreg.h> | | 122 | #include <arm/omap/omap2_gpmcreg.h> |
123 | #include <arm/omap/omap2_gpmcvar.h> | | 123 | #include <arm/omap/omap2_gpmcvar.h> |
124 | | | 124 | |
125 | typedef struct { | | 125 | typedef struct { |
126 | boolean_t cs_valid; | | 126 | boolean_t cs_valid; |
127 | ulong cs_addr; | | 127 | ulong cs_addr; |
128 | ulong cs_size; | | 128 | ulong cs_size; |
129 | } gpmc_csconfig_t; | | 129 | } gpmc_csconfig_t; |
130 | | | 130 | |
131 | struct gpmc_softc { | | 131 | struct gpmc_softc { |
132 | device_t sc_dev; | | 132 | device_t sc_dev; |
133 | bus_dma_tag_t sc_dmac; | | 133 | bus_dma_tag_t sc_dmac; |
134 | bus_space_tag_t sc_iot; | | 134 | bus_space_tag_t sc_iot; |
135 | bus_space_handle_t sc_ioh; | | 135 | bus_space_handle_t sc_ioh; |
136 | gpmc_csconfig_t sc_csconfig[GPMC_NCS]; | | 136 | gpmc_csconfig_t sc_csconfig[GPMC_NCS]; |
137 | }; | | 137 | }; |
138 | | | 138 | |
139 | | | 139 | |
140 | static bus_size_t csreg7[GPMC_NCS] = { | | 140 | static bus_size_t csreg7[GPMC_NCS] = { |
141 | GPMC_CONFIG7_0, | | 141 | GPMC_CONFIG7_0, |
142 | GPMC_CONFIG7_1, | | 142 | GPMC_CONFIG7_1, |
143 | GPMC_CONFIG7_2, | | 143 | GPMC_CONFIG7_2, |
144 | GPMC_CONFIG7_3, | | 144 | GPMC_CONFIG7_3, |
145 | GPMC_CONFIG7_4, | | 145 | GPMC_CONFIG7_4, |
146 | GPMC_CONFIG7_5, | | 146 | GPMC_CONFIG7_5, |
147 | GPMC_CONFIG7_6, | | 147 | GPMC_CONFIG7_6, |
148 | GPMC_CONFIG7_7, | | 148 | GPMC_CONFIG7_7, |
149 | }; | | 149 | }; |
150 | | | 150 | |
151 | | | 151 | |
152 | /* prototypes */ | | 152 | /* prototypes */ |
153 | static int gpmc_match(device_t, cfdata_t, void *); | | 153 | static int gpmc_match(device_t, cfdata_t, void *); |
154 | static void gpmc_attach(device_t, device_t, void *); | | 154 | static void gpmc_attach(device_t, device_t, void *); |
155 | static void gpmc_csconfig_init(struct gpmc_softc *); | | 155 | static void gpmc_csconfig_init(struct gpmc_softc *); |
156 | static int gpmc_search(device_t, cfdata_t, const int *, void *); | | 156 | static int gpmc_search(device_t, cfdata_t, const int *, void *); |
157 | static int gpmc_print(void *, const char *); | | 157 | static int gpmc_print(void *, const char *); |
158 | | | 158 | |
159 | /* attach structures */ | | 159 | /* attach structures */ |
160 | CFATTACH_DECL_NEW(gpmc, sizeof(struct gpmc_softc), | | 160 | CFATTACH_DECL_NEW(gpmc, sizeof(struct gpmc_softc), |
161 | gpmc_match, gpmc_attach, NULL, NULL); | | 161 | gpmc_match, gpmc_attach, NULL, NULL); |
162 | | | 162 | |
163 | static int gpmc_attached; /* XXX assumes only 1 instance */ | | 163 | static int gpmc_attached; /* XXX assumes only 1 instance */ |
164 | | | 164 | |
165 | static int | | 165 | static int |
166 | gpmc_match(device_t parent, cfdata_t match, void *aux) | | 166 | gpmc_match(device_t parent, cfdata_t match, void *aux) |
167 | { | | 167 | { |
168 | struct mainbus_attach_args *mb = aux; | | 168 | struct mainbus_attach_args *mb = aux; |
169 | | | 169 | |
170 | if (gpmc_attached != 0) | | 170 | if (gpmc_attached != 0) |
171 | return 0; | | 171 | return 0; |
172 | | | 172 | |
173 | #if defined(OMAP2) | | 173 | #if defined(OMAP2) |
174 | if (mb->mb_iobase == GPMC_BASE) | | 174 | if (mb->mb_iobase == GPMC_BASE) |
175 | return 1; | | 175 | return 1; |
176 | #endif | | 176 | #endif |
177 | | | 177 | |
178 | return 0; | | 178 | return 0; |
179 | } | | 179 | } |
180 | | | 180 | |
181 | static void | | 181 | static void |
182 | gpmc_attach(device_t parent, device_t self, void *aux) | | 182 | gpmc_attach(device_t parent, device_t self, void *aux) |
183 | { | | 183 | { |
184 | struct gpmc_softc *sc = device_private(self); | | 184 | struct gpmc_softc *sc = device_private(self); |
185 | struct mainbus_attach_args *mb = aux; | | 185 | struct mainbus_attach_args *mb = aux; |
186 | bus_space_handle_t ioh; | | 186 | bus_space_handle_t ioh; |
187 | uint32_t rev; | | 187 | uint32_t rev; |
188 | int err; | | 188 | int err; |
189 | | | 189 | |
190 | sc->sc_dev = self; | | 190 | sc->sc_dev = self; |
191 | sc->sc_iot = &omap_bs_tag; | | 191 | sc->sc_iot = &omap_bs_tag; |
192 | | | 192 | |
193 | err = bus_space_map(sc->sc_iot, mb->mb_iobase, GPMC_SIZE, 0, &ioh); | | 193 | err = bus_space_map(sc->sc_iot, mb->mb_iobase, GPMC_SIZE, 0, &ioh); |
194 | if (err != 0) | | 194 | if (err != 0) |
195 | panic("%s: Cannot map registers, error %d", | | 195 | panic("%s: Cannot map registers, error %d", |
196 | device_xname(self), err); | | 196 | device_xname(self), err); |
197 | | | 197 | |
198 | aprint_normal(": General Purpose Memory Controller"); | | 198 | aprint_normal(": General Purpose Memory Controller"); |
199 | | | 199 | |
200 | rev = bus_space_read_4(sc->sc_iot, ioh, GPMC_REVISION); | | 200 | rev = bus_space_read_4(sc->sc_iot, ioh, GPMC_REVISION); |
201 | | | 201 | |
202 | aprint_normal(", rev %d.%d\n", | | 202 | aprint_normal(", rev %d.%d\n", |
203 | GPMC_REVISION_REV_MAJ(rev), | | 203 | GPMC_REVISION_REV_MAJ(rev), |
204 | GPMC_REVISION_REV_MIN(rev)); | | 204 | GPMC_REVISION_REV_MIN(rev)); |
205 | | | 205 | |
206 | sc->sc_ioh = ioh; | | 206 | sc->sc_ioh = ioh; |
207 | sc->sc_dmac = NULL; | | 207 | sc->sc_dmac = NULL; |
208 | | | 208 | |
209 | gpmc_csconfig_init(sc); | | 209 | gpmc_csconfig_init(sc); |
210 | | | 210 | |
211 | gpmc_attached = 1; | | 211 | gpmc_attached = 1; |
212 | | | 212 | |
213 | /* | | 213 | /* |
214 | * Attach all our devices | | 214 | * Attach all our devices |
215 | */ | | 215 | */ |
216 | config_search_ia(gpmc_search, self, "gpmc", NULL); | | 216 | config_search_ia(gpmc_search, self, "gpmc", NULL); |
217 | } | | 217 | } |
218 | | | 218 | |
219 | static void | | 219 | static void |
220 | gpmc_csconfig_init(struct gpmc_softc *sc) | | 220 | gpmc_csconfig_init(struct gpmc_softc *sc) |
221 | { | | 221 | { |
222 | gpmc_csconfig_t *cs; | | 222 | gpmc_csconfig_t *cs; |
223 | uint32_t r; | | 223 | uint32_t r; |
224 | int i; | | 224 | int i; |
225 | | | 225 | |
226 | cs = &sc->sc_csconfig[0]; | | 226 | cs = &sc->sc_csconfig[0]; |
227 | for (i=0; i < GPMC_NCS; i++) { | | 227 | for (i=0; i < GPMC_NCS; i++) { |
228 | memset(cs, 0, sizeof(gpmc_csconfig_t)); | | 228 | memset(cs, 0, sizeof(gpmc_csconfig_t)); |
229 | r = bus_space_read_4(sc->sc_iot, sc->sc_ioh, csreg7[i]); | | 229 | r = bus_space_read_4(sc->sc_iot, sc->sc_ioh, csreg7[i]); |
230 | if ((r & GPMC_CONFIG7_CSVALID) != 0) { | | 230 | if ((r & GPMC_CONFIG7_CSVALID) != 0) { |
231 | cs->cs_valid = TRUE; | | 231 | cs->cs_valid = TRUE; |
232 | cs->cs_addr = omap_gpmc_config7_addr(r); | | 232 | cs->cs_addr = omap_gpmc_config7_addr(r); |
233 | cs->cs_size = omap_gpmc_config7_size(r); | | 233 | cs->cs_size = omap_gpmc_config7_size(r); |
234 | aprint_normal("%s: CS#%d valid, " | | 234 | aprint_normal("%s: CS#%d valid, " |
235 | "addr 0x%08lx, size %3ldMB\n", | | 235 | "addr 0x%08lx, size %3ldMB\n", |
236 | device_xname(sc->sc_dev), i, | | 236 | device_xname(sc->sc_dev), i, |
237 | cs->cs_addr, (cs->cs_size >> 20)); | | 237 | cs->cs_addr, (cs->cs_size >> 20)); |
238 | } | | 238 | } |
239 | cs++; | | 239 | cs++; |
240 | } | | 240 | } |
241 | } | | 241 | } |
242 | | | 242 | |
243 | static int | | 243 | static int |
244 | gpmc_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux) | | 244 | gpmc_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux) |
245 | { | | 245 | { |
246 | struct gpmc_softc *sc = device_private(parent); | | 246 | struct gpmc_softc *sc = device_private(parent); |
247 | struct gpmc_attach_args aa; | | 247 | struct gpmc_attach_args aa; |
248 | gpmc_csconfig_t *cs; | | 248 | gpmc_csconfig_t *cs; |
249 | int i; | | 249 | int i; |
250 | | | 250 | |
251 | /* Set up the attach args. */ | | 251 | /* Set up the attach args. */ |
252 | if (cf->cf_loc[GPMCCF_NOBYTEACC] == 1) { | | 252 | if (cf->cf_loc[GPMCCF_NOBYTEACC] == 1) { |
253 | if (cf->cf_loc[GPMCCF_MULT] == 1) | | 253 | if (cf->cf_loc[GPMCCF_MULT] == 1) |
254 | aa.gpmc_iot = &nobyteacc_bs_tag; | | 254 | aa.gpmc_iot = &nobyteacc_bs_tag; |
255 | else | | 255 | else |
256 | panic("nobyteacc specified for device with " | | 256 | panic("nobyteacc specified for device with " |
257 | "non-byte multiplier\n"); | | 257 | "non-byte multiplier\n"); |
258 | } else { | | 258 | } else { |
259 | switch (cf->cf_loc[GPMCCF_MULT]) { | | 259 | switch (cf->cf_loc[GPMCCF_MULT]) { |
260 | case 1: | | 260 | case 1: |
261 | aa.gpmc_iot = &omap_bs_tag; | | 261 | aa.gpmc_iot = &omap_bs_tag; |
262 | break; | | 262 | break; |
263 | case 2: | | 263 | case 2: |
264 | aa.gpmc_iot = &omap_a2x_bs_tag; | | 264 | aa.gpmc_iot = &omap_a2x_bs_tag; |
265 | break; | | 265 | break; |
266 | case 4: | | 266 | case 4: |
267 | aa.gpmc_iot = &omap_a4x_bs_tag; | | 267 | aa.gpmc_iot = &omap_a4x_bs_tag; |
268 | break; | | 268 | break; |
269 | default: | | 269 | default: |
270 | panic("Unsupported EMIFS multiplier."); | | 270 | panic("Unsupported EMIFS multiplier."); |
271 | break; | | 271 | break; |
272 | } | | 272 | } |
273 | } | | 273 | } |
274 | | | 274 | |
275 | aa.gpmc_dmac = sc->sc_dmac; | | 275 | aa.gpmc_dmac = sc->sc_dmac; |
276 | aa.gpmc_addr = cf->cf_loc[GPMCCF_ADDR]; | | 276 | aa.gpmc_addr = cf->cf_loc[GPMCCF_ADDR]; |
277 | aa.gpmc_size = cf->cf_loc[GPMCCF_SIZE]; | | 277 | aa.gpmc_size = cf->cf_loc[GPMCCF_SIZE]; |
278 | aa.gpmc_intr = cf->cf_loc[GPMCCF_INTR]; | | 278 | aa.gpmc_intr = cf->cf_loc[GPMCCF_INTR]; |
279 | | | 279 | |
280 | cs = &sc->sc_csconfig[0]; | | 280 | cs = &sc->sc_csconfig[0]; |
281 | for (i=0; i < GPMC_NCS; i++) { | | 281 | for (i = 0; i < GPMC_NCS; i++) { |
| | | 282 | if (cf->cf_loc[GPMCCF_CS] != GPMCCF_CS_DEFAULT) { |
| | | 283 | if (i != cf->cf_loc[GPMCCF_CS]) { |
| | | 284 | cs++; |
| | | 285 | continue; |
| | | 286 | } |
| | | 287 | |
| | | 288 | if (aa.gpmc_addr != GPMCCF_ADDR_DEFAULT |
| | | 289 | && aa.gpmc_addr != cs->cs_addr) |
| | | 290 | panic("cs:addr missmatch:" |
| | | 291 | " cs %d(0x%08lx), addr 0x%08lx\n", |
| | | 292 | cf->cf_loc[GPMCCF_CS], cs->cs_addr, |
| | | 293 | aa.gpmc_addr); |
| | | 294 | aa.gpmc_addr = cs->cs_addr; |
| | | 295 | } |
| | | 296 | |
282 | if ((aa.gpmc_addr >= cs->cs_addr) | | 297 | if ((aa.gpmc_addr >= cs->cs_addr) |
283 | && (aa.gpmc_addr < (cs->cs_addr + cs->cs_size))) { | | 298 | && (aa.gpmc_addr < (cs->cs_addr + cs->cs_size))) { |
284 | /* XXX | | 299 | /* XXX |
285 | * if size was specified, then check it too | | 300 | * if size was specified, then check it too |
286 | * otherwise just assume it is OK | | 301 | * otherwise just assume it is OK |
287 | */ | | 302 | */ |
288 | if ((aa.gpmc_size != GPMCCF_SIZE_DEFAULT) | | 303 | if ((aa.gpmc_size != GPMCCF_SIZE_DEFAULT) |
289 | && ((aa.gpmc_addr + aa.gpmc_size) | | 304 | && ((aa.gpmc_addr + aa.gpmc_size) |
290 | >= (cs->cs_addr + cs->cs_size))) | | 305 | >= (cs->cs_addr + cs->cs_size))) |
291 | continue; /* NG */ | | 306 | continue; /* NG */ |
292 | aa.gpmc_cs = i; | | 307 | aa.gpmc_cs = i; |
293 | if (config_match(parent, cf, &aa)) { | | 308 | if (config_match(parent, cf, &aa)) { |
294 | config_attach(parent, cf, &aa, gpmc_print); | | 309 | config_attach(parent, cf, &aa, gpmc_print); |
295 | return 0; /* love it */ | | 310 | return 0; /* love it */ |
296 | } | | 311 | } |
297 | } | | 312 | } |
298 | cs++; | | 313 | cs++; |
299 | } | | 314 | } |
300 | return 1; /* NG */ | | 315 | return 1; /* NG */ |
301 | } | | 316 | } |
302 | | | 317 | |
303 | static int | | 318 | static int |
304 | gpmc_print(void *aux, const char *name) | | 319 | gpmc_print(void *aux, const char *name) |
305 | { | | 320 | { |
306 | struct gpmc_attach_args *sa = (struct gpmc_attach_args*)aux; | | 321 | struct gpmc_attach_args *sa = (struct gpmc_attach_args*)aux; |
307 | | | 322 | |
308 | if (sa->gpmc_addr != GPMCCF_ADDR_DEFAULT) { | | 323 | if (sa->gpmc_addr != GPMCCF_ADDR_DEFAULT) { |
309 | aprint_normal(" addr 0x%08lx", sa->gpmc_addr); | | 324 | aprint_normal(" addr 0x%08lx", sa->gpmc_addr); |
310 | if (sa->gpmc_size != GPMCCF_SIZE_DEFAULT) | | 325 | if (sa->gpmc_size != GPMCCF_SIZE_DEFAULT) |
311 | aprint_normal("-0x%08lx", | | 326 | aprint_normal("-0x%08lx", |
312 | sa->gpmc_addr + sa->gpmc_size-1); | | 327 | sa->gpmc_addr + sa->gpmc_size-1); |
313 | } | | 328 | } |
314 | if (sa->gpmc_intr != GPMCCF_INTR_DEFAULT) | | 329 | if (sa->gpmc_intr != GPMCCF_INTR_DEFAULT) |
315 | aprint_normal(" intr %d", sa->gpmc_intr); | | 330 | aprint_normal(" intr %d", sa->gpmc_intr); |
316 | | | 331 | |
317 | return UNCONF; | | 332 | return UNCONF; |
318 | } | | 333 | } |
319 | | | 334 | |
320 | uint32_t | | 335 | uint32_t |
321 | gpmc_register_read(struct gpmc_softc *sc, bus_size_t reg) | | 336 | gpmc_register_read(struct gpmc_softc *sc, bus_size_t reg) |
322 | { | | 337 | { |
323 | return bus_space_read_4(sc->sc_iot, sc->sc_ioh, reg); | | 338 | return bus_space_read_4(sc->sc_iot, sc->sc_ioh, reg); |
324 | } | | 339 | } |
325 | | | 340 | |
326 | void | | 341 | void |
327 | gpmc_register_write(struct gpmc_softc *sc, bus_size_t reg, const uint32_t data) | | 342 | gpmc_register_write(struct gpmc_softc *sc, bus_size_t reg, const uint32_t data) |
328 | { | | 343 | { |
329 | bus_space_write_4(sc->sc_iot, sc->sc_ioh, reg, data); | | 344 | bus_space_write_4(sc->sc_iot, sc->sc_ioh, reg, data); |
330 | } | | 345 | } |