Merge tag 'for-v5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power...
[platform/kernel/linux-rpi.git] / drivers / power / reset / sc27xx-poweroff.c
index 29fb08b..90287c3 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/cpu.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/regmap.h>
@@ -13,6 +14,8 @@
 
 #define SC27XX_PWR_PD_HW       0xc2c
 #define SC27XX_PWR_OFF_EN      BIT(0)
+#define SC27XX_SLP_CTRL                0xdf0
+#define SC27XX_LDO_XTL_EN      BIT(3)
 
 static struct regmap *regmap;
 
@@ -27,10 +30,13 @@ static struct regmap *regmap;
  */
 static void sc27xx_poweroff_shutdown(void)
 {
-#ifdef CONFIG_PM_SLEEP_SMP
-       int cpu = smp_processor_id();
+#ifdef CONFIG_HOTPLUG_CPU
+       int cpu;
 
-       freeze_secondary_cpus(cpu);
+       for_each_online_cpu(cpu) {
+               if (cpu != smp_processor_id())
+                       remove_cpu(cpu);
+       }
 #endif
 }
 
@@ -40,6 +46,9 @@ static struct syscore_ops poweroff_syscore_ops = {
 
 static void sc27xx_poweroff_do_poweroff(void)
 {
+       /* Disable the external subsys connection's power firstly */
+       regmap_write(regmap, SC27XX_SLP_CTRL, SC27XX_LDO_XTL_EN);
+
        regmap_write(regmap, SC27XX_PWR_PD_HW, SC27XX_PWR_OFF_EN);
 }
 
@@ -63,4 +72,8 @@ static struct platform_driver sc27xx_poweroff_driver = {
                .name = "sc27xx-poweroff",
        },
 };
-builtin_platform_driver(sc27xx_poweroff_driver);
+module_platform_driver(sc27xx_poweroff_driver);
+
+MODULE_DESCRIPTION("Power off driver for SC27XX PMIC Device");
+MODULE_AUTHOR("Baolin Wang <baolin.wang@unisoc.com>");
+MODULE_LICENSE("GPL v2");