power: reset: msm: Defer set_dload_mode to end of probe
The set_dload_mode() call in msm_restart_probe() may depend on the TCSR base address, which is initialized later in the probe function. Move this call to the end of msm_restart_probe() to avoid potentially trying to use an uninitialized resource. Change-Id: I65c408f065cc7c68a929ec43d50b0a493942a189 Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
This commit is contained in:
parent
e731442230
commit
30787dfc1c
1 changed files with 28 additions and 3 deletions
|
@ -216,6 +216,8 @@ static void halt_spmi_pmic_arbiter(void)
|
|||
static void msm_restart_prepare(const char *cmd)
|
||||
{
|
||||
#ifdef CONFIG_QCOM_DLOAD_MODE
|
||||
bool need_warm_reset = false;
|
||||
|
||||
|
||||
/* Write download mode flags if we're panic'ing
|
||||
* Write download mode flags if restart_mode says so
|
||||
|
@ -226,18 +228,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;
|
||||
|
@ -387,7 +411,6 @@ static int msm_restart_probe(struct platform_device *pdev)
|
|||
pr_err("unable to map imem EDLOAD mode offset\n");
|
||||
}
|
||||
|
||||
set_dload_mode(download_mode);
|
||||
#endif
|
||||
np = of_find_compatible_node(NULL, NULL,
|
||||
"qcom,msm-imem-restart_reason");
|
||||
|
@ -421,6 +444,8 @@ static int msm_restart_probe(struct platform_device *pdev)
|
|||
if (scm_is_call_available(SCM_SVC_PWR, SCM_IO_DEASSERT_PS_HOLD) > 0)
|
||||
scm_deassert_ps_hold_supported = true;
|
||||
|
||||
set_dload_mode(download_mode);
|
||||
|
||||
return 0;
|
||||
|
||||
err_restart_reason:
|
||||
|
|
Loading…
Add table
Reference in a new issue