diff options
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) |