0001
0002
0003
0004
0005 #include <linux/delay.h>
0006 #include <linux/err.h>
0007 #include <linux/init.h>
0008 #include <linux/kernel.h>
0009 #include <linux/io.h>
0010 #include <linux/of.h>
0011 #include <linux/platform_device.h>
0012 #include <linux/module.h>
0013 #include <linux/reboot.h>
0014 #include <linux/pm.h>
0015
0016 static void __iomem *msm_ps_hold;
0017 static int deassert_pshold(struct notifier_block *nb, unsigned long action,
0018 void *data)
0019 {
0020 writel(0, msm_ps_hold);
0021 mdelay(10000);
0022
0023 return NOTIFY_DONE;
0024 }
0025
0026 static struct notifier_block restart_nb = {
0027 .notifier_call = deassert_pshold,
0028 .priority = 128,
0029 };
0030
0031 static void do_msm_poweroff(void)
0032 {
0033 deassert_pshold(&restart_nb, 0, NULL);
0034 }
0035
0036 static int msm_restart_probe(struct platform_device *pdev)
0037 {
0038 struct device *dev = &pdev->dev;
0039 struct resource *mem;
0040
0041 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
0042 msm_ps_hold = devm_ioremap_resource(dev, mem);
0043 if (IS_ERR(msm_ps_hold))
0044 return PTR_ERR(msm_ps_hold);
0045
0046 register_restart_handler(&restart_nb);
0047
0048 pm_power_off = do_msm_poweroff;
0049
0050 return 0;
0051 }
0052
0053 static const struct of_device_id of_msm_restart_match[] = {
0054 { .compatible = "qcom,pshold", },
0055 {},
0056 };
0057 MODULE_DEVICE_TABLE(of, of_msm_restart_match);
0058
0059 static struct platform_driver msm_restart_driver = {
0060 .probe = msm_restart_probe,
0061 .driver = {
0062 .name = "msm-restart",
0063 .of_match_table = of_match_ptr(of_msm_restart_match),
0064 },
0065 };
0066
0067 static int __init msm_restart_init(void)
0068 {
0069 return platform_driver_register(&msm_restart_driver);
0070 }
0071 device_initcall(msm_restart_init);