From 5bf3b85260cb32d71cf894f14340f87139722bc8 Mon Sep 17 00:00:00 2001 From: Dawid Niedzwiecki Date: Mon, 25 Oct 2021 15:00:25 +0200 Subject: 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 Change-Id: I0684389881fde4e8ef3924fc2eff693e15b5c0fa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3241463 Reviewed-by: Keith Short Reviewed-by: Yuval Peress Reviewed-by: Wai-Hong Tam Commit-Queue: Dawid Niedzwiecki --- zephyr/dts/bindings/usbc/named-usbc-ports.yaml | 25 ++++++++++++++++++++++ zephyr/projects/herobrine/herobrine_npcx9/usbc.dts | 9 ++++++-- zephyr/shim/src/ppc_sn5s330.c | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 zephyr/dts/bindings/usbc/named-usbc-ports.yaml 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), \ -- cgit v1.2.1