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;
18 static int do_msm_poweroff(struct sys_off_data *data)
20 writel(0, msm_ps_hold);
26 static int msm_restart_probe(struct platform_device *pdev)
28 msm_ps_hold = devm_platform_ioremap_resource(pdev, 0);
29 if (IS_ERR(msm_ps_hold))
30 return PTR_ERR(msm_ps_hold);
32 devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART,
33 128, do_msm_poweroff, NULL);
35 devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_POWER_OFF,
36 SYS_OFF_PRIO_DEFAULT, do_msm_poweroff,
42 static const struct of_device_id of_msm_restart_match[] = {
43 { .compatible = "qcom,pshold", },
46 MODULE_DEVICE_TABLE(of, of_msm_restart_match);
48 static struct platform_driver msm_restart_driver = {
49 .probe = msm_restart_probe,
51 .name = "msm-restart",
52 .of_match_table = of_match_ptr(of_msm_restart_match),
55 builtin_platform_driver(msm_restart_driver);