summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@chromium.org>2019-12-11 16:04:03 -0700
committerCommit Bot <commit-bot@chromium.org>2020-01-08 17:15:04 +0000
commitb560141a1d8ce034ae5b85718c163fb7ab83c24f (patch)
tree1b0505d2eeaa5bc7c1f521e6fed1015e9ab2d023 /include
parent5750cc926d64033fe7f19b760165011120915ab0 (diff)
downloadchrome-ec-b560141a1d8ce034ae5b85718c163fb7ab83c24f.tar.gz
tcpci: Only drive one CC line when attached
Some of the NCT38XX driver code was more generic TCPCI than specific to the chip. So moved a number of the functions over to be generically handled. In doing this I propagated the idea of tri-state polarity. It is now either NORMAL, FLIPPED, or NONE for unattached. This is needed for the generic handling of correctly setting CC. This required changing the polarity from NONE to the appropriate detected polarity when in auto toggle. tcpci_tcpm_set_cc will now only set a single CC line when attached and both when unattached. BUG=b:146003980, chromium:951681 BRANCH=none TEST=Charging works with both plug orientations with AP on TEST=Device works with both plug orientations with AP on TEST=Charging works with both plug orientations with AP off Change-Id: Ie4b5cc998902a346a4f4a2c1480204b3a81017dd Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1967932 Commit-Queue: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/usb_common.h18
-rw-r--r--include/usb_pd.h8
-rw-r--r--include/usb_pd_tcpm.h12
-rw-r--r--include/usb_tc_sm.h2
4 files changed, 25 insertions, 15 deletions
diff --git a/include/usb_common.h b/include/usb_common.h
index 13bebc7915..b56cd2a38f 100644
--- a/include/usb_common.h
+++ b/include/usb_common.h
@@ -57,12 +57,12 @@ int usb_get_battery_soc(void);
* Returns type C current limit (mA), potentially with the DTS flag, based upon
* states of the CC lines on the partner side.
*
- * @param polarity 0 if cc1 is primary, otherwise 1
+ * @param polarity port polarity
* @param cc1 value of CC1 set by tcpm_get_cc
* @param cc2 value of CC2 set by tcpm_get_cc
* @return current limit (mA) with DTS flag set if appropriate
*/
-typec_current_t usb_get_typec_current_limit(enum pd_cc_polarity_type polarity,
+typec_current_t usb_get_typec_current_limit(enum tcpc_cc_polarity polarity,
enum tcpc_cc_voltage_status cc1, enum tcpc_cc_voltage_status cc2);
/**
@@ -70,9 +70,19 @@ typec_current_t usb_get_typec_current_limit(enum pd_cc_polarity_type polarity,
*
* @param cc1 value of CC1 set by tcpm_get_cc
* @param cc2 value of CC2 set by tcpm_get_cc
- * @return 0 if cc1 is primary, else 1 for cc2 being primary
+ * @return polarity
*/
-enum pd_cc_polarity_type get_snk_polarity(enum tcpc_cc_voltage_status cc1,
+enum tcpc_cc_polarity get_snk_polarity(enum tcpc_cc_voltage_status cc1,
+ enum tcpc_cc_voltage_status cc2);
+
+/**
+ * Returns the polarity of a Source.
+ *
+ * @param cc1 value of CC1 set by tcpm_get_cc
+ * @param cc2 value of CC2 set by tcpm_get_cc
+ * @return polarity
+ */
+enum tcpc_cc_polarity get_src_polarity(enum tcpc_cc_voltage_status cc1,
enum tcpc_cc_voltage_status cc2);
/**
diff --git a/include/usb_pd.h b/include/usb_pd.h
index c2d843863a..74cd8f27c7 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -1370,12 +1370,6 @@ enum pd_data_msg_type {
PD_DATA_VENDOR_DEF = 15,
};
-/* CC Polarity type */
-enum pd_cc_polarity_type {
- POLARITY_CC1 = 0,
- POLARITY_CC2 = 1,
-};
-
/* Protocol revision */
enum pd_rev_type {
PD_REV10,
@@ -2319,7 +2313,7 @@ void pd_transmit_complete(int port, int status);
*
* @param port USB-C port number
*/
-int pd_get_polarity(int port);
+enum tcpc_cc_polarity pd_get_polarity(int port);
/**
* Get port partner data swap capable status
diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h
index 70ef7a17cb..9d6cbec160 100644
--- a/include/usb_pd_tcpm.h
+++ b/include/usb_pd_tcpm.h
@@ -49,6 +49,12 @@ enum tcpc_rp_value {
TYPEC_RP_RESERVED = 3,
};
+enum tcpc_cc_polarity {
+ POLARITY_NONE = -1,
+ POLARITY_CC1 = 0,
+ POLARITY_CC2 = 1,
+};
+
enum tcpm_transmit_type {
TCPC_TX_SOP = 0,
TCPC_TX_SOP_PRIME = 1,
@@ -189,17 +195,17 @@ struct tcpm_drv {
* Set polarity
*
* @param port Type-C port number
- * @param polarity 0=> transmit on CC1, 1=> transmit on CC2
+ * @param polarity port polarity
*
* @return EC_SUCCESS or error
*/
- int (*set_polarity)(int port, int polarity);
+ int (*set_polarity)(int port, enum tcpc_cc_polarity polarity);
/**
* Set Vconn.
*
* @param port Type-C port number
- * @param polarity Polarity of the CC line to read
+ * @param enable Enable/Disable Vconn
*
* @return EC_SUCCESS or error
*/
diff --git a/include/usb_tc_sm.h b/include/usb_tc_sm.h
index 614269d5cd..4782dcbfe9 100644
--- a/include/usb_tc_sm.h
+++ b/include/usb_tc_sm.h
@@ -279,7 +279,7 @@ void pd_request_vconn_swap_off(int port);
* @param cc2 value of CC2 set by tcpm_get_cc
* @return 0 if cc1 is connected, else 1 for cc2
*/
-enum pd_cc_polarity_type get_snk_polarity(enum tcpc_cc_voltage_status cc1,
+enum tcpc_cc_polarity get_snk_polarity(enum tcpc_cc_voltage_status cc1,
enum tcpc_cc_voltage_status cc2);
/**