diff options
Diffstat (limited to 'zephyr/shim/include')
-rw-r--r-- | zephyr/shim/include/config_chip.h | 8 | ||||
-rw-r--r-- | zephyr/shim/include/usbc/bb_retimer_usb_mux.h | 32 | ||||
-rw-r--r-- | zephyr/shim/include/usbc/usb_muxes.h | 32 |
3 files changed, 66 insertions, 6 deletions
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 079d8ed3e2..509f1a3749 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -1589,13 +1589,13 @@ extern struct jump_data mock_jump_data; #ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB #define USBC_PORT_C0_BB_RETIMER_I2C_ADDR \ - DT_REG_ADDR(DT_NODELABEL(usb_c0_bb_retimer)) + DT_PROP(DT_NODELABEL(usb_c0_bb_retimer), i2c_addr_flags) #define USBC_PORT_C1_BB_RETIMER_I2C_ADDR \ - DT_REG_ADDR(DT_NODELABEL(usb_c1_bb_retimer)) + DT_PROP(DT_NODELABEL(usb_c1_bb_retimer), i2c_addr_flags) #define USBC_PORT_C2_BB_RETIMER_I2C_ADDR \ - DT_REG_ADDR(DT_NODELABEL(usb_c2_bb_retimer)) + DT_PROP(DT_NODELABEL(usb_c2_bb_retimer), i2c_addr_flags) #define USBC_PORT_C3_BB_RETIMER_I2C_ADDR \ - DT_REG_ADDR(DT_NODELABEL(usb_c3_bb_retimer)) + DT_PROP(DT_NODELABEL(usb_c3_bb_retimer), i2c_addr_flags) #define CONFIG_USBC_RETIMER_INTEL_BB #endif 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 * |