summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDawid Niedzwiecki <dn@semihalf.com>2022-07-27 12:54:18 +0200
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-05 16:15:24 +0000
commit9a86e5939514697873a56635447bf29787963f71 (patch)
tree2980c5cd84471c3a81747ffc3afd6de991672d67
parentd407150b509ec87aec2b066bce95582a3180c9db (diff)
downloadchrome-ec-9a86e5939514697873a56635447bf29787963f71.tar.gz
zephyr: move tcpc nodes onto i2c buses
Move all tcpc nodes onto the i2c buses from named-usbc-port nodes. The change should simplify the upstream process of the tcpc chips drivers. BUG=b:240617928 TEST=zmake testall; make sure all TCPCs work by attaching a charger BRANCH=main Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I9dfd1187fcb222df41bc3f129265e7dfd0e0c4eb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3797608 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Tested-by: Dawid Niedźwiecki <dn@semihalf.com>
-rw-r--r--zephyr/dts/bindings/usbc/anologix,anx7447-tcpc.yaml19
-rw-r--r--zephyr/dts/bindings/usbc/cros-ec,tcpci.yaml13
-rw-r--r--zephyr/dts/bindings/usbc/cypress,ccgxxf.yaml16
-rw-r--r--zephyr/dts/bindings/usbc/fairchild,fusb302.yaml18
-rw-r--r--zephyr/dts/bindings/usbc/ite,it8xxx2-tcpc.yaml3
-rw-r--r--zephyr/dts/bindings/usbc/named-usbc-port.yaml5
-rw-r--r--zephyr/dts/bindings/usbc/nuvoton,nct38xx.yaml22
-rw-r--r--zephyr/dts/bindings/usbc/parade,ps8xxx.yaml21
-rw-r--r--zephyr/dts/bindings/usbc/richtek,rt1718s-tcpc.yaml17
-rw-r--r--zephyr/projects/brya/i2c.dts28
-rw-r--r--zephyr/projects/brya/usbc.dts31
-rw-r--r--zephyr/projects/corsola/i2c_kingler.dts22
-rw-r--r--zephyr/projects/corsola/usbc_kingler.dts24
-rw-r--r--zephyr/projects/corsola/usbc_krabby.dts8
-rw-r--r--zephyr/projects/corsola/usbc_tentacruel.dts8
-rw-r--r--zephyr/projects/herobrine/usbc_evoker.dts28
-rw-r--r--zephyr/projects/herobrine/usbc_herobrine.dts28
-rw-r--r--zephyr/projects/herobrine/usbc_hoglin.dts28
-rw-r--r--zephyr/projects/herobrine/usbc_villager.dts28
-rw-r--r--zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts20
-rw-r--r--zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/usbc.dts28
-rw-r--r--zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts28
-rw-r--r--zephyr/projects/intelrvp/mtlrvp/usbc.dts32
-rw-r--r--zephyr/projects/rex/rex.dts9
-rw-r--r--zephyr/projects/rex/usbc.dts10
-rw-r--r--zephyr/projects/skyrim/i2c.dts16
-rw-r--r--zephyr/projects/skyrim/usbc.dts18
-rw-r--r--zephyr/projects/trogdor/lazor/i2c.dts12
-rw-r--r--zephyr/projects/trogdor/lazor/usbc.dts14
-rw-r--r--zephyr/shim/include/usbc/tcpc_anx7447.h17
-rw-r--r--zephyr/shim/include/usbc/tcpc_ccgxxf.h17
-rw-r--r--zephyr/shim/include/usbc/tcpc_fusb302.h15
-rw-r--r--zephyr/shim/include/usbc/tcpc_it8xxx2.h2
-rw-r--r--zephyr/shim/include/usbc/tcpc_nct38xx.h17
-rw-r--r--zephyr/shim/include/usbc/tcpc_ps8xxx.h17
-rw-r--r--zephyr/shim/include/usbc/tcpc_rt1718s.h25
-rw-r--r--zephyr/shim/include/usbc/tcpci.h14
-rw-r--r--zephyr/shim/src/tcpc.c64
-rw-r--r--zephyr/shim/src/tcpc_nct38xx.c20
39 files changed, 341 insertions, 421 deletions
diff --git a/zephyr/dts/bindings/usbc/anologix,anx7447-tcpc.yaml b/zephyr/dts/bindings/usbc/anologix,anx7447-tcpc.yaml
index 48543c808d..cb10c3ee15 100644
--- a/zephyr/dts/bindings/usbc/anologix,anx7447-tcpc.yaml
+++ b/zephyr/dts/bindings/usbc/anologix,anx7447-tcpc.yaml
@@ -2,24 +2,9 @@ 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
+include: i2c-device.yaml
+properties:
tcpc-flags:
type: int
default: 0
diff --git a/zephyr/dts/bindings/usbc/cros-ec,tcpci.yaml b/zephyr/dts/bindings/usbc/cros-ec,tcpci.yaml
index a3c36d9ded..10a8f04f55 100644
--- a/zephyr/dts/bindings/usbc/cros-ec,tcpci.yaml
+++ b/zephyr/dts/bindings/usbc/cros-ec,tcpci.yaml
@@ -2,15 +2,4 @@ description: USBC TCPC
compatible: "cros-ec,tcpci"
-properties:
- port:
- type: phandle
- required: true
- description: |
- I2C port used to communicate with controller
-
- i2c-addr-flags:
- type: int
- required: true
- description: |
- I2C address of controller
+include: i2c-device.yaml
diff --git a/zephyr/dts/bindings/usbc/cypress,ccgxxf.yaml b/zephyr/dts/bindings/usbc/cypress,ccgxxf.yaml
index 61f05495ea..54455eace7 100644
--- a/zephyr/dts/bindings/usbc/cypress,ccgxxf.yaml
+++ b/zephyr/dts/bindings/usbc/cypress,ccgxxf.yaml
@@ -6,18 +6,4 @@ description: USBC TCPC
compatible: "cypress,ccgxxf"
-properties:
- port:
- type: phandle
- required: true
- description: |
- I2C port used to communicate with controller
-
- i2c-addr-flags:
- type: string
- default: "CCGXXF_I2C_ADDR1_FLAGS"
- enum:
- - "CCGXXF_I2C_ADDR1_FLAGS"
- - "CCGXXF_I2C_ADDR2_FLAGS"
- description: |
- I2C address of controller
+include: i2c-device.yaml
diff --git a/zephyr/dts/bindings/usbc/fairchild,fusb302.yaml b/zephyr/dts/bindings/usbc/fairchild,fusb302.yaml
index 1eba4dedaf..05b7f9b9ad 100644
--- a/zephyr/dts/bindings/usbc/fairchild,fusb302.yaml
+++ b/zephyr/dts/bindings/usbc/fairchild,fusb302.yaml
@@ -2,20 +2,4 @@ description: USBC TCPC
compatible: "fairchild,fusb302"
-properties:
- port:
- type: phandle
- required: true
- description: |
- I2C port used to communicate with controller
-
- i2c-addr-flags:
- type: string
- default: "FUSB302_I2C_ADDR_FLAGS"
- enum:
- - "FUSB302_I2C_ADDR_FLAGS"
- - "FUSB302_I2C_ADDR_B01_FLAGS"
- - "FUSB302_I2C_ADDR_B10_FLAGS"
- - "FUSB302_I2C_ADDR_B11_FLAGS"
- description: |
- I2C address of controller
+include: i2c-device.yaml
diff --git a/zephyr/dts/bindings/usbc/ite,it8xxx2-tcpc.yaml b/zephyr/dts/bindings/usbc/ite,it8xxx2-tcpc.yaml
deleted file mode 100644
index 846ac5ead7..0000000000
--- a/zephyr/dts/bindings/usbc/ite,it8xxx2-tcpc.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-description: USBC TCPC
-
-compatible: "ite,it8xxx2-tcpc"
diff --git a/zephyr/dts/bindings/usbc/named-usbc-port.yaml b/zephyr/dts/bindings/usbc/named-usbc-port.yaml
index 13c9386473..21c5f90fab 100644
--- a/zephyr/dts/bindings/usbc/named-usbc-port.yaml
+++ b/zephyr/dts/bindings/usbc/named-usbc-port.yaml
@@ -14,6 +14,11 @@ properties:
required: false
description: |
BC1.2 chip for the USB-C port.
+ tcpc:
+ type: phandle
+ required: false
+ description: |
+ TCPC chip for the USB-C port.
usb-muxes:
type: phandles
required: false
diff --git a/zephyr/dts/bindings/usbc/nuvoton,nct38xx.yaml b/zephyr/dts/bindings/usbc/nuvoton,nct38xx.yaml
index ddd307c2a2..5131991aee 100644
--- a/zephyr/dts/bindings/usbc/nuvoton,nct38xx.yaml
+++ b/zephyr/dts/bindings/usbc/nuvoton,nct38xx.yaml
@@ -6,6 +6,8 @@ description: Nuvoton NCT38XX USB TCPC binding
compatible: "nuvoton,nct38xx"
+include: i2c-device.yaml
+
properties:
gpio-dev:
type: phandle
@@ -13,26 +15,6 @@ properties:
Pointer to the NCT38XX GPIO device. This is used to binding the Cros TCPC
port index to Zephyr NCT38XX GPIO device.
- port:
- type: phandle
- description: |
- I2C port used to communicate with controller
-
- i2c-addr-flags:
- type: string
- default: "NCT38XX_I2C_ADDR1_1_FLAGS"
- enum:
- - "NCT38XX_I2C_ADDR1_1_FLAGS"
- - "NCT38XX_I2C_ADDR1_2_FLAGS"
- - "NCT38XX_I2C_ADDR1_3_FLAGS"
- - "NCT38XX_I2C_ADDR1_4_FLAGS"
- - "NCT38XX_I2C_ADDR2_1_FLAGS"
- - "NCT38XX_I2C_ADDR2_2_FLAGS"
- - "NCT38XX_I2C_ADDR2_3_FLAGS"
- - "NCT38XX_I2C_ADDR2_4_FLAGS"
- description: |
- I2C address of controller
-
tcpc-flags:
type: int
default: 0
diff --git a/zephyr/dts/bindings/usbc/parade,ps8xxx.yaml b/zephyr/dts/bindings/usbc/parade,ps8xxx.yaml
index 8a65e736c9..8048e05522 100644
--- a/zephyr/dts/bindings/usbc/parade,ps8xxx.yaml
+++ b/zephyr/dts/bindings/usbc/parade,ps8xxx.yaml
@@ -2,26 +2,9 @@ description: USBC TCPC
compatible: "parade,ps8xxx"
-properties:
- port:
- type: phandle
- required: true
- description: |
- I2C port used to communicate with controller
-
- i2c-addr-flags:
- type: string
- default: "PS8XXX_I2C_ADDR1_FLAGS"
- enum:
- - "PS8XXX_I2C_ADDR1_P1_FLAGS"
- - "PS8XXX_I2C_ADDR1_P2_FLAGS"
- - "PS8XXX_I2C_ADDR1_FLAGS"
- - "PS8XXX_I2C_ADDR2_FLAGS"
- - "PS8XXX_I2C_ADDR3_FLAGS"
- - "PS8XXX_I2C_ADDR4_FLAGS"
- description: |
- I2C address of controller
+include: i2c-device.yaml
+properties:
tcpc-flags:
type: int
default: 0
diff --git a/zephyr/dts/bindings/usbc/richtek,rt1718s-tcpc.yaml b/zephyr/dts/bindings/usbc/richtek,rt1718s-tcpc.yaml
index c82eed0e22..edc815bba4 100644
--- a/zephyr/dts/bindings/usbc/richtek,rt1718s-tcpc.yaml
+++ b/zephyr/dts/bindings/usbc/richtek,rt1718s-tcpc.yaml
@@ -6,22 +6,9 @@ description: USBC RT1718S TCPC
compatible: "richtek,rt1718s-tcpc"
-properties:
- port:
- type: phandle
- required: true
- description: |
- I2C port used to communicate with controller
-
- i2c-addr-flags:
- type: string
- default: "RT1718S_I2C_ADDR1_FLAGS"
- enum:
- - "RT1718S_I2C_ADDR1_FLAGS"
- - "RT1718S_I2C_ADDR2_FLAGS"
- description: |
- I2C address of controller
+include: i2c-device.yaml
+properties:
tcpc-flags:
type: int
default: 0
diff --git a/zephyr/projects/brya/i2c.dts b/zephyr/projects/brya/i2c.dts
index 7ab8bb896b..a8d0a063e5 100644
--- a/zephyr/projects/brya/i2c.dts
+++ b/zephyr/projects/brya/i2c.dts
@@ -3,6 +3,8 @@
* found in the LICENSE file.
*/
+ #include <dt-bindings/usb_pd_tcpm.h>
+
/ {
named-i2c-ports {
compatible = "named-i2c-ports";
@@ -63,6 +65,22 @@
clock-frequency = <I2C_BITRATE_FAST_PLUS>;
pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
pinctrl-names = "default";
+
+ tcpc_port0: nct38xx@70 {
+ compatible = "nuvoton,nct38xx";
+ reg = <0x70>;
+ gpio-dev = <&nct3808_0_P1>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_NO_DEBUG_ACC_CONTROL)>;
+ };
+
+ tcpc_port2: nct38xx@74 {
+ compatible = "nuvoton,nct38xx";
+ reg = <0x74>;
+ gpio-dev = <&nct3808_0_P2>;
+ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
+ };
};
&i2c_ctrl1 {
@@ -110,6 +128,16 @@
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>;
pinctrl-names = "default";
+
+ tcpc_port1: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V |
+ TCPC_FLAGS_CONTROL_VCONN |
+ TCPC_FLAGS_CONTROL_FRS)>;
+ };
};
&i2c_ctrl4 {
diff --git a/zephyr/projects/brya/usbc.dts b/zephyr/projects/brya/usbc.dts
index 6047f999aa..d1bd259038 100644
--- a/zephyr/projects/brya/usbc.dts
+++ b/zephyr/projects/brya/usbc.dts
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
- #include <dt-bindings/usb_pd_tcpm.h>
-
/ {
usbc {
#address-cells = <1>;
@@ -14,15 +12,7 @@
compatible = "named-usbc-port";
reg = <0>;
bc12 = <&bc12_port0>;
- tcpc {
- compatible = "nuvoton,nct38xx";
- gpio-dev = <&nct3808_0_P1>;
- port = <&tcpc0_2>;
- i2c-addr-flags = "NCT38XX_I2C_ADDR1_1_FLAGS";
- tcpc-flags = <(
- TCPC_FLAGS_TCPCI_REV2_0 |
- TCPC_FLAGS_NO_DEBUG_ACC_CONTROL)>;
- };
+ tcpc = <&tcpc_port0>;
chg {
compatible = "ti,bq25710";
status = "okay";
@@ -47,16 +37,7 @@
compatible = "named-usbc-port";
reg = <1>;
bc12 = <&bc12_port1>;
- tcpc {
- compatible = "parade,ps8xxx";
- port = <&tcpc1>;
- i2c-addr-flags = "PS8XXX_I2C_ADDR1_FLAGS";
- tcpc-flags = <(
- TCPC_FLAGS_TCPCI_REV2_0 |
- TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V |
- TCPC_FLAGS_CONTROL_VCONN |
- TCPC_FLAGS_CONTROL_FRS)>;
- };
+ tcpc = <&tcpc_port1>;
usb-muxes = <&virtual_mux_c1 &tcpci_mux_c1>;
};
port1-muxes {
@@ -73,13 +54,7 @@
compatible = "named-usbc-port";
reg = <2>;
bc12 = <&bc12_port2>;
- tcpc {
- compatible = "nuvoton,nct38xx";
- gpio-dev = <&nct3808_0_P2>;
- port = <&tcpc0_2>;
- i2c-addr-flags = "NCT38XX_I2C_ADDR2_1_FLAGS";
- tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
- };
+ tcpc = <&tcpc_port2>;
usb-muxes = <&usb_c2_bb_retimer &virtual_mux_c2>;
};
port2-muxes {
diff --git a/zephyr/projects/corsola/i2c_kingler.dts b/zephyr/projects/corsola/i2c_kingler.dts
index 2f98d3a99b..a8fc6e592b 100644
--- a/zephyr/projects/corsola/i2c_kingler.dts
+++ b/zephyr/projects/corsola/i2c_kingler.dts
@@ -3,6 +3,8 @@
* found in the LICENSE file.
*/
+#include <dt-bindings/usb_pd_tcpm.h>
+
/*
* Kingler and Steelix use the same dts, take care of this when modify it.
*/
@@ -65,6 +67,17 @@
reg = <0x5f>;
irq = <&int_usb_c0_bc12>;
};
+
+ tcpc_port0: anx7447-tcpc@2c {
+ compatible = "anologix,anx7447-tcpc";
+ status = "okay";
+ reg = <0x2c>;
+ tcpc-flags = <(
+ TCPC_FLAGS_VBUS_MONITOR |
+ TCPC_FLAGS_ALERT_OD |
+ TCPC_FLAGS_CONTROL_VCONN |
+ TCPC_FLAGS_CONTROL_FRS)>;
+ };
};
&i2c_ctrl1 {
@@ -83,6 +96,15 @@
status = "okay";
reg = <0x40>;
};
+
+ tcpc_port1: rt1718s-tcpc@40 {
+ compatible = "richtek,rt1718s-tcpc";
+ reg = <0x40>;
+ tcpc-flags = <(
+ TCPC_FLAGS_ALERT_OD |
+ TCPC_FLAGS_CONTROL_VCONN |
+ TCPC_FLAGS_CONTROL_FRS)>;
+ };
};
&i2c_ctrl2 {
diff --git a/zephyr/projects/corsola/usbc_kingler.dts b/zephyr/projects/corsola/usbc_kingler.dts
index 9344603f26..8e96c62a4f 100644
--- a/zephyr/projects/corsola/usbc_kingler.dts
+++ b/zephyr/projects/corsola/usbc_kingler.dts
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
-#include <dt-bindings/usb_pd_tcpm.h>
-
/ {
usbc {
#address-cells = <1>;
@@ -14,17 +12,7 @@
compatible = "named-usbc-port";
reg = <0>;
bc12 = <&bc12_port0>;
- tcpc {
- compatible = "anologix,anx7447-tcpc";
- status = "okay";
- port = <&i2c_usb_c0>;
- i2c-addr-flags = "AN7447_TCPC0_I2C_ADDR_FLAGS";
- tcpc-flags = <(
- TCPC_FLAGS_VBUS_MONITOR |
- TCPC_FLAGS_ALERT_OD |
- TCPC_FLAGS_CONTROL_VCONN |
- TCPC_FLAGS_CONTROL_FRS)>;
- };
+ tcpc = <&tcpc_port0>;
ppc {
compatible = "nxp,nx20p348x";
status = "okay";
@@ -52,15 +40,7 @@
compatible = "named-usbc-port";
reg = <1>;
bc12 = <&bc12_port1>;
- tcpc {
- compatible = "richtek,rt1718s-tcpc";
- port = <&i2c_usb_c1>;
- i2c-addr-flags = "RT1718S_I2C_ADDR2_FLAGS";
- tcpc-flags = <(
- TCPC_FLAGS_ALERT_OD |
- TCPC_FLAGS_CONTROL_VCONN |
- TCPC_FLAGS_CONTROL_FRS)>;
- };
+ tcpc = <&tcpc_port1>;
ppc {
compatible = "nxp,nx20p348x";
status = "okay";
diff --git a/zephyr/projects/corsola/usbc_krabby.dts b/zephyr/projects/corsola/usbc_krabby.dts
index 58540b1769..829405bd87 100644
--- a/zephyr/projects/corsola/usbc_krabby.dts
+++ b/zephyr/projects/corsola/usbc_krabby.dts
@@ -12,15 +12,13 @@
compatible = "named-usbc-port";
reg = <0>;
bc12 = <&bc12_port0>;
+ tcpc = <&usbpd0>;
ppc {
compatible = "richtek,rt1739-ppc";
status = "okay";
port = <&i2c_usb_c0>;
i2c-addr-flags = "RT1739_ADDR1_FLAGS";
};
- tcpc {
- compatible = "ite,it8xxx2-tcpc";
- };
chg {
compatible = "richtek,rt9490";
status = "okay";
@@ -43,6 +41,7 @@
compatible = "named-usbc-port";
reg = <1>;
bc12 = <&bc12_port1>;
+ tcpc = <&usbpd1>;
ppc {
compatible = "silergy,syv682x";
status = "okay";
@@ -50,9 +49,6 @@
i2c-addr-flags = "SYV682X_ADDR0_FLAGS";
frs_en_gpio = <&gpio_ec_x_gpio1>;
};
- tcpc {
- compatible = "ite,it8xxx2-tcpc";
- };
usb-muxes = <&tusb1064_mux_1 &virtual_mux_1>;
};
port1-muxes {
diff --git a/zephyr/projects/corsola/usbc_tentacruel.dts b/zephyr/projects/corsola/usbc_tentacruel.dts
index 286fdb177c..899a95c8d8 100644
--- a/zephyr/projects/corsola/usbc_tentacruel.dts
+++ b/zephyr/projects/corsola/usbc_tentacruel.dts
@@ -18,9 +18,7 @@
port = <&i2c_usb_c0>;
i2c-addr-flags = "RT1739_ADDR1_FLAGS";
};
- tcpc {
- compatible = "ite,it8xxx2-tcpc";
- };
+ tcpc = <&usbpd0>;
chg {
compatible = "richtek,rt9490";
status = "okay";
@@ -50,9 +48,7 @@
i2c-addr-flags = "SYV682X_ADDR0_FLAGS";
frs_en_gpio = <&gpio_ec_x_gpio1>;
};
- tcpc {
- compatible = "ite,it8xxx2-tcpc";
- };
+ tcpc = <&usbpd1>;
usb-muxes = <&ps8743_mux_1 &virtual_mux_1>;
};
port1-muxes {
diff --git a/zephyr/projects/herobrine/usbc_evoker.dts b/zephyr/projects/herobrine/usbc_evoker.dts
index 3a93a52200..12273897b7 100644
--- a/zephyr/projects/herobrine/usbc_evoker.dts
+++ b/zephyr/projects/herobrine/usbc_evoker.dts
@@ -12,18 +12,13 @@
compatible = "named-usbc-port";
reg = <0>;
bc12 = <&bc12_port0>;
+ tcpc = <&tcpc_port0>;
ppc_port0: ppc {
compatible = "ti,sn5s330";
status = "okay";
port = <&i2c_tcpc0>;
i2c-addr-flags = "SN5S330_ADDR0_FLAGS";
};
- tcpc {
- compatible = "parade,ps8xxx";
- status = "okay";
- port = <&i2c_tcpc0>;
- i2c-addr-flags = "PS8XXX_I2C_ADDR1_FLAGS";
- };
chg {
compatible = "intersil,isl923x";
status = "okay";
@@ -39,18 +34,13 @@
compatible = "named-usbc-port";
reg = <1>;
bc12 = <&bc12_port1>;
+ tcpc = <&tcpc_port1>;
ppc {
compatible = "ti,sn5s330";
status = "okay";
port = <&i2c_tcpc1>;
i2c-addr-flags = "SN5S330_ADDR0_FLAGS";
};
- tcpc {
- compatible = "parade,ps8xxx";
- status = "okay";
- port = <&i2c_tcpc1>;
- i2c-addr-flags = "PS8XXX_I2C_ADDR1_FLAGS";
- };
usb-muxes = <&usb_mux_1>;
};
usb_mux_1: usb-mux-1 {
@@ -68,3 +58,17 @@
};
};
};
+
+&i2c1_0 {
+ tcpc_port0: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ };
+};
+
+&i2c2_0 {
+ tcpc_port1: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ };
+};
diff --git a/zephyr/projects/herobrine/usbc_herobrine.dts b/zephyr/projects/herobrine/usbc_herobrine.dts
index 53b8240b56..27c575f5db 100644
--- a/zephyr/projects/herobrine/usbc_herobrine.dts
+++ b/zephyr/projects/herobrine/usbc_herobrine.dts
@@ -12,18 +12,13 @@
compatible = "named-usbc-port";
reg = <0>;
bc12 = <&bc12_port0>;
+ tcpc = <&tcpc_port0>;
ppc_port0: ppc {
compatible = "ti,sn5s330";
status = "okay";
port = <&i2c_tcpc0>;
i2c-addr-flags = "SN5S330_ADDR0_FLAGS";
};
- tcpc {
- compatible = "parade,ps8xxx";
- status = "okay";
- port = <&i2c_tcpc0>;
- i2c-addr-flags = "PS8XXX_I2C_ADDR1_FLAGS";
- };
chg {
compatible = "intersil,isl923x";
status = "okay";
@@ -39,18 +34,13 @@
compatible = "named-usbc-port";
reg = <1>;
bc12 = <&bc12_port1>;
+ tcpc = <&tcpc_port1>;
ppc {
compatible = "ti,sn5s330";
status = "okay";
port = <&i2c_tcpc1>;
i2c-addr-flags = "SN5S330_ADDR0_FLAGS";
};
- tcpc {
- compatible = "parade,ps8xxx";
- status = "okay";
- port = <&i2c_tcpc1>;
- i2c-addr-flags = "PS8XXX_I2C_ADDR1_FLAGS";
- };
usb-muxes = <&usb_mux_1>;
};
usb_mux_1: usb-mux-1 {
@@ -68,3 +58,17 @@
};
};
};
+
+&i2c1_0 {
+ tcpc_port0: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ };
+};
+
+&i2c2_0 {
+ tcpc_port1: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ };
+};
diff --git a/zephyr/projects/herobrine/usbc_hoglin.dts b/zephyr/projects/herobrine/usbc_hoglin.dts
index 38a2bb1fab..eaf0143d4b 100644
--- a/zephyr/projects/herobrine/usbc_hoglin.dts
+++ b/zephyr/projects/herobrine/usbc_hoglin.dts
@@ -12,6 +12,7 @@
compatible = "named-usbc-port";
reg = <0>;
bc12 = <&bc12_port0>;
+ tcpc = <&tcpc_port0>;
ppc_port0: ppc {
compatible = "silergy,syv682x";
status = "okay";
@@ -19,12 +20,6 @@
i2c-addr-flags = "SYV682X_ADDR1_FLAGS";
frs_en_gpio = <&gpio_usb_c0_frs_en>;
};
- tcpc {
- compatible = "parade,ps8xxx";
- status = "okay";
- port = <&i2c_tcpc0>;
- i2c-addr-flags = "PS8XXX_I2C_ADDR2_FLAGS";
- };
chg {
compatible = "intersil,isl923x";
status = "okay";
@@ -40,6 +35,7 @@
compatible = "named-usbc-port";
reg = <1>;
bc12 = <&bc12_port1>;
+ tcpc = <&tcpc_port1>;
ppc_port1: ppc {
compatible = "silergy,syv682x";
status = "okay";
@@ -47,12 +43,6 @@
i2c-addr-flags = "SYV682X_ADDR1_FLAGS";
frs_en_gpio = <&gpio_usb_c1_frs_en>;
};
- tcpc {
- compatible = "parade,ps8xxx";
- status = "okay";
- port = <&i2c_tcpc1>;
- i2c-addr-flags = "PS8XXX_I2C_ADDR2_FLAGS";
- };
usb-muxes = <&usb_mux_1>;
};
usb_mux_1: usb-mux-1 {
@@ -60,3 +50,17 @@
};
};
};
+
+&i2c1_0 {
+ tcpc_port0: ps8xxx@1b {
+ compatible = "parade,ps8xxx";
+ reg = <0x1b>;
+ };
+};
+
+&i2c2_0 {
+ tcpc_port1: ps8xxx@1b {
+ compatible = "parade,ps8xxx";
+ reg = <0x1b>;
+ };
+};
diff --git a/zephyr/projects/herobrine/usbc_villager.dts b/zephyr/projects/herobrine/usbc_villager.dts
index 98506115f3..05a60d1111 100644
--- a/zephyr/projects/herobrine/usbc_villager.dts
+++ b/zephyr/projects/herobrine/usbc_villager.dts
@@ -12,6 +12,7 @@
compatible = "named-usbc-port";
reg = <0>;
bc12 = <&bc12_port0>;
+ tcpc = <&tcpc_port0>;
ppc {
compatible = "silergy,syv682x";
status = "okay";
@@ -19,12 +20,6 @@
i2c-addr-flags = "SYV682X_ADDR1_FLAGS";
frs_en_gpio = <&gpio_usb_c0_frs_en>;
};
- tcpc {
- compatible = "parade,ps8xxx";
- status = "okay";
- port = <&i2c_tcpc0>;
- i2c-addr-flags = "PS8XXX_I2C_ADDR1_FLAGS";
- };
chg {
compatible = "intersil,isl923x";
status = "okay";
@@ -40,6 +35,7 @@
compatible = "named-usbc-port";
reg = <1>;
bc12 = <&bc12_port1>;
+ tcpc = <&tcpc_port1>;
ppc {
compatible = "silergy,syv682x";
status = "okay";
@@ -47,12 +43,6 @@
i2c-addr-flags = "SYV682X_ADDR1_FLAGS";
frs_en_gpio = <&gpio_usb_c1_frs_en>;
};
- tcpc {
- compatible = "parade,ps8xxx";
- status = "okay";
- port = <&i2c_tcpc1>;
- i2c-addr-flags = "PS8XXX_I2C_ADDR1_FLAGS";
- };
usb-muxes = <&usb_mux_1>;
};
usb_mux_1: usb-mux-1 {
@@ -60,3 +50,17 @@
};
};
};
+
+&i2c1_0 {
+ tcpc_port0: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ };
+};
+
+&i2c2_0 {
+ tcpc_port1: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ };
+};
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts
index 38c38f1411..0875f350ec 100644
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts
+++ b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts
@@ -129,6 +129,11 @@
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
pinctrl-names = "default";
+
+ tcpc_port0: fusb302@22 {
+ compatible = "fairchild,fusb302";
+ reg = <0x22>;
+ };
};
&i2c_ctrl0 {
@@ -141,6 +146,11 @@
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>;
pinctrl-names = "default";
+
+ tcpc_port1: fusb302@22 {
+ compatible = "fairchild,fusb302";
+ reg = <0x22>;
+ };
};
&i2c_ctrl2 {
@@ -153,6 +163,11 @@
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
pinctrl-names = "default";
+
+ tcpc_port2: fusb302@22 {
+ compatible = "fairchild,fusb302";
+ reg = <0x22>;
+ };
};
&i2c_ctrl1 {
@@ -165,6 +180,11 @@
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>;
pinctrl-names = "default";
+
+ tcpc_port3: fusb302@22 {
+ compatible = "fairchild,fusb302";
+ reg = <0x22>;
+ };
};
&i2c_ctrl3 {
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/usbc.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/usbc.dts
index cd7c2b050f..4441730f8e 100644
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/usbc.dts
+++ b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/usbc.dts
@@ -10,12 +10,7 @@
usbc_port0: port0@0 {
compatible = "named-usbc-port";
reg = <0>;
- tcpc {
- compatible = "fairchild,fusb302";
- status = "okay";
- port = <&typec_0>;
- i2c-addr-flags = "FUSB302_I2C_ADDR_FLAGS";
- };
+ tcpc = <&tcpc_port0>;
chg {
compatible = "intersil,isl9241";
status = "okay";
@@ -39,12 +34,7 @@
usbc_port1: port1@1 {
compatible = "named-usbc-port";
reg = <1>;
- tcpc {
- compatible = "fairchild,fusb302";
- status = "okay";
- port = <&typec_1>;
- i2c-addr-flags = "FUSB302_I2C_ADDR_FLAGS";
- };
+ tcpc = <&tcpc_port1>;
usb-muxes = <&usb_c1_bb_retimer &virtual_mux_c1>;
};
port1-muxes {
@@ -63,12 +53,7 @@
port2@2 {
compatible = "named-usbc-port";
reg = <2>;
- tcpc {
- compatible = "fairchild,fusb302";
- status = "okay";
- port = <&typec_2>;
- i2c-addr-flags = "FUSB302_I2C_ADDR_FLAGS";
- };
+ tcpc = <&tcpc_port2>;
usb-muxes = <&usb_c2_bb_retimer &virtual_mux_c2>;
};
port2-muxes {
@@ -87,12 +72,7 @@
port3@3 {
compatible = "named-usbc-port";
reg = <3>;
- tcpc {
- compatible = "fairchild,fusb302";
- status = "okay";
- port = <&typec_3>;
- i2c-addr-flags = "FUSB302_I2C_ADDR_FLAGS";
- };
+ tcpc = <&tcpc_port3>;
usb-muxes = <&usb_c3_bb_retimer &virtual_mux_c3>;
};
port3-muxes {
diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts
index 1b00f09a49..9e3289628e 100644
--- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts
+++ b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts
@@ -3,6 +3,8 @@
* found in the LICENSE file.
*/
+ #include <dt-bindings/usb_pd_tcpm.h>
+
/ {
chosen {
cros,rtc = &mtc;
@@ -126,6 +128,22 @@
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
pinctrl-names = "default";
+
+ tcpc_port0: nct38xx@73 {
+ compatible = "nuvoton,nct38xx";
+ reg = <0x73>;
+ gpio-dev = <&nct38xx_c0>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_NO_DEBUG_ACC_CONTROL)>;
+ };
+
+ tcpc_port1: nct38xx@77 {
+ compatible = "nuvoton,nct38xx";
+ reg = <0x77>;
+ gpio-dev = <&nct38xx_c1>;
+ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
+ };
};
&i2c_ctrl0 {
@@ -138,6 +156,16 @@
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
pinctrl-names = "default";
+
+ tcpc_port2: ccgxxf@b {
+ compatible = "cypress,ccgxxf";
+ reg = <0xb>;
+ };
+
+ tcpc_port3: ccgxxf@1b {
+ compatible = "cypress,ccgxxf";
+ reg = <0x1b>;
+ };
};
&i2c_ctrl1 {
diff --git a/zephyr/projects/intelrvp/mtlrvp/usbc.dts b/zephyr/projects/intelrvp/mtlrvp/usbc.dts
index 60831a043c..a71cc32090 100644
--- a/zephyr/projects/intelrvp/mtlrvp/usbc.dts
+++ b/zephyr/projects/intelrvp/mtlrvp/usbc.dts
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
- #include <dt-bindings/usb_pd_tcpm.h>
-
/ {
usbc {
#address-cells = <1>;
@@ -13,15 +11,7 @@
usbc_port0: port0@0 {
compatible = "named-usbc-port";
reg = <0>;
- tcpc {
- compatible = "nuvoton,nct38xx";
- gpio-dev = <&nct38xx_c0>;
- port = <&typec_aic1>;
- i2c-addr-flags = "NCT38XX_I2C_ADDR1_4_FLAGS";
- tcpc-flags = <(
- TCPC_FLAGS_TCPCI_REV2_0 |
- TCPC_FLAGS_NO_DEBUG_ACC_CONTROL)>;
- };
+ tcpc = <&tcpc_port0>;
chg {
compatible = "intersil,isl9241";
status = "okay";
@@ -45,13 +35,7 @@
usbc_port1: port1@1 {
compatible = "named-usbc-port";
reg = <1>;
- tcpc {
- compatible = "nuvoton,nct38xx";
- gpio-dev = <&nct38xx_c1>;
- port = <&typec_aic1>;
- i2c-addr-flags = "NCT38XX_I2C_ADDR2_4_FLAGS";
- tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
- };
+ tcpc = <&tcpc_port1>;
usb-muxes = <&usb_c1_hb_retimer &virtual_mux_c1>;
};
port1-muxes {
@@ -70,11 +54,7 @@
usbc_port2: port2@2 {
compatible = "named-usbc-port";
reg = <2>;
- tcpc {
- compatible = "cypress,ccgxxf";
- port = <&typec_aic2>;
- i2c-addr-flags = "CCGXXF_I2C_ADDR1_FLAGS";
- };
+ tcpc = <&tcpc_port2>;
usb-muxes = <&usb_c2_hb_retimer &virtual_mux_c2>;
};
port2-muxes {
@@ -93,11 +73,7 @@
usbc_port3: port3@3 {
compatible = "named-usbc-port";
reg = <3>;
- tcpc {
- compatible = "cypress,ccgxxf";
- port = <&typec_aic2>;
- i2c-addr-flags = "CCGXXF_I2C_ADDR2_FLAGS";
- };
+ tcpc = <&tcpc_port3>;
usb-muxes = <&usb_c3_hb_retimer &virtual_mux_c3>;
};
port3-muxes {
diff --git a/zephyr/projects/rex/rex.dts b/zephyr/projects/rex/rex.dts
index 6876113731..d35bccf19a 100644
--- a/zephyr/projects/rex/rex.dts
+++ b/zephyr/projects/rex/rex.dts
@@ -3,6 +3,8 @@
* found in the LICENSE file.
*/
+ #include <dt-bindings/usb_pd_tcpm.h>
+
/ {
aliases {
gpio-wp = &ec_wp_l;
@@ -71,6 +73,13 @@
irq = <&int_usb_c0_bc12>;
};
+ tcpc_port0: nct38xx@73 {
+ compatible = "nuvoton,nct38xx";
+ gpio-dev = <&nct3807_C0>;
+ reg = <0x73>;
+ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
+ };
+
nct3807_C0:nct3807_C0@70 {
#address-cells = <1>;
#size-cells = <0>;
diff --git a/zephyr/projects/rex/usbc.dts b/zephyr/projects/rex/usbc.dts
index 2657fc81b7..484aa90c26 100644
--- a/zephyr/projects/rex/usbc.dts
+++ b/zephyr/projects/rex/usbc.dts
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
- #include <dt-bindings/usb_pd_tcpm.h>
-
/ {
usbc {
#address-cells = <1>;
@@ -20,13 +18,7 @@
port = <&i2c_ec_i2c_usb_c0_ppc_b>;
i2c-addr-flags = "SYV682X_ADDR1_FLAGS";
};
- tcpc {
- compatible = "nuvoton,nct38xx";
- gpio-dev = <&nct3807_C0>;
- port = <&i2c_ec_i2c_usb_c0_tcp>;
- i2c-addr-flags = "NCT38XX_I2C_ADDR1_4_FLAGS";
- tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
- };
+ tcpc = <&tcpc_port0>;
chg {
compatible = "intersil,isl9241";
status = "okay";
diff --git a/zephyr/projects/skyrim/i2c.dts b/zephyr/projects/skyrim/i2c.dts
index 8ff3262cd7..9af7eccc8e 100644
--- a/zephyr/projects/skyrim/i2c.dts
+++ b/zephyr/projects/skyrim/i2c.dts
@@ -3,6 +3,8 @@
* found in the LICENSE file.
*/
+ #include <dt-bindings/usb_pd_tcpm.h>
+
/ {
aliases {
i2c-0 = &i2c0_0;
@@ -75,6 +77,13 @@
reg = <0x5f>;
irq = <&int_usb_c0_bc12>;
};
+
+ tcpc_port0: nct38xx@70 {
+ compatible = "nuvoton,nct38xx";
+ reg = <0x70>;
+ gpio-dev = <&nct3807_C0>;
+ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
+ };
};
&i2c_ctrl0 {
@@ -94,6 +103,13 @@
reg = <0x5f>;
irq = <&int_usb_c1_bc12>;
};
+
+ tcpc_port1: nct38xx@70 {
+ compatible = "nuvoton,nct38xx";
+ reg = <0x70>;
+ gpio-dev = <&nct3807_C1>;
+ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
+ };
};
&i2c_ctrl1 {
diff --git a/zephyr/projects/skyrim/usbc.dts b/zephyr/projects/skyrim/usbc.dts
index 966ef1296c..5cfab0a4c8 100644
--- a/zephyr/projects/skyrim/usbc.dts
+++ b/zephyr/projects/skyrim/usbc.dts
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
- #include <dt-bindings/usb_pd_tcpm.h>
-
/ {
usbc {
#address-cells = <1>;
@@ -14,13 +12,7 @@
compatible = "named-usbc-port";
reg = <0>;
bc12 = <&bc12_port0>;
- tcpc {
- compatible = "nuvoton,nct38xx";
- gpio-dev = <&nct3807_C0>;
- port = <&i2c_tcpc0>;
- i2c-addr-flags = "NCT38XX_I2C_ADDR1_1_FLAGS";
- tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
- };
+ tcpc = <&tcpc_port0>;
chg {
compatible = "intersil,isl9241";
status = "okay";
@@ -32,13 +24,7 @@
compatible = "named-usbc-port";
reg = <1>;
bc12 = <&bc12_port1>;
- tcpc {
- compatible = "nuvoton,nct38xx";
- gpio-dev = <&nct3807_C1>;
- port = <&i2c_tcpc1>;
- i2c-addr-flags = "NCT38XX_I2C_ADDR1_1_FLAGS";
- tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
- };
+ tcpc = <&tcpc_port1>;
};
};
};
diff --git a/zephyr/projects/trogdor/lazor/i2c.dts b/zephyr/projects/trogdor/lazor/i2c.dts
index c4afff1f7f..b2721d7a89 100644
--- a/zephyr/projects/trogdor/lazor/i2c.dts
+++ b/zephyr/projects/trogdor/lazor/i2c.dts
@@ -59,6 +59,12 @@
clock-frequency = <I2C_BITRATE_FAST_PLUS>;
pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
pinctrl-names = "default";
+
+ tcpc_port0: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ status = "okay";
+ reg = <0xb>;
+ };
};
&i2c_ctrl1 {
@@ -70,6 +76,12 @@
clock-frequency = <I2C_BITRATE_FAST_PLUS>;
pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>;
pinctrl-names = "default";
+
+ tcpc_port1: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ status = "okay";
+ reg = <0xb>;
+ };
};
&i2c_ctrl2 {
diff --git a/zephyr/projects/trogdor/lazor/usbc.dts b/zephyr/projects/trogdor/lazor/usbc.dts
index 803ce42ba5..67adb0518e 100644
--- a/zephyr/projects/trogdor/lazor/usbc.dts
+++ b/zephyr/projects/trogdor/lazor/usbc.dts
@@ -16,12 +16,7 @@
reg = <0>;
bc12 = <&bc12_port0>;
- tcpc {
- compatible = "parade,ps8xxx";
- status = "okay";
- port = <&i2c_tcpc0>;
- i2c-addr-flags = "PS8XXX_I2C_ADDR1_FLAGS";
- };
+ tcpc = <&tcpc_port0>;
ppc {
compatible = "ti,sn5s330";
@@ -42,12 +37,7 @@
reg = <1>;
bc12 = <&bc12_port1>;
- tcpc {
- compatible = "parade,ps8xxx";
- status = "okay";
- port = <&i2c_tcpc1>;
- i2c-addr-flags = "PS8XXX_I2C_ADDR1_FLAGS";
- };
+ tcpc = <&tcpc_port1>;
ppc {
compatible = "ti,sn5s330";
diff --git a/zephyr/shim/include/usbc/tcpc_anx7447.h b/zephyr/shim/include/usbc/tcpc_anx7447.h
index 7f5c0891f9..8342157827 100644
--- a/zephyr/shim/include/usbc/tcpc_anx7447.h
+++ b/zephyr/shim/include/usbc/tcpc_anx7447.h
@@ -9,13 +9,12 @@
#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), \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &anx7447_tcpm_drv, \
+ .flags = DT_PROP(id, tcpc_flags), \
},
diff --git a/zephyr/shim/include/usbc/tcpc_ccgxxf.h b/zephyr/shim/include/usbc/tcpc_ccgxxf.h
index e19220d40e..e13598f4a2 100644
--- a/zephyr/shim/include/usbc/tcpc_ccgxxf.h
+++ b/zephyr/shim/include/usbc/tcpc_ccgxxf.h
@@ -9,13 +9,12 @@
#define CCGXXF_TCPC_COMPAT cypress_ccgxxf
#define TCPC_CONFIG_CCGXXF(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 = &ccgxxf_tcpm_drv, \
- .flags = TCPC_FLAGS_TCPCI_REV2_0, \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &ccgxxf_tcpm_drv, \
+ .flags = TCPC_FLAGS_TCPCI_REV2_0, \
},
diff --git a/zephyr/shim/include/usbc/tcpc_fusb302.h b/zephyr/shim/include/usbc/tcpc_fusb302.h
index 5333361929..c5f735bd18 100644
--- a/zephyr/shim/include/usbc/tcpc_fusb302.h
+++ b/zephyr/shim/include/usbc/tcpc_fusb302.h
@@ -9,12 +9,11 @@
#define FUSB302_TCPC_COMPAT fairchild_fusb302
#define TCPC_CONFIG_FUSB302(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 = &fusb302_tcpm_drv, \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &fusb302_tcpm_drv, \
},
diff --git a/zephyr/shim/include/usbc/tcpc_it8xxx2.h b/zephyr/shim/include/usbc/tcpc_it8xxx2.h
index f8f77a6d18..543290a893 100644
--- a/zephyr/shim/include/usbc/tcpc_it8xxx2.h
+++ b/zephyr/shim/include/usbc/tcpc_it8xxx2.h
@@ -6,7 +6,7 @@
#include <zephyr/devicetree.h>
#include "driver/tcpm/it8xxx2_pd_public.h"
-#define IT8XXX2_TCPC_COMPAT ite_it8xxx2_tcpc
+#define IT8XXX2_TCPC_COMPAT ite_it8xxx2_usbpd
#define TCPC_CONFIG_IT8XXX2(id) \
{ \
diff --git a/zephyr/shim/include/usbc/tcpc_nct38xx.h b/zephyr/shim/include/usbc/tcpc_nct38xx.h
index 377e19e63d..ebb0452f35 100644
--- a/zephyr/shim/include/usbc/tcpc_nct38xx.h
+++ b/zephyr/shim/include/usbc/tcpc_nct38xx.h
@@ -12,15 +12,14 @@
#define NCT38XX_TCPC_COMPAT nuvoton_nct38xx
#define TCPC_CONFIG_NCT38XX(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 = &nct38xx_tcpm_drv, \
- .flags = DT_PROP(id, tcpc_flags), \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &nct38xx_tcpm_drv, \
+ .flags = DT_PROP(id, tcpc_flags), \
},
/**
diff --git a/zephyr/shim/include/usbc/tcpc_ps8xxx.h b/zephyr/shim/include/usbc/tcpc_ps8xxx.h
index 379b041e8e..43f8fee9d5 100644
--- a/zephyr/shim/include/usbc/tcpc_ps8xxx.h
+++ b/zephyr/shim/include/usbc/tcpc_ps8xxx.h
@@ -9,13 +9,12 @@
#define PS8XXX_COMPAT parade_ps8xxx
#define TCPC_CONFIG_PS8XXX(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 = &ps8xxx_tcpm_drv, \
- .flags = DT_PROP(id, tcpc_flags), \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &ps8xxx_tcpm_drv, \
+ .flags = DT_PROP(id, tcpc_flags), \
},
diff --git a/zephyr/shim/include/usbc/tcpc_rt1718s.h b/zephyr/shim/include/usbc/tcpc_rt1718s.h
index 7da7427a98..4374fb5be6 100644
--- a/zephyr/shim/include/usbc/tcpc_rt1718s.h
+++ b/zephyr/shim/include/usbc/tcpc_rt1718s.h
@@ -8,20 +8,13 @@
#define RT1718S_TCPC_COMPAT richtek_rt1718s_tcpc
-/*
- * Currently, the clang-format will force the back-slash at col:81. Enable
- * format after we fix the issue.
- */
-/* clang-format off */
-#define TCPC_CONFIG_RT1718S(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 = &rt1718s_tcpm_drv, \
- .flags = DT_PROP(id, tcpc_flags), \
+#define TCPC_CONFIG_RT1718S(id) \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &rt1718s_tcpm_drv, \
+ .flags = DT_PROP(id, tcpc_flags), \
},
-/* clang-format on */
diff --git a/zephyr/shim/include/usbc/tcpci.h b/zephyr/shim/include/usbc/tcpci.h
index f65b6b7717..159e85ee27 100644
--- a/zephyr/shim/include/usbc/tcpci.h
+++ b/zephyr/shim/include/usbc/tcpci.h
@@ -10,11 +10,11 @@
#define TCPCI_COMPAT cros_ec_tcpci
#define TCPC_CONFIG_TCPCI(id) \
- { \
- .bus_type = EC_BUS_TYPE_I2C, \
- .i2c_info = { \
- .port = I2C_PORT(DT_PHANDLE(id, port)), \
- .addr_flags = DT_PROP(id, i2c_addr_flags), \
- }, \
- .drv = &tcpci_tcpm_drv, \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &tcpci_tcpm_drv, \
},
diff --git a/zephyr/shim/src/tcpc.c b/zephyr/shim/src/tcpc.c
index 98237044b7..97effc48c8 100644
--- a/zephyr/shim/src/tcpc.c
+++ b/zephyr/shim/src/tcpc.c
@@ -17,40 +17,44 @@
#include "usbc/tcpci.h"
#include "usbc/utils.h"
-#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) || \
- DT_HAS_COMPAT_STATUS_OKAY(NCT38XX_TCPC_COMPAT) || \
- DT_HAS_COMPAT_STATUS_OKAY(RT1718S_TCPC_COMPAT) || \
- DT_HAS_COMPAT_STATUS_OKAY(TCPCI_COMPAT)
+#define HAS_TCPC_PROP(usbc_id) \
+ COND_CODE_1(DT_NODE_HAS_PROP(usbc_id, tcpc), (|| 1), ())
-#define TCPC_CONFIG(id, fn) [USBC_PORT(id)] = fn(id)
+#define DT_HAS_TCPC (0 DT_FOREACH_STATUS_OKAY(named_usbc_port, HAS_TCPC_PROP))
+
+#if DT_HAS_TCPC
+
+#define TCPC_CHIP_ENTRY(usbc_id, tcpc_id, config_fn) \
+ [USBC_PORT_NEW(usbc_id)] = config_fn(tcpc_id)
+
+#define CHECK_COMPAT(compat, usbc_id, tcpc_id, config_fn) \
+ COND_CODE_1(DT_NODE_HAS_COMPAT(tcpc_id, compat), \
+ (TCPC_CHIP_ENTRY(usbc_id, tcpc_id, config_fn)), ())
+
+#define TCPC_CHIP_FIND(usbc_id, tcpc_id) \
+ CHECK_COMPAT(ANX7447_TCPC_COMPAT, usbc_id, tcpc_id, \
+ TCPC_CONFIG_ANX7447) \
+ CHECK_COMPAT(CCGXXF_TCPC_COMPAT, usbc_id, tcpc_id, TCPC_CONFIG_CCGXXF) \
+ CHECK_COMPAT(FUSB302_TCPC_COMPAT, usbc_id, tcpc_id, \
+ TCPC_CONFIG_FUSB302) \
+ CHECK_COMPAT(IT8XXX2_TCPC_COMPAT, usbc_id, tcpc_id, \
+ TCPC_CONFIG_IT8XXX2) \
+ CHECK_COMPAT(PS8XXX_COMPAT, usbc_id, tcpc_id, TCPC_CONFIG_PS8XXX) \
+ CHECK_COMPAT(NCT38XX_TCPC_COMPAT, usbc_id, tcpc_id, \
+ TCPC_CONFIG_NCT38XX) \
+ CHECK_COMPAT(RT1718S_TCPC_COMPAT, usbc_id, tcpc_id, \
+ TCPC_CONFIG_RT1718S) \
+ CHECK_COMPAT(TCPCI_COMPAT, usbc_id, tcpc_id, TCPC_CONFIG_TCPCI)
+
+#define TCPC_CHIP(usbc_id) \
+ COND_CODE_1(DT_NODE_HAS_PROP(usbc_id, tcpc), \
+ (TCPC_CHIP_FIND(usbc_id, DT_PHANDLE(usbc_id, tcpc))), ())
#define MAYBE_CONST \
COND_CODE_1(CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG, (), (const))
-/* 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,
- TCPC_CONFIG_FUSB302)
- DT_FOREACH_STATUS_OKAY_VARGS(IT8XXX2_TCPC_COMPAT, TCPC_CONFIG,
- TCPC_CONFIG_IT8XXX2)
- DT_FOREACH_STATUS_OKAY_VARGS(PS8XXX_COMPAT, TCPC_CONFIG,
- TCPC_CONFIG_PS8XXX)
- DT_FOREACH_STATUS_OKAY_VARGS(NCT38XX_TCPC_COMPAT, TCPC_CONFIG,
- TCPC_CONFIG_NCT38XX)
- DT_FOREACH_STATUS_OKAY_VARGS(RT1718S_TCPC_COMPAT, TCPC_CONFIG,
- TCPC_CONFIG_RT1718S)
- DT_FOREACH_STATUS_OKAY_VARGS(TCPCI_COMPAT, TCPC_CONFIG,
- TCPC_CONFIG_TCPCI)
-};
-/* clang-format on */
+/* Type C Port Controllers */
+MAYBE_CONST struct tcpc_config_t tcpc_config[] = { DT_FOREACH_STATUS_OKAY(
+ named_usbc_port, TCPC_CHIP) };
#endif /* DT_HAS_COMPAT_STATUS_OKAY */
diff --git a/zephyr/shim/src/tcpc_nct38xx.c b/zephyr/shim/src/tcpc_nct38xx.c
index 90a75ad4f9..e1afef8182 100644
--- a/zephyr/shim/src/tcpc_nct38xx.c
+++ b/zephyr/shim/src/tcpc_nct38xx.c
@@ -8,18 +8,26 @@
#include "config.h"
#include "usbc/tcpc_nct38xx.h"
-
-#define TCPC_PORT(id) DT_REG_ADDR(DT_PARENT(id))
+#include "usbc/utils.h"
#define GPIO_DEV_WITH_COMMA(id) DEVICE_DT_GET(DT_PHANDLE(id, gpio_dev)),
-#define GPIO_DEV_BINDING(id) \
- COND_CODE_1(DT_NODE_HAS_PROP(id, gpio_dev), \
- ([TCPC_PORT(id)] = GPIO_DEV_WITH_COMMA(id)), ())
+#define GPIO_DEV_BINDING(usbc_id, tcpc_id) \
+ COND_CODE_1(DT_NODE_HAS_PROP(tcpc_id, gpio_dev), \
+ ([USBC_PORT_NEW(usbc_id)] = GPIO_DEV_WITH_COMMA(tcpc_id)), \
+ ())
+
+#define NCT38XX_CHECK(usbc_id, tcpc_id) \
+ COND_CODE_1(DT_NODE_HAS_COMPAT(tcpc_id, nuvoton_nct38xx), \
+ (GPIO_DEV_BINDING(usbc_id, tcpc_id)), ())
+
+#define NCT38XX_GPIO(usbc_id) \
+ COND_CODE_1(DT_NODE_HAS_PROP(usbc_id, tcpc), \
+ (NCT38XX_CHECK(usbc_id, DT_PHANDLE(usbc_id, tcpc))), ())
/* NCT38XX GPIO device pool for binding the TCPC port and NCT38XX GPIO device */
static const struct device *nct38xx_gpio_devices[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- DT_FOREACH_STATUS_OKAY(nuvoton_nct38xx, GPIO_DEV_BINDING)
+ DT_FOREACH_STATUS_OKAY(named_usbc_port, NCT38XX_GPIO)
};
const struct device *nct38xx_get_gpio_device_from_port(const int port)