hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/power/reset/sc27xx-poweroff.c
....@@ -6,6 +6,7 @@
66
77 #include <linux/cpu.h>
88 #include <linux/kernel.h>
9
+#include <linux/module.h>
910 #include <linux/platform_device.h>
1011 #include <linux/pm.h>
1112 #include <linux/regmap.h>
....@@ -13,6 +14,8 @@
1314
1415 #define SC27XX_PWR_PD_HW 0xc2c
1516 #define SC27XX_PWR_OFF_EN BIT(0)
17
+#define SC27XX_SLP_CTRL 0xdf0
18
+#define SC27XX_LDO_XTL_EN BIT(3)
1619
1720 static struct regmap *regmap;
1821
....@@ -27,10 +30,13 @@
2730 */
2831 static void sc27xx_poweroff_shutdown(void)
2932 {
30
-#ifdef CONFIG_PM_SLEEP_SMP
31
- int cpu = smp_processor_id();
33
+#ifdef CONFIG_HOTPLUG_CPU
34
+ int cpu;
3235
33
- freeze_secondary_cpus(cpu);
36
+ for_each_online_cpu(cpu) {
37
+ if (cpu != smp_processor_id())
38
+ remove_cpu(cpu);
39
+ }
3440 #endif
3541 }
3642
....@@ -40,6 +46,9 @@
4046
4147 static void sc27xx_poweroff_do_poweroff(void)
4248 {
49
+ /* Disable the external subsys connection's power firstly */
50
+ regmap_write(regmap, SC27XX_SLP_CTRL, SC27XX_LDO_XTL_EN);
51
+
4352 regmap_write(regmap, SC27XX_PWR_PD_HW, SC27XX_PWR_OFF_EN);
4453 }
4554
....@@ -63,4 +72,8 @@
6372 .name = "sc27xx-poweroff",
6473 },
6574 };
66
-builtin_platform_driver(sc27xx_poweroff_driver);
75
+module_platform_driver(sc27xx_poweroff_driver);
76
+
77
+MODULE_DESCRIPTION("Power off driver for SC27XX PMIC Device");
78
+MODULE_AUTHOR("Baolin Wang <baolin.wang@unisoc.com>");
79
+MODULE_LICENSE("GPL v2");