Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 1 | /* |
| 2 | * OMAP2/3 System Control Module register access |
| 3 | * |
| 4 | * Copyright (C) 2007 Texas Instruments, Inc. |
| 5 | * Copyright (C) 2007 Nokia Corporation |
| 6 | * |
| 7 | * Written by Paul Walmsley |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | #undef DEBUG |
| 14 | |
| 15 | #include <linux/kernel.h> |
Tony Lindgren | a58caad | 2008-07-03 12:24:44 +0300 | [diff] [blame] | 16 | #include <linux/io.h> |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 17 | |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 18 | #include <plat/common.h> |
Rajendra Nayak | 8014078 | 2008-09-26 17:48:46 +0530 | [diff] [blame] | 19 | #include <plat/sdrc.h> |
Paul Walmsley | 4814ced | 2010-10-08 11:40:20 -0600 | [diff] [blame] | 20 | |
Rajendra Nayak | 8014078 | 2008-09-26 17:48:46 +0530 | [diff] [blame] | 21 | #include "cm-regbits-34xx.h" |
| 22 | #include "prm-regbits-34xx.h" |
| 23 | #include "cm.h" |
| 24 | #include "prm.h" |
| 25 | #include "sdrc.h" |
Manjunath Kondaiah G | 3881573 | 2010-10-08 09:56:37 -0700 | [diff] [blame] | 26 | #include "pm.h" |
Paul Walmsley | 4814ced | 2010-10-08 11:40:20 -0600 | [diff] [blame] | 27 | #include "control.h" |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 28 | |
Tony Lindgren | a58caad | 2008-07-03 12:24:44 +0300 | [diff] [blame] | 29 | static void __iomem *omap2_ctrl_base; |
Santosh Shilimkar | 0c34924 | 2010-09-27 14:02:57 -0600 | [diff] [blame] | 30 | static void __iomem *omap4_ctrl_pad_base; |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 31 | |
Rajendra Nayak | c96631e | 2008-09-26 17:49:02 +0530 | [diff] [blame] | 32 | #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM) |
Rajendra Nayak | 8014078 | 2008-09-26 17:48:46 +0530 | [diff] [blame] | 33 | struct omap3_scratchpad { |
| 34 | u32 boot_config_ptr; |
| 35 | u32 public_restore_ptr; |
| 36 | u32 secure_ram_restore_ptr; |
| 37 | u32 sdrc_module_semaphore; |
| 38 | u32 prcm_block_offset; |
| 39 | u32 sdrc_block_offset; |
| 40 | }; |
| 41 | |
| 42 | struct omap3_scratchpad_prcm_block { |
| 43 | u32 prm_clksrc_ctrl; |
| 44 | u32 prm_clksel; |
| 45 | u32 cm_clksel_core; |
| 46 | u32 cm_clksel_wkup; |
| 47 | u32 cm_clken_pll; |
| 48 | u32 cm_autoidle_pll; |
| 49 | u32 cm_clksel1_pll; |
| 50 | u32 cm_clksel2_pll; |
| 51 | u32 cm_clksel3_pll; |
| 52 | u32 cm_clken_pll_mpu; |
| 53 | u32 cm_autoidle_pll_mpu; |
| 54 | u32 cm_clksel1_pll_mpu; |
| 55 | u32 cm_clksel2_pll_mpu; |
| 56 | u32 prcm_block_size; |
| 57 | }; |
| 58 | |
| 59 | struct omap3_scratchpad_sdrc_block { |
| 60 | u16 sysconfig; |
| 61 | u16 cs_cfg; |
| 62 | u16 sharing; |
| 63 | u16 err_type; |
| 64 | u32 dll_a_ctrl; |
| 65 | u32 dll_b_ctrl; |
| 66 | u32 power; |
| 67 | u32 cs_0; |
| 68 | u32 mcfg_0; |
| 69 | u16 mr_0; |
| 70 | u16 emr_1_0; |
| 71 | u16 emr_2_0; |
| 72 | u16 emr_3_0; |
| 73 | u32 actim_ctrla_0; |
| 74 | u32 actim_ctrlb_0; |
| 75 | u32 rfr_ctrl_0; |
| 76 | u32 cs_1; |
| 77 | u32 mcfg_1; |
| 78 | u16 mr_1; |
| 79 | u16 emr_1_1; |
| 80 | u16 emr_2_1; |
| 81 | u16 emr_3_1; |
| 82 | u32 actim_ctrla_1; |
| 83 | u32 actim_ctrlb_1; |
| 84 | u32 rfr_ctrl_1; |
| 85 | u16 dcdl_1_ctrl; |
| 86 | u16 dcdl_2_ctrl; |
| 87 | u32 flags; |
| 88 | u32 block_size; |
| 89 | }; |
| 90 | |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 91 | void *omap3_secure_ram_storage; |
| 92 | |
Rajendra Nayak | 8014078 | 2008-09-26 17:48:46 +0530 | [diff] [blame] | 93 | /* |
| 94 | * This is used to store ARM registers in SDRAM before attempting |
| 95 | * an MPU OFF. The save and restore happens from the SRAM sleep code. |
| 96 | * The address is stored in scratchpad, so that it can be used |
| 97 | * during the restore path. |
| 98 | */ |
| 99 | u32 omap3_arm_context[128]; |
| 100 | |
Rajendra Nayak | c96631e | 2008-09-26 17:49:02 +0530 | [diff] [blame] | 101 | struct omap3_control_regs { |
| 102 | u32 sysconfig; |
| 103 | u32 devconf0; |
| 104 | u32 mem_dftrw0; |
| 105 | u32 mem_dftrw1; |
| 106 | u32 msuspendmux_0; |
| 107 | u32 msuspendmux_1; |
| 108 | u32 msuspendmux_2; |
| 109 | u32 msuspendmux_3; |
| 110 | u32 msuspendmux_4; |
| 111 | u32 msuspendmux_5; |
| 112 | u32 sec_ctrl; |
| 113 | u32 devconf1; |
| 114 | u32 csirxfe; |
| 115 | u32 iva2_bootaddr; |
| 116 | u32 iva2_bootmod; |
| 117 | u32 debobs_0; |
| 118 | u32 debobs_1; |
| 119 | u32 debobs_2; |
| 120 | u32 debobs_3; |
| 121 | u32 debobs_4; |
| 122 | u32 debobs_5; |
| 123 | u32 debobs_6; |
| 124 | u32 debobs_7; |
| 125 | u32 debobs_8; |
| 126 | u32 prog_io0; |
| 127 | u32 prog_io1; |
| 128 | u32 dss_dpll_spreading; |
| 129 | u32 core_dpll_spreading; |
| 130 | u32 per_dpll_spreading; |
| 131 | u32 usbhost_dpll_spreading; |
| 132 | u32 pbias_lite; |
| 133 | u32 temp_sensor; |
| 134 | u32 sramldo4; |
| 135 | u32 sramldo5; |
| 136 | u32 csi; |
| 137 | }; |
| 138 | |
| 139 | static struct omap3_control_regs control_context; |
| 140 | #endif /* CONFIG_ARCH_OMAP3 && CONFIG_PM */ |
| 141 | |
Tony Lindgren | a58caad | 2008-07-03 12:24:44 +0300 | [diff] [blame] | 142 | #define OMAP_CTRL_REGADDR(reg) (omap2_ctrl_base + (reg)) |
Santosh Shilimkar | 70ba71a | 2010-09-27 14:02:57 -0600 | [diff] [blame] | 143 | #define OMAP4_CTRL_PAD_REGADDR(reg) (omap4_ctrl_pad_base + (reg)) |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 144 | |
Tony Lindgren | a58caad | 2008-07-03 12:24:44 +0300 | [diff] [blame] | 145 | void __init omap2_set_globals_control(struct omap_globals *omap2_globals) |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 146 | { |
Santosh Shilimkar | b7ebb10 | 2010-02-15 18:03:37 +0530 | [diff] [blame] | 147 | /* Static mapping, never released */ |
| 148 | if (omap2_globals->ctrl) { |
| 149 | omap2_ctrl_base = ioremap(omap2_globals->ctrl, SZ_4K); |
| 150 | WARN_ON(!omap2_ctrl_base); |
| 151 | } |
Santosh Shilimkar | 0c34924 | 2010-09-27 14:02:57 -0600 | [diff] [blame] | 152 | |
| 153 | /* Static mapping, never released */ |
| 154 | if (omap2_globals->ctrl_pad) { |
| 155 | omap4_ctrl_pad_base = ioremap(omap2_globals->ctrl_pad, SZ_4K); |
| 156 | WARN_ON(!omap4_ctrl_pad_base); |
| 157 | } |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 158 | } |
| 159 | |
Tony Lindgren | a58caad | 2008-07-03 12:24:44 +0300 | [diff] [blame] | 160 | void __iomem *omap_ctrl_base_get(void) |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 161 | { |
| 162 | return omap2_ctrl_base; |
| 163 | } |
| 164 | |
| 165 | u8 omap_ctrl_readb(u16 offset) |
| 166 | { |
| 167 | return __raw_readb(OMAP_CTRL_REGADDR(offset)); |
| 168 | } |
| 169 | |
| 170 | u16 omap_ctrl_readw(u16 offset) |
| 171 | { |
| 172 | return __raw_readw(OMAP_CTRL_REGADDR(offset)); |
| 173 | } |
| 174 | |
| 175 | u32 omap_ctrl_readl(u16 offset) |
| 176 | { |
| 177 | return __raw_readl(OMAP_CTRL_REGADDR(offset)); |
| 178 | } |
| 179 | |
| 180 | void omap_ctrl_writeb(u8 val, u16 offset) |
| 181 | { |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 182 | __raw_writeb(val, OMAP_CTRL_REGADDR(offset)); |
| 183 | } |
| 184 | |
| 185 | void omap_ctrl_writew(u16 val, u16 offset) |
| 186 | { |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 187 | __raw_writew(val, OMAP_CTRL_REGADDR(offset)); |
| 188 | } |
| 189 | |
| 190 | void omap_ctrl_writel(u32 val, u16 offset) |
| 191 | { |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 192 | __raw_writel(val, OMAP_CTRL_REGADDR(offset)); |
| 193 | } |
| 194 | |
Santosh Shilimkar | 70ba71a | 2010-09-27 14:02:57 -0600 | [diff] [blame] | 195 | /* |
| 196 | * On OMAP4 control pad are not addressable from control |
| 197 | * core base. So the common omap_ctrl_read/write APIs breaks |
| 198 | * Hence export separate APIs to manage the omap4 pad control |
| 199 | * registers. This APIs will work only for OMAP4 |
| 200 | */ |
| 201 | |
| 202 | u32 omap4_ctrl_pad_readl(u16 offset) |
| 203 | { |
| 204 | return __raw_readl(OMAP4_CTRL_PAD_REGADDR(offset)); |
| 205 | } |
| 206 | |
| 207 | void omap4_ctrl_pad_writel(u32 val, u16 offset) |
| 208 | { |
| 209 | __raw_writel(val, OMAP4_CTRL_PAD_REGADDR(offset)); |
| 210 | } |
| 211 | |
Paul Walmsley | 166353b | 2010-12-21 20:01:21 -0700 | [diff] [blame^] | 212 | #ifdef CONFIG_ARCH_OMAP3 |
| 213 | |
| 214 | /** |
| 215 | * omap3_ctrl_write_boot_mode - set scratchpad boot mode for the next boot |
| 216 | * @bootmode: 8-bit value to pass to some boot code |
| 217 | * |
| 218 | * Set the bootmode in the scratchpad RAM. This is used after the |
| 219 | * system restarts. Not sure what actually uses this - it may be the |
| 220 | * bootloader, rather than the boot ROM - contrary to the preserved |
| 221 | * comment below. No return value. |
| 222 | */ |
| 223 | void omap3_ctrl_write_boot_mode(u8 bootmode) |
| 224 | { |
| 225 | u32 l; |
| 226 | |
| 227 | l = ('B' << 24) | ('M' << 16) | bootmode; |
| 228 | |
| 229 | /* |
| 230 | * Reserve the first word in scratchpad for communicating |
| 231 | * with the boot ROM. A pointer to a data structure |
| 232 | * describing the boot process can be stored there, |
| 233 | * cf. OMAP34xx TRM, Initialization / Software Booting |
| 234 | * Configuration. |
| 235 | * |
| 236 | * XXX This should use some omap_ctrl_writel()-type function |
| 237 | */ |
| 238 | __raw_writel(l, OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD + 4)); |
| 239 | } |
| 240 | |
| 241 | #endif |
| 242 | |
Rajendra Nayak | c96631e | 2008-09-26 17:49:02 +0530 | [diff] [blame] | 243 | #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM) |
Rajendra Nayak | 8014078 | 2008-09-26 17:48:46 +0530 | [diff] [blame] | 244 | /* |
| 245 | * Clears the scratchpad contents in case of cold boot- |
| 246 | * called during bootup |
| 247 | */ |
| 248 | void omap3_clear_scratchpad_contents(void) |
| 249 | { |
| 250 | u32 max_offset = OMAP343X_SCRATCHPAD_ROM_OFFSET; |
Manjunath Kondaiah G | 4d63bc1 | 2010-10-08 09:56:11 -0700 | [diff] [blame] | 251 | void __iomem *v_addr; |
Rajendra Nayak | 8014078 | 2008-09-26 17:48:46 +0530 | [diff] [blame] | 252 | u32 offset = 0; |
| 253 | v_addr = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD_ROM); |
| 254 | if (prm_read_mod_reg(OMAP3430_GR_MOD, OMAP3_PRM_RSTST_OFFSET) & |
Paul Walmsley | 2bc4ef7 | 2010-05-18 18:47:24 -0600 | [diff] [blame] | 255 | OMAP3430_GLOBAL_COLD_RST_MASK) { |
Rajendra Nayak | 8014078 | 2008-09-26 17:48:46 +0530 | [diff] [blame] | 256 | for ( ; offset <= max_offset; offset += 0x4) |
| 257 | __raw_writel(0x0, (v_addr + offset)); |
Paul Walmsley | 2bc4ef7 | 2010-05-18 18:47:24 -0600 | [diff] [blame] | 258 | prm_set_mod_reg_bits(OMAP3430_GLOBAL_COLD_RST_MASK, |
| 259 | OMAP3430_GR_MOD, |
| 260 | OMAP3_PRM_RSTST_OFFSET); |
Rajendra Nayak | 8014078 | 2008-09-26 17:48:46 +0530 | [diff] [blame] | 261 | } |
| 262 | } |
| 263 | |
| 264 | /* Populate the scratchpad structure with restore structure */ |
| 265 | void omap3_save_scratchpad_contents(void) |
| 266 | { |
Manjunath Kondaiah G | 4d63bc1 | 2010-10-08 09:56:11 -0700 | [diff] [blame] | 267 | void __iomem *scratchpad_address; |
Rajendra Nayak | 8014078 | 2008-09-26 17:48:46 +0530 | [diff] [blame] | 268 | u32 arm_context_addr; |
| 269 | struct omap3_scratchpad scratchpad_contents; |
| 270 | struct omap3_scratchpad_prcm_block prcm_block_contents; |
| 271 | struct omap3_scratchpad_sdrc_block sdrc_block_contents; |
| 272 | |
Jean Pihet | f7dfe3d | 2010-12-18 16:44:45 +0100 | [diff] [blame] | 273 | /* |
| 274 | * Populate the Scratchpad contents |
| 275 | * |
| 276 | * The "get_*restore_pointer" functions are used to provide a |
| 277 | * physical restore address where the ROM code jumps while waking |
| 278 | * up from MPU OFF/OSWR state. |
| 279 | * The restore pointer is stored into the scratchpad. |
| 280 | */ |
Rajendra Nayak | 8014078 | 2008-09-26 17:48:46 +0530 | [diff] [blame] | 281 | scratchpad_contents.boot_config_ptr = 0x0; |
Nishanth Menon | 458e999 | 2010-12-20 14:05:06 -0600 | [diff] [blame] | 282 | if (cpu_is_omap3630()) |
| 283 | scratchpad_contents.public_restore_ptr = |
| 284 | virt_to_phys(get_omap3630_restore_pointer()); |
| 285 | else if (omap_rev() != OMAP3430_REV_ES3_0 && |
Tero Kristo | 0795a75 | 2008-10-13 17:58:50 +0300 | [diff] [blame] | 286 | omap_rev() != OMAP3430_REV_ES3_1) |
| 287 | scratchpad_contents.public_restore_ptr = |
| 288 | virt_to_phys(get_restore_pointer()); |
| 289 | else |
| 290 | scratchpad_contents.public_restore_ptr = |
| 291 | virt_to_phys(get_es3_restore_pointer()); |
Tero Kristo | 27d59a4 | 2008-10-13 13:15:00 +0300 | [diff] [blame] | 292 | if (omap_type() == OMAP2_DEVICE_TYPE_GP) |
| 293 | scratchpad_contents.secure_ram_restore_ptr = 0x0; |
| 294 | else |
| 295 | scratchpad_contents.secure_ram_restore_ptr = |
| 296 | (u32) __pa(omap3_secure_ram_storage); |
Rajendra Nayak | 8014078 | 2008-09-26 17:48:46 +0530 | [diff] [blame] | 297 | scratchpad_contents.sdrc_module_semaphore = 0x0; |
| 298 | scratchpad_contents.prcm_block_offset = 0x2C; |
| 299 | scratchpad_contents.sdrc_block_offset = 0x64; |
| 300 | |
| 301 | /* Populate the PRCM block contents */ |
| 302 | prcm_block_contents.prm_clksrc_ctrl = prm_read_mod_reg(OMAP3430_GR_MOD, |
| 303 | OMAP3_PRM_CLKSRC_CTRL_OFFSET); |
| 304 | prcm_block_contents.prm_clksel = prm_read_mod_reg(OMAP3430_CCR_MOD, |
| 305 | OMAP3_PRM_CLKSEL_OFFSET); |
| 306 | prcm_block_contents.cm_clksel_core = |
| 307 | cm_read_mod_reg(CORE_MOD, CM_CLKSEL); |
| 308 | prcm_block_contents.cm_clksel_wkup = |
| 309 | cm_read_mod_reg(WKUP_MOD, CM_CLKSEL); |
| 310 | prcm_block_contents.cm_clken_pll = |
Kalle Jokiniemi | cb0cb2b | 2009-05-12 14:02:16 +0300 | [diff] [blame] | 311 | cm_read_mod_reg(PLL_MOD, CM_CLKEN); |
Rajendra Nayak | 8014078 | 2008-09-26 17:48:46 +0530 | [diff] [blame] | 312 | prcm_block_contents.cm_autoidle_pll = |
| 313 | cm_read_mod_reg(PLL_MOD, OMAP3430_CM_AUTOIDLE_PLL); |
| 314 | prcm_block_contents.cm_clksel1_pll = |
| 315 | cm_read_mod_reg(PLL_MOD, OMAP3430_CM_CLKSEL1_PLL); |
| 316 | prcm_block_contents.cm_clksel2_pll = |
| 317 | cm_read_mod_reg(PLL_MOD, OMAP3430_CM_CLKSEL2_PLL); |
| 318 | prcm_block_contents.cm_clksel3_pll = |
| 319 | cm_read_mod_reg(PLL_MOD, OMAP3430_CM_CLKSEL3); |
| 320 | prcm_block_contents.cm_clken_pll_mpu = |
| 321 | cm_read_mod_reg(MPU_MOD, OMAP3430_CM_CLKEN_PLL); |
| 322 | prcm_block_contents.cm_autoidle_pll_mpu = |
| 323 | cm_read_mod_reg(MPU_MOD, OMAP3430_CM_AUTOIDLE_PLL); |
| 324 | prcm_block_contents.cm_clksel1_pll_mpu = |
| 325 | cm_read_mod_reg(MPU_MOD, OMAP3430_CM_CLKSEL1_PLL); |
| 326 | prcm_block_contents.cm_clksel2_pll_mpu = |
| 327 | cm_read_mod_reg(MPU_MOD, OMAP3430_CM_CLKSEL2_PLL); |
| 328 | prcm_block_contents.prcm_block_size = 0x0; |
| 329 | |
| 330 | /* Populate the SDRC block contents */ |
| 331 | sdrc_block_contents.sysconfig = |
| 332 | (sdrc_read_reg(SDRC_SYSCONFIG) & 0xFFFF); |
| 333 | sdrc_block_contents.cs_cfg = |
| 334 | (sdrc_read_reg(SDRC_CS_CFG) & 0xFFFF); |
| 335 | sdrc_block_contents.sharing = |
| 336 | (sdrc_read_reg(SDRC_SHARING) & 0xFFFF); |
| 337 | sdrc_block_contents.err_type = |
| 338 | (sdrc_read_reg(SDRC_ERR_TYPE) & 0xFFFF); |
| 339 | sdrc_block_contents.dll_a_ctrl = sdrc_read_reg(SDRC_DLLA_CTRL); |
| 340 | sdrc_block_contents.dll_b_ctrl = 0x0; |
Rajendra Nayak | f265dc4 | 2009-06-09 22:30:41 +0530 | [diff] [blame] | 341 | /* |
| 342 | * Due to a OMAP3 errata (1.142), on EMU/HS devices SRDC should |
| 343 | * be programed to issue automatic self refresh on timeout |
| 344 | * of AUTO_CNT = 1 prior to any transition to OFF mode. |
| 345 | */ |
| 346 | if ((omap_type() != OMAP2_DEVICE_TYPE_GP) |
| 347 | && (omap_rev() >= OMAP3430_REV_ES3_0)) |
| 348 | sdrc_block_contents.power = (sdrc_read_reg(SDRC_POWER) & |
| 349 | ~(SDRC_POWER_AUTOCOUNT_MASK| |
| 350 | SDRC_POWER_CLKCTRL_MASK)) | |
| 351 | (1 << SDRC_POWER_AUTOCOUNT_SHIFT) | |
| 352 | SDRC_SELF_REFRESH_ON_AUTOCOUNT; |
| 353 | else |
| 354 | sdrc_block_contents.power = sdrc_read_reg(SDRC_POWER); |
| 355 | |
Rajendra Nayak | 8014078 | 2008-09-26 17:48:46 +0530 | [diff] [blame] | 356 | sdrc_block_contents.cs_0 = 0x0; |
| 357 | sdrc_block_contents.mcfg_0 = sdrc_read_reg(SDRC_MCFG_0); |
| 358 | sdrc_block_contents.mr_0 = (sdrc_read_reg(SDRC_MR_0) & 0xFFFF); |
| 359 | sdrc_block_contents.emr_1_0 = 0x0; |
| 360 | sdrc_block_contents.emr_2_0 = 0x0; |
| 361 | sdrc_block_contents.emr_3_0 = 0x0; |
| 362 | sdrc_block_contents.actim_ctrla_0 = |
| 363 | sdrc_read_reg(SDRC_ACTIM_CTRL_A_0); |
| 364 | sdrc_block_contents.actim_ctrlb_0 = |
| 365 | sdrc_read_reg(SDRC_ACTIM_CTRL_B_0); |
| 366 | sdrc_block_contents.rfr_ctrl_0 = |
| 367 | sdrc_read_reg(SDRC_RFR_CTRL_0); |
| 368 | sdrc_block_contents.cs_1 = 0x0; |
| 369 | sdrc_block_contents.mcfg_1 = sdrc_read_reg(SDRC_MCFG_1); |
| 370 | sdrc_block_contents.mr_1 = sdrc_read_reg(SDRC_MR_1) & 0xFFFF; |
| 371 | sdrc_block_contents.emr_1_1 = 0x0; |
| 372 | sdrc_block_contents.emr_2_1 = 0x0; |
| 373 | sdrc_block_contents.emr_3_1 = 0x0; |
| 374 | sdrc_block_contents.actim_ctrla_1 = |
| 375 | sdrc_read_reg(SDRC_ACTIM_CTRL_A_1); |
| 376 | sdrc_block_contents.actim_ctrlb_1 = |
| 377 | sdrc_read_reg(SDRC_ACTIM_CTRL_B_1); |
| 378 | sdrc_block_contents.rfr_ctrl_1 = |
| 379 | sdrc_read_reg(SDRC_RFR_CTRL_1); |
| 380 | sdrc_block_contents.dcdl_1_ctrl = 0x0; |
| 381 | sdrc_block_contents.dcdl_2_ctrl = 0x0; |
| 382 | sdrc_block_contents.flags = 0x0; |
| 383 | sdrc_block_contents.block_size = 0x0; |
| 384 | |
| 385 | arm_context_addr = virt_to_phys(omap3_arm_context); |
| 386 | |
| 387 | /* Copy all the contents to the scratchpad location */ |
| 388 | scratchpad_address = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD); |
| 389 | memcpy_toio(scratchpad_address, &scratchpad_contents, |
| 390 | sizeof(scratchpad_contents)); |
| 391 | /* Scratchpad contents being 32 bits, a divide by 4 done here */ |
| 392 | memcpy_toio(scratchpad_address + |
| 393 | scratchpad_contents.prcm_block_offset, |
| 394 | &prcm_block_contents, sizeof(prcm_block_contents)); |
| 395 | memcpy_toio(scratchpad_address + |
| 396 | scratchpad_contents.sdrc_block_offset, |
| 397 | &sdrc_block_contents, sizeof(sdrc_block_contents)); |
| 398 | /* |
| 399 | * Copies the address of the location in SDRAM where ARM |
| 400 | * registers get saved during a MPU OFF transition. |
| 401 | */ |
| 402 | memcpy_toio(scratchpad_address + |
| 403 | scratchpad_contents.sdrc_block_offset + |
| 404 | sizeof(sdrc_block_contents), &arm_context_addr, 4); |
| 405 | } |
| 406 | |
Rajendra Nayak | c96631e | 2008-09-26 17:49:02 +0530 | [diff] [blame] | 407 | void omap3_control_save_context(void) |
| 408 | { |
| 409 | control_context.sysconfig = omap_ctrl_readl(OMAP2_CONTROL_SYSCONFIG); |
| 410 | control_context.devconf0 = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0); |
| 411 | control_context.mem_dftrw0 = |
| 412 | omap_ctrl_readl(OMAP343X_CONTROL_MEM_DFTRW0); |
| 413 | control_context.mem_dftrw1 = |
| 414 | omap_ctrl_readl(OMAP343X_CONTROL_MEM_DFTRW1); |
| 415 | control_context.msuspendmux_0 = |
| 416 | omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_0); |
| 417 | control_context.msuspendmux_1 = |
| 418 | omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_1); |
| 419 | control_context.msuspendmux_2 = |
| 420 | omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_2); |
| 421 | control_context.msuspendmux_3 = |
| 422 | omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_3); |
| 423 | control_context.msuspendmux_4 = |
| 424 | omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_4); |
| 425 | control_context.msuspendmux_5 = |
| 426 | omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_5); |
| 427 | control_context.sec_ctrl = omap_ctrl_readl(OMAP2_CONTROL_SEC_CTRL); |
| 428 | control_context.devconf1 = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1); |
| 429 | control_context.csirxfe = omap_ctrl_readl(OMAP343X_CONTROL_CSIRXFE); |
| 430 | control_context.iva2_bootaddr = |
| 431 | omap_ctrl_readl(OMAP343X_CONTROL_IVA2_BOOTADDR); |
| 432 | control_context.iva2_bootmod = |
| 433 | omap_ctrl_readl(OMAP343X_CONTROL_IVA2_BOOTMOD); |
| 434 | control_context.debobs_0 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(0)); |
| 435 | control_context.debobs_1 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(1)); |
| 436 | control_context.debobs_2 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(2)); |
| 437 | control_context.debobs_3 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(3)); |
| 438 | control_context.debobs_4 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(4)); |
| 439 | control_context.debobs_5 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(5)); |
| 440 | control_context.debobs_6 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(6)); |
| 441 | control_context.debobs_7 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(7)); |
| 442 | control_context.debobs_8 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(8)); |
| 443 | control_context.prog_io0 = omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO0); |
| 444 | control_context.prog_io1 = omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO1); |
| 445 | control_context.dss_dpll_spreading = |
| 446 | omap_ctrl_readl(OMAP343X_CONTROL_DSS_DPLL_SPREADING); |
| 447 | control_context.core_dpll_spreading = |
| 448 | omap_ctrl_readl(OMAP343X_CONTROL_CORE_DPLL_SPREADING); |
| 449 | control_context.per_dpll_spreading = |
| 450 | omap_ctrl_readl(OMAP343X_CONTROL_PER_DPLL_SPREADING); |
| 451 | control_context.usbhost_dpll_spreading = |
| 452 | omap_ctrl_readl(OMAP343X_CONTROL_USBHOST_DPLL_SPREADING); |
| 453 | control_context.pbias_lite = |
| 454 | omap_ctrl_readl(OMAP343X_CONTROL_PBIAS_LITE); |
| 455 | control_context.temp_sensor = |
| 456 | omap_ctrl_readl(OMAP343X_CONTROL_TEMP_SENSOR); |
| 457 | control_context.sramldo4 = omap_ctrl_readl(OMAP343X_CONTROL_SRAMLDO4); |
| 458 | control_context.sramldo5 = omap_ctrl_readl(OMAP343X_CONTROL_SRAMLDO5); |
| 459 | control_context.csi = omap_ctrl_readl(OMAP343X_CONTROL_CSI); |
| 460 | return; |
| 461 | } |
| 462 | |
| 463 | void omap3_control_restore_context(void) |
| 464 | { |
| 465 | omap_ctrl_writel(control_context.sysconfig, OMAP2_CONTROL_SYSCONFIG); |
| 466 | omap_ctrl_writel(control_context.devconf0, OMAP2_CONTROL_DEVCONF0); |
| 467 | omap_ctrl_writel(control_context.mem_dftrw0, |
| 468 | OMAP343X_CONTROL_MEM_DFTRW0); |
| 469 | omap_ctrl_writel(control_context.mem_dftrw1, |
| 470 | OMAP343X_CONTROL_MEM_DFTRW1); |
| 471 | omap_ctrl_writel(control_context.msuspendmux_0, |
| 472 | OMAP2_CONTROL_MSUSPENDMUX_0); |
| 473 | omap_ctrl_writel(control_context.msuspendmux_1, |
| 474 | OMAP2_CONTROL_MSUSPENDMUX_1); |
| 475 | omap_ctrl_writel(control_context.msuspendmux_2, |
| 476 | OMAP2_CONTROL_MSUSPENDMUX_2); |
| 477 | omap_ctrl_writel(control_context.msuspendmux_3, |
| 478 | OMAP2_CONTROL_MSUSPENDMUX_3); |
| 479 | omap_ctrl_writel(control_context.msuspendmux_4, |
| 480 | OMAP2_CONTROL_MSUSPENDMUX_4); |
| 481 | omap_ctrl_writel(control_context.msuspendmux_5, |
| 482 | OMAP2_CONTROL_MSUSPENDMUX_5); |
| 483 | omap_ctrl_writel(control_context.sec_ctrl, OMAP2_CONTROL_SEC_CTRL); |
| 484 | omap_ctrl_writel(control_context.devconf1, OMAP343X_CONTROL_DEVCONF1); |
| 485 | omap_ctrl_writel(control_context.csirxfe, OMAP343X_CONTROL_CSIRXFE); |
| 486 | omap_ctrl_writel(control_context.iva2_bootaddr, |
| 487 | OMAP343X_CONTROL_IVA2_BOOTADDR); |
| 488 | omap_ctrl_writel(control_context.iva2_bootmod, |
| 489 | OMAP343X_CONTROL_IVA2_BOOTMOD); |
| 490 | omap_ctrl_writel(control_context.debobs_0, OMAP343X_CONTROL_DEBOBS(0)); |
| 491 | omap_ctrl_writel(control_context.debobs_1, OMAP343X_CONTROL_DEBOBS(1)); |
| 492 | omap_ctrl_writel(control_context.debobs_2, OMAP343X_CONTROL_DEBOBS(2)); |
| 493 | omap_ctrl_writel(control_context.debobs_3, OMAP343X_CONTROL_DEBOBS(3)); |
| 494 | omap_ctrl_writel(control_context.debobs_4, OMAP343X_CONTROL_DEBOBS(4)); |
| 495 | omap_ctrl_writel(control_context.debobs_5, OMAP343X_CONTROL_DEBOBS(5)); |
| 496 | omap_ctrl_writel(control_context.debobs_6, OMAP343X_CONTROL_DEBOBS(6)); |
| 497 | omap_ctrl_writel(control_context.debobs_7, OMAP343X_CONTROL_DEBOBS(7)); |
| 498 | omap_ctrl_writel(control_context.debobs_8, OMAP343X_CONTROL_DEBOBS(8)); |
| 499 | omap_ctrl_writel(control_context.prog_io0, OMAP343X_CONTROL_PROG_IO0); |
| 500 | omap_ctrl_writel(control_context.prog_io1, OMAP343X_CONTROL_PROG_IO1); |
| 501 | omap_ctrl_writel(control_context.dss_dpll_spreading, |
| 502 | OMAP343X_CONTROL_DSS_DPLL_SPREADING); |
| 503 | omap_ctrl_writel(control_context.core_dpll_spreading, |
| 504 | OMAP343X_CONTROL_CORE_DPLL_SPREADING); |
| 505 | omap_ctrl_writel(control_context.per_dpll_spreading, |
| 506 | OMAP343X_CONTROL_PER_DPLL_SPREADING); |
| 507 | omap_ctrl_writel(control_context.usbhost_dpll_spreading, |
| 508 | OMAP343X_CONTROL_USBHOST_DPLL_SPREADING); |
| 509 | omap_ctrl_writel(control_context.pbias_lite, |
| 510 | OMAP343X_CONTROL_PBIAS_LITE); |
| 511 | omap_ctrl_writel(control_context.temp_sensor, |
| 512 | OMAP343X_CONTROL_TEMP_SENSOR); |
| 513 | omap_ctrl_writel(control_context.sramldo4, OMAP343X_CONTROL_SRAMLDO4); |
| 514 | omap_ctrl_writel(control_context.sramldo5, OMAP343X_CONTROL_SRAMLDO5); |
| 515 | omap_ctrl_writel(control_context.csi, OMAP343X_CONTROL_CSI); |
| 516 | return; |
| 517 | } |
Nishanth Menon | 458e999 | 2010-12-20 14:05:06 -0600 | [diff] [blame] | 518 | |
| 519 | void omap3630_ctrl_disable_rta(void) |
| 520 | { |
| 521 | if (!cpu_is_omap3630()) |
| 522 | return; |
| 523 | omap_ctrl_writel(OMAP36XX_RTA_DISABLE, OMAP36XX_CONTROL_MEM_RTA_CTRL); |
| 524 | } |
| 525 | |
Rajendra Nayak | c96631e | 2008-09-26 17:49:02 +0530 | [diff] [blame] | 526 | #endif /* CONFIG_ARCH_OMAP3 && CONFIG_PM */ |