From 960852fad42d8a7e79b41a7cf9135910a923b059 Mon Sep 17 00:00:00 2001 From: Oleg Matcovschi Date: Fri, 20 May 2022 09:49:07 -0700 Subject: power: reset: force warm_reset for thermal shutdown Also, remove shadow variable reboot_mode from exynos_reboot_mode_set. Bug: 232092738 Bug: 231628393 Change-Id: I2265e683c3a4b1003d1fea48c463eca3bedd9af9 Signed-off-by: Oleg Matcovschi (cherry picked from commit 6f235f990267f424191b52bc7fd750732f9080d3) --- exynos-gs101-reboot.c | 49 +++++++++++++++++++++++++++++++------------------ exynos-gs201-reboot.c | 49 +++++++++++++++++++++++++++++++------------------ 2 files changed, 62 insertions(+), 36 deletions(-) diff --git a/exynos-gs101-reboot.c b/exynos-gs101-reboot.c index 95ac0e6..70d5c70 100644 --- a/exynos-gs101-reboot.c +++ b/exynos-gs101-reboot.c @@ -39,6 +39,7 @@ static u32 reboot_cmd_offset; static u32 shutdown_offset, shutdown_trigger; static phys_addr_t pmu_alive_base; static bool rsbm_supported; +static bool force_warm_reboot_on_thermal_shutdown; enum pon_reboot_mode { REBOOT_MODE_NORMAL = 0x00, @@ -108,14 +109,14 @@ static void exynos_power_off(void) static void exynos_reboot_mode_set(u32 val) { int ret; - u32 reboot_mode; + u32 mode; phys_addr_t reboot_cmd_addr = pmu_alive_base + reboot_cmd_offset; set_priv_reg(reboot_cmd_addr, val); if (s2mpg10_get_rev_id() > S2MPG10_EVT0 && rsbm_supported) { - reboot_mode = val | BMS_RSBM_VALID; - ret = gbms_storage_write(GBMS_TAG_RSBM, &reboot_mode, sizeof(reboot_mode)); + mode = val | BMS_RSBM_VALID; + ret = gbms_storage_write(GBMS_TAG_RSBM, &mode, sizeof(mode)); if (ret < 0) pr_err("%s(): failed to write gbms storage: %d(%d)\n", __func__, GBMS_TAG_RSBM, ret); @@ -126,34 +127,43 @@ static void exynos_reboot_parse(const char *cmd) { if (cmd) { u32 value = U32_MAX; + bool force_warm_reboot = false; pr_info("Reboot command: '%s'\n", cmd); - if (!strcmp(cmd, "charge")) + if (!strcmp(cmd, "charge")) { value = REBOOT_MODE_CHARGE; - else if (!strcmp(cmd, "bootloader")) + } else if (!strcmp(cmd, "bootloader")) { value = REBOOT_MODE_BOOTLOADER; - else if (!strcmp(cmd, "fastboot")) + } else if (!strcmp(cmd, "fastboot")) { value = REBOOT_MODE_FASTBOOT; - else if (!strcmp(cmd, "recovery")) + } else if (!strcmp(cmd, "recovery")) { value = REBOOT_MODE_RECOVERY; - else if (!strcmp(cmd, "dm-verity device corrupted")) + } else if (!strcmp(cmd, "dm-verity device corrupted")) { value = REBOOT_MODE_DMVERITY_CORRUPTED; - else if (!strcmp(cmd, "rescue")) + } else if (!strcmp(cmd, "rescue")) { value = REBOOT_MODE_RESCUE; - else if (!strcmp(cmd, "shutdown-thermal")) + } else if (!strcmp(cmd, "shutdown-thermal") || + !strcmp(cmd, "shutdown,thermal")) { + if (force_warm_reboot_on_thermal_shutdown) + force_warm_reboot = true; value = REBOOT_MODE_SHUTDOWN_THERMAL; - else if (!strcmp(cmd, "reboot-ab-update")) + } else if (!strcmp(cmd, "reboot-ab-update")) { value = REBOOT_MODE_AB_UPDATE; - else if (!strcmp(cmd, "from_fastboot") || - !strcmp(cmd, "shell") || - !strcmp(cmd, "userrequested") || - !strcmp(cmd, "userrequested,fastboot") || - !strcmp(cmd, "userrequested,recovery") || - !strcmp(cmd, "userrequested,recovery,ui")) + } else if (!strcmp(cmd, "from_fastboot") || + !strcmp(cmd, "shell") || + !strcmp(cmd, "userrequested") || + !strcmp(cmd, "userrequested,fastboot") || + !strcmp(cmd, "userrequested,recovery") || + !strcmp(cmd, "userrequested,recovery,ui")) { value = REBOOT_MODE_NORMAL; - else + } else { pr_err("Unknown reboot command: '%s'\n", cmd); + } + + /* check for warm_reboot */ + if (force_warm_reboot) + reboot_mode = REBOOT_WARM; if (value != U32_MAX) exynos_reboot_mode_set(value); @@ -266,6 +276,9 @@ static int exynos_reboot_probe(struct platform_device *pdev) reboot_cmd_offset = EXYNOS_PMU_SYSIP_DAT0; } + force_warm_reboot_on_thermal_shutdown = of_property_read_bool(np, + "force-warm-reboot-on-thermal-shutdown"); + err = register_reboot_notifier(&exynos_reboot_nb); if (err) { dev_err(dev, "cannot register reboot handler (err=%d)\n", err); diff --git a/exynos-gs201-reboot.c b/exynos-gs201-reboot.c index 0f25600..0e6b2b9 100644 --- a/exynos-gs201-reboot.c +++ b/exynos-gs201-reboot.c @@ -30,6 +30,7 @@ static u32 reboot_cmd_offset; static phys_addr_t pmu_alive_base; +static bool force_warm_reboot_on_thermal_shutdown; enum pon_reboot_mode { REBOOT_MODE_NORMAL = 0x00, @@ -50,7 +51,7 @@ static void exynos_reboot_mode_set(u32 val) { int ret; phys_addr_t reboot_cmd_addr = pmu_alive_base + reboot_cmd_offset; - u32 reboot_mode; + u32 mode; ret = set_priv_reg(reboot_cmd_addr, val); if (ret) { @@ -58,8 +59,8 @@ static void exynos_reboot_mode_set(u32 val) __func__, &reboot_cmd_addr); } - reboot_mode = val | BMS_RSBM_VALID; - ret = gbms_storage_write(GBMS_TAG_RSBM, &reboot_mode, sizeof(reboot_mode)); + mode = val | BMS_RSBM_VALID; + ret = gbms_storage_write(GBMS_TAG_RSBM, &mode, sizeof(mode)); if (ret < 0) pr_err("%s(): failed to write gbms storage: %d(%d)\n", __func__, GBMS_TAG_RSBM, ret); @@ -69,34 +70,43 @@ static void exynos_reboot_parse(const char *cmd) { if (cmd) { u32 value = U32_MAX; + bool force_warm_reboot = false; pr_info("Reboot command: '%s'\n", cmd); - if (!strcmp(cmd, "charge")) + if (!strcmp(cmd, "charge")) { value = REBOOT_MODE_CHARGE; - else if (!strcmp(cmd, "bootloader")) + } else if (!strcmp(cmd, "bootloader")) { value = REBOOT_MODE_BOOTLOADER; - else if (!strcmp(cmd, "fastboot")) + } else if (!strcmp(cmd, "fastboot")) { value = REBOOT_MODE_FASTBOOT; - else if (!strcmp(cmd, "recovery")) + } else if (!strcmp(cmd, "recovery")) { value = REBOOT_MODE_RECOVERY; - else if (!strcmp(cmd, "dm-verity device corrupted")) + } else if (!strcmp(cmd, "dm-verity device corrupted")) { value = REBOOT_MODE_DMVERITY_CORRUPTED; - else if (!strcmp(cmd, "rescue")) + } else if (!strcmp(cmd, "rescue")) { value = REBOOT_MODE_RESCUE; - else if (!strcmp(cmd, "shutdown-thermal")) + } else if (!strcmp(cmd, "shutdown-thermal") || + !strcmp(cmd, "shutdown,thermal")) { + if (force_warm_reboot_on_thermal_shutdown) + force_warm_reboot = true; value = REBOOT_MODE_SHUTDOWN_THERMAL; - else if (!strcmp(cmd, "reboot-ab-update")) + } else if (!strcmp(cmd, "reboot-ab-update")) { value = REBOOT_MODE_AB_UPDATE; - else if (!strcmp(cmd, "from_fastboot") || - !strcmp(cmd, "shell") || - !strcmp(cmd, "userrequested") || - !strcmp(cmd, "userrequested,fastboot") || - !strcmp(cmd, "userrequested,recovery") || - !strcmp(cmd, "userrequested,recovery,ui")) + } else if (!strcmp(cmd, "from_fastboot") || + !strcmp(cmd, "shell") || + !strcmp(cmd, "userrequested") || + !strcmp(cmd, "userrequested,fastboot") || + !strcmp(cmd, "userrequested,recovery") || + !strcmp(cmd, "userrequested,recovery,ui")) { value = REBOOT_MODE_NORMAL; - else + } else { pr_err("Unknown reboot command: '%s'\n", cmd); + } + + /* check for warm_reboot */ + if (force_warm_reboot) + reboot_mode = REBOOT_WARM; if (value != U32_MAX) exynos_reboot_mode_set(value); @@ -185,6 +195,9 @@ static int exynos_reboot_probe(struct platform_device *pdev) reboot_cmd_offset = EXYNOS_PMU_SYSIP_DAT0; } + force_warm_reboot_on_thermal_shutdown = of_property_read_bool(np, + "force-warm-reboot-on-thermal-shutdown"); + err = register_reboot_notifier(&exynos_reboot_nb); if (err) { dev_err(dev, "cannot register reboot handler (err=%d)\n", err); -- cgit v1.2.3