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> 241dbae815STony Lindgren 25120db2cbSTony Lindgren #include <asm/tlb.h> 26120db2cbSTony Lindgren #include <asm/mach/map.h> 27120db2cbSTony Lindgren 2845c3eb7dSTony Lindgren #include <linux/omap-dma.h> 29646e3ed1STony Lindgren 30dc843280STony Lindgren #include "omap_hwmod.h" 31dbc04161STony Lindgren #include "soc.h" 32ee0839c2STony Lindgren #include "iomap.h" 33ee0839c2STony Lindgren #include "voltage.h" 34ee0839c2STony Lindgren #include "powerdomain.h" 35ee0839c2STony Lindgren #include "clockdomain.h" 36ee0839c2STony Lindgren #include "common.h" 37e30384abSVaibhav Hiremath #include "clock.h" 38e80a9729SPaul Walmsley #include "clock2xxx.h" 39657ebfadSPaul Walmsley #include "clock3xxx.h" 40e80a9729SPaul Walmsley #include "clock44xx.h" 411d5aef49STony Lindgren #include "omap-pm.h" 423e6ece13SPaul Walmsley #include "sdrc.h" 43b6a4226cSPaul Walmsley #include "control.h" 443d82cbbbSTony Lindgren #include "serial.h" 45bf027ca1STony Lindgren #include "sram.h" 46c4ceedcbSPaul Walmsley #include "cm2xxx.h" 47c4ceedcbSPaul Walmsley #include "cm3xxx.h" 48d9a16f9aSPaul Walmsley #include "prm.h" 49d9a16f9aSPaul Walmsley #include "cm.h" 50d9a16f9aSPaul Walmsley #include "prcm_mpu44xx.h" 51d9a16f9aSPaul Walmsley #include "prminst44xx.h" 52d9a16f9aSPaul Walmsley #include "cminst44xx.h" 5363a293e0SPaul Walmsley #include "prm2xxx.h" 5463a293e0SPaul Walmsley #include "prm3xxx.h" 5563a293e0SPaul Walmsley #include "prm44xx.h" 561dbae815STony Lindgren 571dbae815STony Lindgren /* 58ff931c82SRajendra Nayak * omap_clk_init: points to a function that does the SoC-specific 59ff931c82SRajendra Nayak * clock initializations 60ff931c82SRajendra Nayak */ 61ff931c82SRajendra Nayak int (*omap_clk_init)(void); 62ff931c82SRajendra Nayak 63ff931c82SRajendra Nayak /* 641dbae815STony Lindgren * The machine specific code may provide the extra mapping besides the 651dbae815STony Lindgren * default mapping provided here. 661dbae815STony Lindgren */ 67cc26b3b0SSyed Mohammed, Khasim 68e48f814eSTony Lindgren #if defined(CONFIG_SOC_OMAP2420) || defined(CONFIG_SOC_OMAP2430) 69cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap24xx_io_desc[] __initdata = { 701dbae815STony Lindgren { 711dbae815STony Lindgren .virtual = L3_24XX_VIRT, 721dbae815STony Lindgren .pfn = __phys_to_pfn(L3_24XX_PHYS), 731dbae815STony Lindgren .length = L3_24XX_SIZE, 741dbae815STony Lindgren .type = MT_DEVICE 751dbae815STony Lindgren }, 7609f21ed4SKyungmin Park { 7709f21ed4SKyungmin Park .virtual = L4_24XX_VIRT, 7809f21ed4SKyungmin Park .pfn = __phys_to_pfn(L4_24XX_PHYS), 7909f21ed4SKyungmin Park .length = L4_24XX_SIZE, 8009f21ed4SKyungmin Park .type = MT_DEVICE 8109f21ed4SKyungmin Park }, 82cc26b3b0SSyed Mohammed, Khasim }; 83cc26b3b0SSyed Mohammed, Khasim 8459b479e0STony Lindgren #ifdef CONFIG_SOC_OMAP2420 85cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap242x_io_desc[] __initdata = { 861dbae815STony Lindgren { 877adb9987SPaul Walmsley .virtual = DSP_MEM_2420_VIRT, 887adb9987SPaul Walmsley .pfn = __phys_to_pfn(DSP_MEM_2420_PHYS), 897adb9987SPaul Walmsley .length = DSP_MEM_2420_SIZE, 90c40fae95STony Lindgren .type = MT_DEVICE 91c40fae95STony Lindgren }, 92c40fae95STony Lindgren { 937adb9987SPaul Walmsley .virtual = DSP_IPI_2420_VIRT, 947adb9987SPaul Walmsley .pfn = __phys_to_pfn(DSP_IPI_2420_PHYS), 957adb9987SPaul Walmsley .length = DSP_IPI_2420_SIZE, 96c40fae95STony Lindgren .type = MT_DEVICE 97c40fae95STony Lindgren }, 98c40fae95STony Lindgren { 997adb9987SPaul Walmsley .virtual = DSP_MMU_2420_VIRT, 1007adb9987SPaul Walmsley .pfn = __phys_to_pfn(DSP_MMU_2420_PHYS), 1017adb9987SPaul Walmsley .length = DSP_MMU_2420_SIZE, 1021dbae815STony Lindgren .type = MT_DEVICE 103cc26b3b0SSyed Mohammed, Khasim }, 1041dbae815STony Lindgren }; 1051dbae815STony Lindgren 106cc26b3b0SSyed Mohammed, Khasim #endif 107cc26b3b0SSyed Mohammed, Khasim 10859b479e0STony Lindgren #ifdef CONFIG_SOC_OMAP2430 109cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap243x_io_desc[] __initdata = { 110cc26b3b0SSyed Mohammed, Khasim { 111cc26b3b0SSyed Mohammed, Khasim .virtual = L4_WK_243X_VIRT, 112cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(L4_WK_243X_PHYS), 113cc26b3b0SSyed Mohammed, Khasim .length = L4_WK_243X_SIZE, 114cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 115cc26b3b0SSyed Mohammed, Khasim }, 116cc26b3b0SSyed Mohammed, Khasim { 117cc26b3b0SSyed Mohammed, Khasim .virtual = OMAP243X_GPMC_VIRT, 118cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(OMAP243X_GPMC_PHYS), 119cc26b3b0SSyed Mohammed, Khasim .length = OMAP243X_GPMC_SIZE, 120cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 121cc26b3b0SSyed Mohammed, Khasim }, 122cc26b3b0SSyed Mohammed, Khasim { 123cc26b3b0SSyed Mohammed, Khasim .virtual = OMAP243X_SDRC_VIRT, 124cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(OMAP243X_SDRC_PHYS), 125cc26b3b0SSyed Mohammed, Khasim .length = OMAP243X_SDRC_SIZE, 126cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 127cc26b3b0SSyed Mohammed, Khasim }, 128cc26b3b0SSyed Mohammed, Khasim { 129cc26b3b0SSyed Mohammed, Khasim .virtual = OMAP243X_SMS_VIRT, 130cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(OMAP243X_SMS_PHYS), 131cc26b3b0SSyed Mohammed, Khasim .length = OMAP243X_SMS_SIZE, 132cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 133cc26b3b0SSyed Mohammed, Khasim }, 134cc26b3b0SSyed Mohammed, Khasim }; 135cc26b3b0SSyed Mohammed, Khasim #endif 136cc26b3b0SSyed Mohammed, Khasim #endif 137cc26b3b0SSyed Mohammed, Khasim 138a8eb7ca0STony Lindgren #ifdef CONFIG_ARCH_OMAP3 139cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap34xx_io_desc[] __initdata = { 140cc26b3b0SSyed Mohammed, Khasim { 141cc26b3b0SSyed Mohammed, Khasim .virtual = L3_34XX_VIRT, 142cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(L3_34XX_PHYS), 143cc26b3b0SSyed Mohammed, Khasim .length = L3_34XX_SIZE, 144cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 145cc26b3b0SSyed Mohammed, Khasim }, 146cc26b3b0SSyed Mohammed, Khasim { 147cc26b3b0SSyed Mohammed, Khasim .virtual = L4_34XX_VIRT, 148cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(L4_34XX_PHYS), 149cc26b3b0SSyed Mohammed, Khasim .length = L4_34XX_SIZE, 150cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 151cc26b3b0SSyed Mohammed, Khasim }, 152cc26b3b0SSyed Mohammed, Khasim { 153cc26b3b0SSyed Mohammed, Khasim .virtual = OMAP34XX_GPMC_VIRT, 154cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(OMAP34XX_GPMC_PHYS), 155cc26b3b0SSyed Mohammed, Khasim .length = OMAP34XX_GPMC_SIZE, 156cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 157cc26b3b0SSyed Mohammed, Khasim }, 158cc26b3b0SSyed Mohammed, Khasim { 159cc26b3b0SSyed Mohammed, Khasim .virtual = OMAP343X_SMS_VIRT, 160cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(OMAP343X_SMS_PHYS), 161cc26b3b0SSyed Mohammed, Khasim .length = OMAP343X_SMS_SIZE, 162cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 163cc26b3b0SSyed Mohammed, Khasim }, 164cc26b3b0SSyed Mohammed, Khasim { 165cc26b3b0SSyed Mohammed, Khasim .virtual = OMAP343X_SDRC_VIRT, 166cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(OMAP343X_SDRC_PHYS), 167cc26b3b0SSyed Mohammed, Khasim .length = OMAP343X_SDRC_SIZE, 168cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 169cc26b3b0SSyed Mohammed, Khasim }, 170cc26b3b0SSyed Mohammed, Khasim { 171cc26b3b0SSyed Mohammed, Khasim .virtual = L4_PER_34XX_VIRT, 172cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(L4_PER_34XX_PHYS), 173cc26b3b0SSyed Mohammed, Khasim .length = L4_PER_34XX_SIZE, 174cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 175cc26b3b0SSyed Mohammed, Khasim }, 176cc26b3b0SSyed Mohammed, Khasim { 177cc26b3b0SSyed Mohammed, Khasim .virtual = L4_EMU_34XX_VIRT, 178cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(L4_EMU_34XX_PHYS), 179cc26b3b0SSyed Mohammed, Khasim .length = L4_EMU_34XX_SIZE, 180cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 181cc26b3b0SSyed Mohammed, Khasim }, 182a4f57b81STony Lindgren #if defined(CONFIG_DEBUG_LL) && \ 183a4f57b81STony Lindgren (defined(CONFIG_MACH_OMAP_ZOOM2) || defined(CONFIG_MACH_OMAP_ZOOM3)) 184a4f57b81STony Lindgren { 185a4f57b81STony Lindgren .virtual = ZOOM_UART_VIRT, 186a4f57b81STony Lindgren .pfn = __phys_to_pfn(ZOOM_UART_BASE), 187a4f57b81STony Lindgren .length = SZ_1M, 188a4f57b81STony Lindgren .type = MT_DEVICE 189a4f57b81STony Lindgren }, 190a4f57b81STony Lindgren #endif 191cc26b3b0SSyed Mohammed, Khasim }; 192cc26b3b0SSyed Mohammed, Khasim #endif 19301001712SHemant Pedanekar 19433959553SKevin Hilman #ifdef CONFIG_SOC_TI81XX 195a920360fSHemant Pedanekar static struct map_desc omapti81xx_io_desc[] __initdata = { 19601001712SHemant Pedanekar { 19701001712SHemant Pedanekar .virtual = L4_34XX_VIRT, 19801001712SHemant Pedanekar .pfn = __phys_to_pfn(L4_34XX_PHYS), 19901001712SHemant Pedanekar .length = L4_34XX_SIZE, 20001001712SHemant Pedanekar .type = MT_DEVICE 2011e6cb146SAfzal Mohammed } 2021e6cb146SAfzal Mohammed }; 2031e6cb146SAfzal Mohammed #endif 2041e6cb146SAfzal Mohammed 205*addb154aSAfzal Mohammed #if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX) 2061e6cb146SAfzal Mohammed static struct map_desc omapam33xx_io_desc[] __initdata = { 20701001712SHemant Pedanekar { 20801001712SHemant Pedanekar .virtual = L4_34XX_VIRT, 20901001712SHemant Pedanekar .pfn = __phys_to_pfn(L4_34XX_PHYS), 21001001712SHemant Pedanekar .length = L4_34XX_SIZE, 21101001712SHemant Pedanekar .type = MT_DEVICE 21201001712SHemant Pedanekar }, 2131e6cb146SAfzal Mohammed { 2141e6cb146SAfzal Mohammed .virtual = L4_WK_AM33XX_VIRT, 2151e6cb146SAfzal Mohammed .pfn = __phys_to_pfn(L4_WK_AM33XX_PHYS), 2161e6cb146SAfzal Mohammed .length = L4_WK_AM33XX_SIZE, 2171e6cb146SAfzal Mohammed .type = MT_DEVICE 2181e6cb146SAfzal Mohammed } 21901001712SHemant Pedanekar }; 22001001712SHemant Pedanekar #endif 22101001712SHemant Pedanekar 22244169075SSantosh Shilimkar #ifdef CONFIG_ARCH_OMAP4 22344169075SSantosh Shilimkar static struct map_desc omap44xx_io_desc[] __initdata = { 22444169075SSantosh Shilimkar { 22544169075SSantosh Shilimkar .virtual = L3_44XX_VIRT, 22644169075SSantosh Shilimkar .pfn = __phys_to_pfn(L3_44XX_PHYS), 22744169075SSantosh Shilimkar .length = L3_44XX_SIZE, 22844169075SSantosh Shilimkar .type = MT_DEVICE, 22944169075SSantosh Shilimkar }, 23044169075SSantosh Shilimkar { 23144169075SSantosh Shilimkar .virtual = L4_44XX_VIRT, 23244169075SSantosh Shilimkar .pfn = __phys_to_pfn(L4_44XX_PHYS), 23344169075SSantosh Shilimkar .length = L4_44XX_SIZE, 23444169075SSantosh Shilimkar .type = MT_DEVICE, 23544169075SSantosh Shilimkar }, 23644169075SSantosh Shilimkar { 23744169075SSantosh Shilimkar .virtual = L4_PER_44XX_VIRT, 23844169075SSantosh Shilimkar .pfn = __phys_to_pfn(L4_PER_44XX_PHYS), 23944169075SSantosh Shilimkar .length = L4_PER_44XX_SIZE, 24044169075SSantosh Shilimkar .type = MT_DEVICE, 24144169075SSantosh Shilimkar }, 242137d105dSSantosh Shilimkar #ifdef CONFIG_OMAP4_ERRATA_I688 243137d105dSSantosh Shilimkar { 244137d105dSSantosh Shilimkar .virtual = OMAP4_SRAM_VA, 245137d105dSSantosh Shilimkar .pfn = __phys_to_pfn(OMAP4_SRAM_PA), 246137d105dSSantosh Shilimkar .length = PAGE_SIZE, 247137d105dSSantosh Shilimkar .type = MT_MEMORY_SO, 248137d105dSSantosh Shilimkar }, 249137d105dSSantosh Shilimkar #endif 250137d105dSSantosh Shilimkar 25144169075SSantosh Shilimkar }; 25244169075SSantosh Shilimkar #endif 253cc26b3b0SSyed Mohammed, Khasim 25405e152c7SR Sricharan #ifdef CONFIG_SOC_OMAP5 25505e152c7SR Sricharan static struct map_desc omap54xx_io_desc[] __initdata = { 25605e152c7SR Sricharan { 25705e152c7SR Sricharan .virtual = L3_54XX_VIRT, 25805e152c7SR Sricharan .pfn = __phys_to_pfn(L3_54XX_PHYS), 25905e152c7SR Sricharan .length = L3_54XX_SIZE, 26005e152c7SR Sricharan .type = MT_DEVICE, 26105e152c7SR Sricharan }, 26205e152c7SR Sricharan { 26305e152c7SR Sricharan .virtual = L4_54XX_VIRT, 26405e152c7SR Sricharan .pfn = __phys_to_pfn(L4_54XX_PHYS), 26505e152c7SR Sricharan .length = L4_54XX_SIZE, 26605e152c7SR Sricharan .type = MT_DEVICE, 26705e152c7SR Sricharan }, 26805e152c7SR Sricharan { 26905e152c7SR Sricharan .virtual = L4_WK_54XX_VIRT, 27005e152c7SR Sricharan .pfn = __phys_to_pfn(L4_WK_54XX_PHYS), 27105e152c7SR Sricharan .length = L4_WK_54XX_SIZE, 27205e152c7SR Sricharan .type = MT_DEVICE, 27305e152c7SR Sricharan }, 27405e152c7SR Sricharan { 27505e152c7SR Sricharan .virtual = L4_PER_54XX_VIRT, 27605e152c7SR Sricharan .pfn = __phys_to_pfn(L4_PER_54XX_PHYS), 27705e152c7SR Sricharan .length = L4_PER_54XX_SIZE, 27805e152c7SR Sricharan .type = MT_DEVICE, 27905e152c7SR Sricharan }, 2801348bbf9SSantosh Shilimkar #ifdef CONFIG_OMAP4_ERRATA_I688 2811348bbf9SSantosh Shilimkar { 2821348bbf9SSantosh Shilimkar .virtual = OMAP4_SRAM_VA, 2831348bbf9SSantosh Shilimkar .pfn = __phys_to_pfn(OMAP4_SRAM_PA), 2841348bbf9SSantosh Shilimkar .length = PAGE_SIZE, 2851348bbf9SSantosh Shilimkar .type = MT_MEMORY_SO, 2861348bbf9SSantosh Shilimkar }, 2871348bbf9SSantosh Shilimkar #endif 28805e152c7SR Sricharan }; 28905e152c7SR Sricharan #endif 29005e152c7SR Sricharan 29159b479e0STony Lindgren #ifdef CONFIG_SOC_OMAP2420 292b6a4226cSPaul Walmsley void __init omap242x_map_io(void) 2936fbd55d0STony Lindgren { 2946fbd55d0STony Lindgren iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc)); 2956fbd55d0STony Lindgren iotable_init(omap242x_io_desc, ARRAY_SIZE(omap242x_io_desc)); 2966fbd55d0STony Lindgren } 2976fbd55d0STony Lindgren #endif 2986fbd55d0STony Lindgren 29959b479e0STony Lindgren #ifdef CONFIG_SOC_OMAP2430 300b6a4226cSPaul Walmsley void __init omap243x_map_io(void) 3016fbd55d0STony Lindgren { 3026fbd55d0STony Lindgren iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc)); 3036fbd55d0STony Lindgren iotable_init(omap243x_io_desc, ARRAY_SIZE(omap243x_io_desc)); 3046fbd55d0STony Lindgren } 3056fbd55d0STony Lindgren #endif 3066fbd55d0STony Lindgren 307a8eb7ca0STony Lindgren #ifdef CONFIG_ARCH_OMAP3 308b6a4226cSPaul Walmsley void __init omap3_map_io(void) 3096fbd55d0STony Lindgren { 3106fbd55d0STony Lindgren iotable_init(omap34xx_io_desc, ARRAY_SIZE(omap34xx_io_desc)); 3116fbd55d0STony Lindgren } 3126fbd55d0STony Lindgren #endif 3136fbd55d0STony Lindgren 31433959553SKevin Hilman #ifdef CONFIG_SOC_TI81XX 315b6a4226cSPaul Walmsley void __init ti81xx_map_io(void) 31601001712SHemant Pedanekar { 317a920360fSHemant Pedanekar iotable_init(omapti81xx_io_desc, ARRAY_SIZE(omapti81xx_io_desc)); 31801001712SHemant Pedanekar } 31901001712SHemant Pedanekar #endif 32001001712SHemant Pedanekar 321*addb154aSAfzal Mohammed #if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX) 322b6a4226cSPaul Walmsley void __init am33xx_map_io(void) 3231e6cb146SAfzal Mohammed { 3241e6cb146SAfzal Mohammed iotable_init(omapam33xx_io_desc, ARRAY_SIZE(omapam33xx_io_desc)); 3256fbd55d0STony Lindgren } 3266fbd55d0STony Lindgren #endif 3276fbd55d0STony Lindgren 3286fbd55d0STony Lindgren #ifdef CONFIG_ARCH_OMAP4 329b6a4226cSPaul Walmsley void __init omap4_map_io(void) 3306fbd55d0STony Lindgren { 3316fbd55d0STony Lindgren iotable_init(omap44xx_io_desc, ARRAY_SIZE(omap44xx_io_desc)); 3322ec1fc4eSSantosh Shilimkar omap_barriers_init(); 3336fbd55d0STony Lindgren } 3346fbd55d0STony Lindgren #endif 3356fbd55d0STony Lindgren 33605e152c7SR Sricharan #ifdef CONFIG_SOC_OMAP5 337b6a4226cSPaul Walmsley void __init omap5_map_io(void) 33805e152c7SR Sricharan { 33905e152c7SR Sricharan iotable_init(omap54xx_io_desc, ARRAY_SIZE(omap54xx_io_desc)); 3401348bbf9SSantosh Shilimkar omap_barriers_init(); 34105e152c7SR Sricharan } 34205e152c7SR Sricharan #endif 3432f135eafSPaul Walmsley /* 3442f135eafSPaul Walmsley * omap2_init_reprogram_sdrc - reprogram SDRC timing parameters 3452f135eafSPaul Walmsley * 3462f135eafSPaul Walmsley * Sets the CORE DPLL3 M2 divider to the same value that it's at 3472f135eafSPaul Walmsley * currently. This has the effect of setting the SDRC SDRAM AC timing 3482f135eafSPaul Walmsley * registers to the values currently defined by the kernel. Currently 3492f135eafSPaul Walmsley * only defined for OMAP3; will return 0 if called on OMAP2. Returns 3502f135eafSPaul Walmsley * -EINVAL if the dpll3_m2_ck cannot be found, 0 if called on OMAP2, 3512f135eafSPaul Walmsley * or passes along the return value of clk_set_rate(). 3522f135eafSPaul Walmsley */ 3532f135eafSPaul Walmsley static int __init _omap2_init_reprogram_sdrc(void) 3542f135eafSPaul Walmsley { 3552f135eafSPaul Walmsley struct clk *dpll3_m2_ck; 3562f135eafSPaul Walmsley int v = -EINVAL; 3572f135eafSPaul Walmsley long rate; 3582f135eafSPaul Walmsley 3592f135eafSPaul Walmsley if (!cpu_is_omap34xx()) 3602f135eafSPaul Walmsley return 0; 3612f135eafSPaul Walmsley 3622f135eafSPaul Walmsley dpll3_m2_ck = clk_get(NULL, "dpll3_m2_ck"); 363e281f7ecSAaro Koskinen if (IS_ERR(dpll3_m2_ck)) 3642f135eafSPaul Walmsley return -EINVAL; 3652f135eafSPaul Walmsley 3662f135eafSPaul Walmsley rate = clk_get_rate(dpll3_m2_ck); 3672f135eafSPaul Walmsley pr_info("Reprogramming SDRC clock to %ld Hz\n", rate); 3682f135eafSPaul Walmsley v = clk_set_rate(dpll3_m2_ck, rate); 3692f135eafSPaul Walmsley if (v) 3702f135eafSPaul Walmsley pr_err("dpll3_m2_clk rate change failed: %d\n", v); 3712f135eafSPaul Walmsley 3722f135eafSPaul Walmsley clk_put(dpll3_m2_ck); 3732f135eafSPaul Walmsley 3742f135eafSPaul Walmsley return v; 3752f135eafSPaul Walmsley } 3762f135eafSPaul Walmsley 3772092e5ccSPaul Walmsley static int _set_hwmod_postsetup_state(struct omap_hwmod *oh, void *data) 3782092e5ccSPaul Walmsley { 3792092e5ccSPaul Walmsley return omap_hwmod_set_postsetup_state(oh, *(u8 *)data); 3802092e5ccSPaul Walmsley } 3812092e5ccSPaul Walmsley 3827b250affSTony Lindgren static void __init omap_hwmod_init_postsetup(void) 383120db2cbSTony Lindgren { 3842092e5ccSPaul Walmsley u8 postsetup_state; 3852092e5ccSPaul Walmsley 3862092e5ccSPaul Walmsley /* Set the default postsetup state for all hwmods */ 3872092e5ccSPaul Walmsley #ifdef CONFIG_PM_RUNTIME 3882092e5ccSPaul Walmsley postsetup_state = _HWMOD_STATE_IDLE; 3892092e5ccSPaul Walmsley #else 3902092e5ccSPaul Walmsley postsetup_state = _HWMOD_STATE_ENABLED; 3912092e5ccSPaul Walmsley #endif 3922092e5ccSPaul Walmsley omap_hwmod_for_each(_set_hwmod_postsetup_state, &postsetup_state); 39355d2cb08SBenoit Cousson 39453da4ce2SKevin Hilman omap_pm_if_early_init(); 3954805734bSPaul Walmsley } 3964805734bSPaul Walmsley 3974ed12be0SRuslan Bilovol static void __init omap_common_late_init(void) 3984ed12be0SRuslan Bilovol { 3994ed12be0SRuslan Bilovol omap_mux_late_init(); 4004ed12be0SRuslan Bilovol omap2_common_pm_late_init(); 4016770b211SRuslan Bilovol omap_soc_device_init(); 4024ed12be0SRuslan Bilovol } 4034ed12be0SRuslan Bilovol 40416110798SPaul Walmsley #ifdef CONFIG_SOC_OMAP2420 4058f5b5a41STony Lindgren void __init omap2420_init_early(void) 4068f5b5a41STony Lindgren { 407b6a4226cSPaul Walmsley omap2_set_globals_tap(OMAP242X_CLASS, OMAP2_L4_IO_ADDRESS(0x48014000)); 408b6a4226cSPaul Walmsley omap2_set_globals_sdrc(OMAP2_L3_IO_ADDRESS(OMAP2420_SDRC_BASE), 409b6a4226cSPaul Walmsley OMAP2_L3_IO_ADDRESS(OMAP2420_SMS_BASE)); 410b6a4226cSPaul Walmsley omap2_set_globals_control(OMAP2_L4_IO_ADDRESS(OMAP242X_CTRL_BASE), 411b6a4226cSPaul Walmsley NULL); 412d9a16f9aSPaul Walmsley omap2_set_globals_prm(OMAP2_L4_IO_ADDRESS(OMAP2420_PRM_BASE)); 413d9a16f9aSPaul Walmsley omap2_set_globals_cm(OMAP2_L4_IO_ADDRESS(OMAP2420_CM_BASE), NULL); 4144de34f35SVaibhav Hiremath omap2xxx_check_revision(); 41563a293e0SPaul Walmsley omap2xxx_prm_init(); 416c4ceedcbSPaul Walmsley omap2xxx_cm_init(); 4177b250affSTony Lindgren omap2xxx_voltagedomains_init(); 4187b250affSTony Lindgren omap242x_powerdomains_init(); 4197b250affSTony Lindgren omap242x_clockdomains_init(); 4207b250affSTony Lindgren omap2420_hwmod_init(); 4217b250affSTony Lindgren omap_hwmod_init_postsetup(); 422ff931c82SRajendra Nayak omap_clk_init = omap2420_clk_init; 4238f5b5a41STony Lindgren } 424bbd707acSShawn Guo 425bbd707acSShawn Guo void __init omap2420_init_late(void) 426bbd707acSShawn Guo { 4274ed12be0SRuslan Bilovol omap_common_late_init(); 428bbd707acSShawn Guo omap2_pm_init(); 42923fb8ba3SRajendra Nayak omap2_clk_enable_autoidle_all(); 430bbd707acSShawn Guo } 43116110798SPaul Walmsley #endif 4328f5b5a41STony Lindgren 43316110798SPaul Walmsley #ifdef CONFIG_SOC_OMAP2430 4348f5b5a41STony Lindgren void __init omap2430_init_early(void) 4358f5b5a41STony Lindgren { 436b6a4226cSPaul Walmsley omap2_set_globals_tap(OMAP243X_CLASS, OMAP2_L4_IO_ADDRESS(0x4900a000)); 437b6a4226cSPaul Walmsley omap2_set_globals_sdrc(OMAP2_L3_IO_ADDRESS(OMAP243X_SDRC_BASE), 438b6a4226cSPaul Walmsley OMAP2_L3_IO_ADDRESS(OMAP243X_SMS_BASE)); 439b6a4226cSPaul Walmsley omap2_set_globals_control(OMAP2_L4_IO_ADDRESS(OMAP243X_CTRL_BASE), 440b6a4226cSPaul Walmsley NULL); 441d9a16f9aSPaul Walmsley omap2_set_globals_prm(OMAP2_L4_IO_ADDRESS(OMAP2430_PRM_BASE)); 442d9a16f9aSPaul Walmsley omap2_set_globals_cm(OMAP2_L4_IO_ADDRESS(OMAP2430_CM_BASE), NULL); 4434de34f35SVaibhav Hiremath omap2xxx_check_revision(); 44463a293e0SPaul Walmsley omap2xxx_prm_init(); 445c4ceedcbSPaul Walmsley omap2xxx_cm_init(); 4467b250affSTony Lindgren omap2xxx_voltagedomains_init(); 4477b250affSTony Lindgren omap243x_powerdomains_init(); 4487b250affSTony Lindgren omap243x_clockdomains_init(); 4497b250affSTony Lindgren omap2430_hwmod_init(); 4507b250affSTony Lindgren omap_hwmod_init_postsetup(); 451ff931c82SRajendra Nayak omap_clk_init = omap2430_clk_init; 4527b250affSTony Lindgren } 453bbd707acSShawn Guo 454bbd707acSShawn Guo void __init omap2430_init_late(void) 455bbd707acSShawn Guo { 4564ed12be0SRuslan Bilovol omap_common_late_init(); 457bbd707acSShawn Guo omap2_pm_init(); 45823fb8ba3SRajendra Nayak omap2_clk_enable_autoidle_all(); 459bbd707acSShawn Guo } 460c4e2d245SSanjeev Premi #endif 4617b250affSTony Lindgren 4627b250affSTony Lindgren /* 4637b250affSTony Lindgren * Currently only board-omap3beagle.c should call this because of the 4647b250affSTony Lindgren * same machine_id for 34xx and 36xx beagle.. Will get fixed with DT. 4657b250affSTony Lindgren */ 466c4e2d245SSanjeev Premi #ifdef CONFIG_ARCH_OMAP3 4677b250affSTony Lindgren void __init omap3_init_early(void) 4687b250affSTony Lindgren { 469b6a4226cSPaul Walmsley omap2_set_globals_tap(OMAP343X_CLASS, OMAP2_L4_IO_ADDRESS(0x4830A000)); 470b6a4226cSPaul Walmsley omap2_set_globals_sdrc(OMAP2_L3_IO_ADDRESS(OMAP343X_SDRC_BASE), 471b6a4226cSPaul Walmsley OMAP2_L3_IO_ADDRESS(OMAP343X_SMS_BASE)); 472b6a4226cSPaul Walmsley omap2_set_globals_control(OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE), 473b6a4226cSPaul Walmsley NULL); 474d9a16f9aSPaul Walmsley omap2_set_globals_prm(OMAP2_L4_IO_ADDRESS(OMAP3430_PRM_BASE)); 475d9a16f9aSPaul Walmsley omap2_set_globals_cm(OMAP2_L4_IO_ADDRESS(OMAP3430_CM_BASE), NULL); 4764de34f35SVaibhav Hiremath omap3xxx_check_revision(); 4774de34f35SVaibhav Hiremath omap3xxx_check_features(); 47863a293e0SPaul Walmsley omap3xxx_prm_init(); 479c4ceedcbSPaul Walmsley omap3xxx_cm_init(); 4807b250affSTony Lindgren omap3xxx_voltagedomains_init(); 4817b250affSTony Lindgren omap3xxx_powerdomains_init(); 4827b250affSTony Lindgren omap3xxx_clockdomains_init(); 4837b250affSTony Lindgren omap3xxx_hwmod_init(); 4847b250affSTony Lindgren omap_hwmod_init_postsetup(); 485ff931c82SRajendra Nayak omap_clk_init = omap3xxx_clk_init; 4868f5b5a41STony Lindgren } 4878f5b5a41STony Lindgren 4888f5b5a41STony Lindgren void __init omap3430_init_early(void) 4898f5b5a41STony Lindgren { 4907b250affSTony Lindgren omap3_init_early(); 4918f5b5a41STony Lindgren } 4928f5b5a41STony Lindgren 4938f5b5a41STony Lindgren void __init omap35xx_init_early(void) 4948f5b5a41STony Lindgren { 4957b250affSTony Lindgren omap3_init_early(); 4968f5b5a41STony Lindgren } 4978f5b5a41STony Lindgren 4988f5b5a41STony Lindgren void __init omap3630_init_early(void) 4998f5b5a41STony Lindgren { 5007b250affSTony Lindgren omap3_init_early(); 5018f5b5a41STony Lindgren } 5028f5b5a41STony Lindgren 5038f5b5a41STony Lindgren void __init am35xx_init_early(void) 5048f5b5a41STony Lindgren { 5057b250affSTony Lindgren omap3_init_early(); 5068f5b5a41STony Lindgren } 5078f5b5a41STony Lindgren 508a920360fSHemant Pedanekar void __init ti81xx_init_early(void) 5098f5b5a41STony Lindgren { 510b6a4226cSPaul Walmsley omap2_set_globals_tap(OMAP343X_CLASS, 511b6a4226cSPaul Walmsley OMAP2_L4_IO_ADDRESS(TI81XX_TAP_BASE)); 512b6a4226cSPaul Walmsley omap2_set_globals_control(OMAP2_L4_IO_ADDRESS(TI81XX_CTRL_BASE), 513b6a4226cSPaul Walmsley NULL); 514d9a16f9aSPaul Walmsley omap2_set_globals_prm(OMAP2_L4_IO_ADDRESS(TI81XX_PRCM_BASE)); 515d9a16f9aSPaul Walmsley omap2_set_globals_cm(OMAP2_L4_IO_ADDRESS(TI81XX_PRCM_BASE), NULL); 5164de34f35SVaibhav Hiremath omap3xxx_check_revision(); 5174de34f35SVaibhav Hiremath ti81xx_check_features(); 5184c3cf901STony Lindgren omap3xxx_voltagedomains_init(); 5194c3cf901STony Lindgren omap3xxx_powerdomains_init(); 5204c3cf901STony Lindgren omap3xxx_clockdomains_init(); 5214c3cf901STony Lindgren omap3xxx_hwmod_init(); 5224c3cf901STony Lindgren omap_hwmod_init_postsetup(); 523ff931c82SRajendra Nayak omap_clk_init = omap3xxx_clk_init; 5248f5b5a41STony Lindgren } 525bbd707acSShawn Guo 526bbd707acSShawn Guo void __init omap3_init_late(void) 527bbd707acSShawn Guo { 5284ed12be0SRuslan Bilovol omap_common_late_init(); 529bbd707acSShawn Guo omap3_pm_init(); 53023fb8ba3SRajendra Nayak omap2_clk_enable_autoidle_all(); 531bbd707acSShawn Guo } 532bbd707acSShawn Guo 533bbd707acSShawn Guo void __init omap3430_init_late(void) 534bbd707acSShawn Guo { 5354ed12be0SRuslan Bilovol omap_common_late_init(); 536bbd707acSShawn Guo omap3_pm_init(); 53723fb8ba3SRajendra Nayak omap2_clk_enable_autoidle_all(); 538bbd707acSShawn Guo } 539bbd707acSShawn Guo 540bbd707acSShawn Guo void __init omap35xx_init_late(void) 541bbd707acSShawn Guo { 5424ed12be0SRuslan Bilovol omap_common_late_init(); 543bbd707acSShawn Guo omap3_pm_init(); 54423fb8ba3SRajendra Nayak omap2_clk_enable_autoidle_all(); 545bbd707acSShawn Guo } 546bbd707acSShawn Guo 547bbd707acSShawn Guo void __init omap3630_init_late(void) 548bbd707acSShawn Guo { 5494ed12be0SRuslan Bilovol omap_common_late_init(); 550bbd707acSShawn Guo omap3_pm_init(); 55123fb8ba3SRajendra Nayak omap2_clk_enable_autoidle_all(); 552bbd707acSShawn Guo } 553bbd707acSShawn Guo 554bbd707acSShawn Guo void __init am35xx_init_late(void) 555bbd707acSShawn Guo { 5564ed12be0SRuslan Bilovol omap_common_late_init(); 557bbd707acSShawn Guo omap3_pm_init(); 55823fb8ba3SRajendra Nayak omap2_clk_enable_autoidle_all(); 559bbd707acSShawn Guo } 560bbd707acSShawn Guo 561bbd707acSShawn Guo void __init ti81xx_init_late(void) 562bbd707acSShawn Guo { 5634ed12be0SRuslan Bilovol omap_common_late_init(); 564bbd707acSShawn Guo omap3_pm_init(); 56523fb8ba3SRajendra Nayak omap2_clk_enable_autoidle_all(); 566bbd707acSShawn Guo } 567c4e2d245SSanjeev Premi #endif 5688f5b5a41STony Lindgren 56908f30989SAfzal Mohammed #ifdef CONFIG_SOC_AM33XX 57008f30989SAfzal Mohammed void __init am33xx_init_early(void) 57108f30989SAfzal Mohammed { 572b6a4226cSPaul Walmsley omap2_set_globals_tap(AM335X_CLASS, 573b6a4226cSPaul Walmsley AM33XX_L4_WK_IO_ADDRESS(AM33XX_TAP_BASE)); 574b6a4226cSPaul Walmsley omap2_set_globals_control(AM33XX_L4_WK_IO_ADDRESS(AM33XX_CTRL_BASE), 575b6a4226cSPaul Walmsley NULL); 576d9a16f9aSPaul Walmsley omap2_set_globals_prm(AM33XX_L4_WK_IO_ADDRESS(AM33XX_PRCM_BASE)); 577d9a16f9aSPaul Walmsley omap2_set_globals_cm(AM33XX_L4_WK_IO_ADDRESS(AM33XX_PRCM_BASE), NULL); 57808f30989SAfzal Mohammed omap3xxx_check_revision(); 57908f30989SAfzal Mohammed ti81xx_check_features(); 580ce3fc89aSVaibhav Hiremath am33xx_voltagedomains_init(); 5813f0ea764SVaibhav Hiremath am33xx_powerdomains_init(); 5829c80f3aaSVaibhav Hiremath am33xx_clockdomains_init(); 583a2cfc509SVaibhav Hiremath am33xx_hwmod_init(); 584a2cfc509SVaibhav Hiremath omap_hwmod_init_postsetup(); 585ff931c82SRajendra Nayak omap_clk_init = am33xx_clk_init; 58608f30989SAfzal Mohammed } 58708f30989SAfzal Mohammed #endif 58808f30989SAfzal Mohammed 589c4e2d245SSanjeev Premi #ifdef CONFIG_ARCH_OMAP4 5908f5b5a41STony Lindgren void __init omap4430_init_early(void) 5918f5b5a41STony Lindgren { 592b6a4226cSPaul Walmsley omap2_set_globals_tap(OMAP443X_CLASS, 593b6a4226cSPaul Walmsley OMAP2_L4_IO_ADDRESS(OMAP443X_SCM_BASE)); 594b6a4226cSPaul Walmsley omap2_set_globals_control(OMAP2_L4_IO_ADDRESS(OMAP443X_SCM_BASE), 595b6a4226cSPaul Walmsley OMAP2_L4_IO_ADDRESS(OMAP443X_CTRL_BASE)); 596d9a16f9aSPaul Walmsley omap2_set_globals_prm(OMAP2_L4_IO_ADDRESS(OMAP4430_PRM_BASE)); 597d9a16f9aSPaul Walmsley omap2_set_globals_cm(OMAP2_L4_IO_ADDRESS(OMAP4430_CM_BASE), 598d9a16f9aSPaul Walmsley OMAP2_L4_IO_ADDRESS(OMAP4430_CM2_BASE)); 599d9a16f9aSPaul Walmsley omap2_set_globals_prcm_mpu(OMAP2_L4_IO_ADDRESS(OMAP4430_PRCM_MPU_BASE)); 600d9a16f9aSPaul Walmsley omap_prm_base_init(); 601d9a16f9aSPaul Walmsley omap_cm_base_init(); 6024de34f35SVaibhav Hiremath omap4xxx_check_revision(); 6034de34f35SVaibhav Hiremath omap4xxx_check_features(); 60463a293e0SPaul Walmsley omap44xx_prm_init(); 6057b250affSTony Lindgren omap44xx_voltagedomains_init(); 6067b250affSTony Lindgren omap44xx_powerdomains_init(); 6077b250affSTony Lindgren omap44xx_clockdomains_init(); 6087b250affSTony Lindgren omap44xx_hwmod_init(); 6097b250affSTony Lindgren omap_hwmod_init_postsetup(); 610ff931c82SRajendra Nayak omap_clk_init = omap4xxx_clk_init; 6118f5b5a41STony Lindgren } 612bbd707acSShawn Guo 613bbd707acSShawn Guo void __init omap4430_init_late(void) 614bbd707acSShawn Guo { 6154ed12be0SRuslan Bilovol omap_common_late_init(); 616bbd707acSShawn Guo omap4_pm_init(); 61723fb8ba3SRajendra Nayak omap2_clk_enable_autoidle_all(); 618bbd707acSShawn Guo } 619c4e2d245SSanjeev Premi #endif 6208f5b5a41STony Lindgren 62105e152c7SR Sricharan #ifdef CONFIG_SOC_OMAP5 62205e152c7SR Sricharan void __init omap5_init_early(void) 62305e152c7SR Sricharan { 624b6a4226cSPaul Walmsley omap2_set_globals_tap(OMAP54XX_CLASS, 625b6a4226cSPaul Walmsley OMAP2_L4_IO_ADDRESS(OMAP54XX_SCM_BASE)); 626b6a4226cSPaul Walmsley omap2_set_globals_control(OMAP2_L4_IO_ADDRESS(OMAP54XX_SCM_BASE), 627b6a4226cSPaul Walmsley OMAP2_L4_IO_ADDRESS(OMAP54XX_CTRL_BASE)); 628d9a16f9aSPaul Walmsley omap2_set_globals_prm(OMAP2_L4_IO_ADDRESS(OMAP54XX_PRM_BASE)); 629d9a16f9aSPaul Walmsley omap2_set_globals_cm(OMAP2_L4_IO_ADDRESS(OMAP54XX_CM_CORE_AON_BASE), 630d9a16f9aSPaul Walmsley OMAP2_L4_IO_ADDRESS(OMAP54XX_CM_CORE_BASE)); 631d9a16f9aSPaul Walmsley omap2_set_globals_prcm_mpu(OMAP2_L4_IO_ADDRESS(OMAP54XX_PRCM_MPU_BASE)); 632d9a16f9aSPaul Walmsley omap_prm_base_init(); 633d9a16f9aSPaul Walmsley omap_cm_base_init(); 63405e152c7SR Sricharan omap5xxx_check_revision(); 63505e152c7SR Sricharan } 63605e152c7SR Sricharan #endif 63705e152c7SR Sricharan 638a4ca9dbeSTony Lindgren void __init omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0, 6394805734bSPaul Walmsley struct omap_sdrc_params *sdrc_cs1) 6404805734bSPaul Walmsley { 641a66cb345STony Lindgren omap_sram_init(); 642a66cb345STony Lindgren 64301001712SHemant Pedanekar if (cpu_is_omap24xx() || omap3_has_sdrc()) { 64458cda884SJean Pihet omap2_sdrc_init(sdrc_cs0, sdrc_cs1); 6452f135eafSPaul Walmsley _omap2_init_reprogram_sdrc(); 646aa4b1f6eSKevin Hilman } 6471dbae815STony Lindgren } 648