Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2fa04578 authored by Lijuan Gao's avatar Lijuan Gao Committed by Gerrit - the friendly Code Review server
Browse files

power: reset: initialize hard reset code



There is a chance that the system can crash when the device is rebooting
after a warm reset. So mark it as hard reset and store the reset reason
into PON spare register.

Change-Id: I6abb9fa8ed4639f51e929b0126cfb834f97b06b0
Signed-off-by: default avatarLijuan Gao <lijuang@codeaurora.org>
parent d5e312a9
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -214,6 +214,8 @@ static void halt_spmi_pmic_arbiter(void)

static void msm_restart_prepare(const char *cmd)
{
	bool need_warm_reset = false;

#ifdef CONFIG_MSM_DLOAD_MODE

	/* Write download mode flags if we're panic'ing
@@ -225,18 +227,40 @@ static void msm_restart_prepare(const char *cmd)
			(in_panic || restart_mode == RESTART_DLOAD));
#endif

	need_warm_reset = (get_dload_mode() ||
				(cmd != NULL && cmd[0] != '\0'));

	if (qpnp_pon_check_hard_reset_stored()) {
		/* Set warm reset as true when device is in dload mode
		 *  or device doesn't boot up into recovery, bootloader or rtc.
		 */
		if (get_dload_mode() ||
			((cmd != NULL && cmd[0] != '\0') &&
			strcmp(cmd, "recovery") &&
			strcmp(cmd, "bootloader") &&
			strcmp(cmd, "rtc")))
			need_warm_reset = true;
	}

	/* Hard reset the PMIC unless memory contents must be maintained. */
	if (get_dload_mode() || (cmd != NULL && cmd[0] != '\0'))
	if (need_warm_reset) {
		qpnp_pon_system_pwr_off(PON_POWER_OFF_WARM_RESET);
	else
	} else {
		qpnp_pon_system_pwr_off(PON_POWER_OFF_HARD_RESET);
	}

	if (cmd != NULL) {
		if (!strncmp(cmd, "bootloader", 10)) {
			qpnp_pon_set_restart_reason(
				PON_RESTART_REASON_BOOTLOADER);
			__raw_writel(0x77665500, restart_reason);
		} else if (!strncmp(cmd, "recovery", 8)) {
			qpnp_pon_set_restart_reason(
				PON_RESTART_REASON_RECOVERY);
			__raw_writel(0x77665502, restart_reason);
		} else if (!strcmp(cmd, "rtc")) {
			qpnp_pon_set_restart_reason(
				PON_RESTART_REASON_RTC);
			__raw_writel(0x77665503, restart_reason);
		} else if (!strncmp(cmd, "oem-", 4)) {
			unsigned long code;