summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-06-17 20:30:59 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-06-17 20:30:59 +0000
commite54fb29be585321186fb300fd86474f0c74eb0b9 (patch)
treeefe9aa91c49b91bc6068e574682769b9b48664c2
parenta8b68ddd562e86ea362a8f474dfb7e305e150b26 (diff)
parent4cc727a5900bc7473b8c0f3b075c6ae63d91e0f9 (diff)
downloadreset-e54fb29be585321186fb300fd86474f0c74eb0b9.tar.gz
Snap for 8735923 from 4cc727a5900bc7473b8c0f3b075c6ae63d91e0f9 to android13-gs-pixel-5.10-release
Change-Id: I6f9801efc43e5c7295e7c5a78766ffb00c47386c
-rw-r--r--exynos-gs101-reboot.c49
-rw-r--r--exynos-gs201-reboot.c92
2 files changed, 83 insertions, 58 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..4917058 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);
@@ -107,6 +117,27 @@ static int exynos_reboot_handler(struct notifier_block *nb, unsigned long mode,
{
exynos_reboot_parse(cmd);
+ if (mode != SYS_POWER_OFF)
+ return NOTIFY_DONE;
+
+ while (1) {
+ /* wait for power button release */
+ if (!pmic_read_pwrkey_status()) {
+#if IS_ENABLED(CONFIG_GS_ACPM)
+ acpm_prepare_reboot();
+#endif
+ pr_info("ready to do power off.\n");
+ break;
+ } else {
+ /*
+ * if power button is not released,
+ * wait and check TA again
+ */
+ pr_info("PWR Key is not released.\n");
+ }
+ mdelay(1000);
+ }
+
return NOTIFY_DONE;
}
@@ -131,27 +162,6 @@ static struct notifier_block exynos_restart_nb = {
.priority = 130,
};
-static void exynos_power_off(struct platform_device *pdev)
-{
- while (1) {
- /* wait for power button release */
- if (!pmic_read_pwrkey_status()) {
-#if IS_ENABLED(CONFIG_GS_ACPM)
- acpm_prepare_reboot();
-#endif
- pr_info("ready to do power off.\n");
- break;
- } else {
- /*
- * if power button is not released,
- * wait and check TA again
- */
- pr_info("PWR Key is not released.\n");
- }
- mdelay(1000);
- }
-}
-
static int exynos_reboot_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -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);
@@ -210,7 +223,6 @@ static const struct of_device_id exynos_reboot_of_match[] = {
static struct platform_driver exynos_reboot_driver = {
.probe = exynos_reboot_probe,
- .shutdown = exynos_power_off,
.driver = {
.name = "exynos-reboot",
.of_match_table = exynos_reboot_of_match,