summaryrefslogtreecommitdiff
path: root/power
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2022-01-26 11:21:15 -0800
committerCommit Bot <commit-bot@chromium.org>2022-01-27 19:30:53 +0000
commitf089fa88e017850cab420fec0bc2445834841d8d (patch)
treec224873439ce0e265e72630afceb5b9dc6a7cc07 /power
parent7b06e378063b3f3d86488ea56a6c50078805210a (diff)
downloadchrome-ec-f089fa88e017850cab420fec0bc2445834841d8d.tar.gz
qcom: Refactor the AP warm reset sequence
Separate the warm reset sequence to the function warm_reset_seq(). Rename the power-on sequence to the function power_on_seq(). Rename the power-off sequence to the function power_off_seq(). No logical change. BRANCH=None BUG=b:215252361 TEST=Trigger the `apreset` command and have the same behavior. Change-Id: I90a5a547b8b182b9236fed3d73a0a4febc56ee0c Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3418116 Reviewed-by: Alexandru Stan <amstan@chromium.org>
Diffstat (limited to 'power')
-rw-r--r--power/qcom.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/power/qcom.c b/power/qcom.c
index 2310dfedfa..af9c24b588 100644
--- a/power/qcom.c
+++ b/power/qcom.c
@@ -612,7 +612,7 @@ enum power_state power_chipset_init(void)
/**
* Power off the AP
*/
-static void power_off(void)
+static void power_off_seq(void)
{
/* Check PMIC POWER_GOOD */
if (is_pmic_pwron()) {
@@ -664,7 +664,7 @@ static int power_is_enough(void)
*
* @return EC_SUCCESS or error
*/
-static int power_on(void)
+static int power_on_seq(void)
{
int ret;
@@ -812,13 +812,15 @@ void chipset_force_shutdown(enum chipset_shutdown_reason reason)
task_wake(TASK_ID_CHIPSET);
}
-void chipset_reset(enum chipset_shutdown_reason reason)
+/**
+ * Warm reset the AP
+ *
+ * @return EC_SUCCESS or error
+ */
+static int warm_reset_seq(void)
{
int rv;
- CPRINTS("%s(%d)", __func__, reason);
- report_ap_reset(reason);
-
/*
* Warm reset sequence:
* 1. Issue a low pulse to PMIC_RESIN_L, which triggers PMIC
@@ -838,7 +840,22 @@ void chipset_reset(enum chipset_shutdown_reason reason)
rv = power_wait_signals_timeout(IN_AP_RST_ASSERTED,
PMIC_POWER_AP_RESPONSE_TIMEOUT);
+
/* Exception case: PMIC not work as expected, request a cold reset */
+ if (rv != EC_SUCCESS)
+ return rv;
+
+ return EC_SUCCESS;
+}
+
+void chipset_reset(enum chipset_shutdown_reason reason)
+{
+ int rv;
+
+ CPRINTS("%s(%d)", __func__, reason);
+ report_ap_reset(reason);
+
+ rv = warm_reset_seq();
if (rv != EC_SUCCESS) {
CPRINTS("AP refuses to warm reset. Cold resetting.");
request_cold_reset();
@@ -991,8 +1008,8 @@ enum power_state power_handle_state(enum power_state state)
/* Initialize components to ready state before AP is up. */
hook_notify(HOOK_CHIPSET_PRE_INIT);
- if (power_on() != EC_SUCCESS) {
- power_off();
+ if (power_on_seq() != EC_SUCCESS) {
+ power_off_seq();
boot_from_off = 0;
return POWER_S5;
}
@@ -1101,7 +1118,7 @@ enum power_state power_handle_state(enum power_state state)
/* Call hooks before we drop power rails */
hook_notify(HOOK_CHIPSET_SHUTDOWN);
- power_off();
+ power_off_seq();
CPRINTS("power shutdown complete");
/* Call hooks after we drop power rails */