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