diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-06-04 11:30:34 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-06-05 22:35:05 +0000 |
commit | 58719e30730e6420533514dabd27c188e60ae607 (patch) | |
tree | 8015dd22c5808e88b648cd52463bf59a34b0a734 /common/host_command_pd.c | |
parent | bdc680d8ed7ea24cdfb1b5498f73a1008c71ad37 (diff) | |
download | chrome-ec-58719e30730e6420533514dabd27c188e60ae607.tar.gz |
pd: use pdcmd task to handle tcpc interrupt
Use the PDCMD task to handle PD MCU interrupts, and use it
to trigger the tcpc_alert().
Note this fixes bug on Glados and Oak that could cause watchdog
reset because tcpc_alert() which uses i2c to talk to tcpc was
called from hooks task and can delay tickling watchdog.
BUG=chrome-os-partner:40920
BRANCH=none
TEST=load on glados and plug zinger into both ports many times.
make sure we get a stable contract and no watchdog reset.
Change-Id: I37625fae2ca0057d2ee8fa1eea6974f2d26d1b91
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/275296
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'common/host_command_pd.c')
-rw-r--r-- | common/host_command_pd.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/common/host_command_pd.c b/common/host_command_pd.c index 140c71ea4e..33bdb52745 100644 --- a/common/host_command_pd.c +++ b/common/host_command_pd.c @@ -14,32 +14,37 @@ #include "system.h" #include "task.h" #include "timer.h" +#include "usb_pd_tcpm.h" #include "util.h" #define CPRINTS(format, args...) cprints(CC_PD_HOST_CMD, format, ## args) #define TASK_EVENT_EXCHANGE_PD_STATUS TASK_EVENT_CUSTOM(1) +#ifdef CONFIG_USB_PD_MCU_CHG_CTRL /* By default allow 5V charging only for the dead battery case */ static enum pd_charge_state charge_state = PD_CHARGE_5V; #define CHARGE_PORT_UNINITIALIZED -2 static int charge_port = CHARGE_PORT_UNINITIALIZED; +int pd_get_active_charge_port(void) +{ + return charge_port; +} +#endif + void host_command_pd_send_status(enum pd_charge_state new_chg_state) { +#ifdef CONFIG_USB_PD_MCU_CHG_CTRL /* Update PD MCU charge state if necessary */ if (new_chg_state != PD_CHARGE_NO_CHANGE) charge_state = new_chg_state; +#endif /* Wake PD HC task to send status */ task_set_event(TASK_ID_PDCMD, TASK_EVENT_EXCHANGE_PD_STATUS, 0); } -int pd_get_active_charge_port(void) -{ - return charge_port; -} - static void pd_exchange_status(void) { struct ec_params_pd_status ec_status; @@ -50,7 +55,9 @@ static void pd_exchange_status(void) #endif /* Send PD charge state and battery state of charge */ +#ifdef CONFIG_USB_PD_MCU_CHG_CTRL ec_status.charge_state = charge_state; +#endif if (charge_get_flags() & CHARGE_FLAG_BATT_RESPONSIVE) ec_status.batt_soc = charge_get_percent(); else @@ -86,6 +93,7 @@ static void pd_exchange_status(void) } #endif +#ifdef CONFIG_USB_PD_MCU_CHG_CTRL #ifdef HAS_TASK_LIGHTBAR /* * If charge port has changed, and it was initialized, then show @@ -109,10 +117,15 @@ static void pd_exchange_status(void) CONFIG_CHARGER_INPUT_CURRENT)); if (rv < 0) CPRINTS("Failed to set input current limit from PD MCU"); +#endif /* CONFIG_USB_PD_MCU_CHG_CTRL */ /* If PD is signalling host event, then pass it up to AP */ if (pd_status.status & PD_STATUS_HOST_EVENT) host_set_single_event(EC_HOST_EVENT_PD_MCU); + +#ifdef CONFIG_USB_PD_TCPM_TCPCI + tcpc_alert(); +#endif } void pd_command_task(void) |