soc: ti: pm33xx: Add base cpuidle support
[rpmsg/hwspinlock.git] / drivers / soc / ti / pm33xx.c
index 2c26e5ea252bb871c751abda1ee4ce3096ca012f..c1346a0a9991a70ea490dc8bd32821781dc326fc 100644 (file)
@@ -132,6 +132,19 @@ static int am33xx_push_sram_idle(void)
        return 0;
 }
 
+static int am33xx_do_sram_idle(u32 wfi_flags)
+{
+       int ret = 0;
+
+       if (!m3_ipc || !pm_ops)
+               return 0;
+
+       if (wfi_flags & WFI_FLAG_WAKE_M3)
+               ret = m3_ipc->ops->prepare_low_power(m3_ipc, WKUP_M3_IDLE);
+
+       return pm_ops->cpu_suspend(am33xx_do_wfi_sram, wfi_flags);
+}
+
 static int __init am43xx_map_gic(void)
 {
        gic_dist_base = ioremap(AM43XX_GIC_DIST_BASE, SZ_4K);
@@ -497,7 +510,7 @@ static int am33xx_pm_probe(struct platform_device *pdev)
        suspend_wfi_flags |= WFI_FLAG_WAKE_M3;
 #endif /* CONFIG_SUSPEND */
 
-       ret = pm_ops->init(NULL);
+       ret = pm_ops->init(am33xx_do_sram_idle);
        if (ret) {
                dev_err(dev, "Unable to call core pm init!\n");
                ret = -ENODEV;
@@ -516,6 +529,8 @@ err_free_sram:
 
 static int am33xx_pm_remove(struct platform_device *pdev)
 {
+       if (pm_ops->deinit)
+               pm_ops->deinit();
        suspend_set_ops(NULL);
        wkup_m3_ipc_put(m3_ipc);
        am33xx_pm_free_sram();