summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTing Shen <phoenixshen@google.com>2022-09-27 17:48:00 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-30 07:01:02 +0000
commit59e3c50db4dfc3538c357a5207f90bf5678bae82 (patch)
tree3ec682e0769fa8ad96bf0cbb693e628d792343c2
parent6f52fb294a8b0e5fb1d2aadad5e3c3b24911a9d0 (diff)
downloadchrome-ec-59e3c50db4dfc3538c357a5207f90bf5678bae82.tar.gz
zephyr: add ppc emulators to the shim
For auto generate ppc_chips array from device tree in test code. BUG=none TEST=./twister -T zephyr/test/drivers/ BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: Ida472578194448c1482da5fda29b7a2a08c0b57e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3920231 Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Yuval Peress <peress@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r--zephyr/shim/include/usbc/ppc_sn5s330.h1
-rw-r--r--zephyr/shim/include/usbc/ppc_syv682x.h1
-rw-r--r--zephyr/shim/src/ppc.c26
-rw-r--r--zephyr/test/drivers/boards/native_posix.overlay2
-rw-r--r--zephyr/test/drivers/common/src/stubs.c17
5 files changed, 19 insertions, 28 deletions
diff --git a/zephyr/shim/include/usbc/ppc_sn5s330.h b/zephyr/shim/include/usbc/ppc_sn5s330.h
index ecbcb53deb..2b70d69e64 100644
--- a/zephyr/shim/include/usbc/ppc_sn5s330.h
+++ b/zephyr/shim/include/usbc/ppc_sn5s330.h
@@ -6,6 +6,7 @@
#include "ppc/sn5s330_public.h"
#define SN5S330_COMPAT ti_sn5s330
+#define SN5S330_EMUL_COMPAT cros_sn5s330_emul
#define PPC_CHIP_SN5S330(id) \
{ .i2c_port = I2C_PORT_BY_DEV(id), \
diff --git a/zephyr/shim/include/usbc/ppc_syv682x.h b/zephyr/shim/include/usbc/ppc_syv682x.h
index 33813a5256..9924e6da5e 100644
--- a/zephyr/shim/include/usbc/ppc_syv682x.h
+++ b/zephyr/shim/include/usbc/ppc_syv682x.h
@@ -6,6 +6,7 @@
#include "ppc/syv682x_public.h"
#define SYV682X_COMPAT silergy_syv682x
+#define SYV682X_EMUL_COMPAT zephyr_syv682x_emul
#define PPC_CHIP_SYV682X(id) \
{ \
diff --git a/zephyr/shim/src/ppc.c b/zephyr/shim/src/ppc.c
index 87161407ae..c4c54d002f 100644
--- a/zephyr/shim/src/ppc.c
+++ b/zephyr/shim/src/ppc.c
@@ -12,11 +12,13 @@
#include "usbc/ppc_syv682x.h"
#include "usbc/ppc.h"
-#if DT_HAS_COMPAT_STATUS_OKAY(AOZ1380_COMPAT) || \
- DT_HAS_COMPAT_STATUS_OKAY(NX20P348X_COMPAT) || \
- DT_HAS_COMPAT_STATUS_OKAY(RT1739_PPC_COMPAT) || \
- DT_HAS_COMPAT_STATUS_OKAY(SN5S330_COMPAT) || \
- DT_HAS_COMPAT_STATUS_OKAY(SYV682X_COMPAT)
+#if DT_HAS_COMPAT_STATUS_OKAY(AOZ1380_COMPAT) || \
+ DT_HAS_COMPAT_STATUS_OKAY(NX20P348X_COMPAT) || \
+ DT_HAS_COMPAT_STATUS_OKAY(RT1739_PPC_COMPAT) || \
+ DT_HAS_COMPAT_STATUS_OKAY(SN5S330_COMPAT) || \
+ DT_HAS_COMPAT_STATUS_OKAY(SN5S330_EMUL_COMPAT) || \
+ DT_HAS_COMPAT_STATUS_OKAY(SYV682X_COMPAT) || \
+ DT_HAS_COMPAT_STATUS_OKAY(SYV682X_EMUL_COMPAT)
#define PPC_CHIP_ENTRY(usbc_id, ppc_id, config_fn) \
[USBC_PORT_NEW(usbc_id)] = config_fn(ppc_id)
@@ -25,12 +27,14 @@
COND_CODE_1(DT_NODE_HAS_COMPAT(ppc_id, compat), \
(PPC_CHIP_ENTRY(usbc_id, ppc_id, config_fn)), ())
-#define PPC_CHIP_FIND(usbc_id, ppc_id) \
- CHECK_COMPAT(AOZ1380_COMPAT, usbc_id, ppc_id, PPC_CHIP_AOZ1380) \
- 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) \
- CHECK_COMPAT(SYV682X_COMPAT, usbc_id, ppc_id, PPC_CHIP_SYV682X)
+#define PPC_CHIP_FIND(usbc_id, ppc_id) \
+ CHECK_COMPAT(AOZ1380_COMPAT, usbc_id, ppc_id, PPC_CHIP_AOZ1380) \
+ 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) \
+ CHECK_COMPAT(SN5S330_EMUL_COMPAT, usbc_id, ppc_id, PPC_CHIP_SN5S330) \
+ CHECK_COMPAT(SYV682X_COMPAT, usbc_id, ppc_id, PPC_CHIP_SYV682X) \
+ CHECK_COMPAT(SYV682X_EMUL_COMPAT, usbc_id, ppc_id, PPC_CHIP_SYV682X)
#define PPC_CHIP(usbc_id) \
COND_CODE_1(DT_NODE_HAS_PROP(usbc_id, ppc), \
diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay
index dca217e181..231a3714aa 100644
--- a/zephyr/test/drivers/boards/native_posix.overlay
+++ b/zephyr/test/drivers/boards/native_posix.overlay
@@ -37,12 +37,14 @@
reg = <0>;
chg = <&isl923x_emul>;
tcpc = <&tcpci_emul>;
+ ppc = <&sn5s330_emul>;
};
port1@1 {
compatible = "named-usbc-port";
reg = <1>;
tcpc = <&ps8xxx_emul>;
+ ppc = <&syv682x_emul>;
};
};
diff --git a/zephyr/test/drivers/common/src/stubs.c b/zephyr/test/drivers/common/src/stubs.c
index 2683b326a8..57f4847ffa 100644
--- a/zephyr/test/drivers/common/src/stubs.c
+++ b/zephyr/test/drivers/common/src/stubs.c
@@ -220,23 +220,6 @@ int pd_set_power_supply_ready(int port)
return EC_SUCCESS;
}
-/* USBC PPC configuration */
-struct ppc_config_t ppc_chips[] = {
- [USBC_PORT_C0] = {
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = SN5S330_ADDR0_FLAGS,
- .drv = &sn5s330_drv,
- },
- [USBC_PORT_C1] = {
- .i2c_port = I2C_PORT_USB_C1,
- .i2c_addr_flags = SYV682X_ADDR1_FLAGS,
- .frs_en = GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c1_frs_en)),
- .drv = &syv682x_drv,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == USBC_PORT_COUNT);
-unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
-
DEFINE_FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t);
DEFINE_FAKE_VOID_FUNC(board_reset_pd_mcu);