From 1c132ac233dbed5b0cc07401eae66ffef7067b38 Mon Sep 17 00:00:00 2001 From: Wai-Hong Tam Date: Wed, 9 Jan 2019 15:10:31 -0800 Subject: cheza: Ensure POWER_GOOD low after forcing shutdown In power_chipset_init(), it forces the system shutdown by turning off the switchcap if it is not a sysjump. The POWER_GOOD indicator needs time to drop. Make sure it is low before executing the power state machine. Make this wait to every case of turning on/off the swithcap. BRANCH=none BUG=b:120889835 TEST=Typed "reboot ap-off" in EC console and verified AP off. Change-Id: I50f4f51793de1482fc2dd9b3dd05819bb2501cdc Signed-off-by: Wai-Hong Tam Reviewed-on: https://chromium-review.googlesource.com/1404100 Commit-Ready: ChromeOS CL Exonerator Bot Reviewed-by: Stephen Boyd --- power/sdm845.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'power') diff --git a/power/sdm845.c b/power/sdm845.c index 6d72ea4040..c229ddd4b9 100644 --- a/power/sdm845.c +++ b/power/sdm845.c @@ -271,22 +271,6 @@ static void wait_switchcap_power_good(int enable) } -/** - * Set the state of the system power signals. - * - * The system power signals are the enable pins of SwitchCap and VBOB. - * They control the power of the set of PMIC chips and the AP. - * - * @param enable 1 to enable or 0 to disable - */ -static void set_system_power(int enable) -{ - CPRINTS("set_system_power(%d)", enable); - gpio_set_level(GPIO_SWITCHCAP_ON_L, enable); - wait_switchcap_power_good(enable); - gpio_set_level(GPIO_VBOB_EN, enable); -} - /** * Get the state of the system power signals. * @@ -342,6 +326,28 @@ static void wait_pmic_pwron(int enable, unsigned int timeout) } } +/** + * Set the state of the system power signals. + * + * The system power signals are the enable pins of SwitchCap and VBOB. + * They control the power of the set of PMIC chips and the AP. + * + * @param enable 1 to enable or 0 to disable + */ +static void set_system_power(int enable) +{ + CPRINTS("%s(%d)", __func__, enable); + gpio_set_level(GPIO_SWITCHCAP_ON_L, enable); + wait_switchcap_power_good(enable); + gpio_set_level(GPIO_VBOB_EN, enable); + if (enable) { + usleep(SYSTEM_POWER_ON_DELAY); + } else { + /* Ensure POWER_GOOD drop to low if it is a forced shutdown */ + wait_pmic_pwron(0, FORCE_OFF_RESPONSE_TIMEOUT); + } +} + /** * Set the PMIC/AP power-on state. * @@ -352,7 +358,7 @@ static void wait_pmic_pwron(int enable, unsigned int timeout) */ static void set_pmic_pwron(int enable) { - CPRINTS("set_pmic_pwron(%d)", enable); + CPRINTS("%s(%d)", __func__, enable); /* Check the PMIC/AP power state */ if (enable == is_pmic_pwron()) @@ -460,9 +466,6 @@ static void power_off(void) /* Force to switch off all rails */ set_system_power(0); - /* If it is forced down, wait to ensure POWER_GOOD down */ - wait_pmic_pwron(0, FORCE_OFF_RESPONSE_TIMEOUT); - /* Turn off the 3.3V and 5V rails. */ gpio_set_level(GPIO_EN_PP3300_A, 0); #ifdef CONFIG_POWER_PP5000_CONTROL @@ -526,7 +529,6 @@ static void power_on(void) #endif /* defined(CONFIG_POWER_PP5000_CONTROL) */ set_system_power(1); - usleep(SYSTEM_POWER_ON_DELAY); /* Enable signal interrupts */ power_signal_enable_interrupt(GPIO_AP_RST_L); -- cgit v1.2.1