1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (c) 2013, The Linux Foundation. All rights reserved.
5 #include <linux/delay.h>
7 #include <linux/init.h>
8 #include <linux/kernel.h>
11 #include <linux/platform_device.h>
12 #include <linux/module.h>
13 #include <linux/reboot.h>
16 static void __iomem *msm_ps_hold;
17 static int deassert_pshold(struct notifier_block *nb, unsigned long action,
20 writel(0, msm_ps_hold);
26 static struct notifier_block restart_nb = {
27 .notifier_call = deassert_pshold,
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 msm_ps_hold = devm_platform_ioremap_resource(pdev, 0);
39 if (IS_ERR(msm_ps_hold))
40 return PTR_ERR(msm_ps_hold);
42 register_restart_handler(&restart_nb);
44 pm_power_off = do_msm_poweroff;
49 static const struct of_device_id of_msm_restart_match[] = {
50 { .compatible = "qcom,pshold", },
53 MODULE_DEVICE_TABLE(of, of_msm_restart_match);
55 static struct platform_driver msm_restart_driver = {
56 .probe = msm_restart_probe,
58 .name = "msm-restart",
59 .of_match_table = of_match_ptr(of_msm_restart_match),
63 static int __init msm_restart_init(void)
65 return platform_driver_register(&msm_restart_driver);
67 device_initcall(msm_restart_init);