From 226a468ebcbc4f690d5f9c34f4912e8c046c17af Mon Sep 17 00:00:00 2001 From: Ayushee Date: Tue, 6 Aug 2019 15:24:10 -0700 Subject: usb_pd: Get USB-C cable type information Added logic to share the USB-C cable type information in host command to configure the virtual mux of Intel SOC. BUG=b:129990370 BRANCH=None TEST=Verified on Intelrvp, able to get correct USB-C cable type information Change-Id: Iee7c274d318f59a482d21b8faa56610509fbdf8e Signed-off-by: Ayushee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1749560 Reviewed-by: Keith Short Reviewed-by: Daisuke Nojiri --- common/usb_pd_policy.c | 5 +++++ common/usb_pd_protocol.c | 1 + include/ec_commands.h | 7 +++++-- include/usb_pd.h | 8 ++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c index 0e53f80c65..554cf86151 100644 --- a/common/usb_pd_policy.c +++ b/common/usb_pd_policy.c @@ -324,6 +324,11 @@ void reset_pd_cable(int port) memset(&cable[port], 0, sizeof(cable[port])); } +uint8_t get_usb_pd_mux_cable_type(int port) +{ + return cable[port].type; +} + #ifdef CONFIG_USB_PD_ALT_MODE #ifdef CONFIG_USB_PD_ALT_MODE_DFP diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 15798615bc..a1d4ccb4c7 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -5433,6 +5433,7 @@ static int hc_usb_pd_control(struct host_cmd_handler_args *args) r_v2->cc_state = pd[p->port].cc_state; r_v2->dp_mode = board_get_dp_pin_mode(p->port); + r_v2->cable_type = get_usb_pd_mux_cable_type(p->port); if (args->version == 1) args->response_size = sizeof(*r_v1); diff --git a/include/ec_commands.h b/include/ec_commands.h index d887f86880..ce0ec1fce9 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -4941,6 +4941,10 @@ struct ec_response_usb_pd_control_v1 { #define USBC_PD_CC_UFP_ATTACHED 4 /* UFP attached to usbc */ #define USBC_PD_CC_DFP_ATTACHED 5 /* DPF attached to usbc */ +#define USBC_CABLE_TYPE_UNDEF 0 /* Undefined */ +#define USBC_CABLE_TYPE_PASSIVE 3 /* Passive cable attached */ +#define USBC_CABLE_TYPE_ACTIVE 4 /* Active cable attached */ + struct ec_response_usb_pd_control_v2 { uint8_t enabled; uint8_t role; @@ -4948,8 +4952,7 @@ struct ec_response_usb_pd_control_v2 { char state[32]; uint8_t cc_state; /* USBC_PD_CC_*Encoded cc state */ uint8_t dp_mode; /* Current DP pin mode (MODE_DP_PIN_[A-E]) */ - /* CL:1500994 Current cable type */ - uint8_t reserved_cable_type; + uint8_t cable_type; /* USBC_CABLE_TYPE_*cable_type */ } __ec_align1; #define EC_CMD_USB_PD_PORTS 0x0102 diff --git a/include/usb_pd.h b/include/usb_pd.h index bf4469ee32..4b36247a94 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -1780,6 +1780,14 @@ uint8_t is_sop_prime_ready(int port, uint8_t data_role, uint32_t pd_flags); */ void reset_pd_cable(int port); +/** + * Return the type of cable attached + * + * @param port USB-C port number + * @return cable type + */ +uint8_t get_usb_pd_mux_cable_type(int port); + /** * Store Device ID & RW hash of device * -- cgit v1.2.1