From 9346e740397d5abf3cb0576bcf6a6e13ab443690 Mon Sep 17 00:00:00 2001 From: Louis Yung-Chieh Lo Date: Fri, 27 Dec 2013 15:34:02 -0800 Subject: nyan: implement chipset_reset() for cold/warm reset For AP hang detection, the warm reset must be implemented. Since the cold reset is easy, implement it at the same time. BUG=chrome-os-partner:23822, chrome-os-partner:24789, chrome-os-partner:24558 BRANCH=nyan TEST=on nyan rev 3.12 power on/off --> work as usual power on, then apreset cold --> system is cold reset (off, then on) power off, then apreset cold --> nothing happens. this is fine. power on, then apreset warm --> system is warm reset (power trail is kept). power off, then apreset warm --> nothing happens. this is fine. power on --> system is back to normal again. Change-Id: I010793b7a2d309e5d606fbc5877e9e3b07c8c5f3 Signed-off-by: Louis Yung-Chieh Lo Reviewed-on: https://chromium-review.googlesource.com/181164 Reviewed-by: Randall Spangler --- power/tegra.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/power/tegra.c b/power/tegra.c index b00ceb498e..a6f3ebb639 100644 --- a/power/tegra.c +++ b/power/tegra.c @@ -332,11 +332,7 @@ static int tegra_power_init(void) * The warm reset triggers AP into the Tegra recovery mode ( * flash SPI from USB). */ - CPRINTF("[%T assert GPIO_PMIC_WARM_RESET_L for %d ms]\n", - PMIC_WARM_RESET_L_HOLD_TIME / MSEC); - gpio_set_level(GPIO_PMIC_WARM_RESET_L, 0); - usleep(PMIC_WARM_RESET_L_HOLD_TIME); - gpio_set_level(GPIO_PMIC_WARM_RESET_L, 1); + chipset_reset(0); } /* Leave power off only if requested by reset flags */ @@ -378,23 +374,6 @@ void chipset_exit_hard_off(void) */ } -void chipset_reset(int is_cold) -{ - /* - * TODO(crosbug.com/p/23822): Implement cold reset. For now, all - * resets are warm resets. - */ - CPRINTF("[%T EC triggered warm reboot]\n"); - - /* - * This is a hack to do an AP warm reboot while still preserving RAM - * contents. This is useful for looking at kernel log message contents - * from previous boot in cases where the AP/OS is hard hung. - */ - power_request = POWER_REQ_ON; - task_wake(TASK_ID_CHIPSET); -} - void chipset_force_shutdown(void) { /* Release the power button, if it was asserted */ @@ -561,6 +540,23 @@ static void power_off(void) CPRINTF("[%T power shutdown complete]\n"); } +void chipset_reset(int is_cold) +{ + if (is_cold) { + CPRINTF("[%T EC triggered cold reboot]\n"); + power_off(); + /* After XPSHOLD is dropped off, the system will be on again */ + power_request = POWER_REQ_ON; + } else { + CPRINTF("[%T EC triggered warm reboot]\n"); + CPRINTF("[%T assert GPIO_PMIC_WARM_RESET_L for %d ms]\n", + PMIC_WARM_RESET_L_HOLD_TIME / MSEC); + gpio_set_level(GPIO_PMIC_WARM_RESET_L, 0); + usleep(PMIC_WARM_RESET_L_HOLD_TIME); + gpio_set_level(GPIO_PMIC_WARM_RESET_L, 1); + } +} + /* * Calculates the delay in microseconds to the next time we have to check * for a power event, -- cgit v1.2.1