This source file includes following definitions.
- sc27xx_poweroff_shutdown
- sc27xx_poweroff_do_poweroff
- sc27xx_poweroff_probe
1
2
3
4
5
6
7 #include <linux/cpu.h>
8 #include <linux/kernel.h>
9 #include <linux/platform_device.h>
10 #include <linux/pm.h>
11 #include <linux/regmap.h>
12 #include <linux/syscore_ops.h>
13
14 #define SC27XX_PWR_PD_HW 0xc2c
15 #define SC27XX_PWR_OFF_EN BIT(0)
16
17 static struct regmap *regmap;
18
19
20
21
22
23
24
25
26
27
28 static void sc27xx_poweroff_shutdown(void)
29 {
30 #ifdef CONFIG_PM_SLEEP_SMP
31 int cpu = smp_processor_id();
32
33 freeze_secondary_cpus(cpu);
34 #endif
35 }
36
37 static struct syscore_ops poweroff_syscore_ops = {
38 .shutdown = sc27xx_poweroff_shutdown,
39 };
40
41 static void sc27xx_poweroff_do_poweroff(void)
42 {
43 regmap_write(regmap, SC27XX_PWR_PD_HW, SC27XX_PWR_OFF_EN);
44 }
45
46 static int sc27xx_poweroff_probe(struct platform_device *pdev)
47 {
48 if (regmap)
49 return -EINVAL;
50
51 regmap = dev_get_regmap(pdev->dev.parent, NULL);
52 if (!regmap)
53 return -ENODEV;
54
55 pm_power_off = sc27xx_poweroff_do_poweroff;
56 register_syscore_ops(&poweroff_syscore_ops);
57 return 0;
58 }
59
60 static struct platform_driver sc27xx_poweroff_driver = {
61 .probe = sc27xx_poweroff_probe,
62 .driver = {
63 .name = "sc27xx-poweroff",
64 },
65 };
66 builtin_platform_driver(sc27xx_poweroff_driver);