Merge tag 'tags/cleanup2-3.15' of git://git.kernel.org/pub/scm/linux/kernel/git/arm...
[linux.git] / arch / arm / mach-exynos / cpuidle.c
index ddbfe8709fe7fe4bd43fb5f2ea3301ba1e304b63..c57cae0e8779213aec55424c43530e1404af4db0 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/cpu_pm.h>
 #include <linux/io.h>
 #include <linux/export.h>
+#include <linux/module.h>
 #include <linux/time.h>
 #include <linux/platform_device.h>
 
 #include <asm/suspend.h>
 #include <asm/unified.h>
 #include <asm/cpuidle.h>
-#include <mach/regs-clock.h>
-#include <mach/regs-pmu.h>
 
 #include <plat/cpu.h>
 #include <plat/pm.h>
 
+#include <mach/map.h>
+
 #include "common.h"
+#include "regs-pmu.h"
 
 #define REG_DIRECTGO_ADDR      (samsung_rev() == EXYNOS4210_REV_1_1 ? \
                        S5P_INFORM7 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \
 
 #define S5P_CHECK_AFTR         0xFCBA0D10
 
+#define EXYNOS5_PWR_CTRL1                      (S5P_VA_CMU + 0x01020)
+#define EXYNOS5_PWR_CTRL2                      (S5P_VA_CMU + 0x01024)
+
+#define PWR_CTRL1_CORE2_DOWN_RATIO             (7 << 28)
+#define PWR_CTRL1_CORE1_DOWN_RATIO             (7 << 16)
+#define PWR_CTRL1_DIV2_DOWN_EN                 (1 << 9)
+#define PWR_CTRL1_DIV1_DOWN_EN                 (1 << 8)
+#define PWR_CTRL1_USE_CORE1_WFE                        (1 << 5)
+#define PWR_CTRL1_USE_CORE0_WFE                        (1 << 4)
+#define PWR_CTRL1_USE_CORE1_WFI                        (1 << 1)
+#define PWR_CTRL1_USE_CORE0_WFI                        (1 << 0)
+
+#define PWR_CTRL2_DIV2_UP_EN                   (1 << 25)
+#define PWR_CTRL2_DIV1_UP_EN                   (1 << 24)
+#define PWR_CTRL2_DUR_STANDBY2_VAL             (1 << 16)
+#define PWR_CTRL2_DUR_STANDBY1_VAL             (1 << 8)
+#define PWR_CTRL2_CORE2_UP_RATIO               (1 << 4)
+#define PWR_CTRL2_CORE1_UP_RATIO               (1 << 0)
+
 static int exynos4_enter_lowpower(struct cpuidle_device *dev,
                                struct cpuidle_driver *drv,
                                int index);
@@ -106,7 +127,7 @@ static int exynos4_enter_core0_aftr(struct cpuidle_device *dev,
        /* Set value of power down register for aftr mode */
        exynos_sys_powerdown_conf(SYS_AFTR);
 
-       __raw_writel(virt_to_phys(s3c_cpu_resume), REG_DIRECTGO_ADDR);
+       __raw_writel(virt_to_phys(exynos_cpu_resume), REG_DIRECTGO_ADDR);
        __raw_writel(S5P_CHECK_AFTR, REG_DIRECTGO_FLAG);
 
        save_cpu_arch_register();
@@ -151,8 +172,8 @@ static int exynos4_enter_lowpower(struct cpuidle_device *dev,
 {
        int new_index = index;
 
-       /* This mode only can be entered when other core's are offline */
-       if (num_online_cpus() > 1)
+       /* AFTR can only be entered when cores other than CPU0 are offline */
+       if (num_online_cpus() > 1 || dev->cpu != 0)
                new_index = drv->safe_state_index;
 
        if (new_index == 0)
@@ -214,10 +235,6 @@ static int exynos_cpuidle_probe(struct platform_device *pdev)
                device = &per_cpu(exynos4_cpuidle_device, cpu_id);
                device->cpu = cpu_id;
 
-               /* Support IDLE only */
-               if (cpu_id != 0)
-                       device->state_count = 1;
-
                ret = cpuidle_register_device(device);
                if (ret) {
                        dev_err(&pdev->dev, "failed to register cpuidle device\n");