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> 251dbae815STony Lindgren 26120db2cbSTony Lindgren #include <asm/tlb.h> 27120db2cbSTony Lindgren 28120db2cbSTony Lindgren #include <asm/mach/map.h> 29120db2cbSTony Lindgren 30a09e64fbSRussell King #include <mach/mux.h> 31a09e64fbSRussell King #include <mach/omapfb.h> 32646e3ed1STony Lindgren #include <mach/sram.h> 33f8de9b2cSPaul Walmsley #include <mach/sdrc.h> 34f8de9b2cSPaul Walmsley #include <mach/gpmc.h> 35646e3ed1STony Lindgren 3644169075SSantosh Shilimkar #ifndef CONFIG_ARCH_OMAP4 /* FIXME: Remove this once clkdev is ready */ 37646e3ed1STony Lindgren #include "clock.h" 381dbae815STony Lindgren 399717100fSPaul Walmsley #include <mach/powerdomain.h> 409717100fSPaul Walmsley 419717100fSPaul Walmsley #include "powerdomains.h" 429717100fSPaul Walmsley 43801954d3SPaul Walmsley #include <mach/clockdomain.h> 44801954d3SPaul Walmsley #include "clockdomains.h" 4544169075SSantosh Shilimkar #endif 461dbae815STony Lindgren /* 471dbae815STony Lindgren * The machine specific code may provide the extra mapping besides the 481dbae815STony Lindgren * default mapping provided here. 491dbae815STony Lindgren */ 50cc26b3b0SSyed Mohammed, Khasim 51cc26b3b0SSyed Mohammed, Khasim #ifdef CONFIG_ARCH_OMAP24XX 52cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap24xx_io_desc[] __initdata = { 531dbae815STony Lindgren { 541dbae815STony Lindgren .virtual = L3_24XX_VIRT, 551dbae815STony Lindgren .pfn = __phys_to_pfn(L3_24XX_PHYS), 561dbae815STony Lindgren .length = L3_24XX_SIZE, 571dbae815STony Lindgren .type = MT_DEVICE 581dbae815STony Lindgren }, 5909f21ed4SKyungmin Park { 6009f21ed4SKyungmin Park .virtual = L4_24XX_VIRT, 6109f21ed4SKyungmin Park .pfn = __phys_to_pfn(L4_24XX_PHYS), 6209f21ed4SKyungmin Park .length = L4_24XX_SIZE, 6309f21ed4SKyungmin Park .type = MT_DEVICE 6409f21ed4SKyungmin Park }, 65cc26b3b0SSyed Mohammed, Khasim }; 66cc26b3b0SSyed Mohammed, Khasim 67cc26b3b0SSyed Mohammed, Khasim #ifdef CONFIG_ARCH_OMAP2420 68cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap242x_io_desc[] __initdata = { 691dbae815STony Lindgren { 70c40fae95STony Lindgren .virtual = DSP_MEM_24XX_VIRT, 71c40fae95STony Lindgren .pfn = __phys_to_pfn(DSP_MEM_24XX_PHYS), 72c40fae95STony Lindgren .length = DSP_MEM_24XX_SIZE, 73c40fae95STony Lindgren .type = MT_DEVICE 74c40fae95STony Lindgren }, 75c40fae95STony Lindgren { 76c40fae95STony Lindgren .virtual = DSP_IPI_24XX_VIRT, 77c40fae95STony Lindgren .pfn = __phys_to_pfn(DSP_IPI_24XX_PHYS), 78c40fae95STony Lindgren .length = DSP_IPI_24XX_SIZE, 79c40fae95STony Lindgren .type = MT_DEVICE 80c40fae95STony Lindgren }, 81c40fae95STony Lindgren { 82c40fae95STony Lindgren .virtual = DSP_MMU_24XX_VIRT, 83c40fae95STony Lindgren .pfn = __phys_to_pfn(DSP_MMU_24XX_PHYS), 84c40fae95STony Lindgren .length = DSP_MMU_24XX_SIZE, 851dbae815STony Lindgren .type = MT_DEVICE 86cc26b3b0SSyed Mohammed, Khasim }, 871dbae815STony Lindgren }; 881dbae815STony Lindgren 89cc26b3b0SSyed Mohammed, Khasim #endif 90cc26b3b0SSyed Mohammed, Khasim 91cc26b3b0SSyed Mohammed, Khasim #ifdef CONFIG_ARCH_OMAP2430 92cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap243x_io_desc[] __initdata = { 93cc26b3b0SSyed Mohammed, Khasim { 94cc26b3b0SSyed Mohammed, Khasim .virtual = L4_WK_243X_VIRT, 95cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(L4_WK_243X_PHYS), 96cc26b3b0SSyed Mohammed, Khasim .length = L4_WK_243X_SIZE, 97cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 98cc26b3b0SSyed Mohammed, Khasim }, 99cc26b3b0SSyed Mohammed, Khasim { 100cc26b3b0SSyed Mohammed, Khasim .virtual = OMAP243X_GPMC_VIRT, 101cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(OMAP243X_GPMC_PHYS), 102cc26b3b0SSyed Mohammed, Khasim .length = OMAP243X_GPMC_SIZE, 103cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 104cc26b3b0SSyed Mohammed, Khasim }, 105cc26b3b0SSyed Mohammed, Khasim { 106cc26b3b0SSyed Mohammed, Khasim .virtual = OMAP243X_SDRC_VIRT, 107cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(OMAP243X_SDRC_PHYS), 108cc26b3b0SSyed Mohammed, Khasim .length = OMAP243X_SDRC_SIZE, 109cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 110cc26b3b0SSyed Mohammed, Khasim }, 111cc26b3b0SSyed Mohammed, Khasim { 112cc26b3b0SSyed Mohammed, Khasim .virtual = OMAP243X_SMS_VIRT, 113cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(OMAP243X_SMS_PHYS), 114cc26b3b0SSyed Mohammed, Khasim .length = OMAP243X_SMS_SIZE, 115cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 116cc26b3b0SSyed Mohammed, Khasim }, 117cc26b3b0SSyed Mohammed, Khasim }; 118cc26b3b0SSyed Mohammed, Khasim #endif 119cc26b3b0SSyed Mohammed, Khasim #endif 120cc26b3b0SSyed Mohammed, Khasim 121cc26b3b0SSyed Mohammed, Khasim #ifdef CONFIG_ARCH_OMAP34XX 122cc26b3b0SSyed Mohammed, Khasim static struct map_desc omap34xx_io_desc[] __initdata = { 123cc26b3b0SSyed Mohammed, Khasim { 124cc26b3b0SSyed Mohammed, Khasim .virtual = L3_34XX_VIRT, 125cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(L3_34XX_PHYS), 126cc26b3b0SSyed Mohammed, Khasim .length = L3_34XX_SIZE, 127cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 128cc26b3b0SSyed Mohammed, Khasim }, 129cc26b3b0SSyed Mohammed, Khasim { 130cc26b3b0SSyed Mohammed, Khasim .virtual = L4_34XX_VIRT, 131cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(L4_34XX_PHYS), 132cc26b3b0SSyed Mohammed, Khasim .length = L4_34XX_SIZE, 133cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 134cc26b3b0SSyed Mohammed, Khasim }, 135cc26b3b0SSyed Mohammed, Khasim { 136cc26b3b0SSyed Mohammed, Khasim .virtual = L4_WK_34XX_VIRT, 137cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(L4_WK_34XX_PHYS), 138cc26b3b0SSyed Mohammed, Khasim .length = L4_WK_34XX_SIZE, 139cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 140cc26b3b0SSyed Mohammed, Khasim }, 141cc26b3b0SSyed Mohammed, Khasim { 142cc26b3b0SSyed Mohammed, Khasim .virtual = OMAP34XX_GPMC_VIRT, 143cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(OMAP34XX_GPMC_PHYS), 144cc26b3b0SSyed Mohammed, Khasim .length = OMAP34XX_GPMC_SIZE, 145cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 146cc26b3b0SSyed Mohammed, Khasim }, 147cc26b3b0SSyed Mohammed, Khasim { 148cc26b3b0SSyed Mohammed, Khasim .virtual = OMAP343X_SMS_VIRT, 149cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(OMAP343X_SMS_PHYS), 150cc26b3b0SSyed Mohammed, Khasim .length = OMAP343X_SMS_SIZE, 151cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 152cc26b3b0SSyed Mohammed, Khasim }, 153cc26b3b0SSyed Mohammed, Khasim { 154cc26b3b0SSyed Mohammed, Khasim .virtual = OMAP343X_SDRC_VIRT, 155cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(OMAP343X_SDRC_PHYS), 156cc26b3b0SSyed Mohammed, Khasim .length = OMAP343X_SDRC_SIZE, 157cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 158cc26b3b0SSyed Mohammed, Khasim }, 159cc26b3b0SSyed Mohammed, Khasim { 160cc26b3b0SSyed Mohammed, Khasim .virtual = L4_PER_34XX_VIRT, 161cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(L4_PER_34XX_PHYS), 162cc26b3b0SSyed Mohammed, Khasim .length = L4_PER_34XX_SIZE, 163cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 164cc26b3b0SSyed Mohammed, Khasim }, 165cc26b3b0SSyed Mohammed, Khasim { 166cc26b3b0SSyed Mohammed, Khasim .virtual = L4_EMU_34XX_VIRT, 167cc26b3b0SSyed Mohammed, Khasim .pfn = __phys_to_pfn(L4_EMU_34XX_PHYS), 168cc26b3b0SSyed Mohammed, Khasim .length = L4_EMU_34XX_SIZE, 169cc26b3b0SSyed Mohammed, Khasim .type = MT_DEVICE 170cc26b3b0SSyed Mohammed, Khasim }, 171cc26b3b0SSyed Mohammed, Khasim }; 172cc26b3b0SSyed Mohammed, Khasim #endif 17344169075SSantosh Shilimkar #ifdef CONFIG_ARCH_OMAP4 17444169075SSantosh Shilimkar static struct map_desc omap44xx_io_desc[] __initdata = { 17544169075SSantosh Shilimkar { 17644169075SSantosh Shilimkar .virtual = L3_44XX_VIRT, 17744169075SSantosh Shilimkar .pfn = __phys_to_pfn(L3_44XX_PHYS), 17844169075SSantosh Shilimkar .length = L3_44XX_SIZE, 17944169075SSantosh Shilimkar .type = MT_DEVICE, 18044169075SSantosh Shilimkar }, 18144169075SSantosh Shilimkar { 18244169075SSantosh Shilimkar .virtual = L4_44XX_VIRT, 18344169075SSantosh Shilimkar .pfn = __phys_to_pfn(L4_44XX_PHYS), 18444169075SSantosh Shilimkar .length = L4_44XX_SIZE, 18544169075SSantosh Shilimkar .type = MT_DEVICE, 18644169075SSantosh Shilimkar }, 18744169075SSantosh Shilimkar { 18844169075SSantosh Shilimkar .virtual = L4_WK_44XX_VIRT, 18944169075SSantosh Shilimkar .pfn = __phys_to_pfn(L4_WK_44XX_PHYS), 19044169075SSantosh Shilimkar .length = L4_WK_44XX_SIZE, 19144169075SSantosh Shilimkar .type = MT_DEVICE, 19244169075SSantosh Shilimkar }, 19344169075SSantosh Shilimkar { 19444169075SSantosh Shilimkar .virtual = OMAP44XX_GPMC_VIRT, 19544169075SSantosh Shilimkar .pfn = __phys_to_pfn(OMAP44XX_GPMC_PHYS), 19644169075SSantosh Shilimkar .length = OMAP44XX_GPMC_SIZE, 19744169075SSantosh Shilimkar .type = MT_DEVICE, 19844169075SSantosh Shilimkar }, 19944169075SSantosh Shilimkar { 20044169075SSantosh Shilimkar .virtual = L4_PER_44XX_VIRT, 20144169075SSantosh Shilimkar .pfn = __phys_to_pfn(L4_PER_44XX_PHYS), 20244169075SSantosh Shilimkar .length = L4_PER_44XX_SIZE, 20344169075SSantosh Shilimkar .type = MT_DEVICE, 20444169075SSantosh Shilimkar }, 20544169075SSantosh Shilimkar { 20644169075SSantosh Shilimkar .virtual = L4_EMU_44XX_VIRT, 20744169075SSantosh Shilimkar .pfn = __phys_to_pfn(L4_EMU_44XX_PHYS), 20844169075SSantosh Shilimkar .length = L4_EMU_44XX_SIZE, 20944169075SSantosh Shilimkar .type = MT_DEVICE, 21044169075SSantosh Shilimkar }, 21144169075SSantosh Shilimkar }; 21244169075SSantosh Shilimkar #endif 213cc26b3b0SSyed Mohammed, Khasim 214120db2cbSTony Lindgren void __init omap2_map_common_io(void) 2151dbae815STony Lindgren { 216cc26b3b0SSyed Mohammed, Khasim #if defined(CONFIG_ARCH_OMAP2420) 217cc26b3b0SSyed Mohammed, Khasim iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc)); 218cc26b3b0SSyed Mohammed, Khasim iotable_init(omap242x_io_desc, ARRAY_SIZE(omap242x_io_desc)); 219cc26b3b0SSyed Mohammed, Khasim #endif 220cc26b3b0SSyed Mohammed, Khasim 221cc26b3b0SSyed Mohammed, Khasim #if defined(CONFIG_ARCH_OMAP2430) 222cc26b3b0SSyed Mohammed, Khasim iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc)); 223cc26b3b0SSyed Mohammed, Khasim iotable_init(omap243x_io_desc, ARRAY_SIZE(omap243x_io_desc)); 224cc26b3b0SSyed Mohammed, Khasim #endif 225cc26b3b0SSyed Mohammed, Khasim 226cc26b3b0SSyed Mohammed, Khasim #if defined(CONFIG_ARCH_OMAP34XX) 227cc26b3b0SSyed Mohammed, Khasim iotable_init(omap34xx_io_desc, ARRAY_SIZE(omap34xx_io_desc)); 228cc26b3b0SSyed Mohammed, Khasim #endif 229120db2cbSTony Lindgren 23044169075SSantosh Shilimkar #if defined(CONFIG_ARCH_OMAP4) 23144169075SSantosh Shilimkar iotable_init(omap44xx_io_desc, ARRAY_SIZE(omap44xx_io_desc)); 23244169075SSantosh Shilimkar #endif 233120db2cbSTony Lindgren /* Normally devicemaps_init() would flush caches and tlb after 234120db2cbSTony Lindgren * mdesc->map_io(), but we must also do it here because of the CPU 235120db2cbSTony Lindgren * revision check below. 236120db2cbSTony Lindgren */ 237120db2cbSTony Lindgren local_flush_tlb_all(); 238120db2cbSTony Lindgren flush_cache_all(); 239120db2cbSTony Lindgren 2401dbae815STony Lindgren omap2_check_revision(); 2411dbae815STony Lindgren omap_sram_init(); 242b7cc6d46SImre Deak omapfb_reserve_sdram(); 243120db2cbSTony Lindgren } 244120db2cbSTony Lindgren 2452f135eafSPaul Walmsley /* 2462f135eafSPaul Walmsley * omap2_init_reprogram_sdrc - reprogram SDRC timing parameters 2472f135eafSPaul Walmsley * 2482f135eafSPaul Walmsley * Sets the CORE DPLL3 M2 divider to the same value that it's at 2492f135eafSPaul Walmsley * currently. This has the effect of setting the SDRC SDRAM AC timing 2502f135eafSPaul Walmsley * registers to the values currently defined by the kernel. Currently 2512f135eafSPaul Walmsley * only defined for OMAP3; will return 0 if called on OMAP2. Returns 2522f135eafSPaul Walmsley * -EINVAL if the dpll3_m2_ck cannot be found, 0 if called on OMAP2, 2532f135eafSPaul Walmsley * or passes along the return value of clk_set_rate(). 2542f135eafSPaul Walmsley */ 2552f135eafSPaul Walmsley static int __init _omap2_init_reprogram_sdrc(void) 2562f135eafSPaul Walmsley { 2572f135eafSPaul Walmsley struct clk *dpll3_m2_ck; 2582f135eafSPaul Walmsley int v = -EINVAL; 2592f135eafSPaul Walmsley long rate; 2602f135eafSPaul Walmsley 2612f135eafSPaul Walmsley if (!cpu_is_omap34xx()) 2622f135eafSPaul Walmsley return 0; 2632f135eafSPaul Walmsley 2642f135eafSPaul Walmsley dpll3_m2_ck = clk_get(NULL, "dpll3_m2_ck"); 2652f135eafSPaul Walmsley if (!dpll3_m2_ck) 2662f135eafSPaul Walmsley return -EINVAL; 2672f135eafSPaul Walmsley 2682f135eafSPaul Walmsley rate = clk_get_rate(dpll3_m2_ck); 2692f135eafSPaul Walmsley pr_info("Reprogramming SDRC clock to %ld Hz\n", rate); 2702f135eafSPaul Walmsley v = clk_set_rate(dpll3_m2_ck, rate); 2712f135eafSPaul Walmsley if (v) 2722f135eafSPaul Walmsley pr_err("dpll3_m2_clk rate change failed: %d\n", v); 2732f135eafSPaul Walmsley 2742f135eafSPaul Walmsley clk_put(dpll3_m2_ck); 2752f135eafSPaul Walmsley 2762f135eafSPaul Walmsley return v; 2772f135eafSPaul Walmsley } 2782f135eafSPaul Walmsley 279*58cda884SJean Pihet void __init omap2_init_common_hw(struct omap_sdrc_params *sdrc_cs0, 280*58cda884SJean Pihet struct omap_sdrc_params *sdrc_cs1) 281120db2cbSTony Lindgren { 2821dbae815STony Lindgren omap2_mux_init(); 28344169075SSantosh Shilimkar #ifndef CONFIG_ARCH_OMAP4 /* FIXME: Remove this once the clkdev is ready */ 2849717100fSPaul Walmsley pwrdm_init(powerdomains_omap); 285801954d3SPaul Walmsley clkdm_init(clockdomains_omap, clkdm_pwrdm_autodeps); 2861dbae815STony Lindgren omap2_clk_init(); 287*58cda884SJean Pihet omap2_sdrc_init(sdrc_cs0, sdrc_cs1); 2882f135eafSPaul Walmsley _omap2_init_reprogram_sdrc(); 28944169075SSantosh Shilimkar #endif 2904bbbc1adSJuha Yrjola gpmc_init(); 2911dbae815STony Lindgren } 292