summaryrefslogtreecommitdiff
path: root/common/power_button_x86.c
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2015-12-19 10:38:52 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-01-06 18:48:11 -0800
commit0af6e77a3a90299418628a997c81436acbec242c (patch)
tree342623ba55704015efdd89515f893974471dcb5e /common/power_button_x86.c
parent0c8a1b8d39734eaae692eacbe04894207bb2c6da (diff)
downloadchrome-ec-0af6e77a3a90299418628a997c81436acbec242c.tar.gz
charger: Change unlocked battery level ignore conditions
x86 systems will auto-power-on when power is applied to the EC. When the battery level is critically low, power-on is prevented, except when the system is unlocked. So, when unlocked, some systems will auto-power-on regardless of battery level, overcurrent the charger / battery, and then repeat forever. Prevent this reboot loop by ignoring auto-power-up when the battery is critically low, regardless of system unlocked status. BUG=chrome-os-partner:48339 TEST=Verify power-up is prevented on no-battery chell w/ donette. Then, run 'powerbtn' on EC console and verify system powers on (and overcurrents). BRANCH=None Change-Id: Ia631b5a8c45b42ec805e4a0c3f827929a0efd236 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/319187 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Diffstat (limited to 'common/power_button_x86.c')
-rw-r--r--common/power_button_x86.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/common/power_button_x86.c b/common/power_button_x86.c
index 9ae2be1ff5..ce7bba990e 100644
--- a/common/power_button_x86.c
+++ b/common/power_button_x86.c
@@ -112,7 +112,7 @@ static const char * const state_names[] = {
*/
static uint64_t tnext_state;
-static void set_pwrbtn_to_pch(int high)
+static void set_pwrbtn_to_pch(int high, int init)
{
/*
* If the battery is discharging and low enough we'd shut down the
@@ -122,7 +122,7 @@ static void set_pwrbtn_to_pch(int high)
*/
#ifdef CONFIG_CHARGER
if (chipset_in_state(CHIPSET_STATE_ANY_OFF) && !high &&
- (charge_want_shutdown() || charge_prevent_power_on())) {
+ (charge_want_shutdown() || charge_prevent_power_on(!init))) {
CPRINTS("PB PCH pwrbtn ignored due to battery level");
high = 1;
}
@@ -137,7 +137,7 @@ void power_button_pch_press(void)
/* Assert power button signal to PCH */
if (!power_button_is_pressed())
- set_pwrbtn_to_pch(0);
+ set_pwrbtn_to_pch(0, 0);
}
void power_button_pch_release(void)
@@ -145,7 +145,7 @@ void power_button_pch_release(void)
CPRINTS("PB PCH force release");
/* Deassert power button signal to PCH */
- set_pwrbtn_to_pch(1);
+ set_pwrbtn_to_pch(1, 0);
/*
* If power button is actually pressed, eat the next release so we
@@ -162,7 +162,7 @@ void power_button_pch_pulse(void)
CPRINTS("PB PCH pulse");
chipset_exit_hard_off();
- set_pwrbtn_to_pch(0);
+ set_pwrbtn_to_pch(0, 0);
pwrbtn_state = PWRBTN_STATE_LID_OPEN;
tnext_state = get_time().val + PWRBTN_INITIAL_US;
task_wake(TASK_ID_POWERBTN);
@@ -203,7 +203,7 @@ static void set_initial_pwrbtn_state(void)
*/
if (power_button_is_pressed()) {
CPRINTS("PB init-jumped-held");
- set_pwrbtn_to_pch(0);
+ set_pwrbtn_to_pch(0, 0);
} else {
CPRINTS("PB init-jumped");
}
@@ -270,12 +270,12 @@ static void state_machine(uint64_t tnow)
tnext_state = tnow + PWRBTN_DELAY_T0;
pwrbtn_state = PWRBTN_STATE_T0;
}
- set_pwrbtn_to_pch(0);
+ set_pwrbtn_to_pch(0, 0);
break;
case PWRBTN_STATE_T0:
tnext_state = tnow + PWRBTN_DELAY_T1;
pwrbtn_state = PWRBTN_STATE_T1;
- set_pwrbtn_to_pch(1);
+ set_pwrbtn_to_pch(1, 0);
break;
case PWRBTN_STATE_T1:
/*
@@ -286,12 +286,12 @@ static void state_machine(uint64_t tnow)
if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
CPRINTS("PB chipset already off");
else
- set_pwrbtn_to_pch(0);
+ set_pwrbtn_to_pch(0, 0);
pwrbtn_state = PWRBTN_STATE_HELD;
break;
case PWRBTN_STATE_RELEASED:
case PWRBTN_STATE_LID_OPEN:
- set_pwrbtn_to_pch(1);
+ set_pwrbtn_to_pch(1, 0);
pwrbtn_state = PWRBTN_STATE_IDLE;
break;
case PWRBTN_STATE_INIT_ON:
@@ -310,7 +310,7 @@ static void state_machine(uint64_t tnow)
* battery is handled inside set_pwrbtn_to_pch().
*/
chipset_exit_hard_off();
- set_pwrbtn_to_pch(0);
+ set_pwrbtn_to_pch(0, 1);
tnext_state = get_time().val + PWRBTN_INITIAL_US;
if (power_button_is_pressed()) {
@@ -329,7 +329,7 @@ static void state_machine(uint64_t tnow)
* button until it's released, so that holding down the
* recovery combination doesn't cause the chipset to shut back
* down. */
- set_pwrbtn_to_pch(1);
+ set_pwrbtn_to_pch(1, 0);
if (power_button_is_pressed())
pwrbtn_state = PWRBTN_STATE_EAT_RELEASE;
else