summaryrefslogtreecommitdiff
path: root/zephyr/shim/include/usbc
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/shim/include/usbc')
-rw-r--r--zephyr/shim/include/usbc/bb_retimer_usb_mux.h32
-rw-r--r--zephyr/shim/include/usbc/usb_muxes.h32
2 files changed, 62 insertions, 2 deletions
diff --git a/zephyr/shim/include/usbc/bb_retimer_usb_mux.h b/zephyr/shim/include/usbc/bb_retimer_usb_mux.h
new file mode 100644
index 0000000000..611c52e081
--- /dev/null
+++ b/zephyr/shim/include/usbc/bb_retimer_usb_mux.h
@@ -0,0 +1,32 @@
+/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __ZEPHYR_SHIM_BB_RETIMER_USB_MUX_H
+#define __ZEPHYR_SHIM_BB_RETIMER_USB_MUX_H
+
+#include "driver/retimer/bb_retimer_public.h"
+
+#define BB_RETIMER_USB_MUX_COMPAT intel_jhl8040r
+
+#define USB_MUX_CONFIG_BB_RETIMER(mux_id, port_id, idx) \
+ { \
+ USB_MUX_COMMON_FIELDS(mux_id, port_id, idx), \
+ .driver = &bb_usb_retimer, \
+ .hpd_update = bb_retimer_hpd_update, \
+ .i2c_port = I2C_PORT(DT_PHANDLE(mux_id, port)), \
+ .i2c_addr_flags = DT_PROP(mux_id, i2c_addr_flags), \
+ }
+
+#define BB_RETIMER_CONTROLS_CONFIG(mux_id, port_id, idx) \
+ { \
+ .retimer_rst_gpio = \
+ GPIO_SIGNAL(DT_PHANDLE(mux_id, reset_pin)), \
+ .usb_ls_en_gpio = COND_CODE_1( \
+ DT_NODE_HAS_PROP(mux_id, ls_en_pin), \
+ (GPIO_SIGNAL(DT_PHANDLE(mux_id, ls_en_pin))), \
+ (GPIO_UNIMPLEMENTED)), \
+ }
+
+#endif /* __ZEPHYR_SHIM_BB_RETIMER_USB_MUX_H */
diff --git a/zephyr/shim/include/usbc/usb_muxes.h b/zephyr/shim/include/usbc/usb_muxes.h
index e56e538a74..9422d4008d 100644
--- a/zephyr/shim/include/usbc/usb_muxes.h
+++ b/zephyr/shim/include/usbc/usb_muxes.h
@@ -10,6 +10,7 @@
#include <zephyr/sys/util_macro.h>
#include "usb_mux.h"
#include "usbc/anx7483_usb_mux.h"
+#include "usbc/bb_retimer_usb_mux.h"
#include "usbc/it5205_usb_mux.h"
#include "usbc/tcpci_usb_mux.h"
#include "usbc/tusb1064_usb_mux.h"
@@ -21,6 +22,7 @@
*/
#define USB_MUX_DRIVERS \
(ANX7483_USB_MUX_COMPAT, USB_MUX_CONFIG_ANX7483), \
+ (BB_RETIMER_USB_MUX_COMPAT, USB_MUX_CONFIG_BB_RETIMER), \
(IT5205_USB_MUX_COMPAT, USB_MUX_CONFIG_IT5205), \
(PS8XXX_USB_MUX_COMPAT, USB_MUX_CONFIG_TCPCI_TCPM), \
(TCPCI_TCPM_USB_MUX_COMPAT, USB_MUX_CONFIG_TCPCI_TCPM), \
@@ -196,8 +198,7 @@
* @param op Operation to perform on USB muxes
*/
#define USB_MUX_DO(port_id, idx, op) \
- USB_MUX_CALL_OP(DT_PHANDLE_BY_IDX(port_id, usb_muxes, idx), \
- port_id, idx, op)
+ USB_MUX_CALL_OP(USB_MUX_GET_CHAIN_N(idx, port_id), port_id, idx, op)
/**
* @brief Declare USB mux structure
@@ -267,6 +268,33 @@
USB_MUX_DO_SKIP_FIRST, op)
/**
+ * @brief Call @p op if @p idx mux in chain has BB retimer compatible
+ *
+ * @param port_id USBC node ID
+ * @param unused2 This argument is expected by DT_FOREACH_PROP_ELEM_VARGS
+ * @param idx Position of USB mux in chain
+ * @param op Operation to perform on BB retimer
+ */
+#define USB_MUX_ONLY_BB_RETIMER(port_id, unused2, idx, op) \
+ COND_CODE_1(USB_MUX_IS_COMPATIBLE( \
+ USB_MUX_GET_CHAIN_N(idx, port_id), \
+ BB_RETIMER_USB_MUX_COMPAT), \
+ (op(USB_MUX_GET_CHAIN_N(idx, port_id), port_id, \
+ idx, BB_RETIMER_CONTROLS_CONFIG)), ())
+
+/**
+ * @brief Call @p op with every BB retimer in chain
+ *
+ * @param port_id USBC node ID
+ * @param op Operation to perform on BB retimers. Needs to accept USB mux node
+ * ID, USBC port node ID, position in chain, and driver config as
+ * arguments.
+ */
+#define USB_MUX_BB_RETIMERS(port_id, op) \
+ DT_FOREACH_PROP_ELEM_VARGS(port_id, usb_muxes, \
+ USB_MUX_ONLY_BB_RETIMER, op)
+
+/**
* @brief If @p port_id has usb_muxes property, call @p op with every mux in
* chain that passes @p filter
*