summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Hurst <shurst@google.com>2021-03-04 14:59:44 -0800
committerCommit Bot <commit-bot@chromium.org>2021-03-12 20:11:41 +0000
commit1dee3ef51fb66a139f2dbb98f8b923199366467d (patch)
treec037057665bb3891645d55e4e67203e661732ef3
parent1de6b4fbda2bdc60c010c8136bfc02697a3839bb (diff)
downloadchrome-ec-1dee3ef51fb66a139f2dbb98f8b923199366467d.tar.gz
TCPMV2: Add explicit setting of VPD VDO CT Current
Add the capablility to explicity set a CTVPDs VDO current. BUG=b:165934405 BRANCH=none TEST=make runtests Verified that returned VDO from chocodile_vpdmcu was correct. Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I2292024986fa89b228b56678d61d1aef2866c817 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2748427 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Sam Hurst <shurst@google.com>
-rw-r--r--board/chocodile_vpdmcu/board.h3
-rw-r--r--common/usbc/usb_pe_ctvpd_sm.c10
-rw-r--r--include/usb_pd_vdo.h11
-rw-r--r--test/test_config.h2
-rw-r--r--test/usb_typec_ctvpd.c32
5 files changed, 41 insertions, 17 deletions
diff --git a/board/chocodile_vpdmcu/board.h b/board/chocodile_vpdmcu/board.h
index 3564a50753..541dae7a44 100644
--- a/board/chocodile_vpdmcu/board.h
+++ b/board/chocodile_vpdmcu/board.h
@@ -83,6 +83,9 @@
/* USB bcdDevice */
#define USB_BCD_DEVICE 0
+/* Charge Through Current */
+#define VPD_CT_CURRENT VPD_CT_CURRENT_3A
+
/* Vbus impedance in milliohms */
#define VPD_VBUS_IMPEDANCE 65
diff --git a/common/usbc/usb_pe_ctvpd_sm.c b/common/usbc/usb_pe_ctvpd_sm.c
index fd1c83a6df..06a9137a2d 100644
--- a/common/usbc/usb_pe_ctvpd_sm.c
+++ b/common/usbc/usb_pe_ctvpd_sm.c
@@ -194,8 +194,14 @@ static void pe_request_run(const int port)
VPD_HW_VERSION,
VPD_FW_VERSION,
VPD_MAX_VBUS_20V,
- VPD_VBUS_IMP(VPD_VBUS_IMPEDANCE),
- VPD_GND_IMP(VPD_GND_IMPEDANCE),
+ IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_CT_CURRENT
+ : 0,
+ IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_VBUS_IMP(
+ VPD_VBUS_IMPEDANCE)
+ : 0,
+ IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_GND_IMP(
+ VPD_GND_IMPEDANCE)
+ : 0,
IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_CTS_SUPPORTED
: VPD_CTS_NOT_SUPPORTED);
diff --git a/include/usb_pd_vdo.h b/include/usb_pd_vdo.h
index 2cb1804a69..ac8e67b73e 100644
--- a/include/usb_pd_vdo.h
+++ b/include/usb_pd_vdo.h
@@ -526,7 +526,7 @@ union active_cable_vdo2_rev30 {
* 0b - 3A capable;
* 1b - 5A capable
* Charge Through Support bit = 0b: Reserved, Shall be set to zero
- * <14:13> : Reserved Shall be set to zero.
+ * <13> : Reserved Shall be set to zero.
* <12:7> : VBUS Impedance
* Charge Through Support bit = 1b:
* Vbus impedance through the VPD in 2 mΩ increments.
@@ -541,12 +541,18 @@ union active_cable_vdo2_rev30 {
* 1b – the VPD supports Charge Through
* 0b – the VPD does not support Charge Through
*/
-#define VDO_VPD(hw, fw, vbus, vbusz, gndz, cts) \
+#define VDO_VPD(hw, fw, vbus, ctc, vbusz, gndz, cts) \
(((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 \
| ((vbus) & 0x3) << 15 \
+ | ((ctc) & 0x1) << 14 \
| ((vbusz) & 0x3f) << 7 \
| ((gndz) & 0x3f) << 1 | (cts))
+enum vpd_ctc_support {
+ VPD_CT_CURRENT_3A,
+ VPD_CT_CURRENT_5A
+};
+
enum vpd_vbus {
VPD_MAX_VBUS_20V,
VPD_MAX_VBUS_30V,
@@ -560,6 +566,7 @@ enum vpd_cts_support {
};
#define VPD_VDO_MAX_VBUS(vdo) (((vdo) >> 15) & 0x3)
+#define VPD_VDO_CURRENT(vdo) (((vdo) >> 14) & 1)
#define VPD_VDO_VBUS_IMP(vdo) (((vdo) >> 7) & 0x3f)
#define VPD_VDO_GND_IMP(vdo) (((vdo) >> 1) & 0x3f)
#define VPD_VDO_CTS(vdo) ((vdo) & 1)
diff --git a/test/test_config.h b/test/test_config.h
index 562be47ca9..eb78fa1995 100644
--- a/test/test_config.h
+++ b/test/test_config.h
@@ -427,7 +427,7 @@ int ncp15wb_calculate_temp(uint16_t adc);
#define VPD_HW_VERSION 0x0001
#define VPD_FW_VERSION 0x0001
#define USB_BCD_DEVICE 0
-
+#define VPD_CT_CURRENT VPD_CT_CURRENT_3A
/* Vbus impedance in milliohms */
#define VPD_VBUS_IMPEDANCE 65
diff --git a/test/usb_typec_ctvpd.c b/test/usb_typec_ctvpd.c
index d46e68e40d..52c8be0639 100644
--- a/test/usb_typec_ctvpd.c
+++ b/test/usb_typec_ctvpd.c
@@ -557,14 +557,16 @@ static int test_vpd_host_src_detection_message_reception(void)
VPD_HW_VERSION,
VPD_FW_VERSION,
VPD_MAX_VBUS_20V,
- VPD_VBUS_IMP(VPD_VBUS_IMPEDANCE),
- VPD_GND_IMP(VPD_GND_IMPEDANCE),
-#ifdef CONFIG_USB_CTVPD
- VPD_CTS_SUPPORTED
-#else
- VPD_CTS_NOT_SUPPORTED
-#endif
- );
+ IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_CT_CURRENT
+ : 0,
+ IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_VBUS_IMP(
+ VPD_VBUS_IMPEDANCE)
+ : 0,
+ IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_GND_IMP(
+ VPD_GND_IMPEDANCE)
+ : 0,
+ IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_CTS_SUPPORTED
+ : VPD_CTS_NOT_SUPPORTED);
mock_set_vconn(VCONN_0);
host_disconnect_source();
@@ -1009,10 +1011,16 @@ static int test_ctvpd_behavior_case4(void)
VPD_HW_VERSION,
VPD_FW_VERSION,
VPD_MAX_VBUS_20V,
- VPD_VBUS_IMP(VPD_VBUS_IMPEDANCE),
- VPD_GND_IMP(VPD_GND_IMPEDANCE),
- VPD_CTS_SUPPORTED
- );
+ IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_CT_CURRENT
+ : 0,
+ IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_VBUS_IMP(
+ VPD_VBUS_IMPEDANCE)
+ : 0,
+ IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_GND_IMP(
+ VPD_GND_IMPEDANCE)
+ : 0,
+ IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_CTS_SUPPORTED
+ : VPD_CTS_NOT_SUPPORTED);
init_port(port);
mock_set_vconn(VCONN_0);