ARM: EXYNOS: add exynos_get_boot_addr() helper
[deliverable/linux.git] / arch / arm / mach-exynos / firmware.c
index 4791a3cc00f9d40e71c474d6130c02697ebcd090..b30562daf6961575d7f017e0cd586999e5b32156 100644 (file)
@@ -48,7 +48,13 @@ static int exynos_do_idle(unsigned long mode)
                __raw_writel(virt_to_phys(exynos_cpu_resume_ns),
                             sysram_ns_base_addr + 0x24);
                __raw_writel(EXYNOS_AFTR_MAGIC, sysram_ns_base_addr + 0x20);
-               exynos_smc(SMC_CMD_CPU0AFTR, 0, 0, 0);
+               if (soc_is_exynos3250()) {
+                       exynos_smc(SMC_CMD_SAVE, OP_TYPE_CORE,
+                                  SMC_POWERSTATE_IDLE, 0);
+                       exynos_smc(SMC_CMD_SHUTDOWN, OP_TYPE_CLUSTER,
+                                  SMC_POWERSTATE_IDLE, 0);
+               } else
+                       exynos_smc(SMC_CMD_CPU0AFTR, 0, 0, 0);
                break;
        case FW_DO_IDLE_SLEEP:
                exynos_smc(SMC_CMD_SLEEP, 0, 0, 0);
@@ -98,6 +104,22 @@ static int exynos_set_cpu_boot_addr(int cpu, unsigned long boot_addr)
        return 0;
 }
 
+static int exynos_get_cpu_boot_addr(int cpu, unsigned long *boot_addr)
+{
+       void __iomem *boot_reg;
+
+       if (!sysram_ns_base_addr)
+               return -ENODEV;
+
+       boot_reg = sysram_ns_base_addr + 0x1c;
+
+       if (soc_is_exynos4412())
+               boot_reg += 4 * cpu;
+
+       *boot_addr = __raw_readl(boot_reg);
+       return 0;
+}
+
 static int exynos_cpu_suspend(unsigned long arg)
 {
        flush_cache_all();
@@ -132,6 +154,7 @@ static int exynos_resume(void)
 static const struct firmware_ops exynos_firmware_ops = {
        .do_idle                = IS_ENABLED(CONFIG_EXYNOS_CPU_SUSPEND) ? exynos_do_idle : NULL,
        .set_cpu_boot_addr      = exynos_set_cpu_boot_addr,
+       .get_cpu_boot_addr      = exynos_get_cpu_boot_addr,
        .cpu_boot               = exynos_cpu_boot,
        .suspend                = IS_ENABLED(CONFIG_PM_SLEEP) ? exynos_suspend : NULL,
        .resume                 = IS_ENABLED(CONFIG_EXYNOS_CPU_SUSPEND) ? exynos_resume : NULL,
@@ -206,3 +229,28 @@ void __init exynos_firmware_init(void)
                outer_cache.configure = exynos_l2_configure;
        }
 }
+
+#define REG_CPU_STATE_ADDR     (sysram_ns_base_addr + 0x28)
+#define BOOT_MODE_MASK         0x1f
+
+void exynos_set_boot_flag(unsigned int cpu, unsigned int mode)
+{
+       unsigned int tmp;
+
+       tmp = __raw_readl(REG_CPU_STATE_ADDR + cpu * 4);
+
+       if (mode & BOOT_MODE_MASK)
+               tmp &= ~BOOT_MODE_MASK;
+
+       tmp |= mode;
+       __raw_writel(tmp, REG_CPU_STATE_ADDR + cpu * 4);
+}
+
+void exynos_clear_boot_flag(unsigned int cpu, unsigned int mode)
+{
+       unsigned int tmp;
+
+       tmp = __raw_readl(REG_CPU_STATE_ADDR + cpu * 4);
+       tmp &= ~mode;
+       __raw_writel(tmp, REG_CPU_STATE_ADDR + cpu * 4);
+}
This page took 0.026748 seconds and 5 git commands to generate.