--- zzzz-none-000/linux-4.4.271/drivers/power/reset/msm-poweroff.c 2021-06-03 06:22:09.000000000 +0000 +++ hawkeye-5590-750/linux-4.4.271/drivers/power/reset/msm-poweroff.c 2023-04-19 10:22:29.000000000 +0000 @@ -21,17 +21,32 @@ #include #include #include +#include +#include static void __iomem *msm_ps_hold; +static int secure; static int do_msm_restart(struct notifier_block *nb, unsigned long action, void *data) { + + int ret; + if (secure) { + ret = qcom_scm_pshold(); + printk("Resetting using secure PSHOLD : returned %d\n", ret); + } else { writel(0, msm_ps_hold); mdelay(10000); + } return NOTIFY_DONE; } +static void msm_poweroff(enum reboot_mode reboot_mode, const char *cmd) +{ + do_msm_restart(0, 0, 0); +} + static struct notifier_block restart_nb = { .notifier_call = do_msm_restart, .priority = 128, @@ -43,6 +58,18 @@ do_msm_restart(&restart_nb, 0, NULL); } +static int do_msm_reboot_notifier(struct notifier_block *nb, + unsigned long action, void *data) +{ + /* Normal Reboot Enable PS HOLD reset sequence */ + arm_pm_restart = msm_poweroff; + return NOTIFY_DONE; +} + +static struct notifier_block reboot_nb1 = { + .notifier_call = do_msm_reboot_notifier, +}; + static int msm_restart_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -53,10 +80,12 @@ if (IS_ERR(msm_ps_hold)) return PTR_ERR(msm_ps_hold); - register_restart_handler(&restart_nb); - pm_power_off = do_msm_poweroff; + secure = of_property_read_bool(pdev->dev.of_node, "qcom,secure"); + + register_reboot_notifier(&reboot_nb1); + return 0; }