18bd22949SKevin Hilman/* 28bd22949SKevin Hilman * (C) Copyright 2007 38bd22949SKevin Hilman * Texas Instruments 48bd22949SKevin Hilman * Karthik Dasu <karthik-dp@ti.com> 58bd22949SKevin Hilman * 68bd22949SKevin Hilman * (C) Copyright 2004 78bd22949SKevin Hilman * Texas Instruments, <www.ti.com> 88bd22949SKevin Hilman * Richard Woodruff <r-woodruff2@ti.com> 98bd22949SKevin Hilman * 108bd22949SKevin Hilman * This program is free software; you can redistribute it and/or 118bd22949SKevin Hilman * modify it under the terms of the GNU General Public License as 128bd22949SKevin Hilman * published by the Free Software Foundation; either version 2 of 138bd22949SKevin Hilman * the License, or (at your option) any later version. 148bd22949SKevin Hilman * 158bd22949SKevin Hilman * This program is distributed in the hope that it will be useful, 168bd22949SKevin Hilman * but WITHOUT ANY WARRANTY; without even the implied warranty of 178bd22949SKevin Hilman * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the 188bd22949SKevin Hilman * GNU General Public License for more details. 198bd22949SKevin Hilman * 208bd22949SKevin Hilman * You should have received a copy of the GNU General Public License 218bd22949SKevin Hilman * along with this program; if not, write to the Free Software 228bd22949SKevin Hilman * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 238bd22949SKevin Hilman * MA 02111-1307 USA 248bd22949SKevin Hilman */ 258bd22949SKevin Hilman#include <linux/linkage.h> 268bd22949SKevin Hilman#include <asm/assembler.h> 27b4b36fd9SJean Pihet#include <plat/sram.h> 288bd22949SKevin Hilman#include <mach/io.h> 298bd22949SKevin Hilman 3059fb659bSPaul Walmsley#include "cm2xxx_3xxx.h" 3159fb659bSPaul Walmsley#include "prm2xxx_3xxx.h" 328bd22949SKevin Hilman#include "sdrc.h" 334814ced5SPaul Walmsley#include "control.h" 348bd22949SKevin Hilman 35fe360e1cSJean Pihet/* 36fe360e1cSJean Pihet * Registers access definitions 37fe360e1cSJean Pihet */ 38fe360e1cSJean Pihet#define SDRC_SCRATCHPAD_SEM_OFFS 0xc 39fe360e1cSJean Pihet#define SDRC_SCRATCHPAD_SEM_V OMAP343X_SCRATCHPAD_REGADDR\ 40fe360e1cSJean Pihet (SDRC_SCRATCHPAD_SEM_OFFS) 41fe360e1cSJean Pihet#define PM_PREPWSTST_CORE_P OMAP3430_PRM_BASE + CORE_MOD +\ 42fe360e1cSJean Pihet OMAP3430_PM_PREPWSTST 4337903009SAbhijit Pagare#define PM_PWSTCTRL_MPU_P OMAP3430_PRM_BASE + MPU_MOD + OMAP2_PM_PWSTCTRL 4489139dceSPeter 'p2' De Schrijver#define CM_IDLEST1_CORE_V OMAP34XX_CM_REGADDR(CORE_MOD, CM_IDLEST1) 459d93b8a2SPeter 'p2' De Schrijver#define CM_IDLEST_CKGEN_V OMAP34XX_CM_REGADDR(PLL_MOD, CM_IDLEST) 46fe360e1cSJean Pihet#define SRAM_BASE_P OMAP3_SRAM_PA 47fe360e1cSJean Pihet#define CONTROL_STAT OMAP343X_CTRL_BASE + OMAP343X_CONTROL_STATUS 48fe360e1cSJean Pihet#define CONTROL_MEM_RTA_CTRL (OMAP343X_CTRL_BASE +\ 49fe360e1cSJean Pihet OMAP36XX_CONTROL_MEM_RTA_CTRL) 50fe360e1cSJean Pihet 51fe360e1cSJean Pihet/* Move this as correct place is available */ 52fe360e1cSJean Pihet#define SCRATCHPAD_MEM_OFFS 0x310 53fe360e1cSJean Pihet#define SCRATCHPAD_BASE_P (OMAP343X_CTRL_BASE +\ 54fe360e1cSJean Pihet OMAP343X_CONTROL_MEM_WKUP +\ 55fe360e1cSJean Pihet SCRATCHPAD_MEM_OFFS) 568bd22949SKevin Hilman#define SDRC_POWER_V OMAP34XX_SDRC_REGADDR(SDRC_POWER) 570795a75aSTero Kristo#define SDRC_SYSCONFIG_P (OMAP343X_SDRC_BASE + SDRC_SYSCONFIG) 580795a75aSTero Kristo#define SDRC_MR_0_P (OMAP343X_SDRC_BASE + SDRC_MR_0) 590795a75aSTero Kristo#define SDRC_EMR2_0_P (OMAP343X_SDRC_BASE + SDRC_EMR2_0) 600795a75aSTero Kristo#define SDRC_MANUAL_0_P (OMAP343X_SDRC_BASE + SDRC_MANUAL_0) 610795a75aSTero Kristo#define SDRC_MR_1_P (OMAP343X_SDRC_BASE + SDRC_MR_1) 620795a75aSTero Kristo#define SDRC_EMR2_1_P (OMAP343X_SDRC_BASE + SDRC_EMR2_1) 630795a75aSTero Kristo#define SDRC_MANUAL_1_P (OMAP343X_SDRC_BASE + SDRC_MANUAL_1) 6489139dceSPeter 'p2' De Schrijver#define SDRC_DLLA_STATUS_V OMAP34XX_SDRC_REGADDR(SDRC_DLLA_STATUS) 6589139dceSPeter 'p2' De Schrijver#define SDRC_DLLA_CTRL_V OMAP34XX_SDRC_REGADDR(SDRC_DLLA_CTRL) 668bd22949SKevin Hilman 67*dd313947SDave Martin/* 68*dd313947SDave Martin * This file needs be built unconditionally as ARM to interoperate correctly 69*dd313947SDave Martin * with non-Thumb-2-capable firmware. 70*dd313947SDave Martin */ 71*dd313947SDave Martin .arm 72a89b6f00SRajendra Nayak 73d3cdfd2aSJean Pihet/* 74d3cdfd2aSJean Pihet * API functions 75d3cdfd2aSJean Pihet */ 76a89b6f00SRajendra Nayak 77f7dfe3d8SJean Pihet/* 78f7dfe3d8SJean Pihet * The "get_*restore_pointer" functions are used to provide a 79f7dfe3d8SJean Pihet * physical restore address where the ROM code jumps while waking 80f7dfe3d8SJean Pihet * up from MPU OFF/OSWR state. 81f7dfe3d8SJean Pihet * The restore pointer is stored into the scratchpad. 82f7dfe3d8SJean Pihet */ 83f7dfe3d8SJean Pihet 84a89b6f00SRajendra Nayak .text 858bd22949SKevin Hilman/* Function call to get the restore pointer for resume from OFF */ 868bd22949SKevin HilmanENTRY(get_restore_pointer) 878bd22949SKevin Hilman stmfd sp!, {lr} @ save registers on stack 888bd22949SKevin Hilman adr r0, restore 898bd22949SKevin Hilman ldmfd sp!, {pc} @ restore regs and return 90*dd313947SDave MartinENDPROC(get_restore_pointer) 91*dd313947SDave Martin .align 928bd22949SKevin HilmanENTRY(get_restore_pointer_sz) 930795a75aSTero Kristo .word . - get_restore_pointer 941e81bc01SJean Pihet 95458e999eSNishanth Menon .text 96458e999eSNishanth Menon/* Function call to get the restore pointer for 3630 resume from OFF */ 97458e999eSNishanth MenonENTRY(get_omap3630_restore_pointer) 98458e999eSNishanth Menon stmfd sp!, {lr} @ save registers on stack 99458e999eSNishanth Menon adr r0, restore_3630 100458e999eSNishanth Menon ldmfd sp!, {pc} @ restore regs and return 101*dd313947SDave MartinENDPROC(get_omap3630_restore_pointer) 102*dd313947SDave Martin .align 103458e999eSNishanth MenonENTRY(get_omap3630_restore_pointer_sz) 104458e999eSNishanth Menon .word . - get_omap3630_restore_pointer 1050795a75aSTero Kristo 1060795a75aSTero Kristo .text 1071e81bc01SJean Pihet/* Function call to get the restore pointer for ES3 to resume from OFF */ 1081e81bc01SJean PihetENTRY(get_es3_restore_pointer) 1091e81bc01SJean Pihet stmfd sp!, {lr} @ save registers on stack 1101e81bc01SJean Pihet adr r0, restore_es3 1111e81bc01SJean Pihet ldmfd sp!, {pc} @ restore regs and return 112*dd313947SDave MartinENDPROC(get_es3_restore_pointer) 113*dd313947SDave Martin .align 1141e81bc01SJean PihetENTRY(get_es3_restore_pointer_sz) 1151e81bc01SJean Pihet .word . - get_es3_restore_pointer 1161e81bc01SJean Pihet 1171e81bc01SJean Pihet .text 118c4236d2eSPeter 'p2' De Schrijver/* 119c4236d2eSPeter 'p2' De Schrijver * L2 cache needs to be toggled for stable OFF mode functionality on 3630. 1201e81bc01SJean Pihet * This function sets up a flag that will allow for this toggling to take 121f7dfe3d8SJean Pihet * place on 3630. Hopefully some version in the future may not need this. 122c4236d2eSPeter 'p2' De Schrijver */ 123c4236d2eSPeter 'p2' De SchrijverENTRY(enable_omap3630_toggle_l2_on_restore) 124c4236d2eSPeter 'p2' De Schrijver stmfd sp!, {lr} @ save registers on stack 125c4236d2eSPeter 'p2' De Schrijver /* Setup so that we will disable and enable l2 */ 126c4236d2eSPeter 'p2' De Schrijver mov r1, #0x1 127*dd313947SDave Martin adrl r2, l2dis_3630 @ may be too distant for plain adr 128*dd313947SDave Martin str r1, [r2] 129c4236d2eSPeter 'p2' De Schrijver ldmfd sp!, {pc} @ restore regs and return 130*dd313947SDave MartinENDPROC(enable_omap3630_toggle_l2_on_restore) 131c4236d2eSPeter 'p2' De Schrijver 132bb1c9034SJean Pihet .text 13327d59a4aSTero Kristo/* Function to call rom code to save secure ram context */ 13427d59a4aSTero KristoENTRY(save_secure_ram_context) 13527d59a4aSTero Kristo stmfd sp!, {r1-r12, lr} @ save registers on stack 13627d59a4aSTero Kristo adr r3, api_params @ r3 points to parameters 13727d59a4aSTero Kristo str r0, [r3,#0x4] @ r0 has sdram address 13827d59a4aSTero Kristo ldr r12, high_mask 13927d59a4aSTero Kristo and r3, r3, r12 14027d59a4aSTero Kristo ldr r12, sram_phy_addr_mask 14127d59a4aSTero Kristo orr r3, r3, r12 14227d59a4aSTero Kristo mov r0, #25 @ set service ID for PPA 14327d59a4aSTero Kristo mov r12, r0 @ copy secure service ID in r12 14427d59a4aSTero Kristo mov r1, #0 @ set task id for ROM code in r1 145ba50ea7eSKalle Jokiniemi mov r2, #4 @ set some flags in r2, r6 14627d59a4aSTero Kristo mov r6, #0xff 14727d59a4aSTero Kristo mcr p15, 0, r0, c7, c10, 4 @ data write barrier 14827d59a4aSTero Kristo mcr p15, 0, r0, c7, c10, 5 @ data memory barrier 14976d50018SDave Martin smc #1 @ call SMI monitor (smi #1) 15027d59a4aSTero Kristo nop 15127d59a4aSTero Kristo nop 15227d59a4aSTero Kristo nop 15327d59a4aSTero Kristo nop 15427d59a4aSTero Kristo ldmfd sp!, {r1-r12, pc} 155*dd313947SDave Martin .align 15627d59a4aSTero Kristosram_phy_addr_mask: 15727d59a4aSTero Kristo .word SRAM_BASE_P 15827d59a4aSTero Kristohigh_mask: 15927d59a4aSTero Kristo .word 0xffff 16027d59a4aSTero Kristoapi_params: 16127d59a4aSTero Kristo .word 0x4, 0x0, 0x0, 0x1, 0x1 162*dd313947SDave MartinENDPROC(save_secure_ram_context) 16327d59a4aSTero KristoENTRY(save_secure_ram_context_sz) 16427d59a4aSTero Kristo .word . - save_secure_ram_context 16527d59a4aSTero Kristo 1668bd22949SKevin Hilman/* 167f7dfe3d8SJean Pihet * ====================== 168f7dfe3d8SJean Pihet * == Idle entry point == 169f7dfe3d8SJean Pihet * ====================== 170f7dfe3d8SJean Pihet */ 171f7dfe3d8SJean Pihet 172f7dfe3d8SJean Pihet/* 1738bd22949SKevin Hilman * Forces OMAP into idle state 1748bd22949SKevin Hilman * 175f7dfe3d8SJean Pihet * omap34xx_cpu_suspend() - This bit of code saves the CPU context if needed 176f7dfe3d8SJean Pihet * and executes the WFI instruction. Calling WFI effectively changes the 177f7dfe3d8SJean Pihet * power domains states to the desired target power states. 1788bd22949SKevin Hilman * 179f7dfe3d8SJean Pihet * 180f7dfe3d8SJean Pihet * Notes: 181bb1c9034SJean Pihet * - this code gets copied to internal SRAM at boot and after wake-up 182bb1c9034SJean Pihet * from OFF mode. The execution pointer in SRAM is _omap_sram_idle. 183f7dfe3d8SJean Pihet * - when the OMAP wakes up it continues at different execution points 184f7dfe3d8SJean Pihet * depending on the low power mode (non-OFF vs OFF modes), 185f7dfe3d8SJean Pihet * cf. 'Resume path for xxx mode' comments. 1868bd22949SKevin Hilman */ 1878bd22949SKevin HilmanENTRY(omap34xx_cpu_suspend) 1888bd22949SKevin Hilman stmfd sp!, {r0-r12, lr} @ save registers on stack 189d3cdfd2aSJean Pihet 190f7dfe3d8SJean Pihet /* 191f7dfe3d8SJean Pihet * r0 contains restore pointer in sdram 192f7dfe3d8SJean Pihet * r1 contains information about saving context: 193f7dfe3d8SJean Pihet * 0 - No context lost 194f7dfe3d8SJean Pihet * 1 - Only L1 and logic lost 195f7dfe3d8SJean Pihet * 2 - Only L2 lost 196f7dfe3d8SJean Pihet * 3 - Both L1 and L2 lost 197f7dfe3d8SJean Pihet */ 198f7dfe3d8SJean Pihet 199f7dfe3d8SJean Pihet /* Directly jump to WFI is the context save is not required */ 200f7dfe3d8SJean Pihet cmp r1, #0x0 201f7dfe3d8SJean Pihet beq omap3_do_wfi 202f7dfe3d8SJean Pihet 203f7dfe3d8SJean Pihet /* Otherwise fall through to the save context code */ 204f7dfe3d8SJean Pihetsave_context_wfi: 205f7dfe3d8SJean Pihet mov r8, r0 @ Store SDRAM address in r8 206f7dfe3d8SJean Pihet mrc p15, 0, r5, c1, c0, 1 @ Read Auxiliary Control Register 207f7dfe3d8SJean Pihet mov r4, #0x1 @ Number of parameters for restore call 208f7dfe3d8SJean Pihet stmia r8!, {r4-r5} @ Push parameters for restore call 209f7dfe3d8SJean Pihet mrc p15, 1, r5, c9, c0, 2 @ Read L2 AUX ctrl register 210f7dfe3d8SJean Pihet stmia r8!, {r4-r5} @ Push parameters for restore call 211f7dfe3d8SJean Pihet 212f7dfe3d8SJean Pihet /* Check what that target sleep state is from r1 */ 213f7dfe3d8SJean Pihet cmp r1, #0x2 @ Only L2 lost, no need to save context 214f7dfe3d8SJean Pihet beq clean_caches 215f7dfe3d8SJean Pihet 216f7dfe3d8SJean Pihetl1_logic_lost: 217f7dfe3d8SJean Pihet /* Store sp and spsr to SDRAM */ 218f7dfe3d8SJean Pihet mov r4, sp 219f7dfe3d8SJean Pihet mrs r5, spsr 220f7dfe3d8SJean Pihet mov r6, lr 221f7dfe3d8SJean Pihet stmia r8!, {r4-r6} 222f7dfe3d8SJean Pihet /* Save all ARM registers */ 223f7dfe3d8SJean Pihet /* Coprocessor access control register */ 224f7dfe3d8SJean Pihet mrc p15, 0, r6, c1, c0, 2 225f7dfe3d8SJean Pihet stmia r8!, {r6} 226f7dfe3d8SJean Pihet /* TTBR0, TTBR1 and Translation table base control */ 227f7dfe3d8SJean Pihet mrc p15, 0, r4, c2, c0, 0 228f7dfe3d8SJean Pihet mrc p15, 0, r5, c2, c0, 1 229f7dfe3d8SJean Pihet mrc p15, 0, r6, c2, c0, 2 230f7dfe3d8SJean Pihet stmia r8!, {r4-r6} 231f7dfe3d8SJean Pihet /* 232f7dfe3d8SJean Pihet * Domain access control register, data fault status register, 233f7dfe3d8SJean Pihet * and instruction fault status register 234f7dfe3d8SJean Pihet */ 235f7dfe3d8SJean Pihet mrc p15, 0, r4, c3, c0, 0 236f7dfe3d8SJean Pihet mrc p15, 0, r5, c5, c0, 0 237f7dfe3d8SJean Pihet mrc p15, 0, r6, c5, c0, 1 238f7dfe3d8SJean Pihet stmia r8!, {r4-r6} 239f7dfe3d8SJean Pihet /* 240f7dfe3d8SJean Pihet * Data aux fault status register, instruction aux fault status, 241f7dfe3d8SJean Pihet * data fault address register and instruction fault address register 242f7dfe3d8SJean Pihet */ 243f7dfe3d8SJean Pihet mrc p15, 0, r4, c5, c1, 0 244f7dfe3d8SJean Pihet mrc p15, 0, r5, c5, c1, 1 245f7dfe3d8SJean Pihet mrc p15, 0, r6, c6, c0, 0 246f7dfe3d8SJean Pihet mrc p15, 0, r7, c6, c0, 2 247f7dfe3d8SJean Pihet stmia r8!, {r4-r7} 248f7dfe3d8SJean Pihet /* 249f7dfe3d8SJean Pihet * user r/w thread and process ID, user r/o thread and process ID, 250f7dfe3d8SJean Pihet * priv only thread and process ID, cache size selection 251f7dfe3d8SJean Pihet */ 252f7dfe3d8SJean Pihet mrc p15, 0, r4, c13, c0, 2 253f7dfe3d8SJean Pihet mrc p15, 0, r5, c13, c0, 3 254f7dfe3d8SJean Pihet mrc p15, 0, r6, c13, c0, 4 255f7dfe3d8SJean Pihet mrc p15, 2, r7, c0, c0, 0 256f7dfe3d8SJean Pihet stmia r8!, {r4-r7} 257f7dfe3d8SJean Pihet /* Data TLB lockdown, instruction TLB lockdown registers */ 258f7dfe3d8SJean Pihet mrc p15, 0, r5, c10, c0, 0 259f7dfe3d8SJean Pihet mrc p15, 0, r6, c10, c0, 1 260f7dfe3d8SJean Pihet stmia r8!, {r5-r6} 261f7dfe3d8SJean Pihet /* Secure or non secure vector base address, FCSE PID, Context PID*/ 262f7dfe3d8SJean Pihet mrc p15, 0, r4, c12, c0, 0 263f7dfe3d8SJean Pihet mrc p15, 0, r5, c13, c0, 0 264f7dfe3d8SJean Pihet mrc p15, 0, r6, c13, c0, 1 265f7dfe3d8SJean Pihet stmia r8!, {r4-r6} 266f7dfe3d8SJean Pihet /* Primary remap, normal remap registers */ 267f7dfe3d8SJean Pihet mrc p15, 0, r4, c10, c2, 0 268f7dfe3d8SJean Pihet mrc p15, 0, r5, c10, c2, 1 269f7dfe3d8SJean Pihet stmia r8!,{r4-r5} 270f7dfe3d8SJean Pihet 271f7dfe3d8SJean Pihet /* Store current cpsr*/ 272f7dfe3d8SJean Pihet mrs r2, cpsr 273f7dfe3d8SJean Pihet stmia r8!, {r2} 274f7dfe3d8SJean Pihet 275f7dfe3d8SJean Pihet mrc p15, 0, r4, c1, c0, 0 276f7dfe3d8SJean Pihet /* save control register */ 277f7dfe3d8SJean Pihet stmia r8!, {r4} 278f7dfe3d8SJean Pihet 279f7dfe3d8SJean Pihetclean_caches: 280f7dfe3d8SJean Pihet /* 281f7dfe3d8SJean Pihet * Clean Data or unified cache to POU 282f7dfe3d8SJean Pihet * How to invalidate only L1 cache???? - #FIX_ME# 283f7dfe3d8SJean Pihet * mcr p15, 0, r11, c7, c11, 1 284f7dfe3d8SJean Pihet */ 285f7dfe3d8SJean Pihet cmp r1, #0x1 @ Check whether L2 inval is required 286f7dfe3d8SJean Pihet beq omap3_do_wfi 287f7dfe3d8SJean Pihet 288f7dfe3d8SJean Pihetclean_l2: 289f7dfe3d8SJean Pihet /* 290f7dfe3d8SJean Pihet * jump out to kernel flush routine 291f7dfe3d8SJean Pihet * - reuse that code is better 292f7dfe3d8SJean Pihet * - it executes in a cached space so is faster than refetch per-block 293f7dfe3d8SJean Pihet * - should be faster and will change with kernel 294f7dfe3d8SJean Pihet * - 'might' have to copy address, load and jump to it 295f7dfe3d8SJean Pihet */ 296f7dfe3d8SJean Pihet ldr r1, kernel_flush 297*dd313947SDave Martin blx r1 298*dd313947SDave Martin /* 299*dd313947SDave Martin * The kernel doesn't interwork: v7_flush_dcache_all in particluar will 300*dd313947SDave Martin * always return in Thumb state when CONFIG_THUMB2_KERNEL is enabled. 301*dd313947SDave Martin * This sequence switches back to ARM. Note that .align may insert a 302*dd313947SDave Martin * nop: bx pc needs to be word-aligned in order to work. 303*dd313947SDave Martin */ 304*dd313947SDave Martin THUMB( .thumb ) 305*dd313947SDave Martin THUMB( .align ) 306*dd313947SDave Martin THUMB( bx pc ) 307*dd313947SDave Martin THUMB( nop ) 308*dd313947SDave Martin .arm 309f7dfe3d8SJean Pihet 310f7dfe3d8SJean Pihetomap3_do_wfi: 3118bd22949SKevin Hilman ldr r4, sdrc_power @ read the SDRC_POWER register 3128bd22949SKevin Hilman ldr r5, [r4] @ read the contents of SDRC_POWER 3138bd22949SKevin Hilman orr r5, r5, #0x40 @ enable self refresh on idle req 3148bd22949SKevin Hilman str r5, [r4] @ write back to SDRC_POWER register 3158bd22949SKevin Hilman 3168bd22949SKevin Hilman /* Data memory barrier and Data sync barrier */ 3178bd22949SKevin Hilman mov r1, #0 3188bd22949SKevin Hilman mcr p15, 0, r1, c7, c10, 4 3198bd22949SKevin Hilman mcr p15, 0, r1, c7, c10, 5 3208bd22949SKevin Hilman 321f7dfe3d8SJean Pihet/* 322f7dfe3d8SJean Pihet * =================================== 323f7dfe3d8SJean Pihet * == WFI instruction => Enter idle == 324f7dfe3d8SJean Pihet * =================================== 325f7dfe3d8SJean Pihet */ 3268bd22949SKevin Hilman wfi @ wait for interrupt 3278bd22949SKevin Hilman 328f7dfe3d8SJean Pihet/* 329f7dfe3d8SJean Pihet * =================================== 330f7dfe3d8SJean Pihet * == Resume path for non-OFF modes == 331f7dfe3d8SJean Pihet * =================================== 332f7dfe3d8SJean Pihet */ 3338bd22949SKevin Hilman nop 3348bd22949SKevin Hilman nop 3358bd22949SKevin Hilman nop 3368bd22949SKevin Hilman nop 3378bd22949SKevin Hilman nop 3388bd22949SKevin Hilman nop 3398bd22949SKevin Hilman nop 3408bd22949SKevin Hilman nop 3418bd22949SKevin Hilman nop 3428bd22949SKevin Hilman nop 34389139dceSPeter 'p2' De Schrijver bl wait_sdrc_ok 3448bd22949SKevin Hilman 345f7dfe3d8SJean Pihet/* 346f7dfe3d8SJean Pihet * =================================== 347f7dfe3d8SJean Pihet * == Exit point from non-OFF modes == 348f7dfe3d8SJean Pihet * =================================== 349f7dfe3d8SJean Pihet */ 3508bd22949SKevin Hilman ldmfd sp!, {r0-r12, pc} @ restore regs and return 351f7dfe3d8SJean Pihet 352f7dfe3d8SJean Pihet 353f7dfe3d8SJean Pihet/* 354f7dfe3d8SJean Pihet * ============================== 355f7dfe3d8SJean Pihet * == Resume path for OFF mode == 356f7dfe3d8SJean Pihet * ============================== 357f7dfe3d8SJean Pihet */ 358f7dfe3d8SJean Pihet 359f7dfe3d8SJean Pihet/* 360f7dfe3d8SJean Pihet * The restore_* functions are called by the ROM code 361f7dfe3d8SJean Pihet * when back from WFI in OFF mode. 362f7dfe3d8SJean Pihet * Cf. the get_*restore_pointer functions. 363f7dfe3d8SJean Pihet * 364f7dfe3d8SJean Pihet * restore_es3: applies to 34xx >= ES3.0 365f7dfe3d8SJean Pihet * restore_3630: applies to 36xx 366f7dfe3d8SJean Pihet * restore: common code for 3xxx 367f7dfe3d8SJean Pihet */ 3680795a75aSTero Kristorestore_es3: 3690795a75aSTero Kristo ldr r5, pm_prepwstst_core_p 3700795a75aSTero Kristo ldr r4, [r5] 3710795a75aSTero Kristo and r4, r4, #0x3 3720795a75aSTero Kristo cmp r4, #0x0 @ Check if previous power state of CORE is OFF 3730795a75aSTero Kristo bne restore 3740795a75aSTero Kristo adr r0, es3_sdrc_fix 3750795a75aSTero Kristo ldr r1, sram_base 3760795a75aSTero Kristo ldr r2, es3_sdrc_fix_sz 3770795a75aSTero Kristo mov r2, r2, ror #2 3780795a75aSTero Kristocopy_to_sram: 3790795a75aSTero Kristo ldmia r0!, {r3} @ val = *src 3800795a75aSTero Kristo stmia r1!, {r3} @ *dst = val 3810795a75aSTero Kristo subs r2, r2, #0x1 @ num_words-- 3820795a75aSTero Kristo bne copy_to_sram 3830795a75aSTero Kristo ldr r1, sram_base 3840795a75aSTero Kristo blx r1 385458e999eSNishanth Menon b restore 386458e999eSNishanth Menon 387458e999eSNishanth Menonrestore_3630: 388458e999eSNishanth Menon ldr r1, pm_prepwstst_core_p 389458e999eSNishanth Menon ldr r2, [r1] 390458e999eSNishanth Menon and r2, r2, #0x3 391458e999eSNishanth Menon cmp r2, #0x0 @ Check if previous power state of CORE is OFF 392458e999eSNishanth Menon bne restore 393458e999eSNishanth Menon /* Disable RTA before giving control */ 394458e999eSNishanth Menon ldr r1, control_mem_rta 395458e999eSNishanth Menon mov r2, #OMAP36XX_RTA_DISABLE 396458e999eSNishanth Menon str r2, [r1] 397f7dfe3d8SJean Pihet 398f7dfe3d8SJean Pihet /* Fall through to common code for the remaining logic */ 399f7dfe3d8SJean Pihet 4008bd22949SKevin Hilmanrestore: 401f7dfe3d8SJean Pihet /* 402f7dfe3d8SJean Pihet * Check what was the reason for mpu reset and store the reason in r9: 403f7dfe3d8SJean Pihet * 0 - No context lost 404f7dfe3d8SJean Pihet * 1 - Only L1 and logic lost 405f7dfe3d8SJean Pihet * 2 - Only L2 lost - In this case, we wont be here 406f7dfe3d8SJean Pihet * 3 - Both L1 and L2 lost 407f7dfe3d8SJean Pihet */ 4088bd22949SKevin Hilman ldr r1, pm_pwstctrl_mpu 4098bd22949SKevin Hilman ldr r2, [r1] 4108bd22949SKevin Hilman and r2, r2, #0x3 4118bd22949SKevin Hilman cmp r2, #0x0 @ Check if target power state was OFF or RET 4128bd22949SKevin Hilman moveq r9, #0x3 @ MPU OFF => L1 and L2 lost 4138bd22949SKevin Hilman movne r9, #0x1 @ Only L1 and L2 lost => avoid L2 invalidation 4148bd22949SKevin Hilman bne logic_l1_restore 415c4236d2eSPeter 'p2' De Schrijver 416c4236d2eSPeter 'p2' De Schrijver ldr r0, l2dis_3630 417c4236d2eSPeter 'p2' De Schrijver cmp r0, #0x1 @ should we disable L2 on 3630? 418c4236d2eSPeter 'p2' De Schrijver bne skipl2dis 419c4236d2eSPeter 'p2' De Schrijver mrc p15, 0, r0, c1, c0, 1 420c4236d2eSPeter 'p2' De Schrijver bic r0, r0, #2 @ disable L2 cache 421c4236d2eSPeter 'p2' De Schrijver mcr p15, 0, r0, c1, c0, 1 422c4236d2eSPeter 'p2' De Schrijverskipl2dis: 42327d59a4aSTero Kristo ldr r0, control_stat 42427d59a4aSTero Kristo ldr r1, [r0] 42527d59a4aSTero Kristo and r1, #0x700 42627d59a4aSTero Kristo cmp r1, #0x300 42727d59a4aSTero Kristo beq l2_inv_gp 42827d59a4aSTero Kristo mov r0, #40 @ set service ID for PPA 42927d59a4aSTero Kristo mov r12, r0 @ copy secure Service ID in r12 43027d59a4aSTero Kristo mov r1, #0 @ set task id for ROM code in r1 43127d59a4aSTero Kristo mov r2, #4 @ set some flags in r2, r6 43227d59a4aSTero Kristo mov r6, #0xff 43327d59a4aSTero Kristo adr r3, l2_inv_api_params @ r3 points to dummy parameters 43427d59a4aSTero Kristo mcr p15, 0, r0, c7, c10, 4 @ data write barrier 43527d59a4aSTero Kristo mcr p15, 0, r0, c7, c10, 5 @ data memory barrier 43676d50018SDave Martin smc #1 @ call SMI monitor (smi #1) 43727d59a4aSTero Kristo /* Write to Aux control register to set some bits */ 43827d59a4aSTero Kristo mov r0, #42 @ set service ID for PPA 43927d59a4aSTero Kristo mov r12, r0 @ copy secure Service ID in r12 44027d59a4aSTero Kristo mov r1, #0 @ set task id for ROM code in r1 44127d59a4aSTero Kristo mov r2, #4 @ set some flags in r2, r6 44227d59a4aSTero Kristo mov r6, #0xff 443a087cad9STero Kristo ldr r4, scratchpad_base 444a087cad9STero Kristo ldr r3, [r4, #0xBC] @ r3 points to parameters 44527d59a4aSTero Kristo mcr p15, 0, r0, c7, c10, 4 @ data write barrier 44627d59a4aSTero Kristo mcr p15, 0, r0, c7, c10, 5 @ data memory barrier 44776d50018SDave Martin smc #1 @ call SMI monitor (smi #1) 44827d59a4aSTero Kristo 44979dcfdd4STero Kristo#ifdef CONFIG_OMAP3_L2_AUX_SECURE_SAVE_RESTORE 45079dcfdd4STero Kristo /* Restore L2 aux control register */ 45179dcfdd4STero Kristo @ set service ID for PPA 45279dcfdd4STero Kristo mov r0, #CONFIG_OMAP3_L2_AUX_SECURE_SERVICE_SET_ID 45379dcfdd4STero Kristo mov r12, r0 @ copy service ID in r12 45479dcfdd4STero Kristo mov r1, #0 @ set task ID for ROM code in r1 45579dcfdd4STero Kristo mov r2, #4 @ set some flags in r2, r6 45679dcfdd4STero Kristo mov r6, #0xff 45779dcfdd4STero Kristo ldr r4, scratchpad_base 45879dcfdd4STero Kristo ldr r3, [r4, #0xBC] 45979dcfdd4STero Kristo adds r3, r3, #8 @ r3 points to parameters 46079dcfdd4STero Kristo mcr p15, 0, r0, c7, c10, 4 @ data write barrier 46179dcfdd4STero Kristo mcr p15, 0, r0, c7, c10, 5 @ data memory barrier 46276d50018SDave Martin smc #1 @ call SMI monitor (smi #1) 46379dcfdd4STero Kristo#endif 46427d59a4aSTero Kristo b logic_l1_restore 465bb1c9034SJean Pihet 466*dd313947SDave Martin .align 46727d59a4aSTero Kristol2_inv_api_params: 46827d59a4aSTero Kristo .word 0x1, 0x00 46927d59a4aSTero Kristol2_inv_gp: 4708bd22949SKevin Hilman /* Execute smi to invalidate L2 cache */ 471bb1c9034SJean Pihet mov r12, #0x1 @ set up to invalidate L2 47276d50018SDave Martin smc #0 @ Call SMI monitor (smieq) 47327d59a4aSTero Kristo /* Write to Aux control register to set some bits */ 474a087cad9STero Kristo ldr r4, scratchpad_base 475a087cad9STero Kristo ldr r3, [r4,#0xBC] 476a087cad9STero Kristo ldr r0, [r3,#4] 47727d59a4aSTero Kristo mov r12, #0x3 47876d50018SDave Martin smc #0 @ Call SMI monitor (smieq) 47979dcfdd4STero Kristo ldr r4, scratchpad_base 48079dcfdd4STero Kristo ldr r3, [r4,#0xBC] 48179dcfdd4STero Kristo ldr r0, [r3,#12] 48279dcfdd4STero Kristo mov r12, #0x2 48376d50018SDave Martin smc #0 @ Call SMI monitor (smieq) 4848bd22949SKevin Hilmanlogic_l1_restore: 485c4236d2eSPeter 'p2' De Schrijver ldr r1, l2dis_3630 486bb1c9034SJean Pihet cmp r1, #0x1 @ Test if L2 re-enable needed on 3630 487c4236d2eSPeter 'p2' De Schrijver bne skipl2reen 488c4236d2eSPeter 'p2' De Schrijver mrc p15, 0, r1, c1, c0, 1 489c4236d2eSPeter 'p2' De Schrijver orr r1, r1, #2 @ re-enable L2 cache 490c4236d2eSPeter 'p2' De Schrijver mcr p15, 0, r1, c1, c0, 1 491c4236d2eSPeter 'p2' De Schrijverskipl2reen: 4928bd22949SKevin Hilman mov r1, #0 493bb1c9034SJean Pihet /* 494bb1c9034SJean Pihet * Invalidate all instruction caches to PoU 495bb1c9034SJean Pihet * and flush branch target cache 496bb1c9034SJean Pihet */ 4978bd22949SKevin Hilman mcr p15, 0, r1, c7, c5, 0 4988bd22949SKevin Hilman 4998bd22949SKevin Hilman ldr r4, scratchpad_base 5008bd22949SKevin Hilman ldr r3, [r4,#0xBC] 50179dcfdd4STero Kristo adds r3, r3, #16 5028bd22949SKevin Hilman ldmia r3!, {r4-r6} 5038bd22949SKevin Hilman mov sp, r4 5048bd22949SKevin Hilman msr spsr_cxsf, r5 5058bd22949SKevin Hilman mov lr, r6 5068bd22949SKevin Hilman 5078bd22949SKevin Hilman ldmia r3!, {r4-r9} 5088bd22949SKevin Hilman /* Coprocessor access Control Register */ 5098bd22949SKevin Hilman mcr p15, 0, r4, c1, c0, 2 5108bd22949SKevin Hilman 5118bd22949SKevin Hilman /* TTBR0 */ 5128bd22949SKevin Hilman MCR p15, 0, r5, c2, c0, 0 5138bd22949SKevin Hilman /* TTBR1 */ 5148bd22949SKevin Hilman MCR p15, 0, r6, c2, c0, 1 5158bd22949SKevin Hilman /* Translation table base control register */ 5168bd22949SKevin Hilman MCR p15, 0, r7, c2, c0, 2 517bb1c9034SJean Pihet /* Domain access Control Register */ 5188bd22949SKevin Hilman MCR p15, 0, r8, c3, c0, 0 519bb1c9034SJean Pihet /* Data fault status Register */ 5208bd22949SKevin Hilman MCR p15, 0, r9, c5, c0, 0 5218bd22949SKevin Hilman 5228bd22949SKevin Hilman ldmia r3!,{r4-r8} 523bb1c9034SJean Pihet /* Instruction fault status Register */ 5248bd22949SKevin Hilman MCR p15, 0, r4, c5, c0, 1 5258bd22949SKevin Hilman /* Data Auxiliary Fault Status Register */ 5268bd22949SKevin Hilman MCR p15, 0, r5, c5, c1, 0 5278bd22949SKevin Hilman /* Instruction Auxiliary Fault Status Register*/ 5288bd22949SKevin Hilman MCR p15, 0, r6, c5, c1, 1 5298bd22949SKevin Hilman /* Data Fault Address Register */ 5308bd22949SKevin Hilman MCR p15, 0, r7, c6, c0, 0 5318bd22949SKevin Hilman /* Instruction Fault Address Register*/ 5328bd22949SKevin Hilman MCR p15, 0, r8, c6, c0, 2 5338bd22949SKevin Hilman ldmia r3!,{r4-r7} 5348bd22949SKevin Hilman 535bb1c9034SJean Pihet /* User r/w thread and process ID */ 5368bd22949SKevin Hilman MCR p15, 0, r4, c13, c0, 2 537bb1c9034SJean Pihet /* User ro thread and process ID */ 5388bd22949SKevin Hilman MCR p15, 0, r5, c13, c0, 3 5398bd22949SKevin Hilman /* Privileged only thread and process ID */ 5408bd22949SKevin Hilman MCR p15, 0, r6, c13, c0, 4 541bb1c9034SJean Pihet /* Cache size selection */ 5428bd22949SKevin Hilman MCR p15, 2, r7, c0, c0, 0 5438bd22949SKevin Hilman ldmia r3!,{r4-r8} 5448bd22949SKevin Hilman /* Data TLB lockdown registers */ 5458bd22949SKevin Hilman MCR p15, 0, r4, c10, c0, 0 5468bd22949SKevin Hilman /* Instruction TLB lockdown registers */ 5478bd22949SKevin Hilman MCR p15, 0, r5, c10, c0, 1 5488bd22949SKevin Hilman /* Secure or Nonsecure Vector Base Address */ 5498bd22949SKevin Hilman MCR p15, 0, r6, c12, c0, 0 5508bd22949SKevin Hilman /* FCSE PID */ 5518bd22949SKevin Hilman MCR p15, 0, r7, c13, c0, 0 5528bd22949SKevin Hilman /* Context PID */ 5538bd22949SKevin Hilman MCR p15, 0, r8, c13, c0, 1 5548bd22949SKevin Hilman 5558bd22949SKevin Hilman ldmia r3!,{r4-r5} 556bb1c9034SJean Pihet /* Primary memory remap register */ 5578bd22949SKevin Hilman MCR p15, 0, r4, c10, c2, 0 558bb1c9034SJean Pihet /* Normal memory remap register */ 5598bd22949SKevin Hilman MCR p15, 0, r5, c10, c2, 1 5608bd22949SKevin Hilman 5618bd22949SKevin Hilman /* Restore cpsr */ 562bb1c9034SJean Pihet ldmia r3!,{r4} @ load CPSR from SDRAM 563bb1c9034SJean Pihet msr cpsr, r4 @ store cpsr 5648bd22949SKevin Hilman 5658bd22949SKevin Hilman /* Enabling MMU here */ 566bb1c9034SJean Pihet mrc p15, 0, r7, c2, c0, 2 @ Read TTBRControl 5678bd22949SKevin Hilman /* Extract N (0:2) bits and decide whether to use TTBR0 or TTBR1 */ 5688bd22949SKevin Hilman and r7, #0x7 5698bd22949SKevin Hilman cmp r7, #0x0 5708bd22949SKevin Hilman beq usettbr0 5718bd22949SKevin Hilmanttbr_error: 572bb1c9034SJean Pihet /* 573bb1c9034SJean Pihet * More work needs to be done to support N[0:2] value other than 0 5748bd22949SKevin Hilman * So looping here so that the error can be detected 5758bd22949SKevin Hilman */ 5768bd22949SKevin Hilman b ttbr_error 5778bd22949SKevin Hilmanusettbr0: 5788bd22949SKevin Hilman mrc p15, 0, r2, c2, c0, 0 5798bd22949SKevin Hilman ldr r5, ttbrbit_mask 5808bd22949SKevin Hilman and r2, r5 5818bd22949SKevin Hilman mov r4, pc 5828bd22949SKevin Hilman ldr r5, table_index_mask 583bb1c9034SJean Pihet and r4, r5 @ r4 = 31 to 20 bits of pc 5848bd22949SKevin Hilman /* Extract the value to be written to table entry */ 5858bd22949SKevin Hilman ldr r1, table_entry 586bb1c9034SJean Pihet /* r1 has the value to be written to table entry*/ 587bb1c9034SJean Pihet add r1, r1, r4 5888bd22949SKevin Hilman /* Getting the address of table entry to modify */ 5898bd22949SKevin Hilman lsr r4, #18 590bb1c9034SJean Pihet /* r2 has the location which needs to be modified */ 591bb1c9034SJean Pihet add r2, r4 5928bd22949SKevin Hilman /* Storing previous entry of location being modified */ 5938bd22949SKevin Hilman ldr r5, scratchpad_base 5948bd22949SKevin Hilman ldr r4, [r2] 5958bd22949SKevin Hilman str r4, [r5, #0xC0] 5968bd22949SKevin Hilman /* Modify the table entry */ 5978bd22949SKevin Hilman str r1, [r2] 598bb1c9034SJean Pihet /* 599bb1c9034SJean Pihet * Storing address of entry being modified 600bb1c9034SJean Pihet * - will be restored after enabling MMU 601bb1c9034SJean Pihet */ 6028bd22949SKevin Hilman ldr r5, scratchpad_base 6038bd22949SKevin Hilman str r2, [r5, #0xC4] 6048bd22949SKevin Hilman 6058bd22949SKevin Hilman mov r0, #0 6068bd22949SKevin Hilman mcr p15, 0, r0, c7, c5, 4 @ Flush prefetch buffer 6078bd22949SKevin Hilman mcr p15, 0, r0, c7, c5, 6 @ Invalidate branch predictor array 6088bd22949SKevin Hilman mcr p15, 0, r0, c8, c5, 0 @ Invalidate instruction TLB 6098bd22949SKevin Hilman mcr p15, 0, r0, c8, c6, 0 @ Invalidate data TLB 610bb1c9034SJean Pihet /* 611bb1c9034SJean Pihet * Restore control register. This enables the MMU. 612bb1c9034SJean Pihet * The caches and prediction are not enabled here, they 613bb1c9034SJean Pihet * will be enabled after restoring the MMU table entry. 614bb1c9034SJean Pihet */ 6158bd22949SKevin Hilman ldmia r3!, {r4} 6168bd22949SKevin Hilman /* Store previous value of control register in scratchpad */ 6178bd22949SKevin Hilman str r4, [r5, #0xC8] 6188bd22949SKevin Hilman ldr r2, cache_pred_disable_mask 6198bd22949SKevin Hilman and r4, r2 6208bd22949SKevin Hilman mcr p15, 0, r4, c1, c0, 0 6218bd22949SKevin Hilman 6220bd40535SRichard Woodruff/* 623f7dfe3d8SJean Pihet * ============================== 624f7dfe3d8SJean Pihet * == Exit point from OFF mode == 625f7dfe3d8SJean Pihet * ============================== 6260bd40535SRichard Woodruff */ 627f7dfe3d8SJean Pihet ldmfd sp!, {r0-r12, pc} @ restore regs and return 6288bd22949SKevin Hilman 6291e81bc01SJean Pihet 6301e81bc01SJean Pihet/* 6311e81bc01SJean Pihet * Internal functions 6321e81bc01SJean Pihet */ 6331e81bc01SJean Pihet 63483521291SJean Pihet/* This function implements the erratum ID i443 WA, applies to 34xx >= ES3.0 */ 6351e81bc01SJean Pihet .text 636*dd313947SDave Martin .align 3 6371e81bc01SJean PihetENTRY(es3_sdrc_fix) 6381e81bc01SJean Pihet ldr r4, sdrc_syscfg @ get config addr 6391e81bc01SJean Pihet ldr r5, [r4] @ get value 6401e81bc01SJean Pihet tst r5, #0x100 @ is part access blocked 6411e81bc01SJean Pihet it eq 6421e81bc01SJean Pihet biceq r5, r5, #0x100 @ clear bit if set 6431e81bc01SJean Pihet str r5, [r4] @ write back change 6441e81bc01SJean Pihet ldr r4, sdrc_mr_0 @ get config addr 6451e81bc01SJean Pihet ldr r5, [r4] @ get value 6461e81bc01SJean Pihet str r5, [r4] @ write back change 6471e81bc01SJean Pihet ldr r4, sdrc_emr2_0 @ get config addr 6481e81bc01SJean Pihet ldr r5, [r4] @ get value 6491e81bc01SJean Pihet str r5, [r4] @ write back change 6501e81bc01SJean Pihet ldr r4, sdrc_manual_0 @ get config addr 6511e81bc01SJean Pihet mov r5, #0x2 @ autorefresh command 6521e81bc01SJean Pihet str r5, [r4] @ kick off refreshes 6531e81bc01SJean Pihet ldr r4, sdrc_mr_1 @ get config addr 6541e81bc01SJean Pihet ldr r5, [r4] @ get value 6551e81bc01SJean Pihet str r5, [r4] @ write back change 6561e81bc01SJean Pihet ldr r4, sdrc_emr2_1 @ get config addr 6571e81bc01SJean Pihet ldr r5, [r4] @ get value 6581e81bc01SJean Pihet str r5, [r4] @ write back change 6591e81bc01SJean Pihet ldr r4, sdrc_manual_1 @ get config addr 6601e81bc01SJean Pihet mov r5, #0x2 @ autorefresh command 6611e81bc01SJean Pihet str r5, [r4] @ kick off refreshes 6621e81bc01SJean Pihet bx lr 6631e81bc01SJean Pihet 664*dd313947SDave Martin .align 6651e81bc01SJean Pihetsdrc_syscfg: 6661e81bc01SJean Pihet .word SDRC_SYSCONFIG_P 6671e81bc01SJean Pihetsdrc_mr_0: 6681e81bc01SJean Pihet .word SDRC_MR_0_P 6691e81bc01SJean Pihetsdrc_emr2_0: 6701e81bc01SJean Pihet .word SDRC_EMR2_0_P 6711e81bc01SJean Pihetsdrc_manual_0: 6721e81bc01SJean Pihet .word SDRC_MANUAL_0_P 6731e81bc01SJean Pihetsdrc_mr_1: 6741e81bc01SJean Pihet .word SDRC_MR_1_P 6751e81bc01SJean Pihetsdrc_emr2_1: 6761e81bc01SJean Pihet .word SDRC_EMR2_1_P 6771e81bc01SJean Pihetsdrc_manual_1: 6781e81bc01SJean Pihet .word SDRC_MANUAL_1_P 679*dd313947SDave MartinENDPROC(es3_sdrc_fix) 6801e81bc01SJean PihetENTRY(es3_sdrc_fix_sz) 6811e81bc01SJean Pihet .word . - es3_sdrc_fix 6821e81bc01SJean Pihet 68383521291SJean Pihet/* 68483521291SJean Pihet * This function implements the erratum ID i581 WA: 68583521291SJean Pihet * SDRC state restore before accessing the SDRAM 68683521291SJean Pihet * 68783521291SJean Pihet * Only used at return from non-OFF mode. For OFF 68883521291SJean Pihet * mode the ROM code configures the SDRC and 68983521291SJean Pihet * the DPLL before calling the restore code directly 69083521291SJean Pihet * from DDR. 69183521291SJean Pihet */ 69283521291SJean Pihet 69389139dceSPeter 'p2' De Schrijver/* Make sure SDRC accesses are ok */ 69489139dceSPeter 'p2' De Schrijverwait_sdrc_ok: 6959d93b8a2SPeter 'p2' De Schrijver 696bb1c9034SJean Pihet/* DPLL3 must be locked before accessing the SDRC. Maybe the HW ensures this */ 6979d93b8a2SPeter 'p2' De Schrijver ldr r4, cm_idlest_ckgen 6989d93b8a2SPeter 'p2' De Schrijverwait_dpll3_lock: 69989139dceSPeter 'p2' De Schrijver ldr r5, [r4] 7009d93b8a2SPeter 'p2' De Schrijver tst r5, #1 7019d93b8a2SPeter 'p2' De Schrijver beq wait_dpll3_lock 7029d93b8a2SPeter 'p2' De Schrijver 7039d93b8a2SPeter 'p2' De Schrijver ldr r4, cm_idlest1_core 7049d93b8a2SPeter 'p2' De Schrijverwait_sdrc_ready: 7059d93b8a2SPeter 'p2' De Schrijver ldr r5, [r4] 7069d93b8a2SPeter 'p2' De Schrijver tst r5, #0x2 7079d93b8a2SPeter 'p2' De Schrijver bne wait_sdrc_ready 7089d93b8a2SPeter 'p2' De Schrijver /* allow DLL powerdown upon hw idle req */ 7098bd22949SKevin Hilman ldr r4, sdrc_power 7108bd22949SKevin Hilman ldr r5, [r4] 7118bd22949SKevin Hilman bic r5, r5, #0x40 7128bd22949SKevin Hilman str r5, [r4] 7139d93b8a2SPeter 'p2' De Schrijver 714*dd313947SDave Martin/* 715*dd313947SDave Martin * PC-relative stores lead to undefined behaviour in Thumb-2: use a r7 as a 716*dd313947SDave Martin * base instead. 717*dd313947SDave Martin * Be careful not to clobber r7 when maintaing this code. 718*dd313947SDave Martin */ 719*dd313947SDave Martin 720bb1c9034SJean Pihetis_dll_in_lock_mode: 72189139dceSPeter 'p2' De Schrijver /* Is dll in lock mode? */ 72289139dceSPeter 'p2' De Schrijver ldr r4, sdrc_dlla_ctrl 72389139dceSPeter 'p2' De Schrijver ldr r5, [r4] 72489139dceSPeter 'p2' De Schrijver tst r5, #0x4 725bb1c9034SJean Pihet bxne lr @ Return if locked 72689139dceSPeter 'p2' De Schrijver /* wait till dll locks */ 727*dd313947SDave Martin adr r7, kick_counter 7289d93b8a2SPeter 'p2' De Schrijverwait_dll_lock_timed: 7299d93b8a2SPeter 'p2' De Schrijver ldr r4, wait_dll_lock_counter 7309d93b8a2SPeter 'p2' De Schrijver add r4, r4, #1 731*dd313947SDave Martin str r4, [r7, #wait_dll_lock_counter - kick_counter] 73289139dceSPeter 'p2' De Schrijver ldr r4, sdrc_dlla_status 733bb1c9034SJean Pihet /* Wait 20uS for lock */ 734bb1c9034SJean Pihet mov r6, #8 7359d93b8a2SPeter 'p2' De Schrijverwait_dll_lock: 7369d93b8a2SPeter 'p2' De Schrijver subs r6, r6, #0x1 7379d93b8a2SPeter 'p2' De Schrijver beq kick_dll 73889139dceSPeter 'p2' De Schrijver ldr r5, [r4] 73989139dceSPeter 'p2' De Schrijver and r5, r5, #0x4 74089139dceSPeter 'p2' De Schrijver cmp r5, #0x4 74189139dceSPeter 'p2' De Schrijver bne wait_dll_lock 742bb1c9034SJean Pihet bx lr @ Return when locked 74389139dceSPeter 'p2' De Schrijver 7449d93b8a2SPeter 'p2' De Schrijver /* disable/reenable DLL if not locked */ 7459d93b8a2SPeter 'p2' De Schrijverkick_dll: 7469d93b8a2SPeter 'p2' De Schrijver ldr r4, sdrc_dlla_ctrl 7479d93b8a2SPeter 'p2' De Schrijver ldr r5, [r4] 7489d93b8a2SPeter 'p2' De Schrijver mov r6, r5 749bb1c9034SJean Pihet bic r6, #(1<<3) @ disable dll 7509d93b8a2SPeter 'p2' De Schrijver str r6, [r4] 7519d93b8a2SPeter 'p2' De Schrijver dsb 752bb1c9034SJean Pihet orr r6, r6, #(1<<3) @ enable dll 7539d93b8a2SPeter 'p2' De Schrijver str r6, [r4] 7549d93b8a2SPeter 'p2' De Schrijver dsb 7559d93b8a2SPeter 'p2' De Schrijver ldr r4, kick_counter 7569d93b8a2SPeter 'p2' De Schrijver add r4, r4, #1 757*dd313947SDave Martin str r4, [r7] @ kick_counter 7589d93b8a2SPeter 'p2' De Schrijver b wait_dll_lock_timed 7599d93b8a2SPeter 'p2' De Schrijver 760*dd313947SDave Martin .align 76189139dceSPeter 'p2' De Schrijvercm_idlest1_core: 76289139dceSPeter 'p2' De Schrijver .word CM_IDLEST1_CORE_V 7639d93b8a2SPeter 'p2' De Schrijvercm_idlest_ckgen: 7649d93b8a2SPeter 'p2' De Schrijver .word CM_IDLEST_CKGEN_V 76589139dceSPeter 'p2' De Schrijversdrc_dlla_status: 76689139dceSPeter 'p2' De Schrijver .word SDRC_DLLA_STATUS_V 76789139dceSPeter 'p2' De Schrijversdrc_dlla_ctrl: 76889139dceSPeter 'p2' De Schrijver .word SDRC_DLLA_CTRL_V 7690795a75aSTero Kristopm_prepwstst_core_p: 7700795a75aSTero Kristo .word PM_PREPWSTST_CORE_P 7718bd22949SKevin Hilmanpm_pwstctrl_mpu: 7728bd22949SKevin Hilman .word PM_PWSTCTRL_MPU_P 7738bd22949SKevin Hilmanscratchpad_base: 7748bd22949SKevin Hilman .word SCRATCHPAD_BASE_P 7750795a75aSTero Kristosram_base: 7760795a75aSTero Kristo .word SRAM_BASE_P + 0x8000 7778bd22949SKevin Hilmansdrc_power: 7788bd22949SKevin Hilman .word SDRC_POWER_V 7798bd22949SKevin Hilmanttbrbit_mask: 7808bd22949SKevin Hilman .word 0xFFFFC000 7818bd22949SKevin Hilmantable_index_mask: 7828bd22949SKevin Hilman .word 0xFFF00000 7838bd22949SKevin Hilmantable_entry: 7848bd22949SKevin Hilman .word 0x00000C02 7858bd22949SKevin Hilmancache_pred_disable_mask: 7868bd22949SKevin Hilman .word 0xFFFFE7FB 78727d59a4aSTero Kristocontrol_stat: 78827d59a4aSTero Kristo .word CONTROL_STAT 789458e999eSNishanth Menoncontrol_mem_rta: 790458e999eSNishanth Menon .word CONTROL_MEM_RTA_CTRL 7910bd40535SRichard Woodruffkernel_flush: 7920bd40535SRichard Woodruff .word v7_flush_dcache_all 793c4236d2eSPeter 'p2' De Schrijverl2dis_3630: 794c4236d2eSPeter 'p2' De Schrijver .word 0 7959d93b8a2SPeter 'p2' De Schrijver /* 7969d93b8a2SPeter 'p2' De Schrijver * When exporting to userspace while the counters are in SRAM, 7979d93b8a2SPeter 'p2' De Schrijver * these 2 words need to be at the end to facilitate retrival! 7989d93b8a2SPeter 'p2' De Schrijver */ 7999d93b8a2SPeter 'p2' De Schrijverkick_counter: 8009d93b8a2SPeter 'p2' De Schrijver .word 0 8019d93b8a2SPeter 'p2' De Schrijverwait_dll_lock_counter: 8029d93b8a2SPeter 'p2' De Schrijver .word 0 803*dd313947SDave MartinENDPROC(omap34xx_cpu_suspend) 804f7dfe3d8SJean Pihet 8058bd22949SKevin HilmanENTRY(omap34xx_cpu_suspend_sz) 8068bd22949SKevin Hilman .word . - omap34xx_cpu_suspend 807