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 28120db2cbSTony Lindgren #include <asm/mach/map.h> 29120db2cbSTony Lindgren 30ce491cf8STony Lindgren #include <plat/sram.h> 31ce491cf8STony Lindgren #include <plat/sdrc.h> 32ce491cf8STony Lindgren #include <plat/serial.h> 33646e3ed1STony Lindgren 34e80a9729SPaul Walmsley #include "clock2xxx.h" 35657ebfadSPaul Walmsley #include "clock3xxx.h" 36e80a9729SPaul Walmsley #include "clock44xx.h" 371dbae815STony Lindgren 384e65331cSTony Lindgren #include "common.h" 39ce491cf8STony Lindgren #include <plat/omap-pm.h> 4081a60482SKevin Hilman #include "voltage.h" 4172e06d08SPaul Walmsley #include "powerdomain.h" 429717100fSPaul Walmsley 431540f214SPaul Walmsley #include "clockdomain.h" 44ce491cf8STony Lindgren #include <plat/omap_hwmod.h> 455d190c40STony Lindgren #include <plat/multi.h> 464e65331cSTony Lindgren #include "common.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 179*a920360fSHemant Pedanekar #ifdef CONFIG_SOC_OMAPTI81XX 180*a920360fSHemant Pedanekar static struct map_desc omapti81xx_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 1861e6cb146SAfzal Mohammed } 1871e6cb146SAfzal Mohammed }; 1881e6cb146SAfzal Mohammed #endif 1891e6cb146SAfzal Mohammed 1901e6cb146SAfzal Mohammed #ifdef CONFIG_SOC_OMAPAM33XX 1911e6cb146SAfzal Mohammed static struct map_desc omapam33xx_io_desc[] __initdata = { 1921e6cb146SAfzal Mohammed { 1931e6cb146SAfzal Mohammed .virtual = L4_34XX_VIRT, 1941e6cb146SAfzal Mohammed .pfn = __phys_to_pfn(L4_34XX_PHYS), 1951e6cb146SAfzal Mohammed .length = L4_34XX_SIZE, 1961e6cb146SAfzal Mohammed .type = MT_DEVICE 19701001712SHemant Pedanekar }, 1981e6cb146SAfzal Mohammed { 1991e6cb146SAfzal Mohammed .virtual = L4_WK_AM33XX_VIRT, 2001e6cb146SAfzal Mohammed .pfn = __phys_to_pfn(L4_WK_AM33XX_PHYS), 2011e6cb146SAfzal Mohammed .length = L4_WK_AM33XX_SIZE, 2021e6cb146SAfzal Mohammed .type = MT_DEVICE 2031e6cb146SAfzal Mohammed } 20401001712SHemant Pedanekar }; 20501001712SHemant Pedanekar #endif 20601001712SHemant Pedanekar 20744169075SSantosh Shilimkar #ifdef CONFIG_ARCH_OMAP4 20844169075SSantosh Shilimkar static struct map_desc omap44xx_io_desc[] __initdata = { 20944169075SSantosh Shilimkar { 21044169075SSantosh Shilimkar .virtual = L3_44XX_VIRT, 21144169075SSantosh Shilimkar .pfn = __phys_to_pfn(L3_44XX_PHYS), 21244169075SSantosh Shilimkar .length = L3_44XX_SIZE, 21344169075SSantosh Shilimkar .type = MT_DEVICE, 21444169075SSantosh Shilimkar }, 21544169075SSantosh Shilimkar { 21644169075SSantosh Shilimkar .virtual = L4_44XX_VIRT, 21744169075SSantosh Shilimkar .pfn = __phys_to_pfn(L4_44XX_PHYS), 21844169075SSantosh Shilimkar .length = L4_44XX_SIZE, 21944169075SSantosh Shilimkar .type = MT_DEVICE, 22044169075SSantosh Shilimkar }, 22144169075SSantosh Shilimkar { 22244169075SSantosh Shilimkar .virtual = OMAP44XX_GPMC_VIRT, 22344169075SSantosh Shilimkar .pfn = __phys_to_pfn(OMAP44XX_GPMC_PHYS), 22444169075SSantosh Shilimkar .length = OMAP44XX_GPMC_SIZE, 22544169075SSantosh Shilimkar .type = MT_DEVICE, 22644169075SSantosh Shilimkar }, 22744169075SSantosh Shilimkar { 228f5d2d659SSantosh Shilimkar .virtual = OMAP44XX_EMIF1_VIRT, 229f5d2d659SSantosh Shilimkar .pfn = __phys_to_pfn(OMAP44XX_EMIF1_PHYS), 230f5d2d659SSantosh Shilimkar .length = OMAP44XX_EMIF1_SIZE, 231f5d2d659SSantosh Shilimkar .type = MT_DEVICE, 232f5d2d659SSantosh Shilimkar }, 233f5d2d659SSantosh Shilimkar { 234f5d2d659SSantosh Shilimkar .virtual = OMAP44XX_EMIF2_VIRT, 235f5d2d659SSantosh Shilimkar .pfn = __phys_to_pfn(OMAP44XX_EMIF2_PHYS), 236f5d2d659SSantosh Shilimkar .length = OMAP44XX_EMIF2_SIZE, 237f5d2d659SSantosh Shilimkar .type = MT_DEVICE, 238f5d2d659SSantosh Shilimkar }, 239f5d2d659SSantosh Shilimkar { 240f5d2d659SSantosh Shilimkar .virtual = OMAP44XX_DMM_VIRT, 241f5d2d659SSantosh Shilimkar .pfn = __phys_to_pfn(OMAP44XX_DMM_PHYS), 242f5d2d659SSantosh Shilimkar .length = OMAP44XX_DMM_SIZE, 243f5d2d659SSantosh Shilimkar .type = MT_DEVICE, 244f5d2d659SSantosh Shilimkar }, 245f5d2d659SSantosh Shilimkar { 24644169075SSantosh Shilimkar .virtual = L4_PER_44XX_VIRT, 24744169075SSantosh Shilimkar .pfn = __phys_to_pfn(L4_PER_44XX_PHYS), 24844169075SSantosh Shilimkar .length = L4_PER_44XX_SIZE, 24944169075SSantosh Shilimkar .type = MT_DEVICE, 25044169075SSantosh Shilimkar }, 25144169075SSantosh Shilimkar { 25244169075SSantosh Shilimkar .virtual = L4_EMU_44XX_VIRT, 25344169075SSantosh Shilimkar .pfn = __phys_to_pfn(L4_EMU_44XX_PHYS), 25444169075SSantosh Shilimkar .length = L4_EMU_44XX_SIZE, 25544169075SSantosh Shilimkar .type = MT_DEVICE, 25644169075SSantosh Shilimkar }, 25744169075SSantosh Shilimkar }; 25844169075SSantosh Shilimkar #endif 259cc26b3b0SSyed Mohammed, Khasim 26059b479e0STony Lindgren #ifdef CONFIG_SOC_OMAP2420 2618185e468SAaro Koskinen void __init omap242x_map_common_io(void) 2626fbd55d0STony Lindgren { 2636fbd55d0STony Lindgren iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc)); 2646fbd55d0STony Lindgren iotable_init(omap242x_io_desc, ARRAY_SIZE(omap242x_io_desc)); 2656fbd55d0STony Lindgren } 2666fbd55d0STony Lindgren #endif 2676fbd55d0STony Lindgren 26859b479e0STony Lindgren #ifdef CONFIG_SOC_OMAP2430 2698185e468SAaro Koskinen void __init omap243x_map_common_io(void) 2706fbd55d0STony Lindgren { 2716fbd55d0STony Lindgren iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc)); 2726fbd55d0STony Lindgren iotable_init(omap243x_io_desc, ARRAY_SIZE(omap243x_io_desc)); 2736fbd55d0STony Lindgren } 2746fbd55d0STony Lindgren #endif 2756fbd55d0STony Lindgren 276a8eb7ca0STony Lindgren #ifdef CONFIG_ARCH_OMAP3 2778185e468SAaro Koskinen void __init omap34xx_map_common_io(void) 2786fbd55d0STony Lindgren { 2796fbd55d0STony Lindgren iotable_init(omap34xx_io_desc, ARRAY_SIZE(omap34xx_io_desc)); 2806fbd55d0STony Lindgren } 2816fbd55d0STony Lindgren #endif 2826fbd55d0STony Lindgren 283*a920360fSHemant Pedanekar #ifdef CONFIG_SOC_OMAPTI81XX 284*a920360fSHemant Pedanekar void __init omapti81xx_map_common_io(void) 28501001712SHemant Pedanekar { 286*a920360fSHemant Pedanekar iotable_init(omapti81xx_io_desc, ARRAY_SIZE(omapti81xx_io_desc)); 28701001712SHemant Pedanekar } 28801001712SHemant Pedanekar #endif 28901001712SHemant Pedanekar 2901e6cb146SAfzal Mohammed #ifdef CONFIG_SOC_OMAPAM33XX 2911e6cb146SAfzal Mohammed void __init omapam33xx_map_common_io(void) 2921e6cb146SAfzal Mohammed { 2931e6cb146SAfzal Mohammed iotable_init(omapam33xx_io_desc, ARRAY_SIZE(omapam33xx_io_desc)); 2941e6cb146SAfzal Mohammed } 2951e6cb146SAfzal Mohammed #endif 2961e6cb146SAfzal Mohammed 2976fbd55d0STony Lindgren #ifdef CONFIG_ARCH_OMAP4 2988185e468SAaro Koskinen void __init omap44xx_map_common_io(void) 2996fbd55d0STony Lindgren { 3006fbd55d0STony Lindgren iotable_init(omap44xx_io_desc, ARRAY_SIZE(omap44xx_io_desc)); 3016fbd55d0STony Lindgren } 3026fbd55d0STony Lindgren #endif 3036fbd55d0STony Lindgren 3042f135eafSPaul Walmsley /* 3052f135eafSPaul Walmsley * omap2_init_reprogram_sdrc - reprogram SDRC timing parameters 3062f135eafSPaul Walmsley * 3072f135eafSPaul Walmsley * Sets the CORE DPLL3 M2 divider to the same value that it's at 3082f135eafSPaul Walmsley * currently. This has the effect of setting the SDRC SDRAM AC timing 3092f135eafSPaul Walmsley * registers to the values currently defined by the kernel. Currently 3102f135eafSPaul Walmsley * only defined for OMAP3; will return 0 if called on OMAP2. Returns 3112f135eafSPaul Walmsley * -EINVAL if the dpll3_m2_ck cannot be found, 0 if called on OMAP2, 3122f135eafSPaul Walmsley * or passes along the return value of clk_set_rate(). 3132f135eafSPaul Walmsley */ 3142f135eafSPaul Walmsley static int __init _omap2_init_reprogram_sdrc(void) 3152f135eafSPaul Walmsley { 3162f135eafSPaul Walmsley struct clk *dpll3_m2_ck; 3172f135eafSPaul Walmsley int v = -EINVAL; 3182f135eafSPaul Walmsley long rate; 3192f135eafSPaul Walmsley 3202f135eafSPaul Walmsley if (!cpu_is_omap34xx()) 3212f135eafSPaul Walmsley return 0; 3222f135eafSPaul Walmsley 3232f135eafSPaul Walmsley dpll3_m2_ck = clk_get(NULL, "dpll3_m2_ck"); 324e281f7ecSAaro Koskinen if (IS_ERR(dpll3_m2_ck)) 3252f135eafSPaul Walmsley return -EINVAL; 3262f135eafSPaul Walmsley 3272f135eafSPaul Walmsley rate = clk_get_rate(dpll3_m2_ck); 3282f135eafSPaul Walmsley pr_info("Reprogramming SDRC clock to %ld Hz\n", rate); 3292f135eafSPaul Walmsley v = clk_set_rate(dpll3_m2_ck, rate); 3302f135eafSPaul Walmsley if (v) 3312f135eafSPaul Walmsley pr_err("dpll3_m2_clk rate change failed: %d\n", v); 3322f135eafSPaul Walmsley 3332f135eafSPaul Walmsley clk_put(dpll3_m2_ck); 3342f135eafSPaul Walmsley 3352f135eafSPaul Walmsley return v; 3362f135eafSPaul Walmsley } 3372f135eafSPaul Walmsley 3382092e5ccSPaul Walmsley static int _set_hwmod_postsetup_state(struct omap_hwmod *oh, void *data) 3392092e5ccSPaul Walmsley { 3402092e5ccSPaul Walmsley return omap_hwmod_set_postsetup_state(oh, *(u8 *)data); 3412092e5ccSPaul Walmsley } 3422092e5ccSPaul Walmsley 3437b250affSTony Lindgren static void __init omap_common_init_early(void) 3447b250affSTony Lindgren { 3457b250affSTony Lindgren omap2_check_revision(); 346df80442dSArnd Bergmann omap_init_consistent_dma_size(); 3477b250affSTony Lindgren } 3487b250affSTony Lindgren 3497b250affSTony Lindgren static void __init omap_hwmod_init_postsetup(void) 350120db2cbSTony Lindgren { 3512092e5ccSPaul Walmsley u8 postsetup_state; 3522092e5ccSPaul Walmsley 3532092e5ccSPaul Walmsley /* Set the default postsetup state for all hwmods */ 3542092e5ccSPaul Walmsley #ifdef CONFIG_PM_RUNTIME 3552092e5ccSPaul Walmsley postsetup_state = _HWMOD_STATE_IDLE; 3562092e5ccSPaul Walmsley #else 3572092e5ccSPaul Walmsley postsetup_state = _HWMOD_STATE_ENABLED; 3582092e5ccSPaul Walmsley #endif 3592092e5ccSPaul Walmsley omap_hwmod_for_each(_set_hwmod_postsetup_state, &postsetup_state); 36055d2cb08SBenoit Cousson 361ff2516fbSPaul Walmsley /* 362ff2516fbSPaul Walmsley * Set the default postsetup state for unusual modules (like 363ff2516fbSPaul Walmsley * MPU WDT). 364ff2516fbSPaul Walmsley * 365ff2516fbSPaul Walmsley * The postsetup_state is not actually used until 366ff2516fbSPaul Walmsley * omap_hwmod_late_init(), so boards that desire full watchdog 367ff2516fbSPaul Walmsley * coverage of kernel initialization can reprogram the 368ff2516fbSPaul Walmsley * postsetup_state between the calls to 369a4ca9dbeSTony Lindgren * omap2_init_common_infra() and omap_sdrc_init(). 370ff2516fbSPaul Walmsley * 371ff2516fbSPaul Walmsley * XXX ideally we could detect whether the MPU WDT was currently 372ff2516fbSPaul Walmsley * enabled here and make this conditional 373ff2516fbSPaul Walmsley */ 374ff2516fbSPaul Walmsley postsetup_state = _HWMOD_STATE_DISABLED; 375ff2516fbSPaul Walmsley omap_hwmod_for_each_by_class("wd_timer", 376ff2516fbSPaul Walmsley _set_hwmod_postsetup_state, 377ff2516fbSPaul Walmsley &postsetup_state); 378ff2516fbSPaul Walmsley 37953da4ce2SKevin Hilman omap_pm_if_early_init(); 3804805734bSPaul Walmsley } 3814805734bSPaul Walmsley 382c4e2d245SSanjeev Premi #ifdef CONFIG_ARCH_OMAP2 3838f5b5a41STony Lindgren void __init omap2420_init_early(void) 3848f5b5a41STony Lindgren { 3854c3cf901STony Lindgren omap2_set_globals_242x(); 3867b250affSTony Lindgren omap_common_init_early(); 3877b250affSTony Lindgren omap2xxx_voltagedomains_init(); 3887b250affSTony Lindgren omap242x_powerdomains_init(); 3897b250affSTony Lindgren omap242x_clockdomains_init(); 3907b250affSTony Lindgren omap2420_hwmod_init(); 3917b250affSTony Lindgren omap_hwmod_init_postsetup(); 3927b250affSTony Lindgren omap2420_clk_init(); 3938f5b5a41STony Lindgren } 3948f5b5a41STony Lindgren 3958f5b5a41STony Lindgren void __init omap2430_init_early(void) 3968f5b5a41STony Lindgren { 3974c3cf901STony Lindgren omap2_set_globals_243x(); 3987b250affSTony Lindgren omap_common_init_early(); 3997b250affSTony Lindgren omap2xxx_voltagedomains_init(); 4007b250affSTony Lindgren omap243x_powerdomains_init(); 4017b250affSTony Lindgren omap243x_clockdomains_init(); 4027b250affSTony Lindgren omap2430_hwmod_init(); 4037b250affSTony Lindgren omap_hwmod_init_postsetup(); 4047b250affSTony Lindgren omap2430_clk_init(); 4057b250affSTony Lindgren } 406c4e2d245SSanjeev Premi #endif 4077b250affSTony Lindgren 4087b250affSTony Lindgren /* 4097b250affSTony Lindgren * Currently only board-omap3beagle.c should call this because of the 4107b250affSTony Lindgren * same machine_id for 34xx and 36xx beagle.. Will get fixed with DT. 4117b250affSTony Lindgren */ 412c4e2d245SSanjeev Premi #ifdef CONFIG_ARCH_OMAP3 4137b250affSTony Lindgren void __init omap3_init_early(void) 4147b250affSTony Lindgren { 4154c3cf901STony Lindgren omap2_set_globals_3xxx(); 4167b250affSTony Lindgren omap_common_init_early(); 4177b250affSTony Lindgren omap3xxx_voltagedomains_init(); 4187b250affSTony Lindgren omap3xxx_powerdomains_init(); 4197b250affSTony Lindgren omap3xxx_clockdomains_init(); 4207b250affSTony Lindgren omap3xxx_hwmod_init(); 4217b250affSTony Lindgren omap_hwmod_init_postsetup(); 4227b250affSTony Lindgren omap3xxx_clk_init(); 4238f5b5a41STony Lindgren } 4248f5b5a41STony Lindgren 4258f5b5a41STony Lindgren void __init omap3430_init_early(void) 4268f5b5a41STony Lindgren { 4277b250affSTony Lindgren omap3_init_early(); 4288f5b5a41STony Lindgren } 4298f5b5a41STony Lindgren 4308f5b5a41STony Lindgren void __init omap35xx_init_early(void) 4318f5b5a41STony Lindgren { 4327b250affSTony Lindgren omap3_init_early(); 4338f5b5a41STony Lindgren } 4348f5b5a41STony Lindgren 4358f5b5a41STony Lindgren void __init omap3630_init_early(void) 4368f5b5a41STony Lindgren { 4377b250affSTony Lindgren omap3_init_early(); 4388f5b5a41STony Lindgren } 4398f5b5a41STony Lindgren 4408f5b5a41STony Lindgren void __init am35xx_init_early(void) 4418f5b5a41STony Lindgren { 4427b250affSTony Lindgren omap3_init_early(); 4438f5b5a41STony Lindgren } 4448f5b5a41STony Lindgren 445*a920360fSHemant Pedanekar void __init ti81xx_init_early(void) 4468f5b5a41STony Lindgren { 447*a920360fSHemant Pedanekar omap2_set_globals_ti81xx(); 4484c3cf901STony Lindgren omap_common_init_early(); 4494c3cf901STony Lindgren omap3xxx_voltagedomains_init(); 4504c3cf901STony Lindgren omap3xxx_powerdomains_init(); 4514c3cf901STony Lindgren omap3xxx_clockdomains_init(); 4524c3cf901STony Lindgren omap3xxx_hwmod_init(); 4534c3cf901STony Lindgren omap_hwmod_init_postsetup(); 4544c3cf901STony Lindgren omap3xxx_clk_init(); 4558f5b5a41STony Lindgren } 456c4e2d245SSanjeev Premi #endif 4578f5b5a41STony Lindgren 458c4e2d245SSanjeev Premi #ifdef CONFIG_ARCH_OMAP4 4598f5b5a41STony Lindgren void __init omap4430_init_early(void) 4608f5b5a41STony Lindgren { 4614c3cf901STony Lindgren omap2_set_globals_443x(); 4627b250affSTony Lindgren omap_common_init_early(); 4637b250affSTony Lindgren omap44xx_voltagedomains_init(); 4647b250affSTony Lindgren omap44xx_powerdomains_init(); 4657b250affSTony Lindgren omap44xx_clockdomains_init(); 4667b250affSTony Lindgren omap44xx_hwmod_init(); 4677b250affSTony Lindgren omap_hwmod_init_postsetup(); 4687b250affSTony Lindgren omap4xxx_clk_init(); 4698f5b5a41STony Lindgren } 470c4e2d245SSanjeev Premi #endif 4718f5b5a41STony Lindgren 472a4ca9dbeSTony Lindgren void __init omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0, 4734805734bSPaul Walmsley struct omap_sdrc_params *sdrc_cs1) 4744805734bSPaul Walmsley { 475a66cb345STony Lindgren omap_sram_init(); 476a66cb345STony Lindgren 47701001712SHemant Pedanekar if (cpu_is_omap24xx() || omap3_has_sdrc()) { 47858cda884SJean Pihet omap2_sdrc_init(sdrc_cs0, sdrc_cs1); 4792f135eafSPaul Walmsley _omap2_init_reprogram_sdrc(); 480aa4b1f6eSKevin Hilman } 4811dbae815STony Lindgren } 482df1e9d1cSTony Lindgren 483df1e9d1cSTony Lindgren /* 484df1e9d1cSTony Lindgren * NOTE: Please use ioremap + __raw_read/write where possible instead of these 485df1e9d1cSTony Lindgren */ 486df1e9d1cSTony Lindgren 487df1e9d1cSTony Lindgren u8 omap_readb(u32 pa) 488df1e9d1cSTony Lindgren { 489df1e9d1cSTony Lindgren return __raw_readb(OMAP2_L4_IO_ADDRESS(pa)); 490df1e9d1cSTony Lindgren } 491df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_readb); 492df1e9d1cSTony Lindgren 493df1e9d1cSTony Lindgren u16 omap_readw(u32 pa) 494df1e9d1cSTony Lindgren { 495df1e9d1cSTony Lindgren return __raw_readw(OMAP2_L4_IO_ADDRESS(pa)); 496df1e9d1cSTony Lindgren } 497df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_readw); 498df1e9d1cSTony Lindgren 499df1e9d1cSTony Lindgren u32 omap_readl(u32 pa) 500df1e9d1cSTony Lindgren { 501df1e9d1cSTony Lindgren return __raw_readl(OMAP2_L4_IO_ADDRESS(pa)); 502df1e9d1cSTony Lindgren } 503df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_readl); 504df1e9d1cSTony Lindgren 505df1e9d1cSTony Lindgren void omap_writeb(u8 v, u32 pa) 506df1e9d1cSTony Lindgren { 507df1e9d1cSTony Lindgren __raw_writeb(v, OMAP2_L4_IO_ADDRESS(pa)); 508df1e9d1cSTony Lindgren } 509df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_writeb); 510df1e9d1cSTony Lindgren 511df1e9d1cSTony Lindgren void omap_writew(u16 v, u32 pa) 512df1e9d1cSTony Lindgren { 513df1e9d1cSTony Lindgren __raw_writew(v, OMAP2_L4_IO_ADDRESS(pa)); 514df1e9d1cSTony Lindgren } 515df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_writew); 516df1e9d1cSTony Lindgren 517df1e9d1cSTony Lindgren void omap_writel(u32 v, u32 pa) 518df1e9d1cSTony Lindgren { 519df1e9d1cSTony Lindgren __raw_writel(v, OMAP2_L4_IO_ADDRESS(pa)); 520df1e9d1cSTony Lindgren } 521df1e9d1cSTony Lindgren EXPORT_SYMBOL(omap_writel); 522