From 813f7256a5ebeb5c949183f963b3a0e30227afb1 Mon Sep 17 00:00:00 2001 From: Jun Lin Date: Tue, 8 Feb 2022 18:44:20 +0800 Subject: zephyr: npcx: add build time check for the hibernate DT node Nuvoton EC supports two hibernate mode: - PSL mode - non-PSL (disable RAM) mode The PSL mode uses the DT node vsby-psl-in-list to configure the PSL input wakeup pins. The non-PSL mode uses the DT node hibernate-wake-pins to configure the GPIO wakeup pins. This CL adds a build time assert to prevent a user from using the incorrect DT node for different mode. Also, add status = "okay" to the vsby-psl-in-list node because the status was disabled at default with PR:42668. BUG=b:216893756 BRANCH=none TEST=set "zmake testall --clobber" TEST=add "CONFIG_PLATFORM_EC_HIBERNATE_PSL=y" and define hibernate-wake-pins node in the prj.conf of npcx9_evb; see the build error. TEST=set "CONFIG_PLATFORM_EC_HIBERNATE_PSL=n" and define vsby-psl-in-list node in the prj.conf of npcx9_evb; see the build error. Signed-off-by: Jun Lin Change-Id: I83f4c3d427ef479445d5e5b992f53056da9bf1ef Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3449996 Reviewed-by: Wai-Hong Tam Reviewed-by: Keith Short Tested-by: Keith Short Commit-Queue: Keith Short --- zephyr/boards/arm/brya/brya.dts | 1 + zephyr/boards/arm/npcx_evb/npcx_evb.dtsi | 16 ---------------- zephyr/boards/arm/volteer/volteer.dts | 1 + zephyr/drivers/cros_system/cros_system_npcx.c | 10 ++++++++++ zephyr/projects/herobrine/gpio.dts | 1 + zephyr/projects/skyrim/gpio.dts | 1 + 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/zephyr/boards/arm/brya/brya.dts b/zephyr/boards/arm/brya/brya.dts index 2220d983e9..db7f35cc26 100644 --- a/zephyr/boards/arm/brya/brya.dts +++ b/zephyr/boards/arm/brya/brya.dts @@ -170,6 +170,7 @@ vsby-psl-in-list { /* Use PSL_IN1/2/3 as detection pins from hibernate mode */ psl-in-pads = <&psl_in1 &psl_in2 &psl_in3>; + status = "okay"; }; def-lvol-io-list { diff --git a/zephyr/boards/arm/npcx_evb/npcx_evb.dtsi b/zephyr/boards/arm/npcx_evb/npcx_evb.dtsi index 23f0e06345..b49be6222c 100644 --- a/zephyr/boards/arm/npcx_evb/npcx_evb.dtsi +++ b/zephyr/boards/arm/npcx_evb/npcx_evb.dtsi @@ -71,11 +71,6 @@ io-channels = <&adc0 4>; }; }; - - vsby-psl-in-list { - /* Use PSL_IN1/2/3 as detection pins from hibernate mode */ - psl-in-pads = <&psl_in1 &psl_in2 &psl_in3>; - }; }; &i2c0_0 { @@ -127,17 +122,6 @@ status = "okay"; }; -/* Power switch logic input pads */ -&psl_in1 { - flag = ; -}; -&psl_in2 { - flag = ; -}; -&psl_in3 { - flag = ; -}; - &cros_kb_raw { status = "okay"; pinctrl-0 = <&alt7_no_ksi0_sl diff --git a/zephyr/boards/arm/volteer/volteer.dts b/zephyr/boards/arm/volteer/volteer.dts index 227e940721..c6623f22dc 100644 --- a/zephyr/boards/arm/volteer/volteer.dts +++ b/zephyr/boards/arm/volteer/volteer.dts @@ -169,6 +169,7 @@ vsby-psl-in-list { /* Use PSL_IN1/2/3/4 as detection pins from hibernate mode */ psl-in-pads = <&psl_in1 &psl_in2 &psl_in3 &psl_in4>; + status = "okay"; }; /* diff --git a/zephyr/drivers/cros_system/cros_system_npcx.c b/zephyr/drivers/cros_system/cros_system_npcx.c index 472f32ab33..b000eeec4d 100644 --- a/zephyr/drivers/cros_system/cros_system_npcx.c +++ b/zephyr/drivers/cros_system/cros_system_npcx.c @@ -502,6 +502,16 @@ static int cros_system_npcx_soc_reset(const struct device *dev) return 0; } +#if defined(CONFIG_PLATFORM_EC_HIBERNATE_PSL) +#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_hibernate_wake_pins) +#error "cros-ec,hibernate-wake-pins cannot be used with HIBERNATE_PSL" +#endif +#else +#if DT_HAS_COMPAT_STATUS_OKAY(nuvoton_npcx_pslctrl_def) +#error "vsby-psl-in-list cannot be used with non-HIBERNATE_PSL" +#endif +#endif + static int cros_system_npcx_hibernate(const struct device *dev, uint32_t seconds, uint32_t microseconds) { diff --git a/zephyr/projects/herobrine/gpio.dts b/zephyr/projects/herobrine/gpio.dts index 796610aa26..59211b75d3 100644 --- a/zephyr/projects/herobrine/gpio.dts +++ b/zephyr/projects/herobrine/gpio.dts @@ -243,6 +243,7 @@ vsby-psl-in-list { /* Use PSL_IN1/2/3/4 as detection pins from hibernate mode */ psl-in-pads = <&psl_in1 &psl_in2 &psl_in3 &psl_in4>; + status = "okay"; }; sku { diff --git a/zephyr/projects/skyrim/gpio.dts b/zephyr/projects/skyrim/gpio.dts index 9aca859395..63dc8510fc 100644 --- a/zephyr/projects/skyrim/gpio.dts +++ b/zephyr/projects/skyrim/gpio.dts @@ -188,6 +188,7 @@ vsby-psl-in-list { /* PSL_IN1/2/4 are used to wake */ psl-in-pads = <&psl_in1 &psl_in2 &psl_in4>; + status = "okay"; }; named-ioexes { -- cgit v1.2.1