summaryrefslogtreecommitdiff
path: root/zephyr
diff options
context:
space:
mode:
authorWealian Liao <whliao@nuvoton.corp-partner.google.com>2021-07-06 14:24:44 +0800
committerCommit Bot <commit-bot@chromium.org>2021-08-02 23:09:47 +0000
commit81ea35f9c0ca50aa3c7013beaf8cd4decd821fc3 (patch)
tree350c986ba5b76f0bb35380dcdc202c1f008b6496 /zephyr
parent01cf7dd4c94a48cde96f5578f53026c85d2e1fa7 (diff)
downloadchrome-ec-81ea35f9c0ca50aa3c7013beaf8cd4decd821fc3.tar.gz
zephyr: npcx_evb: Enable fan
This CL enables fan functionality for npcx7/9_evb BUG=none BRANCH=none TEST='fanset', 'fanduty', 'faninfo' console command ``` uart:~$ fanset 50% Fan rpm given as 50% Setting fan 0 rpm target to 3078 uart:~$ faninfo Actual: 2943 rpm Target: 3078 rpm Duty: 38% Status: 2 (locked) Mode: rpm Auto: no Enable: yes Power: yes ``` Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: I836e1dd62a712bac887d4d12d34541c8c8043a83 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3063105 Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr')
-rw-r--r--zephyr/dts/bindings/gpio/gpio-enum-name.yaml1
-rw-r--r--zephyr/projects/npcx_evb/npcx7/fan.dts29
-rw-r--r--zephyr/projects/npcx_evb/npcx7/gpio.dts3
-rw-r--r--zephyr/projects/npcx_evb/npcx7/prj.conf8
-rw-r--r--zephyr/projects/npcx_evb/npcx7/pwm.dts2
-rw-r--r--zephyr/projects/npcx_evb/npcx7/zmake.yaml1
-rw-r--r--zephyr/projects/npcx_evb/npcx9/fan.dts29
-rw-r--r--zephyr/projects/npcx_evb/npcx9/gpio.dts3
-rw-r--r--zephyr/projects/npcx_evb/npcx9/prj.conf8
-rw-r--r--zephyr/projects/npcx_evb/npcx9/pwm.dts2
-rw-r--r--zephyr/projects/npcx_evb/npcx9/zmake.yaml1
11 files changed, 83 insertions, 4 deletions
diff --git a/zephyr/dts/bindings/gpio/gpio-enum-name.yaml b/zephyr/dts/bindings/gpio/gpio-enum-name.yaml
index 82e9e1b5ab..aa4a01dd3d 100644
--- a/zephyr/dts/bindings/gpio/gpio-enum-name.yaml
+++ b/zephyr/dts/bindings/gpio/gpio-enum-name.yaml
@@ -109,6 +109,7 @@ properties:
- GPIO_PG_MT6315_GPU_ODL
- GPIO_PG_MT6315_PROC_ODL
- GPIO_PG_PP5000_A_ODL
+ - GPIO_PGOOD_FAN
- GPIO_PMIC_EC_PWRGD
- GPIO_PMIC_KPD_PWR_ODL
- GPIO_PMIC_RESIN_L
diff --git a/zephyr/projects/npcx_evb/npcx7/fan.dts b/zephyr/projects/npcx_evb/npcx7/fan.dts
new file mode 100644
index 0000000000..de2852d73a
--- /dev/null
+++ b/zephyr/projects/npcx_evb/npcx7/fan.dts
@@ -0,0 +1,29 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ named-fans {
+ compatible = "named-fans";
+
+ fan_0 {
+ label = "FAN_0";
+ pwm = <&pwm_fan>;
+ rpm_min = <1000>;
+ rpm_start = <1000>;
+ rpm_max = <5200>;
+ tach = <&tach1>;
+ pgood_gpio = <&gpio_pgood_fan>;
+ };
+ };
+};
+
+/* Tachometer for fan speed measurement */
+&tach1 {
+ status = "okay";
+ pinctrl-0 = <&alt3_ta1_sl1>; /* Use TA1 as input pin */
+ port = <NPCX_TACH_PORT_A>; /* port-A is selected */
+ sample-clk = <NPCX_TACH_FREQ_LFCLK>; /* Use LFCLK as sampling clock */
+ pulses-per-round = <2>; /* number of pulses per round of encoder */
+};
diff --git a/zephyr/projects/npcx_evb/npcx7/gpio.dts b/zephyr/projects/npcx_evb/npcx7/gpio.dts
index 15f2c28a5d..51b58c5392 100644
--- a/zephyr/projects/npcx_evb/npcx7/gpio.dts
+++ b/zephyr/projects/npcx_evb/npcx7/gpio.dts
@@ -40,8 +40,9 @@
gpios = <&gpio5 0 GPIO_OUT_HIGH>;
label = "PCH_WAKE_L";
};
- pgood_fan {
+ gpio_pgood_fan: pgood_fan {
gpios = <&gpioc 7 (GPIO_INPUT | GPIO_PULL_UP)>;
+ enum-name = "GPIO_PGOOD_FAN";
label = "PGOOD_FAN";
};
spi_cs_l {
diff --git a/zephyr/projects/npcx_evb/npcx7/prj.conf b/zephyr/projects/npcx_evb/npcx7/prj.conf
index 4b49332a6d..350a9555a5 100644
--- a/zephyr/projects/npcx_evb/npcx7/prj.conf
+++ b/zephyr/projects/npcx_evb/npcx7/prj.conf
@@ -24,7 +24,15 @@ CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y
# PWM
CONFIG_PLATFORM_EC_PWM=y
+# Fan
+CONFIG_SENSOR=y
+CONFIG_SENSOR_SHELL=n
+CONFIG_PLATFORM_EC_FAN=y
+
# Zephyr feature
CONFIG_ASSERT=y
CONFIG_SHELL_MINIMAL=n
CONFIG_LOG=y
+
+# Avoid underflow info from tachometer
+CONFIG_SENSOR_LOG_LEVEL_ERR=y
diff --git a/zephyr/projects/npcx_evb/npcx7/pwm.dts b/zephyr/projects/npcx_evb/npcx7/pwm.dts
index 3b7b88c235..144b4d96b9 100644
--- a/zephyr/projects/npcx_evb/npcx7/pwm.dts
+++ b/zephyr/projects/npcx_evb/npcx7/pwm.dts
@@ -7,7 +7,7 @@
named-pwms {
compatible = "named-pwms";
- fan {
+ pwm_fan: fan {
pwms = <&pwm0 0 0>;
label = "FAN";
frequency = <25000>;
diff --git a/zephyr/projects/npcx_evb/npcx7/zmake.yaml b/zephyr/projects/npcx_evb/npcx7/zmake.yaml
index 710e0a7568..5c74307019 100644
--- a/zephyr/projects/npcx_evb/npcx7/zmake.yaml
+++ b/zephyr/projects/npcx_evb/npcx7/zmake.yaml
@@ -6,6 +6,7 @@ board: npcx7_evb
dts-overlays:
- gpio.dts
- pwm.dts
+ - fan.dts
supported-zephyr-versions:
- v2.6
toolchain: coreboot-sdk
diff --git a/zephyr/projects/npcx_evb/npcx9/fan.dts b/zephyr/projects/npcx_evb/npcx9/fan.dts
new file mode 100644
index 0000000000..de2852d73a
--- /dev/null
+++ b/zephyr/projects/npcx_evb/npcx9/fan.dts
@@ -0,0 +1,29 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ named-fans {
+ compatible = "named-fans";
+
+ fan_0 {
+ label = "FAN_0";
+ pwm = <&pwm_fan>;
+ rpm_min = <1000>;
+ rpm_start = <1000>;
+ rpm_max = <5200>;
+ tach = <&tach1>;
+ pgood_gpio = <&gpio_pgood_fan>;
+ };
+ };
+};
+
+/* Tachometer for fan speed measurement */
+&tach1 {
+ status = "okay";
+ pinctrl-0 = <&alt3_ta1_sl1>; /* Use TA1 as input pin */
+ port = <NPCX_TACH_PORT_A>; /* port-A is selected */
+ sample-clk = <NPCX_TACH_FREQ_LFCLK>; /* Use LFCLK as sampling clock */
+ pulses-per-round = <2>; /* number of pulses per round of encoder */
+};
diff --git a/zephyr/projects/npcx_evb/npcx9/gpio.dts b/zephyr/projects/npcx_evb/npcx9/gpio.dts
index 15f2c28a5d..51b58c5392 100644
--- a/zephyr/projects/npcx_evb/npcx9/gpio.dts
+++ b/zephyr/projects/npcx_evb/npcx9/gpio.dts
@@ -40,8 +40,9 @@
gpios = <&gpio5 0 GPIO_OUT_HIGH>;
label = "PCH_WAKE_L";
};
- pgood_fan {
+ gpio_pgood_fan: pgood_fan {
gpios = <&gpioc 7 (GPIO_INPUT | GPIO_PULL_UP)>;
+ enum-name = "GPIO_PGOOD_FAN";
label = "PGOOD_FAN";
};
spi_cs_l {
diff --git a/zephyr/projects/npcx_evb/npcx9/prj.conf b/zephyr/projects/npcx_evb/npcx9/prj.conf
index e124930bfc..d7fcd3ea69 100644
--- a/zephyr/projects/npcx_evb/npcx9/prj.conf
+++ b/zephyr/projects/npcx_evb/npcx9/prj.conf
@@ -28,7 +28,15 @@ CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y
# PWM
CONFIG_PLATFORM_EC_PWM=y
+# Fan
+CONFIG_SENSOR=y
+CONFIG_SENSOR_SHELL=n
+CONFIG_PLATFORM_EC_FAN=y
+
# Zephyr feature
CONFIG_ASSERT=y
CONFIG_SHELL_MINIMAL=n
CONFIG_LOG=y
+
+# Avoid underflow info from tachometer
+CONFIG_SENSOR_LOG_LEVEL_ERR=y
diff --git a/zephyr/projects/npcx_evb/npcx9/pwm.dts b/zephyr/projects/npcx_evb/npcx9/pwm.dts
index 3b7b88c235..144b4d96b9 100644
--- a/zephyr/projects/npcx_evb/npcx9/pwm.dts
+++ b/zephyr/projects/npcx_evb/npcx9/pwm.dts
@@ -7,7 +7,7 @@
named-pwms {
compatible = "named-pwms";
- fan {
+ pwm_fan: fan {
pwms = <&pwm0 0 0>;
label = "FAN";
frequency = <25000>;
diff --git a/zephyr/projects/npcx_evb/npcx9/zmake.yaml b/zephyr/projects/npcx_evb/npcx9/zmake.yaml
index 29443aba14..98fb09c5a0 100644
--- a/zephyr/projects/npcx_evb/npcx9/zmake.yaml
+++ b/zephyr/projects/npcx_evb/npcx9/zmake.yaml
@@ -6,6 +6,7 @@ board: npcx9_evb
dts-overlays:
- gpio.dts
- pwm.dts
+ - fan.dts
supported-zephyr-versions:
- v2.6
toolchain: coreboot-sdk