summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-01-07 16:15:11 -0700
committerCommit Bot <commit-bot@chromium.org>2021-01-11 21:23:42 +0000
commit986c00a9c68821c7b6b2ba1935760b87c8382858 (patch)
treed9ced3a7605fb06e71fff8f7dd5201a0d604f28b
parent9f3698bc92091ca9f86b7a7779643b0e10036666 (diff)
downloadchrome-ec-986c00a9c68821c7b6b2ba1935760b87c8382858.tar.gz
zephyr: Allow building Intel Burnside Bridge
Add support for bringing this driver into Zephyr. BUG=b:175434113 BRANCH=none TEST=make BOARD=volteer -j30 With a zephyr-chrome CL, build volteer on zephyr Signed-off-by: Simon Glass <sjg@chromium.org> Cq-Depend: chromium:2618537 Change-Id: I9f0432e33a0efb35ccf66a5befe2e5e0fdc789a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2617041
-rw-r--r--board/volteer/usbc_config.c2
-rw-r--r--zephyr/CMakeLists.txt8
-rw-r--r--zephyr/Kconfig.usbc56
-rw-r--r--zephyr/shim/include/config_chip.h23
-rw-r--r--zephyr/shim/src/util.c7
5 files changed, 94 insertions, 2 deletions
diff --git a/board/volteer/usbc_config.c b/board/volteer/usbc_config.c
index fa39544c49..3e2aa2ef26 100644
--- a/board/volteer/usbc_config.c
+++ b/board/volteer/usbc_config.c
@@ -194,7 +194,6 @@ struct tcpc_config_t tcpc_config[] = {
BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == USBC_PORT_COUNT);
BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT);
-#ifndef CONFIG_ZEPHYR /* Requires a few more CLs to build */
/******************************************************************************/
/* USBC mux configuration - Tiger Lake includes internal mux */
struct usb_mux usbc1_tcss_usb_mux = {
@@ -229,7 +228,6 @@ struct bb_usb_control bb_controls[] = {
},
};
BUILD_ASSERT(ARRAY_SIZE(bb_controls) == USBC_PORT_COUNT);
-#endif /* CONFIG_ZEPHYR */
/******************************************************************************/
/* BC1.2 charger detect configuration */
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
index 258baf4206..5d48a59610 100644
--- a/zephyr/CMakeLists.txt
+++ b/zephyr/CMakeLists.txt
@@ -102,6 +102,14 @@ zephyr_sources_ifdef(CONFIG_PLATFORM_EC_USB_CHARGER
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_USB_POWER_DELIVERY
"${PLATFORM_EC}/common/usb_common.c"
"${PLATFORM_EC}/common/usbc/usb_sm.c")
+
+zephyr_sources_ifdef(CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB
+ "${PLATFORM_EC}/driver/retimer/bb_retimer.c")
+zephyr_sources_ifdef(CONFIG_PLATFORM_EC_USBC_SS_MUX
+ "${PLATFORM_EC}/driver/usb_mux/usb_mux.c")
+zephyr_sources_ifdef(CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL
+ "${PLATFORM_EC}/driver/usb_mux/virtual.c")
+
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_USBC_OCP
"${PLATFORM_EC}/common/usbc_ocp.c")
diff --git a/zephyr/Kconfig.usbc b/zephyr/Kconfig.usbc
index 1aa8d7e53d..eed862def4 100644
--- a/zephyr/Kconfig.usbc
+++ b/zephyr/Kconfig.usbc
@@ -64,6 +64,44 @@ config PLATFORM_EC_USB_PID
To reserve a new PID within Google, use go/usb and see
http://google3/hardware/standards/usb
+config PLATFORM_EC_USBC_RETIMER_INTEL_BB
+ bool "Support Intel Burnside Bridge retimer"
+ help
+ Enable this to support the Intel Burnside Bridge Thunderbolt / USB /
+ DisplayPort retimer. This is present on some Intel SoCs.
+
+ Intel Burnside Bridge is a Type-C multi-protocol retimer to be used
+ in on-board applications. Burnside Bridge offers the ability to latch
+ protocol signals into on-chip memory before retransmitting them
+ onwards. It can be used to extend the physical length of the system
+ without increasing high-frequency jitter.
+
+ Burnside Bridge supports spec compliant retimer of following
+ protocols:
+
+ - Display Port: four unidirectional DP lanes
+ - USB3.1 Gen1/2: one bi-directional USB lane
+ - Thunderbolt: two bi-directional CIO lanes
+ - Multifunction Display (MFD): two unidirectional lanes of DP and
+ one bidirectional lane of USB3.1 Gen1/2
+
+config PLATFORM_EC_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG
+ bool "Use runtime configuration of Intel Burnside Bridge"
+ depends on PLATFORM_EC_USBC_RETIMER_INTEL_BB
+ default y
+ help
+ Enable this to allow run-time configuration of the Burnside Bridge
+ driver structure. This makes the bb_controls[] array writable, i.e.
+ not const. It should be declared as such in the board config.
+
+ This is useful when the board has runtime information that changes
+ the configuration, such as Chromium OS Board Info (CBI set in the
+ factory. Without this, multiple EC images would need to be installed
+ depending on the board.
+
+ This is also an entry in the competition for the lonest Kconfig
+ option. The abreviation BB is clearly a missed opportunity.
+
menuconfig PLATFORM_EC_USB_POWER_DELIVERY
bool "USB Type-C Power Delivery (PD)"
default y
@@ -401,6 +439,24 @@ config PLATFORM_EC_USB_MUX_RUNTIME_CONFIG
factory. Without this, multiple EC images would need to be installed
depending on the board.
+config PLATFORM_EC_USBC_SS_MUX
+ bool "SuperSpeed mux"
+ default y
+ help
+ Enable this to support the USB Type-C SuperSpeed Mux. If enabled,
+ the USB stack will call usb_mux_set() to change the mux settings.
+ The board must provide a driver in usb_muxes[] for each port so
+ that this can work.
+
+config PLATFORM_EC_USB_MUX_VIRTUAL
+ bool "USB Mux is virtual"
+ depends on PLATFORM_EC_USBC_SS_MUX
+ help
+ Enable this if a virtual USB mux is supported on the EC, which is
+ actually handled by the AP. In this case the AP gets an interrupt
+ and is is informed when status changes, via the
+ EC_CMD_USB_PD_MUX_INFO host command.
+
endif # PLATFORM_EC_USB_MUX
config PLATFORM_EC_CONSOLE_CMD_PPC_DUMP
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 591e592397..e735ebfb55 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -432,4 +432,27 @@ enum battery_type {
#define CONFIG_USB_PD_ALT_MODE_DFP
#endif
+#undef CONFIG_USBC_RETIMER_INTEL_BB
+#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB
+
+/* TODO(b/176505554): Consider using devicetree */
+#define USBC_PORT_C1_BB_RETIMER_I2C_ADDR 0x40
+#define CONFIG_USBC_RETIMER_INTEL_BB
+#endif
+
+#undef CONFIG_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG
+#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG
+#define CONFIG_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG
+#endif
+
+#undef CONFIG_USBC_SS_MUX
+#ifdef CONFIG_PLATFORM_EC_USBC_SS_MUX
+#define CONFIG_USBC_SS_MUX
+#endif
+
+#undef CONFIG_USB_MUX_VIRTUAL
+#ifdef CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL
+#define CONFIG_USB_MUX_VIRTUAL
+#endif
+
#endif /* __CROS_EC_CONFIG_CHIP_H */
diff --git a/zephyr/shim/src/util.c b/zephyr/shim/src/util.c
index 5a7131b23a..805c3dc18c 100644
--- a/zephyr/shim/src/util.c
+++ b/zephyr/shim/src/util.c
@@ -205,3 +205,10 @@ int uint64divmod(uint64_t *n, int d)
*n = q;
return r;
}
+
+int get_next_bit(uint32_t *mask)
+{
+ int bit = 31 - __builtin_clz(*mask);
+ *mask &= ~BIT(bit);
+ return bit;
+}