169d88a00SPaul Walmsley /* 269d88a00SPaul Walmsley * OMAP2/3 System Control Module register access 369d88a00SPaul Walmsley * 469d88a00SPaul Walmsley * Copyright (C) 2007 Texas Instruments, Inc. 569d88a00SPaul Walmsley * Copyright (C) 2007 Nokia Corporation 669d88a00SPaul Walmsley * 769d88a00SPaul Walmsley * Written by Paul Walmsley 869d88a00SPaul Walmsley * 969d88a00SPaul Walmsley * This program is free software; you can redistribute it and/or modify 1069d88a00SPaul Walmsley * it under the terms of the GNU General Public License version 2 as 1169d88a00SPaul Walmsley * published by the Free Software Foundation. 1269d88a00SPaul Walmsley */ 1369d88a00SPaul Walmsley #undef DEBUG 1469d88a00SPaul Walmsley 1569d88a00SPaul Walmsley #include <linux/kernel.h> 16a58caad1STony Lindgren #include <linux/io.h> 1769d88a00SPaul Walmsley 18ce491cf8STony Lindgren #include <plat/common.h> 19ce491cf8STony Lindgren #include <plat/control.h> 2080140786SRajendra Nayak #include <plat/sdrc.h> 2180140786SRajendra Nayak #include "cm-regbits-34xx.h" 2280140786SRajendra Nayak #include "prm-regbits-34xx.h" 2380140786SRajendra Nayak #include "cm.h" 2480140786SRajendra Nayak #include "prm.h" 2580140786SRajendra Nayak #include "sdrc.h" 2669d88a00SPaul Walmsley 27a58caad1STony Lindgren static void __iomem *omap2_ctrl_base; 280c349246SSantosh Shilimkar static void __iomem *omap4_ctrl_pad_base; 2969d88a00SPaul Walmsley 30c96631e1SRajendra Nayak #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM) 3180140786SRajendra Nayak struct omap3_scratchpad { 3280140786SRajendra Nayak u32 boot_config_ptr; 3380140786SRajendra Nayak u32 public_restore_ptr; 3480140786SRajendra Nayak u32 secure_ram_restore_ptr; 3580140786SRajendra Nayak u32 sdrc_module_semaphore; 3680140786SRajendra Nayak u32 prcm_block_offset; 3780140786SRajendra Nayak u32 sdrc_block_offset; 3880140786SRajendra Nayak }; 3980140786SRajendra Nayak 4080140786SRajendra Nayak struct omap3_scratchpad_prcm_block { 4180140786SRajendra Nayak u32 prm_clksrc_ctrl; 4280140786SRajendra Nayak u32 prm_clksel; 4380140786SRajendra Nayak u32 cm_clksel_core; 4480140786SRajendra Nayak u32 cm_clksel_wkup; 4580140786SRajendra Nayak u32 cm_clken_pll; 4680140786SRajendra Nayak u32 cm_autoidle_pll; 4780140786SRajendra Nayak u32 cm_clksel1_pll; 4880140786SRajendra Nayak u32 cm_clksel2_pll; 4980140786SRajendra Nayak u32 cm_clksel3_pll; 5080140786SRajendra Nayak u32 cm_clken_pll_mpu; 5180140786SRajendra Nayak u32 cm_autoidle_pll_mpu; 5280140786SRajendra Nayak u32 cm_clksel1_pll_mpu; 5380140786SRajendra Nayak u32 cm_clksel2_pll_mpu; 5480140786SRajendra Nayak u32 prcm_block_size; 5580140786SRajendra Nayak }; 5680140786SRajendra Nayak 5780140786SRajendra Nayak struct omap3_scratchpad_sdrc_block { 5880140786SRajendra Nayak u16 sysconfig; 5980140786SRajendra Nayak u16 cs_cfg; 6080140786SRajendra Nayak u16 sharing; 6180140786SRajendra Nayak u16 err_type; 6280140786SRajendra Nayak u32 dll_a_ctrl; 6380140786SRajendra Nayak u32 dll_b_ctrl; 6480140786SRajendra Nayak u32 power; 6580140786SRajendra Nayak u32 cs_0; 6680140786SRajendra Nayak u32 mcfg_0; 6780140786SRajendra Nayak u16 mr_0; 6880140786SRajendra Nayak u16 emr_1_0; 6980140786SRajendra Nayak u16 emr_2_0; 7080140786SRajendra Nayak u16 emr_3_0; 7180140786SRajendra Nayak u32 actim_ctrla_0; 7280140786SRajendra Nayak u32 actim_ctrlb_0; 7380140786SRajendra Nayak u32 rfr_ctrl_0; 7480140786SRajendra Nayak u32 cs_1; 7580140786SRajendra Nayak u32 mcfg_1; 7680140786SRajendra Nayak u16 mr_1; 7780140786SRajendra Nayak u16 emr_1_1; 7880140786SRajendra Nayak u16 emr_2_1; 7980140786SRajendra Nayak u16 emr_3_1; 8080140786SRajendra Nayak u32 actim_ctrla_1; 8180140786SRajendra Nayak u32 actim_ctrlb_1; 8280140786SRajendra Nayak u32 rfr_ctrl_1; 8380140786SRajendra Nayak u16 dcdl_1_ctrl; 8480140786SRajendra Nayak u16 dcdl_2_ctrl; 8580140786SRajendra Nayak u32 flags; 8680140786SRajendra Nayak u32 block_size; 8780140786SRajendra Nayak }; 8880140786SRajendra Nayak 8927d59a4aSTero Kristo void *omap3_secure_ram_storage; 9027d59a4aSTero Kristo 9180140786SRajendra Nayak /* 9280140786SRajendra Nayak * This is used to store ARM registers in SDRAM before attempting 9380140786SRajendra Nayak * an MPU OFF. The save and restore happens from the SRAM sleep code. 9480140786SRajendra Nayak * The address is stored in scratchpad, so that it can be used 9580140786SRajendra Nayak * during the restore path. 9680140786SRajendra Nayak */ 9780140786SRajendra Nayak u32 omap3_arm_context[128]; 9880140786SRajendra Nayak 99c96631e1SRajendra Nayak struct omap3_control_regs { 100c96631e1SRajendra Nayak u32 sysconfig; 101c96631e1SRajendra Nayak u32 devconf0; 102c96631e1SRajendra Nayak u32 mem_dftrw0; 103c96631e1SRajendra Nayak u32 mem_dftrw1; 104c96631e1SRajendra Nayak u32 msuspendmux_0; 105c96631e1SRajendra Nayak u32 msuspendmux_1; 106c96631e1SRajendra Nayak u32 msuspendmux_2; 107c96631e1SRajendra Nayak u32 msuspendmux_3; 108c96631e1SRajendra Nayak u32 msuspendmux_4; 109c96631e1SRajendra Nayak u32 msuspendmux_5; 110c96631e1SRajendra Nayak u32 sec_ctrl; 111c96631e1SRajendra Nayak u32 devconf1; 112c96631e1SRajendra Nayak u32 csirxfe; 113c96631e1SRajendra Nayak u32 iva2_bootaddr; 114c96631e1SRajendra Nayak u32 iva2_bootmod; 115c96631e1SRajendra Nayak u32 debobs_0; 116c96631e1SRajendra Nayak u32 debobs_1; 117c96631e1SRajendra Nayak u32 debobs_2; 118c96631e1SRajendra Nayak u32 debobs_3; 119c96631e1SRajendra Nayak u32 debobs_4; 120c96631e1SRajendra Nayak u32 debobs_5; 121c96631e1SRajendra Nayak u32 debobs_6; 122c96631e1SRajendra Nayak u32 debobs_7; 123c96631e1SRajendra Nayak u32 debobs_8; 124c96631e1SRajendra Nayak u32 prog_io0; 125c96631e1SRajendra Nayak u32 prog_io1; 126c96631e1SRajendra Nayak u32 dss_dpll_spreading; 127c96631e1SRajendra Nayak u32 core_dpll_spreading; 128c96631e1SRajendra Nayak u32 per_dpll_spreading; 129c96631e1SRajendra Nayak u32 usbhost_dpll_spreading; 130c96631e1SRajendra Nayak u32 pbias_lite; 131c96631e1SRajendra Nayak u32 temp_sensor; 132c96631e1SRajendra Nayak u32 sramldo4; 133c96631e1SRajendra Nayak u32 sramldo5; 134c96631e1SRajendra Nayak u32 csi; 135c96631e1SRajendra Nayak }; 136c96631e1SRajendra Nayak 137c96631e1SRajendra Nayak static struct omap3_control_regs control_context; 138c96631e1SRajendra Nayak #endif /* CONFIG_ARCH_OMAP3 && CONFIG_PM */ 139c96631e1SRajendra Nayak 140a58caad1STony Lindgren #define OMAP_CTRL_REGADDR(reg) (omap2_ctrl_base + (reg)) 141*70ba71a2SSantosh Shilimkar #define OMAP4_CTRL_PAD_REGADDR(reg) (omap4_ctrl_pad_base + (reg)) 14269d88a00SPaul Walmsley 143a58caad1STony Lindgren void __init omap2_set_globals_control(struct omap_globals *omap2_globals) 14469d88a00SPaul Walmsley { 145b7ebb10bSSantosh Shilimkar /* Static mapping, never released */ 146b7ebb10bSSantosh Shilimkar if (omap2_globals->ctrl) { 147b7ebb10bSSantosh Shilimkar omap2_ctrl_base = ioremap(omap2_globals->ctrl, SZ_4K); 148b7ebb10bSSantosh Shilimkar WARN_ON(!omap2_ctrl_base); 149b7ebb10bSSantosh Shilimkar } 1500c349246SSantosh Shilimkar 1510c349246SSantosh Shilimkar /* Static mapping, never released */ 1520c349246SSantosh Shilimkar if (omap2_globals->ctrl_pad) { 1530c349246SSantosh Shilimkar omap4_ctrl_pad_base = ioremap(omap2_globals->ctrl_pad, SZ_4K); 1540c349246SSantosh Shilimkar WARN_ON(!omap4_ctrl_pad_base); 1550c349246SSantosh Shilimkar } 15669d88a00SPaul Walmsley } 15769d88a00SPaul Walmsley 158a58caad1STony Lindgren void __iomem *omap_ctrl_base_get(void) 15969d88a00SPaul Walmsley { 16069d88a00SPaul Walmsley return omap2_ctrl_base; 16169d88a00SPaul Walmsley } 16269d88a00SPaul Walmsley 16369d88a00SPaul Walmsley u8 omap_ctrl_readb(u16 offset) 16469d88a00SPaul Walmsley { 16569d88a00SPaul Walmsley return __raw_readb(OMAP_CTRL_REGADDR(offset)); 16669d88a00SPaul Walmsley } 16769d88a00SPaul Walmsley 16869d88a00SPaul Walmsley u16 omap_ctrl_readw(u16 offset) 16969d88a00SPaul Walmsley { 17069d88a00SPaul Walmsley return __raw_readw(OMAP_CTRL_REGADDR(offset)); 17169d88a00SPaul Walmsley } 17269d88a00SPaul Walmsley 17369d88a00SPaul Walmsley u32 omap_ctrl_readl(u16 offset) 17469d88a00SPaul Walmsley { 17569d88a00SPaul Walmsley return __raw_readl(OMAP_CTRL_REGADDR(offset)); 17669d88a00SPaul Walmsley } 17769d88a00SPaul Walmsley 17869d88a00SPaul Walmsley void omap_ctrl_writeb(u8 val, u16 offset) 17969d88a00SPaul Walmsley { 18069d88a00SPaul Walmsley __raw_writeb(val, OMAP_CTRL_REGADDR(offset)); 18169d88a00SPaul Walmsley } 18269d88a00SPaul Walmsley 18369d88a00SPaul Walmsley void omap_ctrl_writew(u16 val, u16 offset) 18469d88a00SPaul Walmsley { 18569d88a00SPaul Walmsley __raw_writew(val, OMAP_CTRL_REGADDR(offset)); 18669d88a00SPaul Walmsley } 18769d88a00SPaul Walmsley 18869d88a00SPaul Walmsley void omap_ctrl_writel(u32 val, u16 offset) 18969d88a00SPaul Walmsley { 19069d88a00SPaul Walmsley __raw_writel(val, OMAP_CTRL_REGADDR(offset)); 19169d88a00SPaul Walmsley } 19269d88a00SPaul Walmsley 193*70ba71a2SSantosh Shilimkar /* 194*70ba71a2SSantosh Shilimkar * On OMAP4 control pad are not addressable from control 195*70ba71a2SSantosh Shilimkar * core base. So the common omap_ctrl_read/write APIs breaks 196*70ba71a2SSantosh Shilimkar * Hence export separate APIs to manage the omap4 pad control 197*70ba71a2SSantosh Shilimkar * registers. This APIs will work only for OMAP4 198*70ba71a2SSantosh Shilimkar */ 199*70ba71a2SSantosh Shilimkar 200*70ba71a2SSantosh Shilimkar u32 omap4_ctrl_pad_readl(u16 offset) 201*70ba71a2SSantosh Shilimkar { 202*70ba71a2SSantosh Shilimkar return __raw_readl(OMAP4_CTRL_PAD_REGADDR(offset)); 203*70ba71a2SSantosh Shilimkar } 204*70ba71a2SSantosh Shilimkar 205*70ba71a2SSantosh Shilimkar void omap4_ctrl_pad_writel(u32 val, u16 offset) 206*70ba71a2SSantosh Shilimkar { 207*70ba71a2SSantosh Shilimkar __raw_writel(val, OMAP4_CTRL_PAD_REGADDR(offset)); 208*70ba71a2SSantosh Shilimkar } 209*70ba71a2SSantosh Shilimkar 210c96631e1SRajendra Nayak #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM) 21180140786SRajendra Nayak /* 21280140786SRajendra Nayak * Clears the scratchpad contents in case of cold boot- 21380140786SRajendra Nayak * called during bootup 21480140786SRajendra Nayak */ 21580140786SRajendra Nayak void omap3_clear_scratchpad_contents(void) 21680140786SRajendra Nayak { 21780140786SRajendra Nayak u32 max_offset = OMAP343X_SCRATCHPAD_ROM_OFFSET; 21880140786SRajendra Nayak u32 *v_addr; 21980140786SRajendra Nayak u32 offset = 0; 22080140786SRajendra Nayak v_addr = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD_ROM); 22180140786SRajendra Nayak if (prm_read_mod_reg(OMAP3430_GR_MOD, OMAP3_PRM_RSTST_OFFSET) & 2222bc4ef71SPaul Walmsley OMAP3430_GLOBAL_COLD_RST_MASK) { 22380140786SRajendra Nayak for ( ; offset <= max_offset; offset += 0x4) 22480140786SRajendra Nayak __raw_writel(0x0, (v_addr + offset)); 2252bc4ef71SPaul Walmsley prm_set_mod_reg_bits(OMAP3430_GLOBAL_COLD_RST_MASK, 2262bc4ef71SPaul Walmsley OMAP3430_GR_MOD, 22780140786SRajendra Nayak OMAP3_PRM_RSTST_OFFSET); 22880140786SRajendra Nayak } 22980140786SRajendra Nayak } 23080140786SRajendra Nayak 23180140786SRajendra Nayak /* Populate the scratchpad structure with restore structure */ 23280140786SRajendra Nayak void omap3_save_scratchpad_contents(void) 23380140786SRajendra Nayak { 23480140786SRajendra Nayak void * __iomem scratchpad_address; 23580140786SRajendra Nayak u32 arm_context_addr; 23680140786SRajendra Nayak struct omap3_scratchpad scratchpad_contents; 23780140786SRajendra Nayak struct omap3_scratchpad_prcm_block prcm_block_contents; 23880140786SRajendra Nayak struct omap3_scratchpad_sdrc_block sdrc_block_contents; 23980140786SRajendra Nayak 24080140786SRajendra Nayak /* Populate the Scratchpad contents */ 24180140786SRajendra Nayak scratchpad_contents.boot_config_ptr = 0x0; 2420795a75aSTero Kristo if (omap_rev() != OMAP3430_REV_ES3_0 && 2430795a75aSTero Kristo omap_rev() != OMAP3430_REV_ES3_1) 24480140786SRajendra Nayak scratchpad_contents.public_restore_ptr = 24580140786SRajendra Nayak virt_to_phys(get_restore_pointer()); 2460795a75aSTero Kristo else 2470795a75aSTero Kristo scratchpad_contents.public_restore_ptr = 2480795a75aSTero Kristo virt_to_phys(get_es3_restore_pointer()); 24927d59a4aSTero Kristo if (omap_type() == OMAP2_DEVICE_TYPE_GP) 25080140786SRajendra Nayak scratchpad_contents.secure_ram_restore_ptr = 0x0; 25127d59a4aSTero Kristo else 25227d59a4aSTero Kristo scratchpad_contents.secure_ram_restore_ptr = 25327d59a4aSTero Kristo (u32) __pa(omap3_secure_ram_storage); 25480140786SRajendra Nayak scratchpad_contents.sdrc_module_semaphore = 0x0; 25580140786SRajendra Nayak scratchpad_contents.prcm_block_offset = 0x2C; 25680140786SRajendra Nayak scratchpad_contents.sdrc_block_offset = 0x64; 25780140786SRajendra Nayak 25880140786SRajendra Nayak /* Populate the PRCM block contents */ 25980140786SRajendra Nayak prcm_block_contents.prm_clksrc_ctrl = prm_read_mod_reg(OMAP3430_GR_MOD, 26080140786SRajendra Nayak OMAP3_PRM_CLKSRC_CTRL_OFFSET); 26180140786SRajendra Nayak prcm_block_contents.prm_clksel = prm_read_mod_reg(OMAP3430_CCR_MOD, 26280140786SRajendra Nayak OMAP3_PRM_CLKSEL_OFFSET); 26380140786SRajendra Nayak prcm_block_contents.cm_clksel_core = 26480140786SRajendra Nayak cm_read_mod_reg(CORE_MOD, CM_CLKSEL); 26580140786SRajendra Nayak prcm_block_contents.cm_clksel_wkup = 26680140786SRajendra Nayak cm_read_mod_reg(WKUP_MOD, CM_CLKSEL); 26780140786SRajendra Nayak prcm_block_contents.cm_clken_pll = 268cb0cb2b8SKalle Jokiniemi cm_read_mod_reg(PLL_MOD, CM_CLKEN); 26980140786SRajendra Nayak prcm_block_contents.cm_autoidle_pll = 27080140786SRajendra Nayak cm_read_mod_reg(PLL_MOD, OMAP3430_CM_AUTOIDLE_PLL); 27180140786SRajendra Nayak prcm_block_contents.cm_clksel1_pll = 27280140786SRajendra Nayak cm_read_mod_reg(PLL_MOD, OMAP3430_CM_CLKSEL1_PLL); 27380140786SRajendra Nayak prcm_block_contents.cm_clksel2_pll = 27480140786SRajendra Nayak cm_read_mod_reg(PLL_MOD, OMAP3430_CM_CLKSEL2_PLL); 27580140786SRajendra Nayak prcm_block_contents.cm_clksel3_pll = 27680140786SRajendra Nayak cm_read_mod_reg(PLL_MOD, OMAP3430_CM_CLKSEL3); 27780140786SRajendra Nayak prcm_block_contents.cm_clken_pll_mpu = 27880140786SRajendra Nayak cm_read_mod_reg(MPU_MOD, OMAP3430_CM_CLKEN_PLL); 27980140786SRajendra Nayak prcm_block_contents.cm_autoidle_pll_mpu = 28080140786SRajendra Nayak cm_read_mod_reg(MPU_MOD, OMAP3430_CM_AUTOIDLE_PLL); 28180140786SRajendra Nayak prcm_block_contents.cm_clksel1_pll_mpu = 28280140786SRajendra Nayak cm_read_mod_reg(MPU_MOD, OMAP3430_CM_CLKSEL1_PLL); 28380140786SRajendra Nayak prcm_block_contents.cm_clksel2_pll_mpu = 28480140786SRajendra Nayak cm_read_mod_reg(MPU_MOD, OMAP3430_CM_CLKSEL2_PLL); 28580140786SRajendra Nayak prcm_block_contents.prcm_block_size = 0x0; 28680140786SRajendra Nayak 28780140786SRajendra Nayak /* Populate the SDRC block contents */ 28880140786SRajendra Nayak sdrc_block_contents.sysconfig = 28980140786SRajendra Nayak (sdrc_read_reg(SDRC_SYSCONFIG) & 0xFFFF); 29080140786SRajendra Nayak sdrc_block_contents.cs_cfg = 29180140786SRajendra Nayak (sdrc_read_reg(SDRC_CS_CFG) & 0xFFFF); 29280140786SRajendra Nayak sdrc_block_contents.sharing = 29380140786SRajendra Nayak (sdrc_read_reg(SDRC_SHARING) & 0xFFFF); 29480140786SRajendra Nayak sdrc_block_contents.err_type = 29580140786SRajendra Nayak (sdrc_read_reg(SDRC_ERR_TYPE) & 0xFFFF); 29680140786SRajendra Nayak sdrc_block_contents.dll_a_ctrl = sdrc_read_reg(SDRC_DLLA_CTRL); 29780140786SRajendra Nayak sdrc_block_contents.dll_b_ctrl = 0x0; 298f265dc4cSRajendra Nayak /* 299f265dc4cSRajendra Nayak * Due to a OMAP3 errata (1.142), on EMU/HS devices SRDC should 300f265dc4cSRajendra Nayak * be programed to issue automatic self refresh on timeout 301f265dc4cSRajendra Nayak * of AUTO_CNT = 1 prior to any transition to OFF mode. 302f265dc4cSRajendra Nayak */ 303f265dc4cSRajendra Nayak if ((omap_type() != OMAP2_DEVICE_TYPE_GP) 304f265dc4cSRajendra Nayak && (omap_rev() >= OMAP3430_REV_ES3_0)) 305f265dc4cSRajendra Nayak sdrc_block_contents.power = (sdrc_read_reg(SDRC_POWER) & 306f265dc4cSRajendra Nayak ~(SDRC_POWER_AUTOCOUNT_MASK| 307f265dc4cSRajendra Nayak SDRC_POWER_CLKCTRL_MASK)) | 308f265dc4cSRajendra Nayak (1 << SDRC_POWER_AUTOCOUNT_SHIFT) | 309f265dc4cSRajendra Nayak SDRC_SELF_REFRESH_ON_AUTOCOUNT; 310f265dc4cSRajendra Nayak else 31180140786SRajendra Nayak sdrc_block_contents.power = sdrc_read_reg(SDRC_POWER); 312f265dc4cSRajendra Nayak 31380140786SRajendra Nayak sdrc_block_contents.cs_0 = 0x0; 31480140786SRajendra Nayak sdrc_block_contents.mcfg_0 = sdrc_read_reg(SDRC_MCFG_0); 31580140786SRajendra Nayak sdrc_block_contents.mr_0 = (sdrc_read_reg(SDRC_MR_0) & 0xFFFF); 31680140786SRajendra Nayak sdrc_block_contents.emr_1_0 = 0x0; 31780140786SRajendra Nayak sdrc_block_contents.emr_2_0 = 0x0; 31880140786SRajendra Nayak sdrc_block_contents.emr_3_0 = 0x0; 31980140786SRajendra Nayak sdrc_block_contents.actim_ctrla_0 = 32080140786SRajendra Nayak sdrc_read_reg(SDRC_ACTIM_CTRL_A_0); 32180140786SRajendra Nayak sdrc_block_contents.actim_ctrlb_0 = 32280140786SRajendra Nayak sdrc_read_reg(SDRC_ACTIM_CTRL_B_0); 32380140786SRajendra Nayak sdrc_block_contents.rfr_ctrl_0 = 32480140786SRajendra Nayak sdrc_read_reg(SDRC_RFR_CTRL_0); 32580140786SRajendra Nayak sdrc_block_contents.cs_1 = 0x0; 32680140786SRajendra Nayak sdrc_block_contents.mcfg_1 = sdrc_read_reg(SDRC_MCFG_1); 32780140786SRajendra Nayak sdrc_block_contents.mr_1 = sdrc_read_reg(SDRC_MR_1) & 0xFFFF; 32880140786SRajendra Nayak sdrc_block_contents.emr_1_1 = 0x0; 32980140786SRajendra Nayak sdrc_block_contents.emr_2_1 = 0x0; 33080140786SRajendra Nayak sdrc_block_contents.emr_3_1 = 0x0; 33180140786SRajendra Nayak sdrc_block_contents.actim_ctrla_1 = 33280140786SRajendra Nayak sdrc_read_reg(SDRC_ACTIM_CTRL_A_1); 33380140786SRajendra Nayak sdrc_block_contents.actim_ctrlb_1 = 33480140786SRajendra Nayak sdrc_read_reg(SDRC_ACTIM_CTRL_B_1); 33580140786SRajendra Nayak sdrc_block_contents.rfr_ctrl_1 = 33680140786SRajendra Nayak sdrc_read_reg(SDRC_RFR_CTRL_1); 33780140786SRajendra Nayak sdrc_block_contents.dcdl_1_ctrl = 0x0; 33880140786SRajendra Nayak sdrc_block_contents.dcdl_2_ctrl = 0x0; 33980140786SRajendra Nayak sdrc_block_contents.flags = 0x0; 34080140786SRajendra Nayak sdrc_block_contents.block_size = 0x0; 34180140786SRajendra Nayak 34280140786SRajendra Nayak arm_context_addr = virt_to_phys(omap3_arm_context); 34380140786SRajendra Nayak 34480140786SRajendra Nayak /* Copy all the contents to the scratchpad location */ 34580140786SRajendra Nayak scratchpad_address = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD); 34680140786SRajendra Nayak memcpy_toio(scratchpad_address, &scratchpad_contents, 34780140786SRajendra Nayak sizeof(scratchpad_contents)); 34880140786SRajendra Nayak /* Scratchpad contents being 32 bits, a divide by 4 done here */ 34980140786SRajendra Nayak memcpy_toio(scratchpad_address + 35080140786SRajendra Nayak scratchpad_contents.prcm_block_offset, 35180140786SRajendra Nayak &prcm_block_contents, sizeof(prcm_block_contents)); 35280140786SRajendra Nayak memcpy_toio(scratchpad_address + 35380140786SRajendra Nayak scratchpad_contents.sdrc_block_offset, 35480140786SRajendra Nayak &sdrc_block_contents, sizeof(sdrc_block_contents)); 35580140786SRajendra Nayak /* 35680140786SRajendra Nayak * Copies the address of the location in SDRAM where ARM 35780140786SRajendra Nayak * registers get saved during a MPU OFF transition. 35880140786SRajendra Nayak */ 35980140786SRajendra Nayak memcpy_toio(scratchpad_address + 36080140786SRajendra Nayak scratchpad_contents.sdrc_block_offset + 36180140786SRajendra Nayak sizeof(sdrc_block_contents), &arm_context_addr, 4); 36280140786SRajendra Nayak } 36380140786SRajendra Nayak 364c96631e1SRajendra Nayak void omap3_control_save_context(void) 365c96631e1SRajendra Nayak { 366c96631e1SRajendra Nayak control_context.sysconfig = omap_ctrl_readl(OMAP2_CONTROL_SYSCONFIG); 367c96631e1SRajendra Nayak control_context.devconf0 = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0); 368c96631e1SRajendra Nayak control_context.mem_dftrw0 = 369c96631e1SRajendra Nayak omap_ctrl_readl(OMAP343X_CONTROL_MEM_DFTRW0); 370c96631e1SRajendra Nayak control_context.mem_dftrw1 = 371c96631e1SRajendra Nayak omap_ctrl_readl(OMAP343X_CONTROL_MEM_DFTRW1); 372c96631e1SRajendra Nayak control_context.msuspendmux_0 = 373c96631e1SRajendra Nayak omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_0); 374c96631e1SRajendra Nayak control_context.msuspendmux_1 = 375c96631e1SRajendra Nayak omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_1); 376c96631e1SRajendra Nayak control_context.msuspendmux_2 = 377c96631e1SRajendra Nayak omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_2); 378c96631e1SRajendra Nayak control_context.msuspendmux_3 = 379c96631e1SRajendra Nayak omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_3); 380c96631e1SRajendra Nayak control_context.msuspendmux_4 = 381c96631e1SRajendra Nayak omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_4); 382c96631e1SRajendra Nayak control_context.msuspendmux_5 = 383c96631e1SRajendra Nayak omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_5); 384c96631e1SRajendra Nayak control_context.sec_ctrl = omap_ctrl_readl(OMAP2_CONTROL_SEC_CTRL); 385c96631e1SRajendra Nayak control_context.devconf1 = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1); 386c96631e1SRajendra Nayak control_context.csirxfe = omap_ctrl_readl(OMAP343X_CONTROL_CSIRXFE); 387c96631e1SRajendra Nayak control_context.iva2_bootaddr = 388c96631e1SRajendra Nayak omap_ctrl_readl(OMAP343X_CONTROL_IVA2_BOOTADDR); 389c96631e1SRajendra Nayak control_context.iva2_bootmod = 390c96631e1SRajendra Nayak omap_ctrl_readl(OMAP343X_CONTROL_IVA2_BOOTMOD); 391c96631e1SRajendra Nayak control_context.debobs_0 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(0)); 392c96631e1SRajendra Nayak control_context.debobs_1 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(1)); 393c96631e1SRajendra Nayak control_context.debobs_2 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(2)); 394c96631e1SRajendra Nayak control_context.debobs_3 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(3)); 395c96631e1SRajendra Nayak control_context.debobs_4 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(4)); 396c96631e1SRajendra Nayak control_context.debobs_5 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(5)); 397c96631e1SRajendra Nayak control_context.debobs_6 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(6)); 398c96631e1SRajendra Nayak control_context.debobs_7 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(7)); 399c96631e1SRajendra Nayak control_context.debobs_8 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(8)); 400c96631e1SRajendra Nayak control_context.prog_io0 = omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO0); 401c96631e1SRajendra Nayak control_context.prog_io1 = omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO1); 402c96631e1SRajendra Nayak control_context.dss_dpll_spreading = 403c96631e1SRajendra Nayak omap_ctrl_readl(OMAP343X_CONTROL_DSS_DPLL_SPREADING); 404c96631e1SRajendra Nayak control_context.core_dpll_spreading = 405c96631e1SRajendra Nayak omap_ctrl_readl(OMAP343X_CONTROL_CORE_DPLL_SPREADING); 406c96631e1SRajendra Nayak control_context.per_dpll_spreading = 407c96631e1SRajendra Nayak omap_ctrl_readl(OMAP343X_CONTROL_PER_DPLL_SPREADING); 408c96631e1SRajendra Nayak control_context.usbhost_dpll_spreading = 409c96631e1SRajendra Nayak omap_ctrl_readl(OMAP343X_CONTROL_USBHOST_DPLL_SPREADING); 410c96631e1SRajendra Nayak control_context.pbias_lite = 411c96631e1SRajendra Nayak omap_ctrl_readl(OMAP343X_CONTROL_PBIAS_LITE); 412c96631e1SRajendra Nayak control_context.temp_sensor = 413c96631e1SRajendra Nayak omap_ctrl_readl(OMAP343X_CONTROL_TEMP_SENSOR); 414c96631e1SRajendra Nayak control_context.sramldo4 = omap_ctrl_readl(OMAP343X_CONTROL_SRAMLDO4); 415c96631e1SRajendra Nayak control_context.sramldo5 = omap_ctrl_readl(OMAP343X_CONTROL_SRAMLDO5); 416c96631e1SRajendra Nayak control_context.csi = omap_ctrl_readl(OMAP343X_CONTROL_CSI); 417c96631e1SRajendra Nayak return; 418c96631e1SRajendra Nayak } 419c96631e1SRajendra Nayak 420c96631e1SRajendra Nayak void omap3_control_restore_context(void) 421c96631e1SRajendra Nayak { 422c96631e1SRajendra Nayak omap_ctrl_writel(control_context.sysconfig, OMAP2_CONTROL_SYSCONFIG); 423c96631e1SRajendra Nayak omap_ctrl_writel(control_context.devconf0, OMAP2_CONTROL_DEVCONF0); 424c96631e1SRajendra Nayak omap_ctrl_writel(control_context.mem_dftrw0, 425c96631e1SRajendra Nayak OMAP343X_CONTROL_MEM_DFTRW0); 426c96631e1SRajendra Nayak omap_ctrl_writel(control_context.mem_dftrw1, 427c96631e1SRajendra Nayak OMAP343X_CONTROL_MEM_DFTRW1); 428c96631e1SRajendra Nayak omap_ctrl_writel(control_context.msuspendmux_0, 429c96631e1SRajendra Nayak OMAP2_CONTROL_MSUSPENDMUX_0); 430c96631e1SRajendra Nayak omap_ctrl_writel(control_context.msuspendmux_1, 431c96631e1SRajendra Nayak OMAP2_CONTROL_MSUSPENDMUX_1); 432c96631e1SRajendra Nayak omap_ctrl_writel(control_context.msuspendmux_2, 433c96631e1SRajendra Nayak OMAP2_CONTROL_MSUSPENDMUX_2); 434c96631e1SRajendra Nayak omap_ctrl_writel(control_context.msuspendmux_3, 435c96631e1SRajendra Nayak OMAP2_CONTROL_MSUSPENDMUX_3); 436c96631e1SRajendra Nayak omap_ctrl_writel(control_context.msuspendmux_4, 437c96631e1SRajendra Nayak OMAP2_CONTROL_MSUSPENDMUX_4); 438c96631e1SRajendra Nayak omap_ctrl_writel(control_context.msuspendmux_5, 439c96631e1SRajendra Nayak OMAP2_CONTROL_MSUSPENDMUX_5); 440c96631e1SRajendra Nayak omap_ctrl_writel(control_context.sec_ctrl, OMAP2_CONTROL_SEC_CTRL); 441c96631e1SRajendra Nayak omap_ctrl_writel(control_context.devconf1, OMAP343X_CONTROL_DEVCONF1); 442c96631e1SRajendra Nayak omap_ctrl_writel(control_context.csirxfe, OMAP343X_CONTROL_CSIRXFE); 443c96631e1SRajendra Nayak omap_ctrl_writel(control_context.iva2_bootaddr, 444c96631e1SRajendra Nayak OMAP343X_CONTROL_IVA2_BOOTADDR); 445c96631e1SRajendra Nayak omap_ctrl_writel(control_context.iva2_bootmod, 446c96631e1SRajendra Nayak OMAP343X_CONTROL_IVA2_BOOTMOD); 447c96631e1SRajendra Nayak omap_ctrl_writel(control_context.debobs_0, OMAP343X_CONTROL_DEBOBS(0)); 448c96631e1SRajendra Nayak omap_ctrl_writel(control_context.debobs_1, OMAP343X_CONTROL_DEBOBS(1)); 449c96631e1SRajendra Nayak omap_ctrl_writel(control_context.debobs_2, OMAP343X_CONTROL_DEBOBS(2)); 450c96631e1SRajendra Nayak omap_ctrl_writel(control_context.debobs_3, OMAP343X_CONTROL_DEBOBS(3)); 451c96631e1SRajendra Nayak omap_ctrl_writel(control_context.debobs_4, OMAP343X_CONTROL_DEBOBS(4)); 452c96631e1SRajendra Nayak omap_ctrl_writel(control_context.debobs_5, OMAP343X_CONTROL_DEBOBS(5)); 453c96631e1SRajendra Nayak omap_ctrl_writel(control_context.debobs_6, OMAP343X_CONTROL_DEBOBS(6)); 454c96631e1SRajendra Nayak omap_ctrl_writel(control_context.debobs_7, OMAP343X_CONTROL_DEBOBS(7)); 455c96631e1SRajendra Nayak omap_ctrl_writel(control_context.debobs_8, OMAP343X_CONTROL_DEBOBS(8)); 456c96631e1SRajendra Nayak omap_ctrl_writel(control_context.prog_io0, OMAP343X_CONTROL_PROG_IO0); 457c96631e1SRajendra Nayak omap_ctrl_writel(control_context.prog_io1, OMAP343X_CONTROL_PROG_IO1); 458c96631e1SRajendra Nayak omap_ctrl_writel(control_context.dss_dpll_spreading, 459c96631e1SRajendra Nayak OMAP343X_CONTROL_DSS_DPLL_SPREADING); 460c96631e1SRajendra Nayak omap_ctrl_writel(control_context.core_dpll_spreading, 461c96631e1SRajendra Nayak OMAP343X_CONTROL_CORE_DPLL_SPREADING); 462c96631e1SRajendra Nayak omap_ctrl_writel(control_context.per_dpll_spreading, 463c96631e1SRajendra Nayak OMAP343X_CONTROL_PER_DPLL_SPREADING); 464c96631e1SRajendra Nayak omap_ctrl_writel(control_context.usbhost_dpll_spreading, 465c96631e1SRajendra Nayak OMAP343X_CONTROL_USBHOST_DPLL_SPREADING); 466c96631e1SRajendra Nayak omap_ctrl_writel(control_context.pbias_lite, 467c96631e1SRajendra Nayak OMAP343X_CONTROL_PBIAS_LITE); 468c96631e1SRajendra Nayak omap_ctrl_writel(control_context.temp_sensor, 469c96631e1SRajendra Nayak OMAP343X_CONTROL_TEMP_SENSOR); 470c96631e1SRajendra Nayak omap_ctrl_writel(control_context.sramldo4, OMAP343X_CONTROL_SRAMLDO4); 471c96631e1SRajendra Nayak omap_ctrl_writel(control_context.sramldo5, OMAP343X_CONTROL_SRAMLDO5); 472c96631e1SRajendra Nayak omap_ctrl_writel(control_context.csi, OMAP343X_CONTROL_CSI); 473c96631e1SRajendra Nayak return; 474c96631e1SRajendra Nayak } 475c96631e1SRajendra Nayak #endif /* CONFIG_ARCH_OMAP3 && CONFIG_PM */ 476