summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2020-01-21 18:25:52 -0800
committerCommit Bot <commit-bot@chromium.org>2020-01-29 20:46:21 +0000
commita8b2362e82e1016f53d50f86469af233c9b4a002 (patch)
treee3761b2136584829e9a308f25ad3dbde1831fa78
parentf22bc063c93bf1245f872008116359f484cadf70 (diff)
downloadchrome-ec-a8b2362e82e1016f53d50f86469af233c9b4a002.tar.gz
TCPMv1: Cleanup sending TBT control flags to host
BUG=b:148114593 BRANCH=none TEST=tested on Volteer, able to get correct TBT control flags Change-Id: If673d4a194d3cc6b9579f0f32511c6363f2614f3 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2013825 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--common/usb_pd_policy.c8
-rw-r--r--common/usb_pd_protocol.c21
-rw-r--r--common/usbc/usb_pe_drp_sm.c2
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c2
-rw-r--r--driver/retimer/bb_retimer.c22
-rw-r--r--include/ec_commands.h25
-rw-r--r--include/usb_pd.h2
-rw-r--r--util/ectool.c29
8 files changed, 52 insertions, 59 deletions
diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c
index db878d2ce7..feb022d911 100644
--- a/common/usb_pd_policy.c
+++ b/common/usb_pd_policy.c
@@ -201,7 +201,7 @@ void reset_pd_cable(int port)
memset(&cable[port], 0, sizeof(cable[port]));
}
-enum idh_ptype get_usb_pd_mux_cable_type(int port)
+enum idh_ptype get_usb_pd_cable_type(int port)
{
return cable[port].type;
}
@@ -627,7 +627,7 @@ static int enter_tbt_compat_mode(int port, uint32_t *payload)
cable[port].dev_mode_resp.vendor_spec_b0;
enter_dev_mode.intel_spec_b0 = cable[port].dev_mode_resp.intel_spec_b0;
enter_dev_mode.cable =
- get_usb_pd_mux_cable_type(port) == IDH_PTYPE_PCABLE ?
+ get_usb_pd_cable_type(port) == IDH_PTYPE_PCABLE ?
TBT_ENTER_PASSIVE_CABLE : TBT_ENTER_ACTIVE_CABLE;
if (cable[port].cable_mode_resp.tbt_cable_speed == TBT_SS_TBT_GEN3) {
@@ -912,7 +912,7 @@ static int process_tbt_compat_discover_modes(int port, uint32_t *payload)
* Enter Mode SOP' (Cable Enter Mode) is skipped for
* passive cables.
*/
- if (get_usb_pd_mux_cable_type(port) == IDH_PTYPE_PCABLE)
+ if (get_usb_pd_cable_type(port) == IDH_PTYPE_PCABLE)
disable_transmit_sop_prime(port);
rsize = enter_tbt_compat_mode(port, payload);
@@ -1200,7 +1200,7 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload,
/* Passive cable Nacked for Discover SVID */
if (cmd == CMD_DISCOVER_SVID && is_tbt_compat_enabled(port) &&
is_transmit_msg_sop_prime(port) &&
- get_usb_pd_mux_cable_type(port) == IDH_PTYPE_PCABLE) {
+ get_usb_pd_cable_type(port) == IDH_PTYPE_PCABLE) {
limit_tbt_cable_speed(port);
rsize = dfp_discover_modes(port, payload);
disable_transmit_sop_prime(port);
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index c2d937e8ef..2e501cfe62 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -5367,10 +5367,10 @@ static const mux_state_t typec_mux_map[USB_PD_CTRL_MUX_COUNT] = {
/*
* Combines the following information into a single byte
- * Bit 0: Thunderbolt cable
- * Bit 1: Type-C adapter type
- * Bit 2: Cable type
- * Bit 3: Link training
+ * Bit 0: Active/Passive cable
+ * Bit 1: Optical/Non-optical cable
+ * Bit 2: Legacy Thunderbolt adapter
+ * Bit 3: Active Link Uni-Direction/Bi-Direction
*/
static uint8_t get_pd_control_flags(int port)
{
@@ -5382,10 +5382,14 @@ static uint8_t get_pd_control_flags(int port)
* Table F-11 TBT3 Cable Discover Mode VDO Responses
* For Passive cables, Active Cable Plug link training is set to 0
*/
- return (cable_resp.lsrx_comm ? USB_PD_MUX_TBT_LINK : 0) |
- (cable_resp.tbt_cable ? USB_PD_MUX_TBT_CABLE_TYPE : 0) |
- (device_resp.tbt_adapter ? USB_PD_MUX_TBT_ADAPTER : 0) |
- (cable_resp.retimer_type ? USB_PD_MUX_TBT_ACTIVE_CABLE : 0);
+ return (cable_resp.lsrx_comm == UNIDIR_LSRX_COMM ?
+ USB_PD_CTRL_ACTIVE_LINK_UNIDIR : 0) |
+ (device_resp.tbt_adapter == TBT_ADAPTER_TBT2_LEGACY ?
+ USB_PD_CTRL_TBT_LEGACY_ADAPTER : 0) |
+ (cable_resp.tbt_cable == TBT_CABLE_OPTICAL ?
+ USB_PD_CTRL_OPTICAL_CABLE : 0) |
+ (cable_resp.retimer_type == USB_RETIMER ?
+ USB_PD_CTRL_ACTIVE_CABLE : 0);
}
static enum ec_status hc_usb_pd_control(struct host_cmd_handler_args *args)
@@ -5473,7 +5477,6 @@ static enum ec_status hc_usb_pd_control(struct host_cmd_handler_args *args)
if (IS_ENABLED(CONFIG_USB_PD_ALT_MODE_DFP))
r_v2->dp_mode = get_dp_pin_mode(p->port);
- r_v2->cable_type = get_usb_pd_mux_cable_type(p->port);
r_v2->control_flags = get_pd_control_flags(p->port);
r_v2->cable_speed = get_tbt_cable_speed(p->port);
r_v2->cable_gen = get_tbt_rounded_support(p->port);
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 33c303797c..12a991db90 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -3834,7 +3834,7 @@ static void pe_vdm_request_exit(int port)
PE_CLR_FLAG(port, PE_FLAGS_INTERRUPTIBLE_AMS);
}
-enum idh_ptype get_usb_pd_mux_cable_type(int port)
+enum idh_ptype get_usb_pd_cable_type(int port)
{
if (pe[port].passive_cable_vdo != PD_VDO_INVALID)
return IDH_PTYPE_PCABLE;
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index 25d0096dc7..c4049451fc 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -1277,8 +1277,6 @@ static enum ec_status hc_usb_pd_control(struct host_cmd_handler_args *args)
if (IS_ENABLED(CONFIG_USB_PD_ALT_MODE_DFP))
r_v2->dp_mode = get_dp_pin_mode(p->port);
- r_v2->cable_type = get_usb_pd_mux_cable_type(p->port);
-
strzcpy(r_v2->state, tc_state_names[get_state_tc(p->port)],
sizeof(r_v2->state));
if (args->version == 1) {
diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c
index f1c30f87ed..f2e378f11e 100644
--- a/driver/retimer/bb_retimer.c
+++ b/driver/retimer/bb_retimer.c
@@ -229,22 +229,22 @@ static int retimer_set_state(int port, mux_state_t mux_state)
set_retimer_con |= BB_RETIMER_TBT_CABLE_TYPE;
/*
- * Bit 20: TBT_ACTIVE_LINK_TRAINING
- * 0 - Active with bi-directional LSRX communication
- * 1 - Active with uni-directional LSRX communication
- * Set to "0" when passive cable plug
- */
- if (cable_resp.lsrx_comm == UNIDIR_LSRX_COMM &&
- (get_usb_pd_mux_cable_type(port) & IDH_PTYPE_ACABLE))
- set_retimer_con |= BB_RETIMER_TBT_ACTIVE_LINK_TRAINING;
-
- /*
* Bit 22: Active/Passive
* 0 - Passive cable
* 1 - Active cable
*/
- if (get_usb_pd_mux_cable_type(port) == IDH_PTYPE_ACABLE)
+ if (get_usb_pd_cable_type(port) == IDH_PTYPE_ACABLE) {
set_retimer_con |= BB_RETIMER_ACTIVE_PASSIVE;
+ /*
+ * Bit 20: TBT_ACTIVE_LINK_TRAINING
+ * 0 - Active with bi-directional LSRX communication
+ * 1 - Active with uni-directional LSRX communication
+ * Set to "0" when passive cable plug
+ */
+ if (cable_resp.lsrx_comm == UNIDIR_LSRX_COMM)
+ set_retimer_con |=
+ BB_RETIMER_TBT_ACTIVE_LINK_TRAINING;
+ }
/*
* Bits 27-25: TBT_CABLE_SPEED_SUPPORT
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 4112ae33f9..ff537234cd 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -5197,27 +5197,24 @@ enum pd_cc_states {
PD_CC_NONE = 0, /* No port partner attached */
/* From DFP perspective */
+ PD_CC_UFP_NONE = 1, /* No UFP accessory connected */
PD_CC_UFP_AUDIO_ACC = 2, /* UFP Audio accessory connected */
PD_CC_UFP_DEBUG_ACC = 3, /* UFP Debug accessory connected */
PD_CC_UFP_ATTACHED = 4, /* Plain UFP attached */
/* From UFP perspective */
- PD_CC_DFP_DEBUG_ACC = 6, /* DFP debug accessory connected */
PD_CC_DFP_ATTACHED = 5, /* Plain DFP attached */
+ PD_CC_DFP_DEBUG_ACC = 6, /* DFP debug accessory connected */
};
-#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 */
-
/* Active/Passive Cable */
-#define USB_PD_MUX_TBT_ACTIVE_CABLE BIT(0)
+#define USB_PD_CTRL_ACTIVE_CABLE BIT(0)
/* Optical/Non-optical cable */
-#define USB_PD_MUX_TBT_CABLE_TYPE BIT(1)
+#define USB_PD_CTRL_OPTICAL_CABLE BIT(1)
/* 3rd Gen TBT device (or AMA)/2nd gen tbt Adapter */
-#define USB_PD_MUX_TBT_ADAPTER BIT(2)
-/* Active Link enabled/disabled */
-#define USB_PD_MUX_TBT_LINK BIT(3)
+#define USB_PD_CTRL_TBT_LEGACY_ADAPTER BIT(2)
+/* Active Link Uni-Direction */
+#define USB_PD_CTRL_ACTIVE_LINK_UNIDIR BIT(3)
/*
* Underdevelopement :
@@ -5230,10 +5227,10 @@ struct ec_response_usb_pd_control_v2 {
char state[32];
uint8_t cc_state; /* enum pd_cc_states representing cc state */
uint8_t dp_mode; /* Current DP pin mode (MODE_DP_PIN_[A-E]) */
- uint8_t cable_type; /* USBC_CABLE_TYPE_*cable_type */
- uint8_t control_flags; /* USB_PD_MUX_*flags */
- uint8_t cable_speed;
- uint8_t cable_gen; /* rounded_support */
+ uint8_t reserved; /* Reserved for future use */
+ uint8_t control_flags; /* USB_PD_CTRL_*flags */
+ uint8_t cable_speed; /* TBT_SS_* cable speed */
+ uint8_t cable_gen; /* TBT_GEN3_* cable rounded support */
} __ec_align1;
#define EC_CMD_USB_PD_PORTS 0x0102
diff --git a/include/usb_pd.h b/include/usb_pd.h
index b14cf8b241..c1e4ff5583 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -1626,7 +1626,7 @@ void reset_pd_cable(int port);
* @param port USB-C port number
* @return cable type
*/
-enum idh_ptype get_usb_pd_mux_cable_type(int port);
+enum idh_ptype get_usb_pd_cable_type(int port);
/**
* Return the response of discover mode SOP prime, with SVID = 0x8087
diff --git a/util/ectool.c b/util/ectool.c
index ded1af6cde..fe580083b8 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -5574,28 +5574,23 @@ int cmd_usb_pd(int argc, char *argv[])
printf("UNKNOWN");
printf("\n");
}
- if (r_v2->cable_type) {
- printf("Cable type:");
- if (r_v2->cable_type == IDH_PTYPE_ACABLE)
- printf("Active");
- else if (r_v2->cable_type == IDH_PTYPE_PCABLE)
- printf("Passive");
- else
- printf("UNKNOWN");
- printf("\n");
- }
- printf("Adapter type:%s\n",
- r_v2->control_flags & USB_PD_MUX_TBT_ADAPTER ?
- "Legacy Thunderbolt" : "Type-C");
+ printf("Cable type:%s\n",
+ r_v2->control_flags & USB_PD_CTRL_ACTIVE_CABLE ?
+ "Active" : "Passive");
- printf("Cable type:%sOptical\n",
+ printf("TBT Adapter type:%s\n",
r_v2->control_flags &
- USB_PD_MUX_TBT_CABLE_TYPE ? "" : "Non-");
+ USB_PD_CTRL_TBT_LEGACY_ADAPTER ?
+ "Legacy" : "Gen3");
+
+ printf("Optical Cable:%s\n",
+ r_v2->control_flags &
+ USB_PD_CTRL_OPTICAL_CABLE ? "True" : "False");
printf("Link LSRX Communication:%s-directional\n",
- r_v2->control_flags & USB_PD_MUX_TBT_LINK ?
- "Uni" : "Bi");
+ r_v2->control_flags &
+ USB_PD_CTRL_ACTIVE_LINK_UNIDIR ? "Uni" : "Bi");
printf("TBT Cable Speed:");
switch (r_v2->cable_speed) {