diff options
author | Alec Berg <alecaberg@chromium.org> | 2014-07-01 11:37:04 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-07-11 01:55:13 +0000 |
commit | 6ab38d8715bb49753b98b21f5430c6986dc12cf2 (patch) | |
tree | a5849e121cb2a410bc10d94eb3d0d75083e0a6a4 | |
parent | bc4973c1f9a49d8ce17b42a74e7373f2a8e8ca09 (diff) | |
download | chrome-ec-6ab38d8715bb49753b98b21f5430c6986dc12cf2.tar.gz |
samus: use real AC_PRESENT signal
Revert
- https://chromium-review.googlesource.com/#/c/205145/2
- https://chromium-review.googlesource.com/#/c/205147/4
Now using the real AC_PRESENT gpio signal instead of whether or
not the PD MCU negotiated for 20V.
BUG=chrome-os-partner:29841, chrome-os-partner:29842
BRANCH=none
TEST=tested on a board with reworked AC_PRESENT signal. Verified
that gpio is correctly reporting state of AC and is charging when
AC is plugged in. Tested the no battery case to make sure
board powers on and stays on with just a charger. Also tested the
dead battery case by plugging in a dead battery, then plugging in
a charger and making sure system powers on and starts charging.
Change-Id: I4424771c91c8a2aa19eda68a8b5194e9265d529c
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/206598
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r-- | board/samus/extpower.c | 11 | ||||
-rw-r--r-- | board/samus_pd/usb_pd_policy.c | 20 | ||||
-rw-r--r-- | common/charge_state_v2.c | 41 | ||||
-rw-r--r-- | common/host_command_pd.c | 16 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 20 | ||||
-rw-r--r-- | include/ec_commands.h | 7 |
6 files changed, 5 insertions, 110 deletions
diff --git a/board/samus/extpower.c b/board/samus/extpower.c index c478d50ece..4da7e655a7 100644 --- a/board/samus/extpower.c +++ b/board/samus/extpower.c @@ -14,19 +14,10 @@ #include "gpio.h" #include "hooks.h" #include "host_command.h" -#include "system.h" -/* - * TODO(crosbug.com/p/29841): remove hack for getting extpower - * is present status from PD MCU. - */ -extern int pd_extpower_is_present(void); int extpower_is_present(void) { - if (system_get_board_version() <= BOARD_VERSION_PROTO_2_B) - return pd_extpower_is_present(); - else - return gpio_get_level(GPIO_AC_PRESENT); + return gpio_get_level(GPIO_AC_PRESENT); } /** diff --git a/board/samus_pd/usb_pd_policy.c b/board/samus_pd/usb_pd_policy.c index 83d6605418..60f6e1c21f 100644 --- a/board/samus_pd/usb_pd_policy.c +++ b/board/samus_pd/usb_pd_policy.c @@ -36,8 +36,6 @@ static unsigned max_mv = -1; /* no cap */ /* Flag for battery status */ static int battery_ok = 1; -static int charger_connected; - int pd_choose_voltage(int cnt, uint32_t *src_caps, uint32_t *rdo) { int i; @@ -142,18 +140,6 @@ static void pd_send_ec_int(void) gpio_set_level(GPIO_EC_INT_L, 1); } -/* - * TODO(crosbug.com/p/29841): remove hack for getting extpower - * is present status from PD MCU. - */ -void pd_charger_change(int c) -{ - if (charger_connected != c) { - charger_connected = c; - pd_send_ec_int(); - } -} - int pd_board_checks(void) { static uint64_t last_time; @@ -203,11 +189,7 @@ static int ec_status_host_cmd(struct host_cmd_handler_args *args) battery_ok = 0; } - /* - * TODO(crosbug.com/p/29841): remove hack for getting extpower - * is present status from PD MCU. - */ - r->status = charger_connected ? EC_CMD_PD_STATUS_FLAG_CHARGER_CONN : 0; + r->status = 0; args->response_size = sizeof(*r); diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 5b9d32ba89..c44d05e096 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -400,23 +400,6 @@ static inline int battery_too_low(void) curr.batt.voltage <= batt_info->voltage_min)); } -#ifdef BOARD_SAMUS -/* - * TODO(crosbug.com/p/29842): remove this workaround once the AC_PRESENT - * input is avaible. - */ -static void check_deep_discharge_again(void) -{ - /* Check again if power is present */ - if (!extpower_is_present()) { - /* AP is off, so shut down the EC now */ - CPRINTS("charge force EC hibernate due to low battery"); - system_hibernate(0, 0); - } -} -DECLARE_DEFERRED(check_deep_discharge_again); -#endif - /* Shut everything down before the battery completely dies. */ static void prevent_deep_discharge(void) { @@ -424,17 +407,9 @@ static void prevent_deep_discharge(void) return; if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) { -#ifdef BOARD_SAMUS - /* - * TODO(crosbug.com/p/29842): remove this workaround once - * the AC_PRESENT input is avaible. - */ - hook_call_deferred(check_deep_discharge_again, 10*SECOND); -#else /* AP is off, so shut down the EC now */ CPRINTS("charge force EC hibernate due to low battery"); system_hibernate(0, 0); -#endif } else if (!shutdown_warning_time.val) { /* Warn AP battery level is so low we'll shut down */ CPRINTS("charge warn shutdown due to low battery"); @@ -510,27 +485,11 @@ void charger_task(void) problem(PR_POST_INIT, rv); else prev_ac = curr.ac; -#ifdef BOARD_SAMUS - /* - * TODO(crosbug.com/p/29841): remove hack for - * getting extpower is present status from PD. - */ - CPRINTS("AC connected"); - host_set_single_event(EC_HOST_EVENT_AC_CONNECTED); -#endif } else { /* Some things are only meaningful on AC */ state_machine_force_idle = 0; battery_seems_to_be_dead = 0; prev_ac = curr.ac; -#ifdef BOARD_SAMUS - /* - * TODO(crosbug.com/p/29841): remove hack for - * getting extpower is present status from PD. - */ - CPRINTS("AC disconnected"); - host_set_single_event(EC_HOST_EVENT_AC_DISCONNECTED); -#endif } } charger_get_params(&curr.chg); diff --git a/common/host_command_pd.c b/common/host_command_pd.c index 27bc8265fa..ed9f97a21e 100644 --- a/common/host_command_pd.c +++ b/common/host_command_pd.c @@ -17,8 +17,6 @@ #define TASK_EVENT_EXCHANGE_PD_STATUS TASK_EVENT_CUSTOM(1) -static int pd_charger_connected; - void host_command_pd_send_status(void) { task_set_event(TASK_ID_PDCMD, TASK_EVENT_EXCHANGE_PD_STATUS, 0); @@ -50,22 +48,10 @@ static void pd_exchange_status(void) task_wait_event(500*MSEC); } - if (rv >= 0) - pd_charger_connected = pd_status.status & - EC_CMD_PD_STATUS_FLAG_CHARGER_CONN; - else + if (rv < 0) CPRINTS("Host command to PD MCU failed"); } -/* - * TODO(crosbug.com/p/29841): remove hack for getting extpower - * is present status from PD MCU. - */ -int pd_extpower_is_present(void) -{ - return pd_charger_connected; -} - void pd_command_task(void) { diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 1c6c9f611a..1e37446a2c 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -771,9 +771,6 @@ static void execute_hard_reset(void) CPRINTF("HARD RESET!\n"); } -#ifdef BOARD_SAMUS_PD -extern void pd_charger_change(int c); -#endif void pd_task(void) { int head; @@ -888,13 +885,6 @@ void pd_task(void) break; case PD_STATE_SNK_DISCONNECTED: /* Source connection monitoring */ -#ifdef BOARD_SAMUS_PD - /* - * TODO(crosbug.com/p/29841): remove hack for - * getting extpower is present status from PD MCU. - */ - pd_charger_change(0); -#endif if (pd_snk_is_vbus_provided()) { cc1_volt = pd_adc_read(0); cc2_volt = pd_adc_read(1); @@ -941,15 +931,7 @@ void pd_task(void) timeout = 10*MSEC; break; case PD_STATE_SNK_READY: - /* we have power and we are happy */ -#ifdef BOARD_SAMUS_PD - /* - * TODO(crosbug.com/p/29841): remove hack for - * getting extpower is present status from PD MCU. - */ - pd_charger_change(1); -#endif - /* check vital parameters from time to time */ + /* we have power, check vitals from time to time */ timeout = 100*MSEC; break; #endif /* CONFIG_USB_PD_DUAL_ROLE */ diff --git a/include/ec_commands.h b/include/ec_commands.h index f09b7c2d08..d867c31dc1 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -2496,13 +2496,8 @@ struct ec_params_pd_status { } __packed; /* Status of PD being sent back to EC */ -/* - * TODO(crosbug.com/p/29841): remove hack for - * getting extpower is present status from PD MCU. - */ -#define EC_CMD_PD_STATUS_FLAG_CHARGER_CONN (1<<0) struct ec_response_pd_status { - int8_t status; + int8_t status; /* currently empty */ } __packed; /*****************************************************************************/ |