1 /*
2  * Copyright (C) 2005 Nokia Corporation
3  * Author: Paul Mundt <paul.mundt@nokia.com>
4  *
5  * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6  *
7  * Modified from the original mach-omap/omap2/board-generic.c did by Paul
8  * to support the OMAP2+ device tree boards with an unique board file.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14 #include <linux/io.h>
15 #include <linux/of_irq.h>
16 #include <linux/of_platform.h>
17 #include <linux/irqdomain.h>
18 
19 #include <asm/setup.h>
20 #include <asm/mach/arch.h>
21 
22 #include "common.h"
23 
24 static const struct of_device_id omap_dt_match_table[] __initconst = {
25 	{ .compatible = "simple-bus", },
26 	{ .compatible = "ti,omap-infra", },
27 	{ }
28 };
29 
30 static void __init omap_generic_init(void)
31 {
32 	omapdss_early_init_of();
33 
34 	pdata_quirks_init(omap_dt_match_table);
35 
36 	omapdss_init_of();
37 }
38 
39 #ifdef CONFIG_SOC_OMAP2420
40 static const char *const omap242x_boards_compat[] __initconst = {
41 	"ti,omap2420",
42 	NULL,
43 };
44 
45 DT_MACHINE_START(OMAP242X_DT, "Generic OMAP2420 (Flattened Device Tree)")
46 	.reserve	= omap_reserve,
47 	.map_io		= omap242x_map_io,
48 	.init_early	= omap2420_init_early,
49 	.init_machine	= omap_generic_init,
50 	.init_time	= omap_init_time,
51 	.dt_compat	= omap242x_boards_compat,
52 	.restart	= omap2xxx_restart,
53 MACHINE_END
54 #endif
55 
56 #ifdef CONFIG_SOC_OMAP2430
57 static const char *const omap243x_boards_compat[] __initconst = {
58 	"ti,omap2430",
59 	NULL,
60 };
61 
62 DT_MACHINE_START(OMAP243X_DT, "Generic OMAP2430 (Flattened Device Tree)")
63 	.reserve	= omap_reserve,
64 	.map_io		= omap243x_map_io,
65 	.init_early	= omap2430_init_early,
66 	.init_machine	= omap_generic_init,
67 	.init_time	= omap_init_time,
68 	.dt_compat	= omap243x_boards_compat,
69 	.restart	= omap2xxx_restart,
70 MACHINE_END
71 #endif
72 
73 #ifdef CONFIG_ARCH_OMAP3
74 /* Some boards need board name for legacy userspace in /proc/cpuinfo */
75 static const char *const n900_boards_compat[] __initconst = {
76 	"nokia,omap3-n900",
77 	NULL,
78 };
79 
80 /* Legacy userspace on Nokia N900 needs ATAGS exported in /proc/atags,
81  * save them while the data is still not overwritten
82  */
83 static void __init rx51_reserve(void)
84 {
85 	save_atags((const struct tag *)(PAGE_OFFSET + 0x100));
86 	omap_reserve();
87 }
88 
89 DT_MACHINE_START(OMAP3_N900_DT, "Nokia RX-51 board")
90 	.reserve	= rx51_reserve,
91 	.map_io		= omap3_map_io,
92 	.init_early	= omap3430_init_early,
93 	.init_machine	= omap_generic_init,
94 	.init_late	= omap3_init_late,
95 	.init_time	= omap_init_time,
96 	.dt_compat	= n900_boards_compat,
97 	.restart	= omap3xxx_restart,
98 MACHINE_END
99 
100 /* Generic omap3 boards, most boards can use these */
101 static const char *const omap3_boards_compat[] __initconst = {
102 	"ti,omap3430",
103 	"ti,omap3",
104 	NULL,
105 };
106 
107 DT_MACHINE_START(OMAP3_DT, "Generic OMAP3 (Flattened Device Tree)")
108 	.reserve	= omap_reserve,
109 	.map_io		= omap3_map_io,
110 	.init_early	= omap3430_init_early,
111 	.init_machine	= omap_generic_init,
112 	.init_late	= omap3_init_late,
113 	.init_time	= omap_init_time,
114 	.dt_compat	= omap3_boards_compat,
115 	.restart	= omap3xxx_restart,
116 MACHINE_END
117 
118 static const char *const omap36xx_boards_compat[] __initconst = {
119 	"ti,omap3630",
120 	"ti,omap36xx",
121 	NULL,
122 };
123 
124 DT_MACHINE_START(OMAP36XX_DT, "Generic OMAP36xx (Flattened Device Tree)")
125 	.reserve	= omap_reserve,
126 	.map_io		= omap3_map_io,
127 	.init_early	= omap3630_init_early,
128 	.init_machine	= omap_generic_init,
129 	.init_late	= omap3_init_late,
130 	.init_time	= omap_init_time,
131 	.dt_compat	= omap36xx_boards_compat,
132 	.restart	= omap3xxx_restart,
133 MACHINE_END
134 
135 static const char *const omap3_gp_boards_compat[] __initconst = {
136 	"ti,omap3-beagle",
137 	"timll,omap3-devkit8000",
138 	NULL,
139 };
140 
141 DT_MACHINE_START(OMAP3_GP_DT, "Generic OMAP3-GP (Flattened Device Tree)")
142 	.reserve	= omap_reserve,
143 	.map_io		= omap3_map_io,
144 	.init_early	= omap3430_init_early,
145 	.init_machine	= omap_generic_init,
146 	.init_late	= omap3_init_late,
147 	.init_time	= omap3_secure_sync32k_timer_init,
148 	.dt_compat	= omap3_gp_boards_compat,
149 	.restart	= omap3xxx_restart,
150 MACHINE_END
151 
152 static const char *const am3517_boards_compat[] __initconst = {
153 	"ti,am3517",
154 	NULL,
155 };
156 
157 DT_MACHINE_START(AM3517_DT, "Generic AM3517 (Flattened Device Tree)")
158 	.reserve	= omap_reserve,
159 	.map_io		= omap3_map_io,
160 	.init_early	= am35xx_init_early,
161 	.init_machine	= omap_generic_init,
162 	.init_late	= omap3_init_late,
163 	.init_time	= omap3_gptimer_timer_init,
164 	.dt_compat	= am3517_boards_compat,
165 	.restart	= omap3xxx_restart,
166 MACHINE_END
167 #endif
168 
169 #ifdef CONFIG_SOC_TI81XX
170 static const char *const ti814x_boards_compat[] __initconst = {
171 	"ti,dm8148",
172 	"ti,dm814",
173 	NULL,
174 };
175 
176 DT_MACHINE_START(TI814X_DT, "Generic ti814x (Flattened Device Tree)")
177 	.reserve	= omap_reserve,
178 	.map_io		= ti81xx_map_io,
179 	.init_early	= ti814x_init_early,
180 	.init_machine	= omap_generic_init,
181 	.init_late	= ti81xx_init_late,
182 	.init_time	= omap3_gptimer_timer_init,
183 	.dt_compat	= ti814x_boards_compat,
184 	.restart	= ti81xx_restart,
185 MACHINE_END
186 
187 static const char *const ti816x_boards_compat[] __initconst = {
188 	"ti,dm8168",
189 	"ti,dm816",
190 	NULL,
191 };
192 
193 DT_MACHINE_START(TI816X_DT, "Generic ti816x (Flattened Device Tree)")
194 	.reserve	= omap_reserve,
195 	.map_io		= ti81xx_map_io,
196 	.init_early	= ti816x_init_early,
197 	.init_machine	= omap_generic_init,
198 	.init_late	= ti81xx_init_late,
199 	.init_time	= omap3_gptimer_timer_init,
200 	.dt_compat	= ti816x_boards_compat,
201 	.restart	= ti81xx_restart,
202 MACHINE_END
203 #endif
204 
205 #ifdef CONFIG_SOC_AM33XX
206 static const char *const am33xx_boards_compat[] __initconst = {
207 	"ti,am33xx",
208 	NULL,
209 };
210 
211 DT_MACHINE_START(AM33XX_DT, "Generic AM33XX (Flattened Device Tree)")
212 	.reserve	= omap_reserve,
213 	.map_io		= am33xx_map_io,
214 	.init_early	= am33xx_init_early,
215 	.init_machine	= omap_generic_init,
216 	.init_late	= am33xx_init_late,
217 	.init_time	= omap3_gptimer_timer_init,
218 	.dt_compat	= am33xx_boards_compat,
219 	.restart	= am33xx_restart,
220 MACHINE_END
221 #endif
222 
223 #ifdef CONFIG_ARCH_OMAP4
224 static const char *const omap4_boards_compat[] __initconst = {
225 	"ti,omap4460",
226 	"ti,omap4430",
227 	"ti,omap4",
228 	NULL,
229 };
230 
231 DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
232 	.l2c_aux_val	= OMAP_L2C_AUX_CTRL,
233 	.l2c_aux_mask	= 0xcf9fffff,
234 	.l2c_write_sec	= omap4_l2c310_write_sec,
235 	.reserve	= omap_reserve,
236 	.smp		= smp_ops(omap4_smp_ops),
237 	.map_io		= omap4_map_io,
238 	.init_early	= omap4430_init_early,
239 	.init_irq	= omap_gic_of_init,
240 	.init_machine	= omap_generic_init,
241 	.init_late	= omap4430_init_late,
242 	.init_time	= omap4_local_timer_init,
243 	.dt_compat	= omap4_boards_compat,
244 	.restart	= omap44xx_restart,
245 MACHINE_END
246 #endif
247 
248 #ifdef CONFIG_SOC_OMAP5
249 static const char *const omap5_boards_compat[] __initconst = {
250 	"ti,omap5432",
251 	"ti,omap5430",
252 	"ti,omap5",
253 	NULL,
254 };
255 
256 DT_MACHINE_START(OMAP5_DT, "Generic OMAP5 (Flattened Device Tree)")
257 #if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE)
258 	.dma_zone_size	= SZ_2G,
259 #endif
260 	.reserve	= omap_reserve,
261 	.smp		= smp_ops(omap4_smp_ops),
262 	.map_io		= omap5_map_io,
263 	.init_early	= omap5_init_early,
264 	.init_irq	= omap_gic_of_init,
265 	.init_machine	= omap_generic_init,
266 	.init_late	= omap5_init_late,
267 	.init_time	= omap5_realtime_timer_init,
268 	.dt_compat	= omap5_boards_compat,
269 	.restart	= omap44xx_restart,
270 MACHINE_END
271 #endif
272 
273 #ifdef CONFIG_SOC_AM43XX
274 static const char *const am43_boards_compat[] __initconst = {
275 	"ti,am4372",
276 	"ti,am43",
277 	NULL,
278 };
279 
280 DT_MACHINE_START(AM43_DT, "Generic AM43 (Flattened Device Tree)")
281 	.l2c_aux_val	= OMAP_L2C_AUX_CTRL,
282 	.l2c_aux_mask	= 0xcf9fffff,
283 	.l2c_write_sec	= omap4_l2c310_write_sec,
284 	.map_io		= am33xx_map_io,
285 	.init_early	= am43xx_init_early,
286 	.init_late	= am43xx_init_late,
287 	.init_irq	= omap_gic_of_init,
288 	.init_machine	= omap_generic_init,
289 	.init_time	= omap4_local_timer_init,
290 	.dt_compat	= am43_boards_compat,
291 	.restart	= omap44xx_restart,
292 MACHINE_END
293 #endif
294 
295 #ifdef CONFIG_SOC_DRA7XX
296 static const char *const dra74x_boards_compat[] __initconst = {
297 	"ti,am5728",
298 	"ti,am5726",
299 	"ti,dra742",
300 	"ti,dra7",
301 	NULL,
302 };
303 
304 DT_MACHINE_START(DRA74X_DT, "Generic DRA74X (Flattened Device Tree)")
305 #if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE)
306 	.dma_zone_size	= SZ_2G,
307 #endif
308 	.reserve	= omap_reserve,
309 	.smp		= smp_ops(omap4_smp_ops),
310 	.map_io		= dra7xx_map_io,
311 	.init_early	= dra7xx_init_early,
312 	.init_late	= dra7xx_init_late,
313 	.init_irq	= omap_gic_of_init,
314 	.init_machine	= omap_generic_init,
315 	.init_time	= omap5_realtime_timer_init,
316 	.dt_compat	= dra74x_boards_compat,
317 	.restart	= omap44xx_restart,
318 MACHINE_END
319 
320 static const char *const dra72x_boards_compat[] __initconst = {
321 	"ti,am5718",
322 	"ti,am5716",
323 	"ti,dra722",
324 	NULL,
325 };
326 
327 DT_MACHINE_START(DRA72X_DT, "Generic DRA72X (Flattened Device Tree)")
328 #if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE)
329 	.dma_zone_size	= SZ_2G,
330 #endif
331 	.reserve	= omap_reserve,
332 	.map_io		= dra7xx_map_io,
333 	.init_early	= dra7xx_init_early,
334 	.init_late	= dra7xx_init_late,
335 	.init_irq	= omap_gic_of_init,
336 	.init_machine	= omap_generic_init,
337 	.init_time	= omap5_realtime_timer_init,
338 	.dt_compat	= dra72x_boards_compat,
339 	.restart	= omap44xx_restart,
340 MACHINE_END
341 #endif
342