summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Michalec <tm@semihalf.com>2022-09-05 19:03:37 +0200
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-13 11:19:22 +0000
commit7ada57a3e1836ee8c81e0a829ce8f78a6c2f36fa (patch)
tree0d17ee60dfc4939b18d2d2322e85fe2711acb7b8
parentd3dd9d4696df8dc28eb4198715cde7dd21f96607 (diff)
downloadchrome-ec-7ada57a3e1836ee8c81e0a829ce8f78a6c2f36fa.tar.gz
zephyr: shim: Move BB retimer controls to separate file
Move bb_controls[] array generation to separate file. BUG=None TEST=zmake build -a BRANCH=None Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: Id875840806593d75c4eebde273b1dff583281d10 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3875323 Commit-Queue: Tomasz Michalec <tmichalec@google.com> Tested-by: Tomasz Michalec <tmichalec@google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/shim/src/CMakeLists.txt4
-rw-r--r--zephyr/shim/src/bb_retimer_usb_mux.c39
-rw-r--r--zephyr/shim/src/usb_muxes.c27
3 files changed, 43 insertions, 27 deletions
diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt
index 70c4779433..636f8ba5c9 100644
--- a/zephyr/shim/src/CMakeLists.txt
+++ b/zephyr/shim/src/CMakeLists.txt
@@ -73,3 +73,7 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBA usba.c)
zephyr_library_sources_ifdef(CONFIG_AP_PWRSEQ power_host_sleep_api.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_MUX usb_muxes.c)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB
+ bb_retimer_usb_mux.c)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_HB
+ bb_retimer_usb_mux.c)
diff --git a/zephyr/shim/src/bb_retimer_usb_mux.c b/zephyr/shim/src/bb_retimer_usb_mux.c
new file mode 100644
index 0000000000..c40068211e
--- /dev/null
+++ b/zephyr/shim/src/bb_retimer_usb_mux.c
@@ -0,0 +1,39 @@
+/* Copyright 2022 The ChromiumOS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <zephyr/devicetree.h>
+#include <zephyr/sys/util_macro.h>
+#include "usb_mux.h"
+#include "usbc/usb_muxes.h"
+
+/**
+ * This prevents creating struct usb_mux bb_controls[] for platforms that didn't
+ * migrate USB mux configuration to DTS yet.
+ */
+#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain)
+
+BB_RETIMER_CHECK_SAME_CONTROLS(BB_RETIMER_INSTANCES_LIST)
+
+/**
+ * @brief bb_controls array should be constant only if configuration cannot
+ * change in runtime
+ */
+#define BB_CONTROLS_CONST \
+ COND_CODE_1(CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG, \
+ (), (const))
+
+/**
+ * Define bb_controls for BB retimers in USB muxes chain e.g.
+ * [0] = {
+ * .retimer_rst_gpio = IOEX_USB_C0_BB_RETIMER_RST,
+ * .usb_ls_en_gpio = IOEX_USB_C0_BB_RETIMER_LS_EN,
+ * },
+ * [1] = { ... },
+ */
+BB_CONTROLS_CONST struct bb_usb_control bb_controls[] = {
+ USB_MUX_BB_RETIMERS_CONTROLS_ARRAY
+};
+
+#endif /* #if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain) */
diff --git a/zephyr/shim/src/usb_muxes.c b/zephyr/shim/src/usb_muxes.c
index 71dc66f76a..3f81e97787 100644
--- a/zephyr/shim/src/usb_muxes.c
+++ b/zephyr/shim/src/usb_muxes.c
@@ -96,31 +96,4 @@ BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == CONFIG_USB_PD_PORT_MAX_COUNT);
*/
USB_MUX_FOREACH_MUX(USB_MUX_DEFINE)
-/* Create bb_controls only if BB or HB retimer driver is enabled */
-#if defined(CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB) || \
- defined(CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_HB)
-
-BB_RETIMER_CHECK_SAME_CONTROLS(BB_RETIMER_INSTANCES_LIST)
-
-/**
- * @brief bb_controls array should be constant only if configuration cannot
- * change in runtime
- */
-#define BB_CONTROLS_CONST \
- COND_CODE_1(CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG, \
- (), (const))
-
-/**
- * Define bb_controls for BB retimers in USB muxes chain e.g.
- * [0] = {
- * .retimer_rst_gpio = IOEX_USB_C0_BB_RETIMER_RST,
- * .usb_ls_en_gpio = IOEX_USB_C0_BB_RETIMER_LS_EN,
- * },
- * [1] = { ... },
- */
-BB_CONTROLS_CONST struct bb_usb_control bb_controls[] = {
- USB_MUX_BB_RETIMERS_CONTROLS_ARRAY
-};
-#endif /* CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB/HB */
-
#endif /* #if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain) */