Merge branch 'work.regset' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux/fpc-iii.git] / drivers / power / reset / msm-poweroff.c
blob0c439f83bf65f3ea4e53c8a515016f58f4848efd
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (c) 2013, The Linux Foundation. All rights reserved.
3 */
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>
14 #include <linux/pm.h>
16 static void __iomem *msm_ps_hold;
17 static int deassert_pshold(struct notifier_block *nb, unsigned long action,
18 void *data)
20 writel(0, msm_ps_hold);
21 mdelay(10000);
23 return NOTIFY_DONE;
26 static struct notifier_block restart_nb = {
27 .notifier_call = deassert_pshold,
28 .priority = 128,
31 static void do_msm_poweroff(void)
33 deassert_pshold(&restart_nb, 0, NULL);
36 static int msm_restart_probe(struct platform_device *pdev)
38 struct device *dev = &pdev->dev;
39 struct resource *mem;
41 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
42 msm_ps_hold = devm_ioremap_resource(dev, mem);
43 if (IS_ERR(msm_ps_hold))
44 return PTR_ERR(msm_ps_hold);
46 register_restart_handler(&restart_nb);
48 pm_power_off = do_msm_poweroff;
50 return 0;
53 static const struct of_device_id of_msm_restart_match[] = {
54 { .compatible = "qcom,pshold", },
55 {},
57 MODULE_DEVICE_TABLE(of, of_msm_restart_match);
59 static struct platform_driver msm_restart_driver = {
60 .probe = msm_restart_probe,
61 .driver = {
62 .name = "msm-restart",
63 .of_match_table = of_match_ptr(of_msm_restart_match),
67 static int __init msm_restart_init(void)
69 return platform_driver_register(&msm_restart_driver);
71 device_initcall(msm_restart_init);