xref: /openbmc/linux/arch/arm/mach-omap2/io.c (revision ee0839c22cdda7f2e5f06e2d0351e2b49e0975ff)
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 #include <linux/module.h>
201dbae815STony Lindgren #include <linux/kernel.h>
211dbae815STony Lindgren #include <linux/init.h>
22fced80c7SRussell King #include <linux/io.h>
232f135eafSPaul Walmsley #include <linux/clk.h>
2491773a00STomi Valkeinen #include <linux/omapfb.h>
251dbae815STony Lindgren 
26120db2cbSTony Lindgren #include <asm/tlb.h>
27120db2cbSTony Lindgren #include <asm/mach/map.h>
28120db2cbSTony Lindgren 
29ce491cf8STony Lindgren #include <plat/sram.h>
30ce491cf8STony Lindgren #include <plat/sdrc.h>
31ce491cf8STony Lindgren #include <plat/serial.h>
32*ee0839c2STony Lindgren #include <plat/omap-pm.h>
33*ee0839c2STony Lindgren #include <plat/omap_hwmod.h>
34*ee0839c2STony Lindgren #include <plat/multi.h>
35646e3ed1STony Lindgren 
36*ee0839c2STony Lindgren #include "iomap.h"
37*ee0839c2STony Lindgren #include "voltage.h"
38*ee0839c2STony Lindgren #include "powerdomain.h"
39*ee0839c2STony Lindgren #include "clockdomain.h"
40*ee0839c2STony Lindgren #include "common.h"
41e80a9729SPaul Walmsley #include "clock2xxx.h"
42657ebfadSPaul Walmsley #include "clock3xxx.h"
43e80a9729SPaul Walmsley #include "clock44xx.h"
441dbae815STony Lindgren 
451dbae815STony Lindgren /*
461dbae815STony Lindgren  * The machine specific code may provide the extra mapping besides the
471dbae815STony Lindgren  * default mapping provided here.
481dbae815STony Lindgren  */
49cc26b3b0SSyed Mohammed, Khasim 
50088ef950STony Lindgren #ifdef CONFIG_ARCH_OMAP2
51cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap24xx_io_desc[] __initdata = {
521dbae815STony Lindgren 	{
531dbae815STony Lindgren 		.virtual	= L3_24XX_VIRT,
541dbae815STony Lindgren 		.pfn		= __phys_to_pfn(L3_24XX_PHYS),
551dbae815STony Lindgren 		.length		= L3_24XX_SIZE,
561dbae815STony Lindgren 		.type		= MT_DEVICE
571dbae815STony Lindgren 	},
5809f21ed4SKyungmin Park 	{
5909f21ed4SKyungmin Park 		.virtual	= L4_24XX_VIRT,
6009f21ed4SKyungmin Park 		.pfn		= __phys_to_pfn(L4_24XX_PHYS),
6109f21ed4SKyungmin Park 		.length		= L4_24XX_SIZE,
6209f21ed4SKyungmin Park 		.type		= MT_DEVICE
6309f21ed4SKyungmin Park 	},
64cc26b3b0SSyed Mohammed, Khasim };
65cc26b3b0SSyed Mohammed, Khasim 
6659b479e0STony Lindgren #ifdef CONFIG_SOC_OMAP2420
67cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap242x_io_desc[] __initdata = {
681dbae815STony Lindgren 	{
697adb9987SPaul Walmsley 		.virtual	= DSP_MEM_2420_VIRT,
707adb9987SPaul Walmsley 		.pfn		= __phys_to_pfn(DSP_MEM_2420_PHYS),
717adb9987SPaul Walmsley 		.length		= DSP_MEM_2420_SIZE,
72c40fae95STony Lindgren 		.type		= MT_DEVICE
73c40fae95STony Lindgren 	},
74c40fae95STony Lindgren 	{
757adb9987SPaul Walmsley 		.virtual	= DSP_IPI_2420_VIRT,
767adb9987SPaul Walmsley 		.pfn		= __phys_to_pfn(DSP_IPI_2420_PHYS),
777adb9987SPaul Walmsley 		.length		= DSP_IPI_2420_SIZE,
78c40fae95STony Lindgren 		.type		= MT_DEVICE
79c40fae95STony Lindgren 	},
80c40fae95STony Lindgren 	{
817adb9987SPaul Walmsley 		.virtual	= DSP_MMU_2420_VIRT,
827adb9987SPaul Walmsley 		.pfn		= __phys_to_pfn(DSP_MMU_2420_PHYS),
837adb9987SPaul Walmsley 		.length		= DSP_MMU_2420_SIZE,
841dbae815STony Lindgren 		.type		= MT_DEVICE
85cc26b3b0SSyed Mohammed, Khasim 	},
861dbae815STony Lindgren };
871dbae815STony Lindgren 
88cc26b3b0SSyed Mohammed, Khasim #endif
89cc26b3b0SSyed Mohammed, Khasim 
9059b479e0STony Lindgren #ifdef CONFIG_SOC_OMAP2430
91cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap243x_io_desc[] __initdata = {
92cc26b3b0SSyed Mohammed, Khasim 	{
93cc26b3b0SSyed Mohammed, Khasim 		.virtual	= L4_WK_243X_VIRT,
94cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(L4_WK_243X_PHYS),
95cc26b3b0SSyed Mohammed, Khasim 		.length		= L4_WK_243X_SIZE,
96cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
97cc26b3b0SSyed Mohammed, Khasim 	},
98cc26b3b0SSyed Mohammed, Khasim 	{
99cc26b3b0SSyed Mohammed, Khasim 		.virtual	= OMAP243X_GPMC_VIRT,
100cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(OMAP243X_GPMC_PHYS),
101cc26b3b0SSyed Mohammed, Khasim 		.length		= OMAP243X_GPMC_SIZE,
102cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
103cc26b3b0SSyed Mohammed, Khasim 	},
104cc26b3b0SSyed Mohammed, Khasim 	{
105cc26b3b0SSyed Mohammed, Khasim 		.virtual	= OMAP243X_SDRC_VIRT,
106cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(OMAP243X_SDRC_PHYS),
107cc26b3b0SSyed Mohammed, Khasim 		.length		= OMAP243X_SDRC_SIZE,
108cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
109cc26b3b0SSyed Mohammed, Khasim 	},
110cc26b3b0SSyed Mohammed, Khasim 	{
111cc26b3b0SSyed Mohammed, Khasim 		.virtual	= OMAP243X_SMS_VIRT,
112cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(OMAP243X_SMS_PHYS),
113cc26b3b0SSyed Mohammed, Khasim 		.length		= OMAP243X_SMS_SIZE,
114cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
115cc26b3b0SSyed Mohammed, Khasim 	},
116cc26b3b0SSyed Mohammed, Khasim };
117cc26b3b0SSyed Mohammed, Khasim #endif
118cc26b3b0SSyed Mohammed, Khasim #endif
119cc26b3b0SSyed Mohammed, Khasim 
120a8eb7ca0STony Lindgren #ifdef	CONFIG_ARCH_OMAP3
121cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap34xx_io_desc[] __initdata = {
122cc26b3b0SSyed Mohammed, Khasim 	{
123cc26b3b0SSyed Mohammed, Khasim 		.virtual	= L3_34XX_VIRT,
124cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(L3_34XX_PHYS),
125cc26b3b0SSyed Mohammed, Khasim 		.length		= L3_34XX_SIZE,
126cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
127cc26b3b0SSyed Mohammed, Khasim 	},
128cc26b3b0SSyed Mohammed, Khasim 	{
129cc26b3b0SSyed Mohammed, Khasim 		.virtual	= L4_34XX_VIRT,
130cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
131cc26b3b0SSyed Mohammed, Khasim 		.length		= L4_34XX_SIZE,
132cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
133cc26b3b0SSyed Mohammed, Khasim 	},
134cc26b3b0SSyed Mohammed, Khasim 	{
135cc26b3b0SSyed Mohammed, Khasim 		.virtual	= OMAP34XX_GPMC_VIRT,
136cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(OMAP34XX_GPMC_PHYS),
137cc26b3b0SSyed Mohammed, Khasim 		.length		= OMAP34XX_GPMC_SIZE,
138cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
139cc26b3b0SSyed Mohammed, Khasim 	},
140cc26b3b0SSyed Mohammed, Khasim 	{
141cc26b3b0SSyed Mohammed, Khasim 		.virtual	= OMAP343X_SMS_VIRT,
142cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(OMAP343X_SMS_PHYS),
143cc26b3b0SSyed Mohammed, Khasim 		.length		= OMAP343X_SMS_SIZE,
144cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
145cc26b3b0SSyed Mohammed, Khasim 	},
146cc26b3b0SSyed Mohammed, Khasim 	{
147cc26b3b0SSyed Mohammed, Khasim 		.virtual	= OMAP343X_SDRC_VIRT,
148cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(OMAP343X_SDRC_PHYS),
149cc26b3b0SSyed Mohammed, Khasim 		.length		= OMAP343X_SDRC_SIZE,
150cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
151cc26b3b0SSyed Mohammed, Khasim 	},
152cc26b3b0SSyed Mohammed, Khasim 	{
153cc26b3b0SSyed Mohammed, Khasim 		.virtual	= L4_PER_34XX_VIRT,
154cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(L4_PER_34XX_PHYS),
155cc26b3b0SSyed Mohammed, Khasim 		.length		= L4_PER_34XX_SIZE,
156cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
157cc26b3b0SSyed Mohammed, Khasim 	},
158cc26b3b0SSyed Mohammed, Khasim 	{
159cc26b3b0SSyed Mohammed, Khasim 		.virtual	= L4_EMU_34XX_VIRT,
160cc26b3b0SSyed Mohammed, Khasim 		.pfn		= __phys_to_pfn(L4_EMU_34XX_PHYS),
161cc26b3b0SSyed Mohammed, Khasim 		.length		= L4_EMU_34XX_SIZE,
162cc26b3b0SSyed Mohammed, Khasim 		.type		= MT_DEVICE
163cc26b3b0SSyed Mohammed, Khasim 	},
164a4f57b81STony Lindgren #if defined(CONFIG_DEBUG_LL) &&							\
165a4f57b81STony Lindgren 	(defined(CONFIG_MACH_OMAP_ZOOM2) || defined(CONFIG_MACH_OMAP_ZOOM3))
166a4f57b81STony Lindgren 	{
167a4f57b81STony Lindgren 		.virtual	= ZOOM_UART_VIRT,
168a4f57b81STony Lindgren 		.pfn		= __phys_to_pfn(ZOOM_UART_BASE),
169a4f57b81STony Lindgren 		.length		= SZ_1M,
170a4f57b81STony Lindgren 		.type		= MT_DEVICE
171a4f57b81STony Lindgren 	},
172a4f57b81STony Lindgren #endif
173cc26b3b0SSyed Mohammed, Khasim };
174cc26b3b0SSyed Mohammed, Khasim #endif
17501001712SHemant Pedanekar 
176a920360fSHemant Pedanekar #ifdef CONFIG_SOC_OMAPTI81XX
177a920360fSHemant Pedanekar static struct map_desc omapti81xx_io_desc[] __initdata = {
17801001712SHemant Pedanekar 	{
17901001712SHemant Pedanekar 		.virtual	= L4_34XX_VIRT,
18001001712SHemant Pedanekar 		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
18101001712SHemant Pedanekar 		.length		= L4_34XX_SIZE,
18201001712SHemant Pedanekar 		.type		= MT_DEVICE
1831e6cb146SAfzal Mohammed 	}
1841e6cb146SAfzal Mohammed };
1851e6cb146SAfzal Mohammed #endif
1861e6cb146SAfzal Mohammed 
1871e6cb146SAfzal Mohammed #ifdef CONFIG_SOC_OMAPAM33XX
1881e6cb146SAfzal Mohammed static struct map_desc omapam33xx_io_desc[] __initdata = {
18901001712SHemant Pedanekar 	{
19001001712SHemant Pedanekar 		.virtual	= L4_34XX_VIRT,
19101001712SHemant Pedanekar 		.pfn		= __phys_to_pfn(L4_34XX_PHYS),
19201001712SHemant Pedanekar 		.length		= L4_34XX_SIZE,
19301001712SHemant Pedanekar 		.type		= MT_DEVICE
19401001712SHemant Pedanekar 	},
1951e6cb146SAfzal Mohammed 	{
1961e6cb146SAfzal Mohammed 		.virtual	= L4_WK_AM33XX_VIRT,
1971e6cb146SAfzal Mohammed 		.pfn		= __phys_to_pfn(L4_WK_AM33XX_PHYS),
1981e6cb146SAfzal Mohammed 		.length		= L4_WK_AM33XX_SIZE,
1991e6cb146SAfzal Mohammed 		.type		= MT_DEVICE
2001e6cb146SAfzal Mohammed 	}
20101001712SHemant Pedanekar };
20201001712SHemant Pedanekar #endif
20301001712SHemant Pedanekar 
20444169075SSantosh Shilimkar #ifdef	CONFIG_ARCH_OMAP4
20544169075SSantosh Shilimkar static struct map_desc omap44xx_io_desc[] __initdata = {
20644169075SSantosh Shilimkar 	{
20744169075SSantosh Shilimkar 		.virtual	= L3_44XX_VIRT,
20844169075SSantosh Shilimkar 		.pfn		= __phys_to_pfn(L3_44XX_PHYS),
20944169075SSantosh Shilimkar 		.length		= L3_44XX_SIZE,
21044169075SSantosh Shilimkar 		.type		= MT_DEVICE,
21144169075SSantosh Shilimkar 	},
21244169075SSantosh Shilimkar 	{
21344169075SSantosh Shilimkar 		.virtual	= L4_44XX_VIRT,
21444169075SSantosh Shilimkar 		.pfn		= __phys_to_pfn(L4_44XX_PHYS),
21544169075SSantosh Shilimkar 		.length		= L4_44XX_SIZE,
21644169075SSantosh Shilimkar 		.type		= MT_DEVICE,
21744169075SSantosh Shilimkar 	},
21844169075SSantosh Shilimkar 	{
21944169075SSantosh Shilimkar 		.virtual	= OMAP44XX_GPMC_VIRT,
22044169075SSantosh Shilimkar 		.pfn		= __phys_to_pfn(OMAP44XX_GPMC_PHYS),
22144169075SSantosh Shilimkar 		.length		= OMAP44XX_GPMC_SIZE,
22244169075SSantosh Shilimkar 		.type		= MT_DEVICE,
22344169075SSantosh Shilimkar 	},
22444169075SSantosh Shilimkar 	{
225f5d2d659SSantosh Shilimkar 		.virtual	= OMAP44XX_EMIF1_VIRT,
226f5d2d659SSantosh Shilimkar 		.pfn		= __phys_to_pfn(OMAP44XX_EMIF1_PHYS),
227f5d2d659SSantosh Shilimkar 		.length		= OMAP44XX_EMIF1_SIZE,
228f5d2d659SSantosh Shilimkar 		.type		= MT_DEVICE,
229f5d2d659SSantosh Shilimkar 	},
230f5d2d659SSantosh Shilimkar 	{
231f5d2d659SSantosh Shilimkar 		.virtual	= OMAP44XX_EMIF2_VIRT,
232f5d2d659SSantosh Shilimkar 		.pfn		= __phys_to_pfn(OMAP44XX_EMIF2_PHYS),
233f5d2d659SSantosh Shilimkar 		.length		= OMAP44XX_EMIF2_SIZE,
234f5d2d659SSantosh Shilimkar 		.type		= MT_DEVICE,
235f5d2d659SSantosh Shilimkar 	},
236f5d2d659SSantosh Shilimkar 	{
237f5d2d659SSantosh Shilimkar 		.virtual	= OMAP44XX_DMM_VIRT,
238f5d2d659SSantosh Shilimkar 		.pfn		= __phys_to_pfn(OMAP44XX_DMM_PHYS),
239f5d2d659SSantosh Shilimkar 		.length		= OMAP44XX_DMM_SIZE,
240f5d2d659SSantosh Shilimkar 		.type		= MT_DEVICE,
241f5d2d659SSantosh Shilimkar 	},
242f5d2d659SSantosh Shilimkar 	{
24344169075SSantosh Shilimkar 		.virtual	= L4_PER_44XX_VIRT,
24444169075SSantosh Shilimkar 		.pfn		= __phys_to_pfn(L4_PER_44XX_PHYS),
24544169075SSantosh Shilimkar 		.length		= L4_PER_44XX_SIZE,
24644169075SSantosh Shilimkar 		.type		= MT_DEVICE,
24744169075SSantosh Shilimkar 	},
24844169075SSantosh Shilimkar 	{
24944169075SSantosh Shilimkar 		.virtual	= L4_EMU_44XX_VIRT,
25044169075SSantosh Shilimkar 		.pfn		= __phys_to_pfn(L4_EMU_44XX_PHYS),
25144169075SSantosh Shilimkar 		.length		= L4_EMU_44XX_SIZE,
25244169075SSantosh Shilimkar 		.type		= MT_DEVICE,
25344169075SSantosh Shilimkar 	},
254137d105dSSantosh Shilimkar #ifdef CONFIG_OMAP4_ERRATA_I688
255137d105dSSantosh Shilimkar 	{
256137d105dSSantosh Shilimkar 		.virtual	= OMAP4_SRAM_VA,
257137d105dSSantosh Shilimkar 		.pfn		= __phys_to_pfn(OMAP4_SRAM_PA),
258137d105dSSantosh Shilimkar 		.length		= PAGE_SIZE,
259137d105dSSantosh Shilimkar 		.type		= MT_MEMORY_SO,
260137d105dSSantosh Shilimkar 	},
261137d105dSSantosh Shilimkar #endif
262137d105dSSantosh Shilimkar 
26344169075SSantosh Shilimkar };
26444169075SSantosh Shilimkar #endif
265cc26b3b0SSyed Mohammed, Khasim 
26659b479e0STony Lindgren #ifdef CONFIG_SOC_OMAP2420
2678185e468SAaro Koskinen void __init omap242x_map_common_io(void)
2686fbd55d0STony Lindgren {
2696fbd55d0STony Lindgren 	iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
2706fbd55d0STony Lindgren 	iotable_init(omap242x_io_desc, ARRAY_SIZE(omap242x_io_desc));
2716fbd55d0STony Lindgren }
2726fbd55d0STony Lindgren #endif
2736fbd55d0STony Lindgren 
27459b479e0STony Lindgren #ifdef CONFIG_SOC_OMAP2430
2758185e468SAaro Koskinen void __init omap243x_map_common_io(void)
2766fbd55d0STony Lindgren {
2776fbd55d0STony Lindgren 	iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
2786fbd55d0STony Lindgren 	iotable_init(omap243x_io_desc, ARRAY_SIZE(omap243x_io_desc));
2796fbd55d0STony Lindgren }
2806fbd55d0STony Lindgren #endif
2816fbd55d0STony Lindgren 
282a8eb7ca0STony Lindgren #ifdef CONFIG_ARCH_OMAP3
2838185e468SAaro Koskinen void __init omap34xx_map_common_io(void)
2846fbd55d0STony Lindgren {
2856fbd55d0STony Lindgren 	iotable_init(omap34xx_io_desc, ARRAY_SIZE(omap34xx_io_desc));
2866fbd55d0STony Lindgren }
2876fbd55d0STony Lindgren #endif
2886fbd55d0STony Lindgren 
289a920360fSHemant Pedanekar #ifdef CONFIG_SOC_OMAPTI81XX
290a920360fSHemant Pedanekar void __init omapti81xx_map_common_io(void)
29101001712SHemant Pedanekar {
292a920360fSHemant Pedanekar 	iotable_init(omapti81xx_io_desc, ARRAY_SIZE(omapti81xx_io_desc));
29301001712SHemant Pedanekar }
29401001712SHemant Pedanekar #endif
29501001712SHemant Pedanekar 
2961e6cb146SAfzal Mohammed #ifdef CONFIG_SOC_OMAPAM33XX
2971e6cb146SAfzal Mohammed void __init omapam33xx_map_common_io(void)
2981e6cb146SAfzal Mohammed {
2991e6cb146SAfzal Mohammed 	iotable_init(omapam33xx_io_desc, ARRAY_SIZE(omapam33xx_io_desc));
3006fbd55d0STony Lindgren }
3016fbd55d0STony Lindgren #endif
3026fbd55d0STony Lindgren 
3036fbd55d0STony Lindgren #ifdef CONFIG_ARCH_OMAP4
3048185e468SAaro Koskinen void __init omap44xx_map_common_io(void)
3056fbd55d0STony Lindgren {
3066fbd55d0STony Lindgren 	iotable_init(omap44xx_io_desc, ARRAY_SIZE(omap44xx_io_desc));
3076fbd55d0STony Lindgren }
3086fbd55d0STony Lindgren #endif
3096fbd55d0STony Lindgren 
3102f135eafSPaul Walmsley /*
3112f135eafSPaul Walmsley  * omap2_init_reprogram_sdrc - reprogram SDRC timing parameters
3122f135eafSPaul Walmsley  *
3132f135eafSPaul Walmsley  * Sets the CORE DPLL3 M2 divider to the same value that it's at
3142f135eafSPaul Walmsley  * currently.  This has the effect of setting the SDRC SDRAM AC timing
3152f135eafSPaul Walmsley  * registers to the values currently defined by the kernel.  Currently
3162f135eafSPaul Walmsley  * only defined for OMAP3; will return 0 if called on OMAP2.  Returns
3172f135eafSPaul Walmsley  * -EINVAL if the dpll3_m2_ck cannot be found, 0 if called on OMAP2,
3182f135eafSPaul Walmsley  * or passes along the return value of clk_set_rate().
3192f135eafSPaul Walmsley  */
3202f135eafSPaul Walmsley static int __init _omap2_init_reprogram_sdrc(void)
3212f135eafSPaul Walmsley {
3222f135eafSPaul Walmsley 	struct clk *dpll3_m2_ck;
3232f135eafSPaul Walmsley 	int v = -EINVAL;
3242f135eafSPaul Walmsley 	long rate;
3252f135eafSPaul Walmsley 
3262f135eafSPaul Walmsley 	if (!cpu_is_omap34xx())
3272f135eafSPaul Walmsley 		return 0;
3282f135eafSPaul Walmsley 
3292f135eafSPaul Walmsley 	dpll3_m2_ck = clk_get(NULL, "dpll3_m2_ck");
330e281f7ecSAaro Koskinen 	if (IS_ERR(dpll3_m2_ck))
3312f135eafSPaul Walmsley 		return -EINVAL;
3322f135eafSPaul Walmsley 
3332f135eafSPaul Walmsley 	rate = clk_get_rate(dpll3_m2_ck);
3342f135eafSPaul Walmsley 	pr_info("Reprogramming SDRC clock to %ld Hz\n", rate);
3352f135eafSPaul Walmsley 	v = clk_set_rate(dpll3_m2_ck, rate);
3362f135eafSPaul Walmsley 	if (v)
3372f135eafSPaul Walmsley 		pr_err("dpll3_m2_clk rate change failed: %d\n", v);
3382f135eafSPaul Walmsley 
3392f135eafSPaul Walmsley 	clk_put(dpll3_m2_ck);
3402f135eafSPaul Walmsley 
3412f135eafSPaul Walmsley 	return v;
3422f135eafSPaul Walmsley }
3432f135eafSPaul Walmsley 
3442092e5ccSPaul Walmsley static int _set_hwmod_postsetup_state(struct omap_hwmod *oh, void *data)
3452092e5ccSPaul Walmsley {
3462092e5ccSPaul Walmsley 	return omap_hwmod_set_postsetup_state(oh, *(u8 *)data);
3472092e5ccSPaul Walmsley }
3482092e5ccSPaul Walmsley 
3497b250affSTony Lindgren static void __init omap_common_init_early(void)
3507b250affSTony Lindgren {
3517b250affSTony Lindgren 	omap2_check_revision();
352df80442dSArnd Bergmann 	omap_init_consistent_dma_size();
3537b250affSTony Lindgren }
3547b250affSTony Lindgren 
3557b250affSTony Lindgren static void __init omap_hwmod_init_postsetup(void)
356120db2cbSTony Lindgren {
3572092e5ccSPaul Walmsley 	u8 postsetup_state;
3582092e5ccSPaul Walmsley 
3592092e5ccSPaul Walmsley 	/* Set the default postsetup state for all hwmods */
3602092e5ccSPaul Walmsley #ifdef CONFIG_PM_RUNTIME
3612092e5ccSPaul Walmsley 	postsetup_state = _HWMOD_STATE_IDLE;
3622092e5ccSPaul Walmsley #else
3632092e5ccSPaul Walmsley 	postsetup_state = _HWMOD_STATE_ENABLED;
3642092e5ccSPaul Walmsley #endif
3652092e5ccSPaul Walmsley 	omap_hwmod_for_each(_set_hwmod_postsetup_state, &postsetup_state);
36655d2cb08SBenoit Cousson 
367ff2516fbSPaul Walmsley 	/*
368ff2516fbSPaul Walmsley 	 * Set the default postsetup state for unusual modules (like
369ff2516fbSPaul Walmsley 	 * MPU WDT).
370ff2516fbSPaul Walmsley 	 *
371ff2516fbSPaul Walmsley 	 * The postsetup_state is not actually used until
372ff2516fbSPaul Walmsley 	 * omap_hwmod_late_init(), so boards that desire full watchdog
373ff2516fbSPaul Walmsley 	 * coverage of kernel initialization can reprogram the
374ff2516fbSPaul Walmsley 	 * postsetup_state between the calls to
375a4ca9dbeSTony Lindgren 	 * omap2_init_common_infra() and omap_sdrc_init().
376ff2516fbSPaul Walmsley 	 *
377ff2516fbSPaul Walmsley 	 * XXX ideally we could detect whether the MPU WDT was currently
378ff2516fbSPaul Walmsley 	 * enabled here and make this conditional
379ff2516fbSPaul Walmsley 	 */
380ff2516fbSPaul Walmsley 	postsetup_state = _HWMOD_STATE_DISABLED;
381ff2516fbSPaul Walmsley 	omap_hwmod_for_each_by_class("wd_timer",
382ff2516fbSPaul Walmsley 				     _set_hwmod_postsetup_state,
383ff2516fbSPaul Walmsley 				     &postsetup_state);
384ff2516fbSPaul Walmsley 
38553da4ce2SKevin Hilman 	omap_pm_if_early_init();
3864805734bSPaul Walmsley }
3874805734bSPaul Walmsley 
38816110798SPaul Walmsley #ifdef CONFIG_SOC_OMAP2420
3898f5b5a41STony Lindgren void __init omap2420_init_early(void)
3908f5b5a41STony Lindgren {
3914c3cf901STony Lindgren 	omap2_set_globals_242x();
3927b250affSTony Lindgren 	omap_common_init_early();
3937b250affSTony Lindgren 	omap2xxx_voltagedomains_init();
3947b250affSTony Lindgren 	omap242x_powerdomains_init();
3957b250affSTony Lindgren 	omap242x_clockdomains_init();
3967b250affSTony Lindgren 	omap2420_hwmod_init();
3977b250affSTony Lindgren 	omap_hwmod_init_postsetup();
3987b250affSTony Lindgren 	omap2420_clk_init();
3998f5b5a41STony Lindgren }
40016110798SPaul Walmsley #endif
4018f5b5a41STony Lindgren 
40216110798SPaul Walmsley #ifdef CONFIG_SOC_OMAP2430
4038f5b5a41STony Lindgren void __init omap2430_init_early(void)
4048f5b5a41STony Lindgren {
4054c3cf901STony Lindgren 	omap2_set_globals_243x();
4067b250affSTony Lindgren 	omap_common_init_early();
4077b250affSTony Lindgren 	omap2xxx_voltagedomains_init();
4087b250affSTony Lindgren 	omap243x_powerdomains_init();
4097b250affSTony Lindgren 	omap243x_clockdomains_init();
4107b250affSTony Lindgren 	omap2430_hwmod_init();
4117b250affSTony Lindgren 	omap_hwmod_init_postsetup();
4127b250affSTony Lindgren 	omap2430_clk_init();
4137b250affSTony Lindgren }
414c4e2d245SSanjeev Premi #endif
4157b250affSTony Lindgren 
4167b250affSTony Lindgren /*
4177b250affSTony Lindgren  * Currently only board-omap3beagle.c should call this because of the
4187b250affSTony Lindgren  * same machine_id for 34xx and 36xx beagle.. Will get fixed with DT.
4197b250affSTony Lindgren  */
420c4e2d245SSanjeev Premi #ifdef CONFIG_ARCH_OMAP3
4217b250affSTony Lindgren void __init omap3_init_early(void)
4227b250affSTony Lindgren {
4234c3cf901STony Lindgren 	omap2_set_globals_3xxx();
4247b250affSTony Lindgren 	omap_common_init_early();
4257b250affSTony Lindgren 	omap3xxx_voltagedomains_init();
4267b250affSTony Lindgren 	omap3xxx_powerdomains_init();
4277b250affSTony Lindgren 	omap3xxx_clockdomains_init();
4287b250affSTony Lindgren 	omap3xxx_hwmod_init();
4297b250affSTony Lindgren 	omap_hwmod_init_postsetup();
4307b250affSTony Lindgren 	omap3xxx_clk_init();
4318f5b5a41STony Lindgren }
4328f5b5a41STony Lindgren 
4338f5b5a41STony Lindgren void __init omap3430_init_early(void)
4348f5b5a41STony Lindgren {
4357b250affSTony Lindgren 	omap3_init_early();
4368f5b5a41STony Lindgren }
4378f5b5a41STony Lindgren 
4388f5b5a41STony Lindgren void __init omap35xx_init_early(void)
4398f5b5a41STony Lindgren {
4407b250affSTony Lindgren 	omap3_init_early();
4418f5b5a41STony Lindgren }
4428f5b5a41STony Lindgren 
4438f5b5a41STony Lindgren void __init omap3630_init_early(void)
4448f5b5a41STony Lindgren {
4457b250affSTony Lindgren 	omap3_init_early();
4468f5b5a41STony Lindgren }
4478f5b5a41STony Lindgren 
4488f5b5a41STony Lindgren void __init am35xx_init_early(void)
4498f5b5a41STony Lindgren {
4507b250affSTony Lindgren 	omap3_init_early();
4518f5b5a41STony Lindgren }
4528f5b5a41STony Lindgren 
453a920360fSHemant Pedanekar void __init ti81xx_init_early(void)
4548f5b5a41STony Lindgren {
455a920360fSHemant Pedanekar 	omap2_set_globals_ti81xx();
4564c3cf901STony Lindgren 	omap_common_init_early();
4574c3cf901STony Lindgren 	omap3xxx_voltagedomains_init();
4584c3cf901STony Lindgren 	omap3xxx_powerdomains_init();
4594c3cf901STony Lindgren 	omap3xxx_clockdomains_init();
4604c3cf901STony Lindgren 	omap3xxx_hwmod_init();
4614c3cf901STony Lindgren 	omap_hwmod_init_postsetup();
4624c3cf901STony Lindgren 	omap3xxx_clk_init();
4638f5b5a41STony Lindgren }
464c4e2d245SSanjeev Premi #endif
4658f5b5a41STony Lindgren 
466c4e2d245SSanjeev Premi #ifdef CONFIG_ARCH_OMAP4
4678f5b5a41STony Lindgren void __init omap4430_init_early(void)
4688f5b5a41STony Lindgren {
4694c3cf901STony Lindgren 	omap2_set_globals_443x();
4707b250affSTony Lindgren 	omap_common_init_early();
4717b250affSTony Lindgren 	omap44xx_voltagedomains_init();
4727b250affSTony Lindgren 	omap44xx_powerdomains_init();
4737b250affSTony Lindgren 	omap44xx_clockdomains_init();
4747b250affSTony Lindgren 	omap44xx_hwmod_init();
4757b250affSTony Lindgren 	omap_hwmod_init_postsetup();
4767b250affSTony Lindgren 	omap4xxx_clk_init();
4778f5b5a41STony Lindgren }
478c4e2d245SSanjeev Premi #endif
4798f5b5a41STony Lindgren 
480a4ca9dbeSTony Lindgren void __init omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
4814805734bSPaul Walmsley 				      struct omap_sdrc_params *sdrc_cs1)
4824805734bSPaul Walmsley {
483a66cb345STony Lindgren 	omap_sram_init();
484a66cb345STony Lindgren 
48501001712SHemant Pedanekar 	if (cpu_is_omap24xx() || omap3_has_sdrc()) {
48658cda884SJean Pihet 		omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
4872f135eafSPaul Walmsley 		_omap2_init_reprogram_sdrc();
488aa4b1f6eSKevin Hilman 	}
4891dbae815STony Lindgren }
490df1e9d1cSTony Lindgren 
491df1e9d1cSTony Lindgren /*
492df1e9d1cSTony Lindgren  * NOTE: Please use ioremap + __raw_read/write where possible instead of these
493df1e9d1cSTony Lindgren  */
494df1e9d1cSTony Lindgren 
495df1e9d1cSTony Lindgren u8 omap_readb(u32 pa)
496df1e9d1cSTony Lindgren {
497df1e9d1cSTony Lindgren 	return __raw_readb(OMAP2_L4_IO_ADDRESS(pa));
498df1e9d1cSTony Lindgren }
499df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_readb);
500df1e9d1cSTony Lindgren 
501df1e9d1cSTony Lindgren u16 omap_readw(u32 pa)
502df1e9d1cSTony Lindgren {
503df1e9d1cSTony Lindgren 	return __raw_readw(OMAP2_L4_IO_ADDRESS(pa));
504df1e9d1cSTony Lindgren }
505df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_readw);
506df1e9d1cSTony Lindgren 
507df1e9d1cSTony Lindgren u32 omap_readl(u32 pa)
508df1e9d1cSTony Lindgren {
509df1e9d1cSTony Lindgren 	return __raw_readl(OMAP2_L4_IO_ADDRESS(pa));
510df1e9d1cSTony Lindgren }
511df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_readl);
512df1e9d1cSTony Lindgren 
513df1e9d1cSTony Lindgren void omap_writeb(u8 v, u32 pa)
514df1e9d1cSTony Lindgren {
515df1e9d1cSTony Lindgren 	__raw_writeb(v, OMAP2_L4_IO_ADDRESS(pa));
516df1e9d1cSTony Lindgren }
517df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_writeb);
518df1e9d1cSTony Lindgren 
519df1e9d1cSTony Lindgren void omap_writew(u16 v, u32 pa)
520df1e9d1cSTony Lindgren {
521df1e9d1cSTony Lindgren 	__raw_writew(v, OMAP2_L4_IO_ADDRESS(pa));
522df1e9d1cSTony Lindgren }
523df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_writew);
524df1e9d1cSTony Lindgren 
525df1e9d1cSTony Lindgren void omap_writel(u32 v, u32 pa)
526df1e9d1cSTony Lindgren {
527df1e9d1cSTony Lindgren 	__raw_writel(v, OMAP2_L4_IO_ADDRESS(pa));
528df1e9d1cSTony Lindgren }
529df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_writel);
530