summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDawid Niedzwiecki <dn@semihalf.com>2021-10-25 15:00:25 +0200
committerCommit Bot <commit-bot@chromium.org>2021-11-02 08:44:11 +0000
commit5bf3b85260cb32d71cf894f14340f87139722bc8 (patch)
tree743fa7242b6541f0118f784b74dc0e87aa265b1b
parent726d6b72d5fc9f2a61093ab676463cba06f3431d (diff)
downloadchrome-ec-5bf3b85260cb32d71cf894f14340f87139722bc8.tar.gz
zephyr: Fix declaring the ppc_chips array
DT_INST_FOREACH_STATUS_OKAY doesn't care about the order so use reg property in usbc node so we can rely on it at ppc_chip definition. It allows to reference "ppc_chip[0]" for port 0 etc. BUG=b:194432779 TEST=zmake testall BRANCH=main Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I0684389881fde4e8ef3924fc2eff693e15b5c0fa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3241463 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Dawid Niedzwiecki <dawidn@google.com>
-rw-r--r--zephyr/dts/bindings/usbc/named-usbc-ports.yaml25
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/usbc.dts9
-rw-r--r--zephyr/shim/src/ppc_sn5s330.c2
3 files changed, 33 insertions, 3 deletions
diff --git a/zephyr/dts/bindings/usbc/named-usbc-ports.yaml b/zephyr/dts/bindings/usbc/named-usbc-ports.yaml
new file mode 100644
index 0000000000..c4a55ba153
--- /dev/null
+++ b/zephyr/dts/bindings/usbc/named-usbc-ports.yaml
@@ -0,0 +1,25 @@
+# Copyright (c) 2021 The Chromium OS Authors
+# SPDX-License-Identifier: Apache-2.0
+
+description: Named USB-C ports parent node
+
+compatible: "named-usbc-ports"
+
+include: base.yaml
+
+properties:
+ "#address-cells":
+ required: true
+ const: 1
+ "#size-cells":
+ required: true
+ const: 0
+
+child-binding:
+ description: Named USB-C port
+ properties:
+ reg:
+ type: array
+ required: true
+ description: |
+ USB-C port number to serialize devices used for USB-C communication
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/usbc.dts b/zephyr/projects/herobrine/herobrine_npcx9/usbc.dts
index c742bcf386..189bf6abd3 100644
--- a/zephyr/projects/herobrine/herobrine_npcx9/usbc.dts
+++ b/zephyr/projects/herobrine/herobrine_npcx9/usbc.dts
@@ -5,7 +5,11 @@
/ {
usbc {
- port0: usbc-port0 {
+ compatible = "named-usbc-ports";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ port0: usbc-port@0 {
+ reg = <0>;
bc12 {
compatible = "pericom,pi3usb9201";
status = "okay";
@@ -21,7 +25,8 @@
};
};
- port1: usbc-port1 {
+ port1: usbc-port@1 {
+ reg = <1>;
bc12 {
compatible = "pericom,pi3usb9201";
status = "okay";
diff --git a/zephyr/shim/src/ppc_sn5s330.c b/zephyr/shim/src/ppc_sn5s330.c
index b57f243c51..7bc11ec4ad 100644
--- a/zephyr/shim/src/ppc_sn5s330.c
+++ b/zephyr/shim/src/ppc_sn5s330.c
@@ -17,7 +17,7 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) > 0,
"No compatible PPC instance found");
#define USBC_PORT_PPC(inst) \
- { \
+ [DT_REG_ADDR(DT_PARENT(DT_DRV_INST(inst)))] = { \
.i2c_port = I2C_PORT(DT_PHANDLE(DT_DRV_INST(inst), port)), \
.i2c_addr_flags = DT_STRING_UPPER_TOKEN( \
DT_DRV_INST(inst), i2c_addr_flags), \