From 0c46bcc3e77c3e7049e1354e0a4802d6bba8c9e2 Mon Sep 17 00:00:00 2001 From: YH Huang Date: Wed, 17 Jun 2015 15:25:13 +0800 Subject: oak: power off ap if reboot ap-off When ec gets the console command "reboot ap-off", turn off ap. BRANCH=none BUG=none TEST=manual Enter "reboot ap-off" in ec console and then ap is off. Change-Id: Iba2c3743ae37ee9ceaadba58752d2129fb00d3a8 Signed-off-by: YH Huang Reviewed-on: https://chromium-review.googlesource.com/277976 Reviewed-by: Rong Chang Commit-Queue: Rong Chang --- power/mediatek.c | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/power/mediatek.c b/power/mediatek.c index 3aa1c1c564..c8b08b2faa 100644 --- a/power/mediatek.c +++ b/power/mediatek.c @@ -389,6 +389,28 @@ void chipset_force_shutdown(void) /*****************************************************************************/ +/** + * Power off the AP + */ +static void power_off(void) +{ + /* Call hooks before we drop power rails */ + hook_notify(HOOK_CHIPSET_SHUTDOWN); + /* switch off all rails */ + chipset_turn_off_power_rails(); + + /* Change SUSPEND_L pin to high-Z to reduce power draw. */ + gpio_set_flags(power_signal_list[MTK_SUSPEND_ASSERTED].gpio, + GPIO_INPUT); + + lid_opened = 0; + enable_sleep(SLEEP_MASK_AP_RUN); +#ifdef HAS_TASK_POWERLED + powerled_set_state(POWERLED_STATE_OFF); +#endif + CPRINTS("power shutdown complete"); +} + /** * Check if there has been a power-on event * @@ -415,6 +437,12 @@ static int check_for_power_on_event(void) return POWER_ON_BY_IN_POWER_GOOD; } } else { + if (ap_off_flag) { + CPRINTS("RESET_FLAG_AP_OFF is on"); + power_off(); + return POWER_ON_CANCEL; + } + CPRINTS("POWER_GOOD is not asserted"); } @@ -530,28 +558,6 @@ static int wait_for_power_button_release(unsigned int timeout_us) return EC_SUCCESS; } -/** - * Power off the AP - */ -static void power_off(void) -{ - /* Call hooks before we drop power rails */ - hook_notify(HOOK_CHIPSET_SHUTDOWN); - /* switch off all rails */ - chipset_turn_off_power_rails(); - - /* Change SUSPEND_L pin to high-Z to reduce power draw. */ - gpio_set_flags(power_signal_list[MTK_SUSPEND_ASSERTED].gpio, - GPIO_INPUT); - - lid_opened = 0; - enable_sleep(SLEEP_MASK_AP_RUN); -#ifdef HAS_TASK_POWERLED - powerled_set_state(POWERLED_STATE_OFF); -#endif - CPRINTS("power shutdown complete"); -} - void chipset_reset(int is_cold) { if (is_cold) { -- cgit v1.2.1