From 28bfc8037156ba0f9c8189ef6e8b7c8a7d22d4cc Mon Sep 17 00:00:00 2001 From: Caveh Jalali Date: Mon, 31 Jul 2017 17:07:47 -0700 Subject: [PATCH] PD_CONTROL: add subcommand to power up a TCPC. add a subcommand to the PD_CONTROL message to power up a specific TCPC. in practice, this typically just takes the TCPC out of sleep mode for cases where sleep mode is controlled by the EC. under the covers, board_set_tcpc_power_mode() gets a weak function definition so we don't need to special case this everywhere. TEST="make buildall" passes; "make tests" passes for reef. BRANCH=none BUG=b:35586895 Change-Id: Ib50e265d11eca10c3714049d8cfdf2657eff48c1 Signed-off-by: Caveh Jalali Reviewed-on: https://chromium-review.googlesource.com/596796 Reviewed-by: Shawn N --- common/usb_pd_protocol.c | 3 +++ include/ec_commands.h | 3 ++- include/usb_pd_tcpm.h | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 81e1bd2e8a..054ea56d8f 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -3915,6 +3915,9 @@ static int pd_control(struct host_cmd_handler_args *args) #else return EC_RES_INVALID_COMMAND; #endif + } else if (cmd->subcmd == PD_CHIP_ON && board_set_tcpc_power_mode) { + board_set_tcpc_power_mode(cmd->chip, 1); + return EC_RES_SUCCESS; } else { return EC_RES_INVALID_COMMAND; } diff --git a/include/ec_commands.h b/include/ec_commands.h index 67d026118f..d15c213e98 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -4179,7 +4179,8 @@ enum ec_pd_control_cmd { PD_SUSPEND = 0, /* Suspend the PD chip (EC: stop talking to PD) */ PD_RESUME, /* Resume the PD chip (EC: start talking to PD) */ PD_RESET, /* Force reset the PD chip */ - PD_CONTROL_DISABLE /* Disable further calls to this command */ + PD_CONTROL_DISABLE, /* Disable further calls to this command */ + PD_CHIP_ON, /* Power on the PD chip */ }; struct __ec_align1 ec_params_pd_control { diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h index 3f231fb3f7..edcd3f5875 100644 --- a/include/usb_pd_tcpm.h +++ b/include/usb_pd_tcpm.h @@ -242,6 +242,14 @@ struct tcpc_config_t { */ uint16_t tcpc_get_alert_status(void); +/** + * Optional, set the TCPC power mode. + * + * @param port Type-C port number + * @param mode 0: off/sleep, 1: on/awake + */ +void board_set_tcpc_power_mode(int port, int mode) __attribute__((weak)); + /** * Initialize TCPC. *