2 * linux/arch/arm/mach-omap2/io.c
4 * OMAP2 I/O mapping code
6 * Copyright (C) 2005 Nokia Corporation
7 * Copyright (C) 2007-2009 Texas Instruments
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License version 2 as
17 * published by the Free Software Foundation.
19 #include <linux/module.h>
20 #include <linux/kernel.h>
21 #include <linux/init.h>
23 #include <linux/clk.h>
26 #include <asm/mach/map.h>
28 #include <plat/serial.h>
29 #include <plat/omap-pm.h>
30 #include <plat/omap_hwmod.h>
31 #include <plat/multi.h>
32 #include <plat-omap/dma-omap.h>
34 #include "../plat-omap/sram.h"
39 #include "powerdomain.h"
40 #include "clockdomain.h"
43 #include "clock2xxx.h"
44 #include "clock3xxx.h"
45 #include "clock44xx.h"
49 * The machine specific code may provide the extra mapping besides the
50 * default mapping provided here.
53 #if defined(CONFIG_SOC_OMAP2420) || defined(CONFIG_SOC_OMAP2430)
54 static struct map_desc omap24xx_io_desc[] __initdata = {
56 .virtual = L3_24XX_VIRT,
57 .pfn = __phys_to_pfn(L3_24XX_PHYS),
58 .length = L3_24XX_SIZE,
62 .virtual = L4_24XX_VIRT,
63 .pfn = __phys_to_pfn(L4_24XX_PHYS),
64 .length = L4_24XX_SIZE,
69 #ifdef CONFIG_SOC_OMAP2420
70 static struct map_desc omap242x_io_desc[] __initdata = {
72 .virtual = DSP_MEM_2420_VIRT,
73 .pfn = __phys_to_pfn(DSP_MEM_2420_PHYS),
74 .length = DSP_MEM_2420_SIZE,
78 .virtual = DSP_IPI_2420_VIRT,
79 .pfn = __phys_to_pfn(DSP_IPI_2420_PHYS),
80 .length = DSP_IPI_2420_SIZE,
84 .virtual = DSP_MMU_2420_VIRT,
85 .pfn = __phys_to_pfn(DSP_MMU_2420_PHYS),
86 .length = DSP_MMU_2420_SIZE,
93 #ifdef CONFIG_SOC_OMAP2430
94 static struct map_desc omap243x_io_desc[] __initdata = {
96 .virtual = L4_WK_243X_VIRT,
97 .pfn = __phys_to_pfn(L4_WK_243X_PHYS),
98 .length = L4_WK_243X_SIZE,
102 .virtual = OMAP243X_GPMC_VIRT,
103 .pfn = __phys_to_pfn(OMAP243X_GPMC_PHYS),
104 .length = OMAP243X_GPMC_SIZE,
108 .virtual = OMAP243X_SDRC_VIRT,
109 .pfn = __phys_to_pfn(OMAP243X_SDRC_PHYS),
110 .length = OMAP243X_SDRC_SIZE,
114 .virtual = OMAP243X_SMS_VIRT,
115 .pfn = __phys_to_pfn(OMAP243X_SMS_PHYS),
116 .length = OMAP243X_SMS_SIZE,
123 #ifdef CONFIG_ARCH_OMAP3
124 static struct map_desc omap34xx_io_desc[] __initdata = {
126 .virtual = L3_34XX_VIRT,
127 .pfn = __phys_to_pfn(L3_34XX_PHYS),
128 .length = L3_34XX_SIZE,
132 .virtual = L4_34XX_VIRT,
133 .pfn = __phys_to_pfn(L4_34XX_PHYS),
134 .length = L4_34XX_SIZE,
138 .virtual = OMAP34XX_GPMC_VIRT,
139 .pfn = __phys_to_pfn(OMAP34XX_GPMC_PHYS),
140 .length = OMAP34XX_GPMC_SIZE,
144 .virtual = OMAP343X_SMS_VIRT,
145 .pfn = __phys_to_pfn(OMAP343X_SMS_PHYS),
146 .length = OMAP343X_SMS_SIZE,
150 .virtual = OMAP343X_SDRC_VIRT,
151 .pfn = __phys_to_pfn(OMAP343X_SDRC_PHYS),
152 .length = OMAP343X_SDRC_SIZE,
156 .virtual = L4_PER_34XX_VIRT,
157 .pfn = __phys_to_pfn(L4_PER_34XX_PHYS),
158 .length = L4_PER_34XX_SIZE,
162 .virtual = L4_EMU_34XX_VIRT,
163 .pfn = __phys_to_pfn(L4_EMU_34XX_PHYS),
164 .length = L4_EMU_34XX_SIZE,
167 #if defined(CONFIG_DEBUG_LL) && \
168 (defined(CONFIG_MACH_OMAP_ZOOM2) || defined(CONFIG_MACH_OMAP_ZOOM3))
170 .virtual = ZOOM_UART_VIRT,
171 .pfn = __phys_to_pfn(ZOOM_UART_BASE),
179 #ifdef CONFIG_SOC_TI81XX
180 static struct map_desc omapti81xx_io_desc[] __initdata = {
182 .virtual = L4_34XX_VIRT,
183 .pfn = __phys_to_pfn(L4_34XX_PHYS),
184 .length = L4_34XX_SIZE,
190 #ifdef CONFIG_SOC_AM33XX
191 static struct map_desc omapam33xx_io_desc[] __initdata = {
193 .virtual = L4_34XX_VIRT,
194 .pfn = __phys_to_pfn(L4_34XX_PHYS),
195 .length = L4_34XX_SIZE,
199 .virtual = L4_WK_AM33XX_VIRT,
200 .pfn = __phys_to_pfn(L4_WK_AM33XX_PHYS),
201 .length = L4_WK_AM33XX_SIZE,
207 #ifdef CONFIG_ARCH_OMAP4
208 static struct map_desc omap44xx_io_desc[] __initdata = {
210 .virtual = L3_44XX_VIRT,
211 .pfn = __phys_to_pfn(L3_44XX_PHYS),
212 .length = L3_44XX_SIZE,
216 .virtual = L4_44XX_VIRT,
217 .pfn = __phys_to_pfn(L4_44XX_PHYS),
218 .length = L4_44XX_SIZE,
222 .virtual = L4_PER_44XX_VIRT,
223 .pfn = __phys_to_pfn(L4_PER_44XX_PHYS),
224 .length = L4_PER_44XX_SIZE,
227 #ifdef CONFIG_OMAP4_ERRATA_I688
229 .virtual = OMAP4_SRAM_VA,
230 .pfn = __phys_to_pfn(OMAP4_SRAM_PA),
232 .type = MT_MEMORY_SO,
239 #ifdef CONFIG_SOC_OMAP5
240 static struct map_desc omap54xx_io_desc[] __initdata = {
242 .virtual = L3_54XX_VIRT,
243 .pfn = __phys_to_pfn(L3_54XX_PHYS),
244 .length = L3_54XX_SIZE,
248 .virtual = L4_54XX_VIRT,
249 .pfn = __phys_to_pfn(L4_54XX_PHYS),
250 .length = L4_54XX_SIZE,
254 .virtual = L4_WK_54XX_VIRT,
255 .pfn = __phys_to_pfn(L4_WK_54XX_PHYS),
256 .length = L4_WK_54XX_SIZE,
260 .virtual = L4_PER_54XX_VIRT,
261 .pfn = __phys_to_pfn(L4_PER_54XX_PHYS),
262 .length = L4_PER_54XX_SIZE,
268 #ifdef CONFIG_SOC_OMAP2420
269 void __init omap242x_map_common_io(void)
271 iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
272 iotable_init(omap242x_io_desc, ARRAY_SIZE(omap242x_io_desc));
276 #ifdef CONFIG_SOC_OMAP2430
277 void __init omap243x_map_common_io(void)
279 iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
280 iotable_init(omap243x_io_desc, ARRAY_SIZE(omap243x_io_desc));
284 #ifdef CONFIG_ARCH_OMAP3
285 void __init omap34xx_map_common_io(void)
287 iotable_init(omap34xx_io_desc, ARRAY_SIZE(omap34xx_io_desc));
291 #ifdef CONFIG_SOC_TI81XX
292 void __init omapti81xx_map_common_io(void)
294 iotable_init(omapti81xx_io_desc, ARRAY_SIZE(omapti81xx_io_desc));
298 #ifdef CONFIG_SOC_AM33XX
299 void __init omapam33xx_map_common_io(void)
301 iotable_init(omapam33xx_io_desc, ARRAY_SIZE(omapam33xx_io_desc));
305 #ifdef CONFIG_ARCH_OMAP4
306 void __init omap44xx_map_common_io(void)
308 iotable_init(omap44xx_io_desc, ARRAY_SIZE(omap44xx_io_desc));
309 omap_barriers_init();
313 #ifdef CONFIG_SOC_OMAP5
314 void __init omap5_map_common_io(void)
316 iotable_init(omap54xx_io_desc, ARRAY_SIZE(omap54xx_io_desc));
320 * omap2_init_reprogram_sdrc - reprogram SDRC timing parameters
322 * Sets the CORE DPLL3 M2 divider to the same value that it's at
323 * currently. This has the effect of setting the SDRC SDRAM AC timing
324 * registers to the values currently defined by the kernel. Currently
325 * only defined for OMAP3; will return 0 if called on OMAP2. Returns
326 * -EINVAL if the dpll3_m2_ck cannot be found, 0 if called on OMAP2,
327 * or passes along the return value of clk_set_rate().
329 static int __init _omap2_init_reprogram_sdrc(void)
331 struct clk *dpll3_m2_ck;
335 if (!cpu_is_omap34xx())
338 dpll3_m2_ck = clk_get(NULL, "dpll3_m2_ck");
339 if (IS_ERR(dpll3_m2_ck))
342 rate = clk_get_rate(dpll3_m2_ck);
343 pr_info("Reprogramming SDRC clock to %ld Hz\n", rate);
344 v = clk_set_rate(dpll3_m2_ck, rate);
346 pr_err("dpll3_m2_clk rate change failed: %d\n", v);
348 clk_put(dpll3_m2_ck);
353 static int _set_hwmod_postsetup_state(struct omap_hwmod *oh, void *data)
355 return omap_hwmod_set_postsetup_state(oh, *(u8 *)data);
358 static void __init omap_common_init_early(void)
360 omap_init_consistent_dma_size();
363 static void __init omap_hwmod_init_postsetup(void)
367 /* Set the default postsetup state for all hwmods */
368 #ifdef CONFIG_PM_RUNTIME
369 postsetup_state = _HWMOD_STATE_IDLE;
371 postsetup_state = _HWMOD_STATE_ENABLED;
373 omap_hwmod_for_each(_set_hwmod_postsetup_state, &postsetup_state);
375 omap_pm_if_early_init();
378 #ifdef CONFIG_SOC_OMAP2420
379 void __init omap2420_init_early(void)
381 omap2_set_globals_242x();
382 omap2xxx_check_revision();
383 omap_common_init_early();
384 omap2xxx_voltagedomains_init();
385 omap242x_powerdomains_init();
386 omap242x_clockdomains_init();
387 omap2420_hwmod_init();
388 omap_hwmod_init_postsetup();
392 void __init omap2420_init_late(void)
394 omap_mux_late_init();
395 omap2_common_pm_late_init();
400 #ifdef CONFIG_SOC_OMAP2430
401 void __init omap2430_init_early(void)
403 omap2_set_globals_243x();
404 omap2xxx_check_revision();
405 omap_common_init_early();
406 omap2xxx_voltagedomains_init();
407 omap243x_powerdomains_init();
408 omap243x_clockdomains_init();
409 omap2430_hwmod_init();
410 omap_hwmod_init_postsetup();
414 void __init omap2430_init_late(void)
416 omap_mux_late_init();
417 omap2_common_pm_late_init();
423 * Currently only board-omap3beagle.c should call this because of the
424 * same machine_id for 34xx and 36xx beagle.. Will get fixed with DT.
426 #ifdef CONFIG_ARCH_OMAP3
427 void __init omap3_init_early(void)
429 omap2_set_globals_3xxx();
430 omap3xxx_check_revision();
431 omap3xxx_check_features();
432 omap_common_init_early();
433 omap3xxx_voltagedomains_init();
434 omap3xxx_powerdomains_init();
435 omap3xxx_clockdomains_init();
436 omap3xxx_hwmod_init();
437 omap_hwmod_init_postsetup();
441 void __init omap3430_init_early(void)
446 void __init omap35xx_init_early(void)
451 void __init omap3630_init_early(void)
456 void __init am35xx_init_early(void)
461 void __init ti81xx_init_early(void)
463 omap2_set_globals_ti81xx();
464 omap3xxx_check_revision();
465 ti81xx_check_features();
466 omap_common_init_early();
467 omap3xxx_voltagedomains_init();
468 omap3xxx_powerdomains_init();
469 omap3xxx_clockdomains_init();
470 omap3xxx_hwmod_init();
471 omap_hwmod_init_postsetup();
475 void __init omap3_init_late(void)
477 omap_mux_late_init();
478 omap2_common_pm_late_init();
482 void __init omap3430_init_late(void)
484 omap_mux_late_init();
485 omap2_common_pm_late_init();
489 void __init omap35xx_init_late(void)
491 omap_mux_late_init();
492 omap2_common_pm_late_init();
496 void __init omap3630_init_late(void)
498 omap_mux_late_init();
499 omap2_common_pm_late_init();
503 void __init am35xx_init_late(void)
505 omap_mux_late_init();
506 omap2_common_pm_late_init();
510 void __init ti81xx_init_late(void)
512 omap_mux_late_init();
513 omap2_common_pm_late_init();
518 #ifdef CONFIG_SOC_AM33XX
519 void __init am33xx_init_early(void)
521 omap2_set_globals_am33xx();
522 omap3xxx_check_revision();
523 ti81xx_check_features();
524 omap_common_init_early();
525 am33xx_voltagedomains_init();
526 am33xx_powerdomains_init();
527 am33xx_clockdomains_init();
529 omap_hwmod_init_postsetup();
534 #ifdef CONFIG_ARCH_OMAP4
535 void __init omap4430_init_early(void)
537 omap2_set_globals_443x();
538 omap4xxx_check_revision();
539 omap4xxx_check_features();
540 omap_common_init_early();
541 omap44xx_voltagedomains_init();
542 omap44xx_powerdomains_init();
543 omap44xx_clockdomains_init();
544 omap44xx_hwmod_init();
545 omap_hwmod_init_postsetup();
549 void __init omap4430_init_late(void)
551 omap_mux_late_init();
552 omap2_common_pm_late_init();
557 #ifdef CONFIG_SOC_OMAP5
558 void __init omap5_init_early(void)
560 omap2_set_globals_5xxx();
561 omap5xxx_check_revision();
562 omap_common_init_early();
566 void __init omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
567 struct omap_sdrc_params *sdrc_cs1)
571 if (cpu_is_omap24xx() || omap3_has_sdrc()) {
572 omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
573 _omap2_init_reprogram_sdrc();