summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorudaykiran <udaykiran@google.com>2021-06-02 12:12:57 -0700
committerCommit Bot <commit-bot@chromium.org>2021-07-02 23:33:01 +0000
commit65b8e9a2a37b91c47e22151c9438b121d7b02558 (patch)
treefc489fe4af468e4d7b261a6b4425a94579e42f91
parentf281dad60e108a5d9d0b6047b4a649af67afaa09 (diff)
downloadchrome-ec-65b8e9a2a37b91c47e22151c9438b121d7b02558.tar.gz
DP Altmode DFP: Add `mfallow` command
The USB Type-C Altmode allows for protocols other than USB to be transferred over a USB connection. Chromebooks use this functionality to transfer DisplayPort on USB signals. This is achieved through USB-PD handshake through SVDMs to discover, configure, and to enter or exit Alt modes. When DisplayPort as an Alt Mode is enabled, allowable functionalities are: -- SS and high speed USB functionality and two-lane DP. -- HS USB functionality and 4-lane DP. Chromebooks honor Multifunction bit set in the DPStatus message sent by a dock. However, for development purposes we would like to have control to honor the MF bit or ignore it, there by achieving 2-lane DP vs 4-lane DP functionality. 4-lane DP functionality is required to test higher resolution monitors such as 4k60. BUG=b:181365633 BRANCH=none TEST=make BOARD, tested on G5 dock with kindred. Signed-off-by: udaykiran <udaykiran@google.com> Change-Id: Icc25f339a78d1423b094d2acf9d586721ec2df46 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2939383 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--board/bobba/board.h1
-rw-r--r--board/fennel/board.h2
-rw-r--r--board/jacuzzi/board.h2
-rw-r--r--board/kodama/board.h2
-rw-r--r--board/makomo/board.h2
-rw-r--r--board/mushu/board.h2
-rw-r--r--board/oak/board.h1
-rw-r--r--board/samus_pd/board.h1
-rw-r--r--common/usb_pd_alt_mode_dfp.c67
-rw-r--r--include/config.h4
10 files changed, 79 insertions, 5 deletions
diff --git a/board/bobba/board.h b/board/bobba/board.h
index 4cb9fc3427..032232a898 100644
--- a/board/bobba/board.h
+++ b/board/bobba/board.h
@@ -19,6 +19,7 @@
/* EC console commands */
#define CONFIG_CMD_ACCELS
#define CONFIG_CMD_ACCEL_INFO
+#undef CONFIG_CMD_MFALLOW
/* Reduce flash space usage */
#define CONFIG_DEBUG_ASSERT_BRIEF
diff --git a/board/fennel/board.h b/board/fennel/board.h
index 6f24ede6ea..71a7c91e28 100644
--- a/board/fennel/board.h
+++ b/board/fennel/board.h
@@ -12,7 +12,7 @@
#define VARIANT_KUKUI_BATTERY_SMART
#define VARIANT_KUKUI_CHARGER_ISL9238
#define VARIANT_KUKUI_EC_STM32F098
-
+#undef CONFIG_CMD_MFALLOW
#ifndef SECTION_IS_RW
#define VARIANT_KUKUI_NO_SENSORS
#endif /* SECTION_IS_RW */
diff --git a/board/jacuzzi/board.h b/board/jacuzzi/board.h
index da98822c9b..8aeb53de02 100644
--- a/board/jacuzzi/board.h
+++ b/board/jacuzzi/board.h
@@ -12,6 +12,7 @@
#define VARIANT_KUKUI_BATTERY_SMART
#define VARIANT_KUKUI_CHARGER_ISL9238
#define VARIANT_KUKUI_EC_STM32F098
+#undef CONFIG_CMD_MFALLOW
#ifndef SECTION_IS_RW
#define VARIANT_KUKUI_NO_SENSORS
@@ -67,6 +68,7 @@
#define CONFIG_ALS
#define CONFIG_CMD_ACCEL_INFO
+
#define CONFIG_LID_ANGLE
#define CONFIG_LID_ANGLE_UPDATE
#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
diff --git a/board/kodama/board.h b/board/kodama/board.h
index 0d110614b2..48e39b2300 100644
--- a/board/kodama/board.h
+++ b/board/kodama/board.h
@@ -13,6 +13,8 @@
#define VARIANT_KUKUI_EC_STM32F098
#define VARIANT_KUKUI_POGO_KEYBOARD
#define VARIANT_KUKUI_TABLET_PWRBTN
+#undef CONFIG_CMD_MFALLOW
+
#ifndef SECTION_IS_RW
#define VARIANT_KUKUI_NO_SENSORS
diff --git a/board/makomo/board.h b/board/makomo/board.h
index 1073d29e2a..7fcbf74bb8 100644
--- a/board/makomo/board.h
+++ b/board/makomo/board.h
@@ -15,6 +15,7 @@
#ifndef SECTION_IS_RW
#define VARIANT_KUKUI_NO_SENSORS
+#undef CONFIG_CMD_MFALLOW
#endif /* SECTION_IS_RW */
#include "baseboard.h"
@@ -60,6 +61,7 @@
#define CONFIG_ALS
#define CONFIG_CMD_ACCEL_INFO
+
#define CONFIG_LID_ANGLE
#define CONFIG_LID_ANGLE_UPDATE
#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
diff --git a/board/mushu/board.h b/board/mushu/board.h
index 7534190178..fe47cc0acd 100644
--- a/board/mushu/board.h
+++ b/board/mushu/board.h
@@ -17,6 +17,8 @@
#define CONFIG_LOW_POWER_IDLE
#define CONFIG_HOSTCMD_ESPI
+#undef CONFIG_CMD_MFALLOW
+
#undef CONFIG_UART_TX_BUF_SIZE
#define CONFIG_UART_TX_BUF_SIZE 4096
diff --git a/board/oak/board.h b/board/oak/board.h
index 6e33390d0b..abd3403f63 100644
--- a/board/oak/board.h
+++ b/board/oak/board.h
@@ -129,6 +129,7 @@
/* Optional features */
#define CONFIG_CMD_HOSTCMD
+#undef CONFIG_CMD_MFALLOW
/* Drivers */
/* USB Mux */
diff --git a/board/samus_pd/board.h b/board/samus_pd/board.h
index 287d4df07d..70dd92824a 100644
--- a/board/samus_pd/board.h
+++ b/board/samus_pd/board.h
@@ -17,6 +17,7 @@
/* To save space */
#undef CONFIG_SUPPRESSED_HOST_COMMANDS
+#undef CONFIG_CMD_MFALLOW
/* Optional features */
#define CONFIG_ADC
diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c
index 930f77a4b5..9f26bfedcd 100644
--- a/common/usb_pd_alt_mode_dfp.c
+++ b/common/usb_pd_alt_mode_dfp.c
@@ -46,6 +46,12 @@ int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT];
uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT];
+/* Console command multi-function preference set for a PD port. */
+
+__maybe_unused bool dp_port_mf_allow[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+ [0 ... CONFIG_USB_PD_PORT_MAX_COUNT - 1] = true};
+
+
__overridable const struct svdm_response svdm_rsp = {
.identity = NULL,
.svids = NULL,
@@ -180,6 +186,18 @@ int pd_dfp_dp_get_pin_mode(int port, uint32_t status)
pd_get_amode_data(port, TCPC_TX_SOP, USB_SID_DISPLAYPORT);
uint32_t mode_caps;
uint32_t pin_caps;
+ int mf_pref;
+
+ /*
+ * Default dp_port_mf_allow is true, we allow mf operation
+ * if UFP_D supports it.
+ */
+
+ if (IS_ENABLED(CONFIG_CMD_MFALLOW))
+ mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]) &&
+ dp_port_mf_allow[port];
+ else
+ mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]);
if (!modep)
return 0;
@@ -190,7 +208,7 @@ int pd_dfp_dp_get_pin_mode(int port, uint32_t status)
pin_caps = PD_DP_PIN_CAPS(mode_caps);
/* if don't want multi-function then ignore those pin configs */
- if (!PD_VDO_DPSTS_MF_PREF(status))
+ if (!mf_pref)
pin_caps &= ~MODE_DP_PIN_MF_MASK;
/* TODO(crosbug.com/p/39656) revisit if DFP drives USB Gen 2 signals */
@@ -1215,8 +1233,16 @@ __overridable uint8_t get_dp_pin_mode(int port)
static mux_state_t svdm_dp_get_mux_mode(int port)
{
- int mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]);
int pin_mode = get_dp_pin_mode(port);
+ /* Default dp_port_mf_allow is true */
+ int mf_pref;
+
+ if (IS_ENABLED(CONFIG_CMD_MFALLOW))
+ mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]) &&
+ dp_port_mf_allow[port];
+ else
+ mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]);
+
/*
* Multi-function operation is only allowed if that pin config is
* supported.
@@ -1230,9 +1256,16 @@ static mux_state_t svdm_dp_get_mux_mode(int port)
__overridable int svdm_dp_config(int port, uint32_t *payload)
{
int opos = pd_alt_mode(port, TCPC_TX_SOP, USB_SID_DISPLAYPORT);
- int mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]);
uint8_t pin_mode = get_dp_pin_mode(port);
mux_state_t mux_mode = svdm_dp_get_mux_mode(port);
+ /* Default dp_port_mf_allow is true */
+ int mf_pref;
+
+ if (IS_ENABLED(CONFIG_CMD_MFALLOW))
+ mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]) &&
+ dp_port_mf_allow[port];
+ else
+ mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]);
if (!pin_mode)
return 0;
@@ -1469,3 +1502,31 @@ const struct svdm_amode_fx supported_modes[] = {
#endif /* CONFIG_USB_PD_TBT_COMPAT_MODE */
};
const int supported_modes_cnt = ARRAY_SIZE(supported_modes);
+
+#ifdef CONFIG_CMD_MFALLOW
+static int command_mfallow(int argc, char **argv)
+{
+ char *e;
+ int port;
+
+ if (argc < 3)
+ return EC_ERROR_PARAM_COUNT;
+
+ port = strtoi(argv[1], &e, 10);
+ if (*e || port >= board_get_usb_pd_port_count())
+ return EC_ERROR_PARAM2;
+
+ if (!strcasecmp(argv[2], "true"))
+ dp_port_mf_allow[port] = true;
+ else if (!strcasecmp(argv[2], "false"))
+ dp_port_mf_allow[port] = false;
+ else
+ return EC_ERROR_PARAM1;
+
+ ccprintf("Port: %d multi function allowed is %s ", port, argv[2]);
+ return EC_SUCCESS;
+}
+
+DECLARE_CONSOLE_COMMAND(mfallow, command_mfallow, "port [true | false]",
+ "Controls Multifunction choice during DP Altmode.");
+#endif
diff --git a/include/config.h b/include/config.h
index 4fab158063..6405a0b06d 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1373,9 +1373,9 @@
#undef CONFIG_CMD_BATDEBUG
#define CONFIG_CMD_BATTFAKE
#undef CONFIG_CMD_BATT_MFG_ACCESS
-#define CONFIG_CMD_RETIMER
#undef CONFIG_CMD_BUTTON
#define CONFIG_CMD_CBI
+
/*
* HAS_TASK_CHIPSET implies the GSC presence.
* HAS_TASK_CONSOLE means UART console enabled.
@@ -1435,6 +1435,7 @@
#undef CONFIG_CMD_MCDP
#define CONFIG_CMD_MD
#define CONFIG_CMD_MEM
+#define CONFIG_CMD_MFALLOW
#define CONFIG_CMD_MMAPINFO
#define CONFIG_CMD_PD
#undef CONFIG_CMD_PD_DEV_DUMP_INFO
@@ -1452,6 +1453,7 @@
#undef CONFIG_CMD_RAND
#define CONFIG_CMD_REGULATOR
#undef CONFIG_CMD_RESET_FLAGS
+#define CONFIG_CMD_RETIMER
#undef CONFIG_CMD_RTC
#undef CONFIG_CMD_RTC_ALARM
#define CONFIG_CMD_RW