Commit | Line | Data |
---|---|---|
97fb5e8d | 1 | // SPDX-License-Identifier: GPL-2.0-only |
78be3176 | 2 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved. |
78be3176 AK |
3 | */ |
4 | ||
5 | #include <linux/delay.h> | |
6 | #include <linux/err.h> | |
7 | #include <linux/init.h> | |
8 | #include <linux/kernel.h> | |
9 | #include <linux/io.h> | |
10 | #include <linux/of.h> | |
11 | #include <linux/platform_device.h> | |
12 | #include <linux/module.h> | |
13 | #include <linux/reboot.h> | |
18a702e0 | 14 | #include <linux/pm.h> |
78be3176 AK |
15 | |
16 | static void __iomem *msm_ps_hold; | |
fd8b8f17 | 17 | static int deassert_pshold(struct notifier_block *nb, unsigned long action, |
18a702e0 | 18 | void *data) |
78be3176 AK |
19 | { |
20 | writel(0, msm_ps_hold); | |
21 | mdelay(10000); | |
18a702e0 PG |
22 | |
23 | return NOTIFY_DONE; | |
78be3176 AK |
24 | } |
25 | ||
18a702e0 | 26 | static struct notifier_block restart_nb = { |
fd8b8f17 | 27 | .notifier_call = deassert_pshold, |
18a702e0 PG |
28 | .priority = 128, |
29 | }; | |
30 | ||
78be3176 AK |
31 | static void do_msm_poweroff(void) |
32 | { | |
fd8b8f17 | 33 | deassert_pshold(&restart_nb, 0, NULL); |
78be3176 AK |
34 | } |
35 | ||
36 | static int msm_restart_probe(struct platform_device *pdev) | |
37 | { | |
19223ffa | 38 | msm_ps_hold = devm_platform_ioremap_resource(pdev, 0); |
78be3176 AK |
39 | if (IS_ERR(msm_ps_hold)) |
40 | return PTR_ERR(msm_ps_hold); | |
41 | ||
18a702e0 PG |
42 | register_restart_handler(&restart_nb); |
43 | ||
78be3176 | 44 | pm_power_off = do_msm_poweroff; |
18a702e0 | 45 | |
78be3176 AK |
46 | return 0; |
47 | } | |
48 | ||
49 | static const struct of_device_id of_msm_restart_match[] = { | |
50 | { .compatible = "qcom,pshold", }, | |
51 | {}, | |
52 | }; | |
53 | MODULE_DEVICE_TABLE(of, of_msm_restart_match); | |
54 | ||
55 | static struct platform_driver msm_restart_driver = { | |
56 | .probe = msm_restart_probe, | |
57 | .driver = { | |
58 | .name = "msm-restart", | |
59 | .of_match_table = of_match_ptr(of_msm_restart_match), | |
60 | }, | |
61 | }; | |
4e579a5c | 62 | builtin_platform_driver(msm_restart_driver); |