summaryrefslogtreecommitdiff
path: root/zephyr/projects/npcx_evb
diff options
context:
space:
mode:
authorWealian Liao <whliao@nuvoton.corp-partner.google.com>2021-07-06 10:59:58 +0800
committerCommit Bot <commit-bot@chromium.org>2021-07-30 17:56:00 +0000
commit5f8e59c305bd8f9497a7409a0d27e034896e4038 (patch)
tree1c69569347dc40d55eebd9c7ab66a1e78e5346f4 /zephyr/projects/npcx_evb
parent7bf38c623e11a98c24aa28ed9cb5c08516a7853b (diff)
downloadchrome-ec-5f8e59c305bd8f9497a7409a0d27e034896e4038.tar.gz
zephyr: npcx_evb: Enable PWM
This CL enables 2 PWM channels for npcx7/9_evb. BRANCH=none BUG=none TEST='pwmduty' console command & check the output waveform is correct. ``` uart:~$ pwmduty PWM channels: 0: 50% 1: 25% ``` Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: I6fa5d3b7fd3bf1f9d1fdb3f64ca3488ad3addacc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3063104 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr/projects/npcx_evb')
-rw-r--r--zephyr/projects/npcx_evb/npcx7/include/pwm_map.h16
-rw-r--r--zephyr/projects/npcx_evb/npcx7/prj.conf3
-rw-r--r--zephyr/projects/npcx_evb/npcx7/pwm.dts32
-rw-r--r--zephyr/projects/npcx_evb/npcx7/zmake.yaml1
-rw-r--r--zephyr/projects/npcx_evb/npcx9/include/pwm_map.h16
-rw-r--r--zephyr/projects/npcx_evb/npcx9/prj.conf3
-rw-r--r--zephyr/projects/npcx_evb/npcx9/pwm.dts32
-rw-r--r--zephyr/projects/npcx_evb/npcx9/zmake.yaml1
8 files changed, 104 insertions, 0 deletions
diff --git a/zephyr/projects/npcx_evb/npcx7/include/pwm_map.h b/zephyr/projects/npcx_evb/npcx7/include/pwm_map.h
new file mode 100644
index 0000000000..371e95c116
--- /dev/null
+++ b/zephyr/projects/npcx_evb/npcx7/include/pwm_map.h
@@ -0,0 +1,16 @@
+/* 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.
+ */
+
+#ifndef __ZEPHYR_PWM_MAP_H
+#define __ZEPHYR_PWM_MAP_H
+
+#include <devicetree.h>
+
+#include "pwm/pwm.h"
+
+#define PWM_CH_FAN NAMED_PWM(fan)
+#define PWM_CH_KBLIGHT NAMED_PWM(kblight)
+
+#endif /* __ZEPHYR_PWM_MAP_H */
diff --git a/zephyr/projects/npcx_evb/npcx7/prj.conf b/zephyr/projects/npcx_evb/npcx7/prj.conf
index 16a01208e9..4b49332a6d 100644
--- a/zephyr/projects/npcx_evb/npcx7/prj.conf
+++ b/zephyr/projects/npcx_evb/npcx7/prj.conf
@@ -21,6 +21,9 @@ CONFIG_PLATFORM_EC_VSTORE=n
# Board version is selected over GPIO board ID pins.
CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y
+# PWM
+CONFIG_PLATFORM_EC_PWM=y
+
# Zephyr feature
CONFIG_ASSERT=y
CONFIG_SHELL_MINIMAL=n
diff --git a/zephyr/projects/npcx_evb/npcx7/pwm.dts b/zephyr/projects/npcx_evb/npcx7/pwm.dts
new file mode 100644
index 0000000000..3b7b88c235
--- /dev/null
+++ b/zephyr/projects/npcx_evb/npcx7/pwm.dts
@@ -0,0 +1,32 @@
+/* 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-pwms {
+ compatible = "named-pwms";
+
+ fan {
+ pwms = <&pwm0 0 0>;
+ label = "FAN";
+ frequency = <25000>;
+ };
+ kblight {
+ pwms = <&pwm2 0 0>;
+ label = "KBLIGHT";
+ frequency = <10000>;
+ };
+ };
+};
+
+/* fan */
+&pwm0 {
+ status = "okay";
+ drive-open-drain;
+};
+
+/* kblight */
+&pwm2 {
+ status = "okay";
+};
diff --git a/zephyr/projects/npcx_evb/npcx7/zmake.yaml b/zephyr/projects/npcx_evb/npcx7/zmake.yaml
index 10cb8dffb7..710e0a7568 100644
--- a/zephyr/projects/npcx_evb/npcx7/zmake.yaml
+++ b/zephyr/projects/npcx_evb/npcx7/zmake.yaml
@@ -5,6 +5,7 @@
board: npcx7_evb
dts-overlays:
- gpio.dts
+ - pwm.dts
supported-zephyr-versions:
- v2.6
toolchain: coreboot-sdk
diff --git a/zephyr/projects/npcx_evb/npcx9/include/pwm_map.h b/zephyr/projects/npcx_evb/npcx9/include/pwm_map.h
new file mode 100644
index 0000000000..371e95c116
--- /dev/null
+++ b/zephyr/projects/npcx_evb/npcx9/include/pwm_map.h
@@ -0,0 +1,16 @@
+/* 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.
+ */
+
+#ifndef __ZEPHYR_PWM_MAP_H
+#define __ZEPHYR_PWM_MAP_H
+
+#include <devicetree.h>
+
+#include "pwm/pwm.h"
+
+#define PWM_CH_FAN NAMED_PWM(fan)
+#define PWM_CH_KBLIGHT NAMED_PWM(kblight)
+
+#endif /* __ZEPHYR_PWM_MAP_H */
diff --git a/zephyr/projects/npcx_evb/npcx9/prj.conf b/zephyr/projects/npcx_evb/npcx9/prj.conf
index 98474940ba..e124930bfc 100644
--- a/zephyr/projects/npcx_evb/npcx9/prj.conf
+++ b/zephyr/projects/npcx_evb/npcx9/prj.conf
@@ -25,6 +25,9 @@ CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y
# Board version is selected over GPIO board ID pins.
CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y
+# PWM
+CONFIG_PLATFORM_EC_PWM=y
+
# Zephyr feature
CONFIG_ASSERT=y
CONFIG_SHELL_MINIMAL=n
diff --git a/zephyr/projects/npcx_evb/npcx9/pwm.dts b/zephyr/projects/npcx_evb/npcx9/pwm.dts
new file mode 100644
index 0000000000..3b7b88c235
--- /dev/null
+++ b/zephyr/projects/npcx_evb/npcx9/pwm.dts
@@ -0,0 +1,32 @@
+/* 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-pwms {
+ compatible = "named-pwms";
+
+ fan {
+ pwms = <&pwm0 0 0>;
+ label = "FAN";
+ frequency = <25000>;
+ };
+ kblight {
+ pwms = <&pwm2 0 0>;
+ label = "KBLIGHT";
+ frequency = <10000>;
+ };
+ };
+};
+
+/* fan */
+&pwm0 {
+ status = "okay";
+ drive-open-drain;
+};
+
+/* kblight */
+&pwm2 {
+ status = "okay";
+};
diff --git a/zephyr/projects/npcx_evb/npcx9/zmake.yaml b/zephyr/projects/npcx_evb/npcx9/zmake.yaml
index 5aaa630542..29443aba14 100644
--- a/zephyr/projects/npcx_evb/npcx9/zmake.yaml
+++ b/zephyr/projects/npcx_evb/npcx9/zmake.yaml
@@ -5,6 +5,7 @@
board: npcx9_evb
dts-overlays:
- gpio.dts
+ - pwm.dts
supported-zephyr-versions:
- v2.6
toolchain: coreboot-sdk