summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyushee <ayushee.shah@intel.com>2019-08-06 15:24:10 -0700
committerCommit Bot <commit-bot@chromium.org>2019-08-16 06:32:51 +0000
commit226a468ebcbc4f690d5f9c34f4912e8c046c17af (patch)
tree43d1741a316f80529e6d0f4cccce3f5df58f06ab
parent1fd14e8629cfef0dd34ba43a1d83eead3a6ccd2f (diff)
downloadchrome-ec-226a468ebcbc4f690d5f9c34f4912e8c046c17af.tar.gz
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 <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1749560 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--common/usb_pd_policy.c5
-rw-r--r--common/usb_pd_protocol.c1
-rw-r--r--include/ec_commands.h7
-rw-r--r--include/usb_pd.h8
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
@@ -1781,6 +1781,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
*
* @param port USB-C port number