xref: /openbmc/linux/arch/arm/mach-omap2/io.c (revision 81a604823797ddb3aaf2a78cc1c6a1fa8f4d200c)
11dbae815STony Lindgren /*
21dbae815STony Lindgren  * linux/arch/arm/mach-omap2/io.c
31dbae815STony Lindgren  *
41dbae815STony Lindgren  * OMAP2 I/O mapping code
51dbae815STony Lindgren  *
61dbae815STony Lindgren  * Copyright (C) 2005 Nokia Corporation
744169075SSantosh Shilimkar  * Copyright (C) 2007-2009 Texas Instruments
8646e3ed1STony Lindgren  *
9646e3ed1STony Lindgren  * Author:
10646e3ed1STony Lindgren  *	Juha Yrjola <juha.yrjola@nokia.com>
11646e3ed1STony Lindgren  *	Syed Khasim <x0khasim@ti.com>
121dbae815STony Lindgren  *
1344169075SSantosh Shilimkar  * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
1444169075SSantosh Shilimkar  *
151dbae815STony Lindgren  * This program is free software; you can redistribute it and/or modify
161dbae815STony Lindgren  * it under the terms of the GNU General Public License version 2 as
171dbae815STony Lindgren  * published by the Free Software Foundation.
181dbae815STony Lindgren  */
191dbae815STony Lindgren 
201dbae815STony Lindgren #include <linux/module.h>
211dbae815STony Lindgren #include <linux/kernel.h>
221dbae815STony Lindgren #include <linux/init.h>
23fced80c7SRussell King #include <linux/io.h>
242f135eafSPaul Walmsley #include <linux/clk.h>
2591773a00STomi Valkeinen #include <linux/omapfb.h>
261dbae815STony Lindgren 
27120db2cbSTony Lindgren #include <asm/tlb.h>
28120db2cbSTony Lindgren 
29120db2cbSTony Lindgren #include <asm/mach/map.h>
30120db2cbSTony Lindgren 
31ce491cf8STony Lindgren #include <plat/sram.h>
32ce491cf8STony Lindgren #include <plat/sdrc.h>
33ce491cf8STony Lindgren #include <plat/serial.h>
34646e3ed1STony Lindgren 
35e80a9729SPaul Walmsley #include "clock2xxx.h"
36657ebfadSPaul Walmsley #include "clock3xxx.h"
37e80a9729SPaul Walmsley #include "clock44xx.h"
38b0a330dcSManjunath Kondaiah G #include "io.h"
391dbae815STony Lindgren 
40ce491cf8STony Lindgren #include <plat/omap-pm.h>
41*81a60482SKevin Hilman #include "voltage.h"
4272e06d08SPaul Walmsley #include "powerdomain.h"
439717100fSPaul Walmsley 
441540f214SPaul Walmsley #include "clockdomain.h"
45ce491cf8STony Lindgren #include <plat/omap_hwmod.h>
465d190c40STony Lindgren #include <plat/multi.h>
4702bfc030SPaul Walmsley 
481dbae815STony Lindgren /*
491dbae815STony Lindgren  * The machine specific code may provide the extra mapping besides the
501dbae815STony Lindgren  * default mapping provided here.
511dbae815STony Lindgren  */
52cc26b3b0SSyed Mohammed, Khasim 
53088ef950STony Lindgren #ifdef CONFIG_ARCH_OMAP2
54cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap24xx_io_desc[] __initdata = {
551dbae815STony Lindgren 	{
561dbae815STony Lindgren 		.virtual	= L3_24XX_VIRT,
571dbae815STony Lindgren 		.pfn		= __phys_to_pfn(L3_24XX_PHYS),
581dbae815STony Lindgren 		.length		= L3_24XX_SIZE,
591dbae815STony Lindgren 		.type		= MT_DEVICE
601dbae815STony Lindgren 	},
6109f21ed4SKyungmin Park 	{
6209f21ed4SKyungmin Park 		.virtual	= L4_24XX_VIRT,
6309f21ed4SKyungmin Park 		.pfn		= __phys_to_pfn(L4_24XX_PHYS),
6409f21ed4SKyungmin Park 		.length		= L4_24XX_SIZE,
6509f21ed4SKyungmin Park 		.type		= MT_DEVICE
6609f21ed4SKyungmin Park 	},
67cc26b3b0SSyed Mohammed, Khasim };
68cc26b3b0SSyed Mohammed, Khasim 
6959b479e0STony Lindgren #ifdef CONFIG_SOC_OMAP2420
70cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap242x_io_desc[] __initdata = {
711dbae815STony Lindgren 	{
727adb9987SPaul Walmsley 		.virtual	= DSP_MEM_2420_VIRT,
737adb9987SPaul Walmsley 		.pfn		= __phys_to_pfn(DSP_MEM_2420_PHYS),
747adb9987SPaul Walmsley 		.length		= DSP_MEM_2420_SIZE,
75c40fae95STony Lindgren 		.type		= MT_DEVICE
76c40fae95STony Lindgren 	},
77c40fae95STony Lindgren 	{
787adb9987SPaul Walmsley 		.virtual	= DSP_IPI_2420_VIRT,
797adb9987SPaul Walmsley 		.pfn		= __phys_to_pfn(DSP_IPI_2420_PHYS),
807adb9987SPaul Walmsley 		.length		= DSP_IPI_2420_SIZE,
81c40fae95STony Lindgren 		.type		= MT_DEVICE
82c40fae95STony Lindgren 	},
83c40fae95STony Lindgren 	{
847adb9987SPaul Walmsley 		.virtual	= DSP_MMU_2420_VIRT,
857adb9987SPaul Walmsley 		.pfn		= __phys_to_pfn(DSP_MMU_2420_PHYS),
867adb9987SPaul Walmsley 		.length		= DSP_MMU_2420_SIZE,
871dbae815STony Lindgren 		.type		= MT_DEVICE
88cc26b3b0SSyed Mohammed, Khasim 	},
891dbae815STony Lindgren };
901dbae815STony Lindgren 
91cc26b3b0SSyed Mohammed, Khasim #endif
92cc26b3b0SSyed Mohammed, Khasim 
9359b479e0STony Lindgren #ifdef CONFIG_SOC_OMAP2430
94cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap243x_io_desc[] __initdata = {
95cc26b3b0SSyed Mohammed, Khasim 	{
96cc26b3b0SSyed Mohammed, Khasim 		.virtual	= L4_WK_243X_VIRT,
97cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(L4_WK_243X_PHYS),
98cc26b3b0SSyed Mohammed, Khasim 		.length		= L4_WK_243X_SIZE,
99cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
100cc26b3b0SSyed Mohammed, Khasim 	},
101cc26b3b0SSyed Mohammed, Khasim 	{
102cc26b3b0SSyed Mohammed, Khasim 		.virtual	= OMAP243X_GPMC_VIRT,
103cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(OMAP243X_GPMC_PHYS),
104cc26b3b0SSyed Mohammed, Khasim 		.length		= OMAP243X_GPMC_SIZE,
105cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
106cc26b3b0SSyed Mohammed, Khasim 	},
107cc26b3b0SSyed Mohammed, Khasim 	{
108cc26b3b0SSyed Mohammed, Khasim 		.virtual	= OMAP243X_SDRC_VIRT,
109cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(OMAP243X_SDRC_PHYS),
110cc26b3b0SSyed Mohammed, Khasim 		.length		= OMAP243X_SDRC_SIZE,
111cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
112cc26b3b0SSyed Mohammed, Khasim 	},
113cc26b3b0SSyed Mohammed, Khasim 	{
114cc26b3b0SSyed Mohammed, Khasim 		.virtual	= OMAP243X_SMS_VIRT,
115cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(OMAP243X_SMS_PHYS),
116cc26b3b0SSyed Mohammed, Khasim 		.length		= OMAP243X_SMS_SIZE,
117cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
118cc26b3b0SSyed Mohammed, Khasim 	},
119cc26b3b0SSyed Mohammed, Khasim };
120cc26b3b0SSyed Mohammed, Khasim #endif
121cc26b3b0SSyed Mohammed, Khasim #endif
122cc26b3b0SSyed Mohammed, Khasim 
123a8eb7ca0STony Lindgren #ifdef	CONFIG_ARCH_OMAP3
124cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap34xx_io_desc[] __initdata = {
125cc26b3b0SSyed Mohammed, Khasim 	{
126cc26b3b0SSyed Mohammed, Khasim 		.virtual	= L3_34XX_VIRT,
127cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(L3_34XX_PHYS),
128cc26b3b0SSyed Mohammed, Khasim 		.length		= L3_34XX_SIZE,
129cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
130cc26b3b0SSyed Mohammed, Khasim 	},
131cc26b3b0SSyed Mohammed, Khasim 	{
132cc26b3b0SSyed Mohammed, Khasim 		.virtual	= L4_34XX_VIRT,
133cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
134cc26b3b0SSyed Mohammed, Khasim 		.length		= L4_34XX_SIZE,
135cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
136cc26b3b0SSyed Mohammed, Khasim 	},
137cc26b3b0SSyed Mohammed, Khasim 	{
138cc26b3b0SSyed Mohammed, Khasim 		.virtual	= OMAP34XX_GPMC_VIRT,
139cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(OMAP34XX_GPMC_PHYS),
140cc26b3b0SSyed Mohammed, Khasim 		.length		= OMAP34XX_GPMC_SIZE,
141cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
142cc26b3b0SSyed Mohammed, Khasim 	},
143cc26b3b0SSyed Mohammed, Khasim 	{
144cc26b3b0SSyed Mohammed, Khasim 		.virtual	= OMAP343X_SMS_VIRT,
145cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(OMAP343X_SMS_PHYS),
146cc26b3b0SSyed Mohammed, Khasim 		.length		= OMAP343X_SMS_SIZE,
147cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
148cc26b3b0SSyed Mohammed, Khasim 	},
149cc26b3b0SSyed Mohammed, Khasim 	{
150cc26b3b0SSyed Mohammed, Khasim 		.virtual	= OMAP343X_SDRC_VIRT,
151cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(OMAP343X_SDRC_PHYS),
152cc26b3b0SSyed Mohammed, Khasim 		.length		= OMAP343X_SDRC_SIZE,
153cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
154cc26b3b0SSyed Mohammed, Khasim 	},
155cc26b3b0SSyed Mohammed, Khasim 	{
156cc26b3b0SSyed Mohammed, Khasim 		.virtual	= L4_PER_34XX_VIRT,
157cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(L4_PER_34XX_PHYS),
158cc26b3b0SSyed Mohammed, Khasim 		.length		= L4_PER_34XX_SIZE,
159cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
160cc26b3b0SSyed Mohammed, Khasim 	},
161cc26b3b0SSyed Mohammed, Khasim 	{
162cc26b3b0SSyed Mohammed, Khasim 		.virtual	= L4_EMU_34XX_VIRT,
163cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(L4_EMU_34XX_PHYS),
164cc26b3b0SSyed Mohammed, Khasim 		.length		= L4_EMU_34XX_SIZE,
165cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
166cc26b3b0SSyed Mohammed, Khasim 	},
167a4f57b81STony Lindgren #if defined(CONFIG_DEBUG_LL) &&							\
168a4f57b81STony Lindgren 	(defined(CONFIG_MACH_OMAP_ZOOM2) || defined(CONFIG_MACH_OMAP_ZOOM3))
169a4f57b81STony Lindgren 	{
170a4f57b81STony Lindgren 		.virtual	= ZOOM_UART_VIRT,
171a4f57b81STony Lindgren 		.pfn		= __phys_to_pfn(ZOOM_UART_BASE),
172a4f57b81STony Lindgren 		.length		= SZ_1M,
173a4f57b81STony Lindgren 		.type		= MT_DEVICE
174a4f57b81STony Lindgren 	},
175a4f57b81STony Lindgren #endif
176cc26b3b0SSyed Mohammed, Khasim };
177cc26b3b0SSyed Mohammed, Khasim #endif
17801001712SHemant Pedanekar 
17901001712SHemant Pedanekar #ifdef CONFIG_SOC_OMAPTI816X
18001001712SHemant Pedanekar static struct map_desc omapti816x_io_desc[] __initdata = {
18101001712SHemant Pedanekar 	{
18201001712SHemant Pedanekar 		.virtual	= L4_34XX_VIRT,
18301001712SHemant Pedanekar 		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
18401001712SHemant Pedanekar 		.length		= L4_34XX_SIZE,
18501001712SHemant Pedanekar 		.type		= MT_DEVICE
18601001712SHemant Pedanekar 	},
18701001712SHemant Pedanekar };
18801001712SHemant Pedanekar #endif
18901001712SHemant Pedanekar 
19044169075SSantosh Shilimkar #ifdef	CONFIG_ARCH_OMAP4
19144169075SSantosh Shilimkar static struct map_desc omap44xx_io_desc[] __initdata = {
19244169075SSantosh Shilimkar 	{
19344169075SSantosh Shilimkar 		.virtual	= L3_44XX_VIRT,
19444169075SSantosh Shilimkar 		.pfn		= __phys_to_pfn(L3_44XX_PHYS),
19544169075SSantosh Shilimkar 		.length		= L3_44XX_SIZE,
19644169075SSantosh Shilimkar 		.type		= MT_DEVICE,
19744169075SSantosh Shilimkar 	},
19844169075SSantosh Shilimkar 	{
19944169075SSantosh Shilimkar 		.virtual	= L4_44XX_VIRT,
20044169075SSantosh Shilimkar 		.pfn		= __phys_to_pfn(L4_44XX_PHYS),
20144169075SSantosh Shilimkar 		.length		= L4_44XX_SIZE,
20244169075SSantosh Shilimkar 		.type		= MT_DEVICE,
20344169075SSantosh Shilimkar 	},
20444169075SSantosh Shilimkar 	{
20544169075SSantosh Shilimkar 		.virtual	= OMAP44XX_GPMC_VIRT,
20644169075SSantosh Shilimkar 		.pfn		= __phys_to_pfn(OMAP44XX_GPMC_PHYS),
20744169075SSantosh Shilimkar 		.length		= OMAP44XX_GPMC_SIZE,
20844169075SSantosh Shilimkar 		.type		= MT_DEVICE,
20944169075SSantosh Shilimkar 	},
21044169075SSantosh Shilimkar 	{
211f5d2d659SSantosh Shilimkar 		.virtual	= OMAP44XX_EMIF1_VIRT,
212f5d2d659SSantosh Shilimkar 		.pfn		= __phys_to_pfn(OMAP44XX_EMIF1_PHYS),
213f5d2d659SSantosh Shilimkar 		.length		= OMAP44XX_EMIF1_SIZE,
214f5d2d659SSantosh Shilimkar 		.type		= MT_DEVICE,
215f5d2d659SSantosh Shilimkar 	},
216f5d2d659SSantosh Shilimkar 	{
217f5d2d659SSantosh Shilimkar 		.virtual	= OMAP44XX_EMIF2_VIRT,
218f5d2d659SSantosh Shilimkar 		.pfn		= __phys_to_pfn(OMAP44XX_EMIF2_PHYS),
219f5d2d659SSantosh Shilimkar 		.length		= OMAP44XX_EMIF2_SIZE,
220f5d2d659SSantosh Shilimkar 		.type		= MT_DEVICE,
221f5d2d659SSantosh Shilimkar 	},
222f5d2d659SSantosh Shilimkar 	{
223f5d2d659SSantosh Shilimkar 		.virtual	= OMAP44XX_DMM_VIRT,
224f5d2d659SSantosh Shilimkar 		.pfn		= __phys_to_pfn(OMAP44XX_DMM_PHYS),
225f5d2d659SSantosh Shilimkar 		.length		= OMAP44XX_DMM_SIZE,
226f5d2d659SSantosh Shilimkar 		.type		= MT_DEVICE,
227f5d2d659SSantosh Shilimkar 	},
228f5d2d659SSantosh Shilimkar 	{
22944169075SSantosh Shilimkar 		.virtual	= L4_PER_44XX_VIRT,
23044169075SSantosh Shilimkar 		.pfn		= __phys_to_pfn(L4_PER_44XX_PHYS),
23144169075SSantosh Shilimkar 		.length		= L4_PER_44XX_SIZE,
23244169075SSantosh Shilimkar 		.type		= MT_DEVICE,
23344169075SSantosh Shilimkar 	},
23444169075SSantosh Shilimkar 	{
23544169075SSantosh Shilimkar 		.virtual	= L4_EMU_44XX_VIRT,
23644169075SSantosh Shilimkar 		.pfn		= __phys_to_pfn(L4_EMU_44XX_PHYS),
23744169075SSantosh Shilimkar 		.length		= L4_EMU_44XX_SIZE,
23844169075SSantosh Shilimkar 		.type		= MT_DEVICE,
23944169075SSantosh Shilimkar 	},
24044169075SSantosh Shilimkar };
24144169075SSantosh Shilimkar #endif
242cc26b3b0SSyed Mohammed, Khasim 
2436fbd55d0STony Lindgren static void __init _omap2_map_common_io(void)
2441dbae815STony Lindgren {
245120db2cbSTony Lindgren 	/* Normally devicemaps_init() would flush caches and tlb after
246120db2cbSTony Lindgren 	 * mdesc->map_io(), but we must also do it here because of the CPU
247120db2cbSTony Lindgren 	 * revision check below.
248120db2cbSTony Lindgren 	 */
249120db2cbSTony Lindgren 	local_flush_tlb_all();
250120db2cbSTony Lindgren 	flush_cache_all();
251120db2cbSTony Lindgren 
2521dbae815STony Lindgren 	omap2_check_revision();
2531dbae815STony Lindgren 	omap_sram_init();
254120db2cbSTony Lindgren }
255120db2cbSTony Lindgren 
25659b479e0STony Lindgren #ifdef CONFIG_SOC_OMAP2420
2578185e468SAaro Koskinen void __init omap242x_map_common_io(void)
2586fbd55d0STony Lindgren {
2596fbd55d0STony Lindgren 	iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
2606fbd55d0STony Lindgren 	iotable_init(omap242x_io_desc, ARRAY_SIZE(omap242x_io_desc));
2616fbd55d0STony Lindgren 	_omap2_map_common_io();
2626fbd55d0STony Lindgren }
2636fbd55d0STony Lindgren #endif
2646fbd55d0STony Lindgren 
26559b479e0STony Lindgren #ifdef CONFIG_SOC_OMAP2430
2668185e468SAaro Koskinen void __init omap243x_map_common_io(void)
2676fbd55d0STony Lindgren {
2686fbd55d0STony Lindgren 	iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
2696fbd55d0STony Lindgren 	iotable_init(omap243x_io_desc, ARRAY_SIZE(omap243x_io_desc));
2706fbd55d0STony Lindgren 	_omap2_map_common_io();
2716fbd55d0STony Lindgren }
2726fbd55d0STony Lindgren #endif
2736fbd55d0STony Lindgren 
274a8eb7ca0STony Lindgren #ifdef CONFIG_ARCH_OMAP3
2758185e468SAaro Koskinen void __init omap34xx_map_common_io(void)
2766fbd55d0STony Lindgren {
2776fbd55d0STony Lindgren 	iotable_init(omap34xx_io_desc, ARRAY_SIZE(omap34xx_io_desc));
2786fbd55d0STony Lindgren 	_omap2_map_common_io();
2796fbd55d0STony Lindgren }
2806fbd55d0STony Lindgren #endif
2816fbd55d0STony Lindgren 
28201001712SHemant Pedanekar #ifdef CONFIG_SOC_OMAPTI816X
28301001712SHemant Pedanekar void __init omapti816x_map_common_io(void)
28401001712SHemant Pedanekar {
28501001712SHemant Pedanekar 	iotable_init(omapti816x_io_desc, ARRAY_SIZE(omapti816x_io_desc));
28601001712SHemant Pedanekar 	_omap2_map_common_io();
28701001712SHemant Pedanekar }
28801001712SHemant Pedanekar #endif
28901001712SHemant Pedanekar 
2906fbd55d0STony Lindgren #ifdef CONFIG_ARCH_OMAP4
2918185e468SAaro Koskinen void __init omap44xx_map_common_io(void)
2926fbd55d0STony Lindgren {
2936fbd55d0STony Lindgren 	iotable_init(omap44xx_io_desc, ARRAY_SIZE(omap44xx_io_desc));
2946fbd55d0STony Lindgren 	_omap2_map_common_io();
2956fbd55d0STony Lindgren }
2966fbd55d0STony Lindgren #endif
2976fbd55d0STony Lindgren 
2982f135eafSPaul Walmsley /*
2992f135eafSPaul Walmsley  * omap2_init_reprogram_sdrc - reprogram SDRC timing parameters
3002f135eafSPaul Walmsley  *
3012f135eafSPaul Walmsley  * Sets the CORE DPLL3 M2 divider to the same value that it's at
3022f135eafSPaul Walmsley  * currently.  This has the effect of setting the SDRC SDRAM AC timing
3032f135eafSPaul Walmsley  * registers to the values currently defined by the kernel.  Currently
3042f135eafSPaul Walmsley  * only defined for OMAP3; will return 0 if called on OMAP2.  Returns
3052f135eafSPaul Walmsley  * -EINVAL if the dpll3_m2_ck cannot be found, 0 if called on OMAP2,
3062f135eafSPaul Walmsley  * or passes along the return value of clk_set_rate().
3072f135eafSPaul Walmsley  */
3082f135eafSPaul Walmsley static int __init _omap2_init_reprogram_sdrc(void)
3092f135eafSPaul Walmsley {
3102f135eafSPaul Walmsley 	struct clk *dpll3_m2_ck;
3112f135eafSPaul Walmsley 	int v = -EINVAL;
3122f135eafSPaul Walmsley 	long rate;
3132f135eafSPaul Walmsley 
3142f135eafSPaul Walmsley 	if (!cpu_is_omap34xx())
3152f135eafSPaul Walmsley 		return 0;
3162f135eafSPaul Walmsley 
3172f135eafSPaul Walmsley 	dpll3_m2_ck = clk_get(NULL, "dpll3_m2_ck");
318e281f7ecSAaro Koskinen 	if (IS_ERR(dpll3_m2_ck))
3192f135eafSPaul Walmsley 		return -EINVAL;
3202f135eafSPaul Walmsley 
3212f135eafSPaul Walmsley 	rate = clk_get_rate(dpll3_m2_ck);
3222f135eafSPaul Walmsley 	pr_info("Reprogramming SDRC clock to %ld Hz\n", rate);
3232f135eafSPaul Walmsley 	v = clk_set_rate(dpll3_m2_ck, rate);
3242f135eafSPaul Walmsley 	if (v)
3252f135eafSPaul Walmsley 		pr_err("dpll3_m2_clk rate change failed: %d\n", v);
3262f135eafSPaul Walmsley 
3272f135eafSPaul Walmsley 	clk_put(dpll3_m2_ck);
3282f135eafSPaul Walmsley 
3292f135eafSPaul Walmsley 	return v;
3302f135eafSPaul Walmsley }
3312f135eafSPaul Walmsley 
3322092e5ccSPaul Walmsley static int _set_hwmod_postsetup_state(struct omap_hwmod *oh, void *data)
3332092e5ccSPaul Walmsley {
3342092e5ccSPaul Walmsley 	return omap_hwmod_set_postsetup_state(oh, *(u8 *)data);
3352092e5ccSPaul Walmsley }
3362092e5ccSPaul Walmsley 
337741e3a89STony Lindgren /* See irq.c, omap4-common.c and entry-macro.S */
3389f9605c2SRussell King void __iomem *omap_irq_base;
3399f9605c2SRussell King 
3404805734bSPaul Walmsley void __init omap2_init_common_infrastructure(void)
341120db2cbSTony Lindgren {
3422092e5ccSPaul Walmsley 	u8 postsetup_state;
3432092e5ccSPaul Walmsley 
3446e01478aSPaul Walmsley 	if (cpu_is_omap242x()) {
3458179488aSPaul Walmsley 		omap242x_powerdomains_init();
346a5ffef6aSPaul Walmsley 		omap242x_clockdomains_init();
3477359154eSPaul Walmsley 		omap2420_hwmod_init();
3486e01478aSPaul Walmsley 	} else if (cpu_is_omap243x()) {
3498179488aSPaul Walmsley 		omap243x_powerdomains_init();
350a5ffef6aSPaul Walmsley 		omap243x_clockdomains_init();
3517359154eSPaul Walmsley 		omap2430_hwmod_init();
3526e01478aSPaul Walmsley 	} else if (cpu_is_omap34xx()) {
353*81a60482SKevin Hilman 		omap3xxx_voltagedomains_init();
3546e01478aSPaul Walmsley 		omap3xxx_powerdomains_init();
3554aef7a2aSRajendra Nayak 		omap3xxx_clockdomains_init();
3567359154eSPaul Walmsley 		omap3xxx_hwmod_init();
3576e01478aSPaul Walmsley 	} else if (cpu_is_omap44xx()) {
358*81a60482SKevin Hilman 		omap44xx_voltagedomains_init();
3596e01478aSPaul Walmsley 		omap44xx_powerdomains_init();
360dc0b3a70SPaul Walmsley 		omap44xx_clockdomains_init();
36155d2cb08SBenoit Cousson 		omap44xx_hwmod_init();
3626e01478aSPaul Walmsley 	} else {
3632092e5ccSPaul Walmsley 		pr_err("Could not init hwmod data - unknown SoC\n");
3646e01478aSPaul Walmsley         }
3652092e5ccSPaul Walmsley 
3662092e5ccSPaul Walmsley 	/* Set the default postsetup state for all hwmods */
3672092e5ccSPaul Walmsley #ifdef CONFIG_PM_RUNTIME
3682092e5ccSPaul Walmsley 	postsetup_state = _HWMOD_STATE_IDLE;
3692092e5ccSPaul Walmsley #else
3702092e5ccSPaul Walmsley 	postsetup_state = _HWMOD_STATE_ENABLED;
3712092e5ccSPaul Walmsley #endif
3722092e5ccSPaul Walmsley 	omap_hwmod_for_each(_set_hwmod_postsetup_state, &postsetup_state);
37355d2cb08SBenoit Cousson 
374ff2516fbSPaul Walmsley 	/*
375ff2516fbSPaul Walmsley 	 * Set the default postsetup state for unusual modules (like
376ff2516fbSPaul Walmsley 	 * MPU WDT).
377ff2516fbSPaul Walmsley 	 *
378ff2516fbSPaul Walmsley 	 * The postsetup_state is not actually used until
379ff2516fbSPaul Walmsley 	 * omap_hwmod_late_init(), so boards that desire full watchdog
380ff2516fbSPaul Walmsley 	 * coverage of kernel initialization can reprogram the
381ff2516fbSPaul Walmsley 	 * postsetup_state between the calls to
382ff2516fbSPaul Walmsley 	 * omap2_init_common_infra() and omap2_init_common_devices().
383ff2516fbSPaul Walmsley 	 *
384ff2516fbSPaul Walmsley 	 * XXX ideally we could detect whether the MPU WDT was currently
385ff2516fbSPaul Walmsley 	 * enabled here and make this conditional
386ff2516fbSPaul Walmsley 	 */
387ff2516fbSPaul Walmsley 	postsetup_state = _HWMOD_STATE_DISABLED;
388ff2516fbSPaul Walmsley 	omap_hwmod_for_each_by_class("wd_timer",
389ff2516fbSPaul Walmsley 				     _set_hwmod_postsetup_state,
390ff2516fbSPaul Walmsley 				     &postsetup_state);
391ff2516fbSPaul Walmsley 
39253da4ce2SKevin Hilman 	omap_pm_if_early_init();
393e80a9729SPaul Walmsley 
39481b34fbeSPaul Walmsley 	if (cpu_is_omap2420())
39581b34fbeSPaul Walmsley 		omap2420_clk_init();
39681b34fbeSPaul Walmsley 	else if (cpu_is_omap2430())
39781b34fbeSPaul Walmsley 		omap2430_clk_init();
398e80a9729SPaul Walmsley 	else if (cpu_is_omap34xx())
399e80a9729SPaul Walmsley 		omap3xxx_clk_init();
400e80a9729SPaul Walmsley 	else if (cpu_is_omap44xx())
401e80a9729SPaul Walmsley 		omap4xxx_clk_init();
402e80a9729SPaul Walmsley 	else
4032092e5ccSPaul Walmsley 		pr_err("Could not init clock framework - unknown SoC\n");
4044805734bSPaul Walmsley }
4054805734bSPaul Walmsley 
4064805734bSPaul Walmsley void __init omap2_init_common_devices(struct omap_sdrc_params *sdrc_cs0,
4074805734bSPaul Walmsley 				      struct omap_sdrc_params *sdrc_cs1)
4084805734bSPaul Walmsley {
40901001712SHemant Pedanekar 	if (cpu_is_omap24xx() || omap3_has_sdrc()) {
41058cda884SJean Pihet 		omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
4112f135eafSPaul Walmsley 		_omap2_init_reprogram_sdrc();
412aa4b1f6eSKevin Hilman 	}
4135d190c40STony Lindgren 
4141dbae815STony Lindgren }
415df1e9d1cSTony Lindgren 
416df1e9d1cSTony Lindgren /*
417df1e9d1cSTony Lindgren  * NOTE: Please use ioremap + __raw_read/write where possible instead of these
418df1e9d1cSTony Lindgren  */
419df1e9d1cSTony Lindgren 
420df1e9d1cSTony Lindgren u8 omap_readb(u32 pa)
421df1e9d1cSTony Lindgren {
422df1e9d1cSTony Lindgren 	return __raw_readb(OMAP2_L4_IO_ADDRESS(pa));
423df1e9d1cSTony Lindgren }
424df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_readb);
425df1e9d1cSTony Lindgren 
426df1e9d1cSTony Lindgren u16 omap_readw(u32 pa)
427df1e9d1cSTony Lindgren {
428df1e9d1cSTony Lindgren 	return __raw_readw(OMAP2_L4_IO_ADDRESS(pa));
429df1e9d1cSTony Lindgren }
430df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_readw);
431df1e9d1cSTony Lindgren 
432df1e9d1cSTony Lindgren u32 omap_readl(u32 pa)
433df1e9d1cSTony Lindgren {
434df1e9d1cSTony Lindgren 	return __raw_readl(OMAP2_L4_IO_ADDRESS(pa));
435df1e9d1cSTony Lindgren }
436df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_readl);
437df1e9d1cSTony Lindgren 
438df1e9d1cSTony Lindgren void omap_writeb(u8 v, u32 pa)
439df1e9d1cSTony Lindgren {
440df1e9d1cSTony Lindgren 	__raw_writeb(v, OMAP2_L4_IO_ADDRESS(pa));
441df1e9d1cSTony Lindgren }
442df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_writeb);
443df1e9d1cSTony Lindgren 
444df1e9d1cSTony Lindgren void omap_writew(u16 v, u32 pa)
445df1e9d1cSTony Lindgren {
446df1e9d1cSTony Lindgren 	__raw_writew(v, OMAP2_L4_IO_ADDRESS(pa));
447df1e9d1cSTony Lindgren }
448df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_writew);
449df1e9d1cSTony Lindgren 
450df1e9d1cSTony Lindgren void omap_writel(u32 v, u32 pa)
451df1e9d1cSTony Lindgren {
452df1e9d1cSTony Lindgren 	__raw_writel(v, OMAP2_L4_IO_ADDRESS(pa));
453df1e9d1cSTony Lindgren }
454df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_writel);
455