diff options
author | Eric Yilun Lin <yllin@chromium.org> | 2022-06-27 14:53:35 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-18 03:58:47 +0000 |
commit | 830b6f897fd70f8d9c845723737c7027bbc13591 (patch) | |
tree | 92a700c64d38429fabeaea3c57c82ea40c88b157 | |
parent | 546fc64f509d55b2608b10f808562e913eaf2ffd (diff) | |
download | chrome-ec-830b6f897fd70f8d9c845723737c7027bbc13591.tar.gz |
anx7447: add device binding for TCPC and USB_MUX
add anx7447 dt-bindings for TCPC and USBC MUX.
BUG=b:227359727
TEST=enable on kingler, and TCPC/USBC works
BRANCH=none
Change-Id: Ib248d8b4bd0eee447193be0de28605da9aa8b1c9
Signed-off-by: Eric Yilun Lin <yllin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3725850
Reviewed-by: Keith Short <keithshort@chromium.org>
Commit-Queue: Eric Yilun Lin <yllin@google.com>
Tested-by: Eric Yilun Lin <yllin@google.com>
Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r-- | zephyr/dts/bindings/usbc/anologix,anx7447-tcpc.yaml | 27 | ||||
-rw-r--r-- | zephyr/dts/bindings/usbc/mux/analogix,usbc-mux-anx7447.yaml | 15 | ||||
-rw-r--r-- | zephyr/shim/include/usbc/tcpc_anx7447.h | 21 | ||||
-rw-r--r-- | zephyr/shim/include/usbc/tcpci_usb_mux.h | 2 | ||||
-rw-r--r-- | zephyr/shim/include/usbc/usb_muxes.h | 3 | ||||
-rw-r--r-- | zephyr/shim/src/tcpc.c | 6 |
6 files changed, 72 insertions, 2 deletions
diff --git a/zephyr/dts/bindings/usbc/anologix,anx7447-tcpc.yaml b/zephyr/dts/bindings/usbc/anologix,anx7447-tcpc.yaml new file mode 100644 index 0000000000..48543c808d --- /dev/null +++ b/zephyr/dts/bindings/usbc/anologix,anx7447-tcpc.yaml @@ -0,0 +1,27 @@ +description: Anologix ANX7447 USBC TCPC binding + +compatible: "anologix,anx7447-tcpc" + +properties: + port: + type: phandle + required: true + description: | + I2C port used to communicate with controller + + i2c-addr-flags: + type: string + default: "AN7447_TCPC0_I2C_ADDR_FLAGS" + enum: + - "AN7447_TCPC0_I2C_ADDR_FLAGS" + - "AN7447_TCPC1_I2C_ADDR_FLAGS" + - "AN7447_TCPC2_I2C_ADDR_FLAGS" + - "AN7447_TCPC3_I2C_ADDR_FLAGS" + description: | + I2C address of controller + + tcpc-flags: + type: int + default: 0 + description: | + TCPC configuration flags diff --git a/zephyr/dts/bindings/usbc/mux/analogix,usbc-mux-anx7447.yaml b/zephyr/dts/bindings/usbc/mux/analogix,usbc-mux-anx7447.yaml new file mode 100644 index 0000000000..17ad0fcb04 --- /dev/null +++ b/zephyr/dts/bindings/usbc/mux/analogix,usbc-mux-anx7447.yaml @@ -0,0 +1,15 @@ +# 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. + +description: USBC ANX7447 USB MUX + +include: cros-ec,usbc-mux-tcpci.yaml + +compatible: "analogix,usbc-mux-anx7447" + +properties: + hpd-update: + required: false + enum: + - anx7447_tcpc_update_hpd_status diff --git a/zephyr/shim/include/usbc/tcpc_anx7447.h b/zephyr/shim/include/usbc/tcpc_anx7447.h new file mode 100644 index 0000000000..7f5c0891f9 --- /dev/null +++ b/zephyr/shim/include/usbc/tcpc_anx7447.h @@ -0,0 +1,21 @@ +/* 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 "tcpm/anx7447_public.h" + +#define ANX7447_TCPC_COMPAT anologix_anx7447_tcpc + +#define TCPC_CONFIG_ANX7447(id) \ + { \ + .bus_type = EC_BUS_TYPE_I2C, \ + .i2c_info = { \ + .port = I2C_PORT(DT_PHANDLE(id, port)), \ + .addr_flags = DT_STRING_UPPER_TOKEN( \ + id, i2c_addr_flags), \ + }, \ + .drv = &anx7447_tcpm_drv, \ + .flags = DT_PROP(id, tcpc_flags), \ + }, diff --git a/zephyr/shim/include/usbc/tcpci_usb_mux.h b/zephyr/shim/include/usbc/tcpci_usb_mux.h index 74a2fe8ffc..1f98bafc23 100644 --- a/zephyr/shim/include/usbc/tcpci_usb_mux.h +++ b/zephyr/shim/include/usbc/tcpci_usb_mux.h @@ -7,9 +7,11 @@ #define __ZEPHYR_SHIM_TCPCI_USB_MUX_H #include "dt-bindings/usbc_mux.h" +#include "tcpm/anx7447_public.h" #include "tcpm/ps8xxx_public.h" #include "tcpm/tcpci.h" +#define ANX7447_USB_MUX_COMPAT analogix_usbc_mux_anx7447 #define TCPCI_TCPM_USB_MUX_COMPAT cros_ec_usbc_mux_tcpci #define PS8XXX_USB_MUX_COMPAT parade_usbc_mux_ps8xxx diff --git a/zephyr/shim/include/usbc/usb_muxes.h b/zephyr/shim/include/usbc/usb_muxes.h index 250b3dd329..61422a743b 100644 --- a/zephyr/shim/include/usbc/usb_muxes.h +++ b/zephyr/shim/include/usbc/usb_muxes.h @@ -22,7 +22,8 @@ * element of list has to have (compatible, config) format. */ #define USB_MUX_DRIVERS \ - (ANX7483_USB_MUX_COMPAT, USB_MUX_CONFIG_ANX7483), \ + (ANX7447_USB_MUX_COMPAT, USB_MUX_CONFIG_TCPCI_TCPM), \ + (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), \ (PS8743_USB_MUX_COMPAT, USB_MUX_CONFIG_PS8743), \ diff --git a/zephyr/shim/src/tcpc.c b/zephyr/shim/src/tcpc.c index 02cecdd70f..98237044b7 100644 --- a/zephyr/shim/src/tcpc.c +++ b/zephyr/shim/src/tcpc.c @@ -7,6 +7,7 @@ #include <zephyr/sys/util.h> #include "usb_pd_tcpm.h" #include "usb_pd.h" +#include "usbc/tcpc_anx7447.h" #include "usbc/tcpc_ccgxxf.h" #include "usbc/tcpc_fusb302.h" #include "usbc/tcpc_it8xxx2.h" @@ -16,7 +17,8 @@ #include "usbc/tcpci.h" #include "usbc/utils.h" -#if DT_HAS_COMPAT_STATUS_OKAY(CCGXXF_TCPC_COMPAT) || \ +#if DT_HAS_COMPAT_STATUS_OKAY(ANX7447_TCPC_COMPAT) || \ + DT_HAS_COMPAT_STATUS_OKAY(CCGXXF_TCPC_COMPAT) || \ DT_HAS_COMPAT_STATUS_OKAY(FUSB302_TCPC_COMPAT) || \ DT_HAS_COMPAT_STATUS_OKAY(IT8XXX2_TCPC_COMPAT) || \ DT_HAS_COMPAT_STATUS_OKAY(PS8XXX_COMPAT) || \ @@ -32,6 +34,8 @@ /* Enable clang-format when the formatted code is readable. */ /* clang-format off */ MAYBE_CONST struct tcpc_config_t tcpc_config[] = { + DT_FOREACH_STATUS_OKAY_VARGS(ANX7447_TCPC_COMPAT, TCPC_CONFIG, + TCPC_CONFIG_ANX7447) DT_FOREACH_STATUS_OKAY_VARGS(CCGXXF_TCPC_COMPAT, TCPC_CONFIG, TCPC_CONFIG_CCGXXF) DT_FOREACH_STATUS_OKAY_VARGS(FUSB302_TCPC_COMPAT, TCPC_CONFIG, |