1b2b9762fSSantosh Shilimkar /* 2b2b9762fSSantosh Shilimkar * OMAP MPUSS low power code 3b2b9762fSSantosh Shilimkar * 4b2b9762fSSantosh Shilimkar * Copyright (C) 2011 Texas Instruments, Inc. 5b2b9762fSSantosh Shilimkar * Santosh Shilimkar <santosh.shilimkar@ti.com> 6b2b9762fSSantosh Shilimkar * 7b2b9762fSSantosh Shilimkar * OMAP4430 MPUSS mainly consists of dual Cortex-A9 with per-CPU 8b2b9762fSSantosh Shilimkar * Local timer and Watchdog, GIC, SCU, PL310 L2 cache controller, 9b2b9762fSSantosh Shilimkar * CPU0 and CPU1 LPRM modules. 10b2b9762fSSantosh Shilimkar * CPU0, CPU1 and MPUSS each have there own power domain and 11b2b9762fSSantosh Shilimkar * hence multiple low power combinations of MPUSS are possible. 12b2b9762fSSantosh Shilimkar * 13b2b9762fSSantosh Shilimkar * The CPU0 and CPU1 can't support Closed switch Retention (CSWR) 14b2b9762fSSantosh Shilimkar * because the mode is not supported by hw constraints of dormant 15b2b9762fSSantosh Shilimkar * mode. While waking up from the dormant mode, a reset signal 16b2b9762fSSantosh Shilimkar * to the Cortex-A9 processor must be asserted by the external 17b2b9762fSSantosh Shilimkar * power controller. 18b2b9762fSSantosh Shilimkar * 19b2b9762fSSantosh Shilimkar * With architectural inputs and hardware recommendations, only 20b2b9762fSSantosh Shilimkar * below modes are supported from power gain vs latency point of view. 21b2b9762fSSantosh Shilimkar * 22b2b9762fSSantosh Shilimkar * CPU0 CPU1 MPUSS 23b2b9762fSSantosh Shilimkar * ---------------------------------------------- 24b2b9762fSSantosh Shilimkar * ON ON ON 25b2b9762fSSantosh Shilimkar * ON(Inactive) OFF ON(Inactive) 26b2b9762fSSantosh Shilimkar * OFF OFF CSWR 273ba2a739SSantosh Shilimkar * OFF OFF OSWR 283ba2a739SSantosh Shilimkar * OFF OFF OFF(Device OFF *TBD) 29b2b9762fSSantosh Shilimkar * ---------------------------------------------- 30b2b9762fSSantosh Shilimkar * 31b2b9762fSSantosh Shilimkar * Note: CPU0 is the master core and it is the last CPU to go down 32b2b9762fSSantosh Shilimkar * and first to wake-up when MPUSS low power states are excercised 33b2b9762fSSantosh Shilimkar * 34b2b9762fSSantosh Shilimkar * 35b2b9762fSSantosh Shilimkar * This program is free software; you can redistribute it and/or modify 36b2b9762fSSantosh Shilimkar * it under the terms of the GNU General Public License version 2 as 37b2b9762fSSantosh Shilimkar * published by the Free Software Foundation. 38b2b9762fSSantosh Shilimkar */ 39b2b9762fSSantosh Shilimkar 40b2b9762fSSantosh Shilimkar #include <linux/kernel.h> 41b2b9762fSSantosh Shilimkar #include <linux/io.h> 42b2b9762fSSantosh Shilimkar #include <linux/errno.h> 43b2b9762fSSantosh Shilimkar #include <linux/linkage.h> 44b2b9762fSSantosh Shilimkar #include <linux/smp.h> 45b2b9762fSSantosh Shilimkar 46b2b9762fSSantosh Shilimkar #include <asm/cacheflush.h> 47b2b9762fSSantosh Shilimkar #include <asm/tlbflush.h> 48b2b9762fSSantosh Shilimkar #include <asm/smp_scu.h> 49b2b9762fSSantosh Shilimkar #include <asm/pgalloc.h> 50b2b9762fSSantosh Shilimkar #include <asm/suspend.h> 515e94c6e3SSantosh Shilimkar #include <asm/hardware/cache-l2x0.h> 52b2b9762fSSantosh Shilimkar 53e4c060dbSTony Lindgren #include "soc.h" 54b2b9762fSSantosh Shilimkar #include "common.h" 55c49f34bcSTony Lindgren #include "omap44xx.h" 56b2b9762fSSantosh Shilimkar #include "omap4-sar-layout.h" 57b2b9762fSSantosh Shilimkar #include "pm.h" 583ba2a739SSantosh Shilimkar #include "prcm_mpu44xx.h" 593ba2a739SSantosh Shilimkar #include "prminst44xx.h" 603ba2a739SSantosh Shilimkar #include "prcm44xx.h" 613ba2a739SSantosh Shilimkar #include "prm44xx.h" 623ba2a739SSantosh Shilimkar #include "prm-regbits-44xx.h" 63b2b9762fSSantosh Shilimkar 64b2b9762fSSantosh Shilimkar #ifdef CONFIG_SMP 65b2b9762fSSantosh Shilimkar 66b2b9762fSSantosh Shilimkar struct omap4_cpu_pm_info { 67b2b9762fSSantosh Shilimkar struct powerdomain *pwrdm; 68b2b9762fSSantosh Shilimkar void __iomem *scu_sar_addr; 69b2b9762fSSantosh Shilimkar void __iomem *wkup_sar_addr; 705e94c6e3SSantosh Shilimkar void __iomem *l2x0_sar_addr; 71ff999b8aSSantosh Shilimkar void (*secondary_startup)(void); 72b2b9762fSSantosh Shilimkar }; 73b2b9762fSSantosh Shilimkar 74b2b9762fSSantosh Shilimkar static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info); 75e44f9a77SSantosh Shilimkar static struct powerdomain *mpuss_pd; 765e94c6e3SSantosh Shilimkar static void __iomem *sar_base; 77b2b9762fSSantosh Shilimkar 78b2b9762fSSantosh Shilimkar /* 79b2b9762fSSantosh Shilimkar * Program the wakeup routine address for the CPU0 and CPU1 80b2b9762fSSantosh Shilimkar * used for OFF or DORMANT wakeup. 81b2b9762fSSantosh Shilimkar */ 82b2b9762fSSantosh Shilimkar static inline void set_cpu_wakeup_addr(unsigned int cpu_id, u32 addr) 83b2b9762fSSantosh Shilimkar { 84b2b9762fSSantosh Shilimkar struct omap4_cpu_pm_info *pm_info = &per_cpu(omap4_pm_info, cpu_id); 85b2b9762fSSantosh Shilimkar 86b2b9762fSSantosh Shilimkar __raw_writel(addr, pm_info->wkup_sar_addr); 87b2b9762fSSantosh Shilimkar } 88b2b9762fSSantosh Shilimkar 89b2b9762fSSantosh Shilimkar /* 90b2b9762fSSantosh Shilimkar * Store the SCU power status value to scratchpad memory 91b2b9762fSSantosh Shilimkar */ 92b2b9762fSSantosh Shilimkar static void scu_pwrst_prepare(unsigned int cpu_id, unsigned int cpu_state) 93b2b9762fSSantosh Shilimkar { 94b2b9762fSSantosh Shilimkar struct omap4_cpu_pm_info *pm_info = &per_cpu(omap4_pm_info, cpu_id); 95b2b9762fSSantosh Shilimkar u32 scu_pwr_st; 96b2b9762fSSantosh Shilimkar 97b2b9762fSSantosh Shilimkar switch (cpu_state) { 98b2b9762fSSantosh Shilimkar case PWRDM_POWER_RET: 99b2b9762fSSantosh Shilimkar scu_pwr_st = SCU_PM_DORMANT; 100b2b9762fSSantosh Shilimkar break; 101b2b9762fSSantosh Shilimkar case PWRDM_POWER_OFF: 102b2b9762fSSantosh Shilimkar scu_pwr_st = SCU_PM_POWEROFF; 103b2b9762fSSantosh Shilimkar break; 104b2b9762fSSantosh Shilimkar case PWRDM_POWER_ON: 105b2b9762fSSantosh Shilimkar case PWRDM_POWER_INACTIVE: 106b2b9762fSSantosh Shilimkar default: 107b2b9762fSSantosh Shilimkar scu_pwr_st = SCU_PM_NORMAL; 108b2b9762fSSantosh Shilimkar break; 109b2b9762fSSantosh Shilimkar } 110b2b9762fSSantosh Shilimkar 111b2b9762fSSantosh Shilimkar __raw_writel(scu_pwr_st, pm_info->scu_sar_addr); 112b2b9762fSSantosh Shilimkar } 113b2b9762fSSantosh Shilimkar 1143ba2a739SSantosh Shilimkar /* Helper functions for MPUSS OSWR */ 1153ba2a739SSantosh Shilimkar static inline void mpuss_clear_prev_logic_pwrst(void) 1163ba2a739SSantosh Shilimkar { 1173ba2a739SSantosh Shilimkar u32 reg; 1183ba2a739SSantosh Shilimkar 1193ba2a739SSantosh Shilimkar reg = omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION, 1203ba2a739SSantosh Shilimkar OMAP4430_PRM_MPU_INST, OMAP4_RM_MPU_MPU_CONTEXT_OFFSET); 1213ba2a739SSantosh Shilimkar omap4_prminst_write_inst_reg(reg, OMAP4430_PRM_PARTITION, 1223ba2a739SSantosh Shilimkar OMAP4430_PRM_MPU_INST, OMAP4_RM_MPU_MPU_CONTEXT_OFFSET); 1233ba2a739SSantosh Shilimkar } 1243ba2a739SSantosh Shilimkar 1253ba2a739SSantosh Shilimkar static inline void cpu_clear_prev_logic_pwrst(unsigned int cpu_id) 1263ba2a739SSantosh Shilimkar { 1273ba2a739SSantosh Shilimkar u32 reg; 1283ba2a739SSantosh Shilimkar 1293ba2a739SSantosh Shilimkar if (cpu_id) { 1303ba2a739SSantosh Shilimkar reg = omap4_prcm_mpu_read_inst_reg(OMAP4430_PRCM_MPU_CPU1_INST, 1313ba2a739SSantosh Shilimkar OMAP4_RM_CPU1_CPU1_CONTEXT_OFFSET); 1323ba2a739SSantosh Shilimkar omap4_prcm_mpu_write_inst_reg(reg, OMAP4430_PRCM_MPU_CPU1_INST, 1333ba2a739SSantosh Shilimkar OMAP4_RM_CPU1_CPU1_CONTEXT_OFFSET); 1343ba2a739SSantosh Shilimkar } else { 1353ba2a739SSantosh Shilimkar reg = omap4_prcm_mpu_read_inst_reg(OMAP4430_PRCM_MPU_CPU0_INST, 1363ba2a739SSantosh Shilimkar OMAP4_RM_CPU0_CPU0_CONTEXT_OFFSET); 1373ba2a739SSantosh Shilimkar omap4_prcm_mpu_write_inst_reg(reg, OMAP4430_PRCM_MPU_CPU0_INST, 1383ba2a739SSantosh Shilimkar OMAP4_RM_CPU0_CPU0_CONTEXT_OFFSET); 1393ba2a739SSantosh Shilimkar } 1403ba2a739SSantosh Shilimkar } 1413ba2a739SSantosh Shilimkar 1423ba2a739SSantosh Shilimkar /** 1433ba2a739SSantosh Shilimkar * omap4_mpuss_read_prev_context_state: 1443ba2a739SSantosh Shilimkar * Function returns the MPUSS previous context state 1453ba2a739SSantosh Shilimkar */ 1463ba2a739SSantosh Shilimkar u32 omap4_mpuss_read_prev_context_state(void) 1473ba2a739SSantosh Shilimkar { 1483ba2a739SSantosh Shilimkar u32 reg; 1493ba2a739SSantosh Shilimkar 1503ba2a739SSantosh Shilimkar reg = omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION, 1513ba2a739SSantosh Shilimkar OMAP4430_PRM_MPU_INST, OMAP4_RM_MPU_MPU_CONTEXT_OFFSET); 1523ba2a739SSantosh Shilimkar reg &= OMAP4430_LOSTCONTEXT_DFF_MASK; 1533ba2a739SSantosh Shilimkar return reg; 1543ba2a739SSantosh Shilimkar } 1553ba2a739SSantosh Shilimkar 1565e94c6e3SSantosh Shilimkar /* 1575e94c6e3SSantosh Shilimkar * Store the CPU cluster state for L2X0 low power operations. 1585e94c6e3SSantosh Shilimkar */ 1595e94c6e3SSantosh Shilimkar static void l2x0_pwrst_prepare(unsigned int cpu_id, unsigned int save_state) 1605e94c6e3SSantosh Shilimkar { 1615e94c6e3SSantosh Shilimkar struct omap4_cpu_pm_info *pm_info = &per_cpu(omap4_pm_info, cpu_id); 1625e94c6e3SSantosh Shilimkar 1635e94c6e3SSantosh Shilimkar __raw_writel(save_state, pm_info->l2x0_sar_addr); 1645e94c6e3SSantosh Shilimkar } 1655e94c6e3SSantosh Shilimkar 1665e94c6e3SSantosh Shilimkar /* 1675e94c6e3SSantosh Shilimkar * Save the L2X0 AUXCTRL and POR value to SAR memory. Its used to 1685e94c6e3SSantosh Shilimkar * in every restore MPUSS OFF path. 1695e94c6e3SSantosh Shilimkar */ 1705e94c6e3SSantosh Shilimkar #ifdef CONFIG_CACHE_L2X0 1715e94c6e3SSantosh Shilimkar static void save_l2x0_context(void) 1725e94c6e3SSantosh Shilimkar { 1735e94c6e3SSantosh Shilimkar u32 val; 1745e94c6e3SSantosh Shilimkar void __iomem *l2x0_base = omap4_get_l2cache_base(); 1755e94c6e3SSantosh Shilimkar 1765e94c6e3SSantosh Shilimkar val = __raw_readl(l2x0_base + L2X0_AUX_CTRL); 1775e94c6e3SSantosh Shilimkar __raw_writel(val, sar_base + L2X0_AUXCTRL_OFFSET); 1785e94c6e3SSantosh Shilimkar val = __raw_readl(l2x0_base + L2X0_PREFETCH_CTRL); 1795e94c6e3SSantosh Shilimkar __raw_writel(val, sar_base + L2X0_PREFETCH_CTRL_OFFSET); 1805e94c6e3SSantosh Shilimkar } 1815e94c6e3SSantosh Shilimkar #else 1825e94c6e3SSantosh Shilimkar static void save_l2x0_context(void) 1835e94c6e3SSantosh Shilimkar {} 1845e94c6e3SSantosh Shilimkar #endif 1855e94c6e3SSantosh Shilimkar 186b2b9762fSSantosh Shilimkar /** 187b2b9762fSSantosh Shilimkar * omap4_enter_lowpower: OMAP4 MPUSS Low Power Entry Function 188b2b9762fSSantosh Shilimkar * The purpose of this function is to manage low power programming 189b2b9762fSSantosh Shilimkar * of OMAP4 MPUSS subsystem 190b2b9762fSSantosh Shilimkar * @cpu : CPU ID 191b2b9762fSSantosh Shilimkar * @power_state: Low power state. 192e44f9a77SSantosh Shilimkar * 193e44f9a77SSantosh Shilimkar * MPUSS states for the context save: 194e44f9a77SSantosh Shilimkar * save_state = 195e44f9a77SSantosh Shilimkar * 0 - Nothing lost and no need to save: MPUSS INACTIVE 196e44f9a77SSantosh Shilimkar * 1 - CPUx L1 and logic lost: MPUSS CSWR 197e44f9a77SSantosh Shilimkar * 2 - CPUx L1 and logic lost + GIC lost: MPUSS OSWR 198e44f9a77SSantosh Shilimkar * 3 - CPUx L1 and logic lost + GIC + L2 lost: DEVICE OFF 199b2b9762fSSantosh Shilimkar */ 200b2b9762fSSantosh Shilimkar int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state) 201b2b9762fSSantosh Shilimkar { 202*32d174edSPaul Walmsley struct omap4_cpu_pm_info *pm_info = &per_cpu(omap4_pm_info, cpu); 203b2b9762fSSantosh Shilimkar unsigned int save_state = 0; 204b2b9762fSSantosh Shilimkar unsigned int wakeup_cpu; 205b2b9762fSSantosh Shilimkar 206b2b9762fSSantosh Shilimkar if (omap_rev() == OMAP4430_REV_ES1_0) 207b2b9762fSSantosh Shilimkar return -ENXIO; 208b2b9762fSSantosh Shilimkar 209b2b9762fSSantosh Shilimkar switch (power_state) { 210b2b9762fSSantosh Shilimkar case PWRDM_POWER_ON: 211b2b9762fSSantosh Shilimkar case PWRDM_POWER_INACTIVE: 212b2b9762fSSantosh Shilimkar save_state = 0; 213b2b9762fSSantosh Shilimkar break; 214b2b9762fSSantosh Shilimkar case PWRDM_POWER_OFF: 215b2b9762fSSantosh Shilimkar save_state = 1; 216b2b9762fSSantosh Shilimkar break; 217b2b9762fSSantosh Shilimkar case PWRDM_POWER_RET: 218b2b9762fSSantosh Shilimkar default: 219b2b9762fSSantosh Shilimkar /* 220b2b9762fSSantosh Shilimkar * CPUx CSWR is invalid hardware state. Also CPUx OSWR 221b2b9762fSSantosh Shilimkar * doesn't make much scense, since logic is lost and $L1 222b2b9762fSSantosh Shilimkar * needs to be cleaned because of coherency. This makes 223b2b9762fSSantosh Shilimkar * CPUx OSWR equivalent to CPUX OFF and hence not supported 224b2b9762fSSantosh Shilimkar */ 225b2b9762fSSantosh Shilimkar WARN_ON(1); 226b2b9762fSSantosh Shilimkar return -ENXIO; 227b2b9762fSSantosh Shilimkar } 228b2b9762fSSantosh Shilimkar 229e0555489SKevin Hilman pwrdm_pre_transition(NULL); 23049404dd0SSantosh Shilimkar 2313ba2a739SSantosh Shilimkar /* 2323ba2a739SSantosh Shilimkar * Check MPUSS next state and save interrupt controller if needed. 2333ba2a739SSantosh Shilimkar * In MPUSS OSWR or device OFF, interrupt controller contest is lost. 2343ba2a739SSantosh Shilimkar */ 2353ba2a739SSantosh Shilimkar mpuss_clear_prev_logic_pwrst(); 2363ba2a739SSantosh Shilimkar if ((pwrdm_read_next_pwrst(mpuss_pd) == PWRDM_POWER_RET) && 2373ba2a739SSantosh Shilimkar (pwrdm_read_logic_retst(mpuss_pd) == PWRDM_POWER_OFF)) 2383ba2a739SSantosh Shilimkar save_state = 2; 2393ba2a739SSantosh Shilimkar 2403ba2a739SSantosh Shilimkar cpu_clear_prev_logic_pwrst(cpu); 241*32d174edSPaul Walmsley pwrdm_set_next_pwrst(pm_info->pwrdm, power_state); 242b2b9762fSSantosh Shilimkar set_cpu_wakeup_addr(cpu, virt_to_phys(omap4_cpu_resume)); 243b2b9762fSSantosh Shilimkar scu_pwrst_prepare(cpu, power_state); 2445e94c6e3SSantosh Shilimkar l2x0_pwrst_prepare(cpu, save_state); 245b2b9762fSSantosh Shilimkar 246b2b9762fSSantosh Shilimkar /* 247b2b9762fSSantosh Shilimkar * Call low level function with targeted low power state. 248b2b9762fSSantosh Shilimkar */ 249b2b9762fSSantosh Shilimkar cpu_suspend(save_state, omap4_finish_suspend); 250b2b9762fSSantosh Shilimkar 251b2b9762fSSantosh Shilimkar /* 252b2b9762fSSantosh Shilimkar * Restore the CPUx power state to ON otherwise CPUx 253b2b9762fSSantosh Shilimkar * power domain can transitions to programmed low power 254b2b9762fSSantosh Shilimkar * state while doing WFI outside the low powe code. On 255b2b9762fSSantosh Shilimkar * secure devices, CPUx does WFI which can result in 256b2b9762fSSantosh Shilimkar * domain transition 257b2b9762fSSantosh Shilimkar */ 258b2b9762fSSantosh Shilimkar wakeup_cpu = smp_processor_id(); 259*32d174edSPaul Walmsley pwrdm_set_next_pwrst(pm_info->pwrdm, PWRDM_POWER_ON); 260b2b9762fSSantosh Shilimkar 261e0555489SKevin Hilman pwrdm_post_transition(NULL); 26249404dd0SSantosh Shilimkar 263b2b9762fSSantosh Shilimkar return 0; 264b2b9762fSSantosh Shilimkar } 265b2b9762fSSantosh Shilimkar 266b5b4f288SSantosh Shilimkar /** 267b5b4f288SSantosh Shilimkar * omap4_hotplug_cpu: OMAP4 CPU hotplug entry 268b5b4f288SSantosh Shilimkar * @cpu : CPU ID 269b5b4f288SSantosh Shilimkar * @power_state: CPU low power state. 270b5b4f288SSantosh Shilimkar */ 271ccdeed62SSantosh Shilimkar int __cpuinit omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state) 272b5b4f288SSantosh Shilimkar { 273ff999b8aSSantosh Shilimkar struct omap4_cpu_pm_info *pm_info = &per_cpu(omap4_pm_info, cpu); 274*32d174edSPaul Walmsley unsigned int cpu_state = 0; 275b5b4f288SSantosh Shilimkar 276b5b4f288SSantosh Shilimkar if (omap_rev() == OMAP4430_REV_ES1_0) 277b5b4f288SSantosh Shilimkar return -ENXIO; 278b5b4f288SSantosh Shilimkar 279b5b4f288SSantosh Shilimkar if (power_state == PWRDM_POWER_OFF) 280b5b4f288SSantosh Shilimkar cpu_state = 1; 281b5b4f288SSantosh Shilimkar 282*32d174edSPaul Walmsley pwrdm_clear_all_prev_pwrst(pm_info->pwrdm); 283*32d174edSPaul Walmsley pwrdm_set_next_pwrst(pm_info->pwrdm, power_state); 284ff999b8aSSantosh Shilimkar set_cpu_wakeup_addr(cpu, virt_to_phys(pm_info->secondary_startup)); 285b5b4f288SSantosh Shilimkar scu_pwrst_prepare(cpu, power_state); 286b5b4f288SSantosh Shilimkar 287b5b4f288SSantosh Shilimkar /* 288260db902SMasanari Iida * CPU never retuns back if targeted power state is OFF mode. 289b5b4f288SSantosh Shilimkar * CPU ONLINE follows normal CPU ONLINE ptah via 290b5b4f288SSantosh Shilimkar * omap_secondary_startup(). 291b5b4f288SSantosh Shilimkar */ 292b5b4f288SSantosh Shilimkar omap4_finish_suspend(cpu_state); 293b5b4f288SSantosh Shilimkar 294*32d174edSPaul Walmsley pwrdm_set_next_pwrst(pm_info->pwrdm, PWRDM_POWER_ON); 295b5b4f288SSantosh Shilimkar return 0; 296b5b4f288SSantosh Shilimkar } 297b5b4f288SSantosh Shilimkar 298b5b4f288SSantosh Shilimkar 299b2b9762fSSantosh Shilimkar /* 300b2b9762fSSantosh Shilimkar * Initialise OMAP4 MPUSS 301b2b9762fSSantosh Shilimkar */ 302b2b9762fSSantosh Shilimkar int __init omap4_mpuss_init(void) 303b2b9762fSSantosh Shilimkar { 304b2b9762fSSantosh Shilimkar struct omap4_cpu_pm_info *pm_info; 305b2b9762fSSantosh Shilimkar 306b2b9762fSSantosh Shilimkar if (omap_rev() == OMAP4430_REV_ES1_0) { 307b2b9762fSSantosh Shilimkar WARN(1, "Power Management not supported on OMAP4430 ES1.0\n"); 308b2b9762fSSantosh Shilimkar return -ENODEV; 309b2b9762fSSantosh Shilimkar } 310b2b9762fSSantosh Shilimkar 3115e94c6e3SSantosh Shilimkar sar_base = omap4_get_sar_ram_base(); 3125e94c6e3SSantosh Shilimkar 313b2b9762fSSantosh Shilimkar /* Initilaise per CPU PM information */ 314b2b9762fSSantosh Shilimkar pm_info = &per_cpu(omap4_pm_info, 0x0); 315b2b9762fSSantosh Shilimkar pm_info->scu_sar_addr = sar_base + SCU_OFFSET0; 316b2b9762fSSantosh Shilimkar pm_info->wkup_sar_addr = sar_base + CPU0_WAKEUP_NS_PA_ADDR_OFFSET; 3175e94c6e3SSantosh Shilimkar pm_info->l2x0_sar_addr = sar_base + L2X0_SAVE_OFFSET0; 318b2b9762fSSantosh Shilimkar pm_info->pwrdm = pwrdm_lookup("cpu0_pwrdm"); 319b2b9762fSSantosh Shilimkar if (!pm_info->pwrdm) { 320b2b9762fSSantosh Shilimkar pr_err("Lookup failed for CPU0 pwrdm\n"); 321b2b9762fSSantosh Shilimkar return -ENODEV; 322b2b9762fSSantosh Shilimkar } 323b2b9762fSSantosh Shilimkar 324b2b9762fSSantosh Shilimkar /* Clear CPU previous power domain state */ 325b2b9762fSSantosh Shilimkar pwrdm_clear_all_prev_pwrst(pm_info->pwrdm); 3263ba2a739SSantosh Shilimkar cpu_clear_prev_logic_pwrst(0); 327b2b9762fSSantosh Shilimkar 328b2b9762fSSantosh Shilimkar /* Initialise CPU0 power domain state to ON */ 329b2b9762fSSantosh Shilimkar pwrdm_set_next_pwrst(pm_info->pwrdm, PWRDM_POWER_ON); 330b2b9762fSSantosh Shilimkar 331b2b9762fSSantosh Shilimkar pm_info = &per_cpu(omap4_pm_info, 0x1); 332b2b9762fSSantosh Shilimkar pm_info->scu_sar_addr = sar_base + SCU_OFFSET1; 333b2b9762fSSantosh Shilimkar pm_info->wkup_sar_addr = sar_base + CPU1_WAKEUP_NS_PA_ADDR_OFFSET; 3345e94c6e3SSantosh Shilimkar pm_info->l2x0_sar_addr = sar_base + L2X0_SAVE_OFFSET1; 335ff999b8aSSantosh Shilimkar if (cpu_is_omap446x()) 336ff999b8aSSantosh Shilimkar pm_info->secondary_startup = omap_secondary_startup_4460; 337ff999b8aSSantosh Shilimkar else 338ff999b8aSSantosh Shilimkar pm_info->secondary_startup = omap_secondary_startup; 339ff999b8aSSantosh Shilimkar 340b2b9762fSSantosh Shilimkar pm_info->pwrdm = pwrdm_lookup("cpu1_pwrdm"); 341b2b9762fSSantosh Shilimkar if (!pm_info->pwrdm) { 342b2b9762fSSantosh Shilimkar pr_err("Lookup failed for CPU1 pwrdm\n"); 343b2b9762fSSantosh Shilimkar return -ENODEV; 344b2b9762fSSantosh Shilimkar } 345b2b9762fSSantosh Shilimkar 346b2b9762fSSantosh Shilimkar /* Clear CPU previous power domain state */ 347b2b9762fSSantosh Shilimkar pwrdm_clear_all_prev_pwrst(pm_info->pwrdm); 3483ba2a739SSantosh Shilimkar cpu_clear_prev_logic_pwrst(1); 349b2b9762fSSantosh Shilimkar 350b2b9762fSSantosh Shilimkar /* Initialise CPU1 power domain state to ON */ 351b2b9762fSSantosh Shilimkar pwrdm_set_next_pwrst(pm_info->pwrdm, PWRDM_POWER_ON); 352b2b9762fSSantosh Shilimkar 353e44f9a77SSantosh Shilimkar mpuss_pd = pwrdm_lookup("mpu_pwrdm"); 354e44f9a77SSantosh Shilimkar if (!mpuss_pd) { 355e44f9a77SSantosh Shilimkar pr_err("Failed to lookup MPUSS power domain\n"); 356e44f9a77SSantosh Shilimkar return -ENODEV; 357e44f9a77SSantosh Shilimkar } 358e44f9a77SSantosh Shilimkar pwrdm_clear_all_prev_pwrst(mpuss_pd); 3593ba2a739SSantosh Shilimkar mpuss_clear_prev_logic_pwrst(); 360e44f9a77SSantosh Shilimkar 361b2b9762fSSantosh Shilimkar /* Save device type on scratchpad for low level code to use */ 362b2b9762fSSantosh Shilimkar if (omap_type() != OMAP2_DEVICE_TYPE_GP) 363b2b9762fSSantosh Shilimkar __raw_writel(1, sar_base + OMAP_TYPE_OFFSET); 364b2b9762fSSantosh Shilimkar else 365b2b9762fSSantosh Shilimkar __raw_writel(0, sar_base + OMAP_TYPE_OFFSET); 366b2b9762fSSantosh Shilimkar 3675e94c6e3SSantosh Shilimkar save_l2x0_context(); 3685e94c6e3SSantosh Shilimkar 369b2b9762fSSantosh Shilimkar return 0; 370b2b9762fSSantosh Shilimkar } 371b2b9762fSSantosh Shilimkar 372b2b9762fSSantosh Shilimkar #endif 373