diff options
author | Diana Z <dzigterman@chromium.org> | 2022-09-19 14:24:46 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-09-20 23:31:38 +0000 |
commit | f259d9e4426beba5429c7b87ab78d160780ca946 (patch) | |
tree | c403a092a89233d9a34efe19ddb098f23599b25f | |
parent | 60fca7c2143af0f15eb843a6fc57185102b5a7fb (diff) | |
download | chrome-ec-f259d9e4426beba5429c7b87ab78d160780ca946.tar.gz |
Skyrim: Convert muxes to devicetree
Move the existing mux arrays into devicetree.
LOW_COVERAGE_REASON=Skyrim board tests not created yet: b/247151116
BRANCH=None
BUG=b:244457125
TEST=zmake build skyrim and variants, load onto skyrim and confirm ports
work as well as before
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I27dd8fa1882460d4d6bad88852ee93bb555ec9dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3905888
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | zephyr/projects/skyrim/i2c_common.dtsi | 11 | ||||
-rw-r--r-- | zephyr/projects/skyrim/morthal.dts | 34 | ||||
-rw-r--r-- | zephyr/projects/skyrim/skyrim.dts | 34 | ||||
-rw-r--r-- | zephyr/projects/skyrim/src/usbc_config.c | 60 | ||||
-rw-r--r-- | zephyr/projects/skyrim/src/winterhold/usbc_config.c | 60 | ||||
-rw-r--r-- | zephyr/projects/skyrim/winterhold.dts | 31 |
6 files changed, 114 insertions, 116 deletions
diff --git a/zephyr/projects/skyrim/i2c_common.dtsi b/zephyr/projects/skyrim/i2c_common.dtsi index 3d6d292d0f..8358b1c296 100644 --- a/zephyr/projects/skyrim/i2c_common.dtsi +++ b/zephyr/projects/skyrim/i2c_common.dtsi @@ -204,6 +204,17 @@ clock-frequency = <I2C_BITRATE_FAST>; pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; pinctrl-names = "default"; + + amd_fp6_port0: amd_fp6@5c { + compatible = "amd,usbc-mux-amd-fp6"; + status = "okay"; + reg = <0x5c>; + }; + amd_fp6_port1: amd_fp6@52 { + compatible = "amd,usbc-mux-amd-fp6"; + status = "okay"; + reg = <0x52>; + }; }; &i2c_ctrl3 { diff --git a/zephyr/projects/skyrim/morthal.dts b/zephyr/projects/skyrim/morthal.dts index b78478c331..b1ea8abb14 100644 --- a/zephyr/projects/skyrim/morthal.dts +++ b/zephyr/projects/skyrim/morthal.dts @@ -3,6 +3,8 @@ * found in the LICENSE file. */ +#include <dt-bindings/usbc_mux.h> + #include "i2c_common.dtsi" / { @@ -124,18 +126,50 @@ }; }; +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "baseboard_anx7483_c0_mux_set"; + }; +}; + &i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "baseboard_anx7483_c1_mux_set"; + }; ppc_port1: nx20p348x@71 { compatible = "nxp,nx20p348x"; status = "okay"; reg = <0x71>; }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; }; &usbc_port0 { ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; }; &usbc_port1 { ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; + usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + alternative-chain; + }; }; diff --git a/zephyr/projects/skyrim/skyrim.dts b/zephyr/projects/skyrim/skyrim.dts index 1de22787bb..5bc7519154 100644 --- a/zephyr/projects/skyrim/skyrim.dts +++ b/zephyr/projects/skyrim/skyrim.dts @@ -3,6 +3,8 @@ * found in the LICENSE file. */ +#include <dt-bindings/usbc_mux.h> + #include "i2c_common.dtsi" / { @@ -142,12 +144,31 @@ }; }; +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "baseboard_anx7483_c0_mux_set"; + }; +}; + &i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "baseboard_anx7483_c1_mux_set"; + }; ppc_port1: nx20p348x@71 { compatible = "nxp,nx20p348x"; status = "okay"; reg = <0x71>; }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; }; &i2c4_1 { @@ -161,8 +182,21 @@ &usbc_port0 { chg_alt = <&alt_charger>; ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; }; &usbc_port1 { ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; + usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + alternative-chain; + }; }; diff --git a/zephyr/projects/skyrim/src/usbc_config.c b/zephyr/projects/skyrim/src/usbc_config.c index b92865af6e..0012bb9130 100644 --- a/zephyr/projects/skyrim/src/usbc_config.c +++ b/zephyr/projects/skyrim/src/usbc_config.c @@ -31,6 +31,7 @@ #include "usb_mux.h" #include "usb_pd_tcpm.h" #include "usbc_ppc.h" +#include "usbc/usb_muxes.h" #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) @@ -175,17 +176,6 @@ int baseboard_anx7483_c1_mux_set(const struct usb_mux *me, return EC_SUCCESS; } -struct usb_mux_chain usbc0_anx7483 = { - .mux = - &(const struct usb_mux){ - .usb_port = USBC_PORT_C0, - .i2c_port = I2C_PORT_TCPC0, - .i2c_addr_flags = ANX7483_I2C_ADDR0_FLAGS, - .driver = &anx7483_usb_retimer_driver, - .board_set = &baseboard_anx7483_c0_mux_set, - }, -}; - __overridable int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) { @@ -200,51 +190,6 @@ __overridable int board_c1_ps8818_mux_set(const struct usb_mux *me, return 0; } -struct usb_mux_chain usbc1_ps8818 = { - .mux = - &(const struct usb_mux){ - .usb_port = USBC_PORT_C1, - .i2c_port = I2C_PORT_TCPC1, - .flags = USB_MUX_FLAG_RESETS_IN_G3, - .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS, - .driver = &ps8818_usb_retimer_driver, - .board_set = &board_c1_ps8818_mux_set, - }, -}; - -struct usb_mux_chain usbc1_anx7483 = { - .mux = - &(const struct usb_mux){ - .usb_port = USBC_PORT_C1, - .i2c_port = I2C_PORT_TCPC1, - .i2c_addr_flags = ANX7483_I2C_ADDR0_FLAGS, - .driver = &anx7483_usb_retimer_driver, - .board_set = &baseboard_anx7483_c1_mux_set, - }, -}; - -struct usb_mux_chain usb_muxes[] = { - [USBC_PORT_C0] = { - .mux = &(const struct usb_mux) { - .usb_port = USBC_PORT_C0, - .i2c_port = I2C_PORT_USB_MUX, - .i2c_addr_flags = AMD_FP6_C0_MUX_I2C_ADDR, - .driver = &amd_fp6_usb_mux_driver, - }, - .next = &usbc0_anx7483, - }, - [USBC_PORT_C1] = { - .mux = &(const struct usb_mux) { - .usb_port = USBC_PORT_C1, - .i2c_port = I2C_PORT_USB_MUX, - .i2c_addr_flags = AMD_FP6_C4_MUX_I2C_ADDR, - .driver = &amd_fp6_usb_mux_driver, - }, - /* .next = filled in by setup_mux based on fw_config */ - } -}; -BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == CONFIG_USB_PD_PORT_MAX_COUNT); - static void setup_mux(void) { uint32_t val; @@ -255,10 +200,9 @@ static void setup_mux(void) if (val == FW_IO_DB_PS8811_PS8818) { CPRINTSUSB("C1: Setting PS8818 mux"); - usb_muxes[USBC_PORT_C1].next = &usbc1_ps8818; + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); } else if (val == FW_IO_DB_NONE_ANX7483) { CPRINTSUSB("C1: Setting ANX7483 mux"); - usb_muxes[USBC_PORT_C1].next = &usbc1_anx7483; } else { CPRINTSUSB("Unexpected DB_IO board: %d", val); } diff --git a/zephyr/projects/skyrim/src/winterhold/usbc_config.c b/zephyr/projects/skyrim/src/winterhold/usbc_config.c index afc527adf9..b44d6acf1b 100644 --- a/zephyr/projects/skyrim/src/winterhold/usbc_config.c +++ b/zephyr/projects/skyrim/src/winterhold/usbc_config.c @@ -30,6 +30,7 @@ #include "usb_mux.h" #include "usb_pd_tcpm.h" #include "usbc_ppc.h" +#include "usbc/usb_muxes.h" #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) @@ -174,17 +175,6 @@ int baseboard_anx7483_c1_mux_set(const struct usb_mux *me, return EC_SUCCESS; } -struct usb_mux_chain usbc0_anx7483 = { - .mux = - &(const struct usb_mux){ - .usb_port = USBC_PORT_C0, - .i2c_port = I2C_PORT_TCPC0, - .i2c_addr_flags = ANX7483_I2C_ADDR0_FLAGS, - .driver = &anx7483_usb_retimer_driver, - .board_set = &baseboard_anx7483_c0_mux_set, - }, -}; - __overridable int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) { @@ -199,51 +189,6 @@ __overridable int board_c1_ps8818_mux_set(const struct usb_mux *me, return 0; } -struct usb_mux_chain usbc1_ps8818 = { - .mux = - &(const struct usb_mux){ - .usb_port = USBC_PORT_C1, - .i2c_port = I2C_PORT_TCPC1, - .flags = USB_MUX_FLAG_RESETS_IN_G3, - .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS, - .driver = &ps8818_usb_retimer_driver, - .board_set = &board_c1_ps8818_mux_set, - }, -}; - -struct usb_mux_chain usbc1_anx7483 = { - .mux = - &(const struct usb_mux){ - .usb_port = USBC_PORT_C1, - .i2c_port = I2C_PORT_TCPC1, - .i2c_addr_flags = ANX7483_I2C_ADDR0_FLAGS, - .driver = &anx7483_usb_retimer_driver, - .board_set = &baseboard_anx7483_c1_mux_set, - }, -}; - -struct usb_mux_chain usb_muxes[] = { - [USBC_PORT_C0] = { - .mux = &(const struct usb_mux) { - .usb_port = USBC_PORT_C0, - .i2c_port = I2C_PORT_USB_MUX, - .i2c_addr_flags = AMD_FP6_C0_MUX_I2C_ADDR, - .driver = &amd_fp6_usb_mux_driver, - }, - .next = &usbc0_anx7483, - }, - [USBC_PORT_C1] = { - .mux = &(const struct usb_mux) { - .usb_port = USBC_PORT_C1, - .i2c_port = I2C_PORT_USB_MUX, - .i2c_addr_flags = AMD_FP6_C4_MUX_I2C_ADDR, - .driver = &amd_fp6_usb_mux_driver, - }, - /* .next = filled in by setup_mux based on fw_config */ - } -}; -BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == CONFIG_USB_PD_PORT_MAX_COUNT); - static void setup_mux(void) { uint32_t val; @@ -254,10 +199,9 @@ static void setup_mux(void) if (val == FW_IO_DB_PS8811_PS8818) { CPRINTSUSB("C1: Setting PS8818 mux"); - usb_muxes[USBC_PORT_C1].next = &usbc1_ps8818; + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); } else if (val == FW_IO_DB_NONE_ANX7483) { CPRINTSUSB("C1: Setting ANX7483 mux"); - usb_muxes[USBC_PORT_C1].next = &usbc1_anx7483; } else { CPRINTSUSB("Unexpected DB_IO board: %d", val); } diff --git a/zephyr/projects/skyrim/winterhold.dts b/zephyr/projects/skyrim/winterhold.dts index 82bde53b54..16cc421d68 100644 --- a/zephyr/projects/skyrim/winterhold.dts +++ b/zephyr/projects/skyrim/winterhold.dts @@ -3,6 +3,8 @@ * found in the LICENSE file. */ +#include <dt-bindings/usbc_mux.h> + #include "i2c_common.dtsi" / { @@ -114,6 +116,11 @@ }; &i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "baseboard_anx7483_c0_mux_set"; + }; ppc_port0: nx20p348x@71 { compatible = "nxp,nx20p348x"; status = "okay"; @@ -122,17 +129,41 @@ }; &i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "baseboard_anx7483_c1_mux_set"; + }; ppc_port1: nx20p348x@71 { compatible = "nxp,nx20p348x"; status = "okay"; reg = <0x71>; }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; }; &usbc_port0 { ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; }; &usbc_port1 { ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; + usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + alternative-chain; + }; }; |