From 0330a72acf5a36c729f853db24bf8a3361e5f60c Mon Sep 17 00:00:00 2001 From: Scott Collyer Date: Tue, 21 Mar 2023 14:13:55 -0700 Subject: driver: shim: Port KTU1125 PPC driver to Zephyr This CL adds the shim layer required to support the KTU1125 PPC driver. BUG=b:267589112 BRANCH=None TEST=zmake build rex Verified basic type-c/PD operation on SKU2 system Change-Id: Ie8b83910ce60c0e3f276a7b3086f9b9c708bdaf7 Signed-off-by: Scott Collyer Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4358755 Reviewed-by: Boris Mittelberg Tested-by: Boris Mittelberg Commit-Queue: caveh jalali --- zephyr/dts/bindings/usbc/ppc/kinetic,ktu1125.yaml | 5 +++++ zephyr/shim/include/usbc/ppc.h | 2 ++ zephyr/shim/include/usbc/ppc_ktu1125.h | 14 ++++++++++++++ zephyr/shim/src/ppc.c | 4 ++++ 4 files changed, 25 insertions(+) create mode 100644 zephyr/dts/bindings/usbc/ppc/kinetic,ktu1125.yaml create mode 100644 zephyr/shim/include/usbc/ppc_ktu1125.h diff --git a/zephyr/dts/bindings/usbc/ppc/kinetic,ktu1125.yaml b/zephyr/dts/bindings/usbc/ppc/kinetic,ktu1125.yaml new file mode 100644 index 0000000000..104d81e340 --- /dev/null +++ b/zephyr/dts/bindings/usbc/ppc/kinetic,ktu1125.yaml @@ -0,0 +1,5 @@ +description: USBC PPC + +compatible: "kinetic,ktu1125" + +include: ["i2c-device.yaml", "ppc-chip.yaml"] diff --git a/zephyr/shim/include/usbc/ppc.h b/zephyr/shim/include/usbc/ppc.h index 98e9c3f728..5889755bd2 100644 --- a/zephyr/shim/include/usbc/ppc.h +++ b/zephyr/shim/include/usbc/ppc.h @@ -7,6 +7,7 @@ #define ZEPHYR_CHROME_USBC_PPC_H #include "usbc/ppc_aoz1380.h" +#include "usbc/ppc_ktu1125.h" #include "usbc/ppc_nx20p348x.h" #include "usbc/ppc_rt1739.h" #include "usbc/ppc_sn5s330.h" @@ -61,6 +62,7 @@ * "is-alt" property set. */ DT_FOREACH_STATUS_OKAY(AOZ1380_COMPAT, PPC_ALT_DECLARE) +DT_FOREACH_STATUS_OKAY(KTU1125_COMPAT, PPC_ALT_DECLARE) DT_FOREACH_STATUS_OKAY(NX20P348X_COMPAT, PPC_ALT_DECLARE) DT_FOREACH_STATUS_OKAY(RT1739_PPC_COMPAT, PPC_ALT_DECLARE) DT_FOREACH_STATUS_OKAY(SN5S330_COMPAT, PPC_ALT_DECLARE) diff --git a/zephyr/shim/include/usbc/ppc_ktu1125.h b/zephyr/shim/include/usbc/ppc_ktu1125.h new file mode 100644 index 0000000000..4ca7caca83 --- /dev/null +++ b/zephyr/shim/include/usbc/ppc_ktu1125.h @@ -0,0 +1,14 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ppc/ktu1125_public.h" + +#define KTU1125_COMPAT kinetic_ktu1125 + +#define PPC_CHIP_KTU1125(id) \ + { \ + .i2c_port = I2C_PORT_BY_DEV(id), \ + .i2c_addr_flags = DT_REG_ADDR(id), .drv = &ktu1125_drv, \ + } diff --git a/zephyr/shim/src/ppc.c b/zephyr/shim/src/ppc.c index c25daf5392..ec5f2f26e1 100644 --- a/zephyr/shim/src/ppc.c +++ b/zephyr/shim/src/ppc.c @@ -5,6 +5,7 @@ #include "usbc/ppc.h" #include "usbc/ppc_aoz1380.h" +#include "usbc/ppc_ktu1125.h" #include "usbc/ppc_nx20p348x.h" #include "usbc/ppc_rt1739.h" #include "usbc/ppc_sn5s330.h" @@ -14,6 +15,7 @@ #include #if DT_HAS_COMPAT_STATUS_OKAY(AOZ1380_COMPAT) || \ + DT_HAS_COMPAT_STATUS_OKAY(KTU1125_COMPAT) || \ DT_HAS_COMPAT_STATUS_OKAY(NX20P348X_COMPAT) || \ DT_HAS_COMPAT_STATUS_OKAY(RT1739_PPC_COMPAT) || \ DT_HAS_COMPAT_STATUS_OKAY(SN5S330_COMPAT) || \ @@ -30,6 +32,7 @@ #define PPC_CHIP_FIND(usbc_id, ppc_id) \ CHECK_COMPAT(AOZ1380_COMPAT, usbc_id, ppc_id, PPC_CHIP_AOZ1380) \ + CHECK_COMPAT(KTU1125_COMPAT, usbc_id, ppc_id, PPC_CHIP_KTU1125) \ CHECK_COMPAT(NX20P348X_COMPAT, usbc_id, ppc_id, PPC_CHIP_NX20P348X) \ CHECK_COMPAT(RT1739_PPC_COMPAT, usbc_id, ppc_id, PPC_CHIP_RT1739) \ CHECK_COMPAT(SN5S330_COMPAT, usbc_id, ppc_id, PPC_CHIP_SN5S330) \ @@ -66,6 +69,7 @@ struct ppc_config_t ppc_chips_alt[] = { DT_FOREACH_STATUS_OKAY(named_usbc_port, * "is-alt" property set. */ DT_FOREACH_STATUS_OKAY_VARGS(AOZ1380_COMPAT, PPC_ALT_DEFINE, PPC_CHIP_AOZ1380) +DT_FOREACH_STATUS_OKAY_VARGS(KTU1125_COMPAT, PPC_ALT_DEFINE, PPC_CHIP_KTU1125) DT_FOREACH_STATUS_OKAY_VARGS(NX20P348X_COMPAT, PPC_ALT_DEFINE, PPC_CHIP_NX20P348X) DT_FOREACH_STATUS_OKAY_VARGS(RT1739_PPC_COMPAT, PPC_ALT_DEFINE, PPC_CHIP_RT1739) -- cgit v1.2.1