tests/pwm: enable PWM case to work on D2000 board
This test case uses PWM0 port to test PWM on Quark Se.
However PWM0 port on Quark D2000 is initialized as tdo,
not PWM0 and disabling tdo will kill JTAG on D2000. So
use PWM1 and add PINMUX setting code to configure PIN_24
as PWM1 port, then the case will work on D2000 board.
Change-Id: Ib28d4750dac7396529388b781fb64bde048139d6
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
diff --git a/tests/drivers/pwm/pwm_api/Makefile b/tests/drivers/pwm/pwm_api/Makefile
index 0e0de3a..ff37b7c 100644
--- a/tests/drivers/pwm/pwm_api/Makefile
+++ b/tests/drivers/pwm/pwm_api/Makefile
@@ -1,4 +1,4 @@
BOARD ?= quark_se_c1000_devboard
-CONF_FILE = prj.conf
+CONF_FILE ?= prj.conf
include ${ZEPHYR_BASE}/Makefile.test
diff --git a/tests/drivers/pwm/pwm_api/prj_d2000.conf b/tests/drivers/pwm/pwm_api/prj_d2000.conf
new file mode 100644
index 0000000..78d0dc0
--- /dev/null
+++ b/tests/drivers/pwm/pwm_api/prj_d2000.conf
@@ -0,0 +1,4 @@
+CONFIG_PWM=y
+CONFIG_PINMUX=y
+CONFIG_PWM_QMSI_NUM_PORTS=2
+CONFIG_ZTEST=y
diff --git a/tests/drivers/pwm/pwm_api/src/test_pwm.c b/tests/drivers/pwm/pwm_api/src/test_pwm.c
index 8881e04..3d1b195 100644
--- a/tests/drivers/pwm/pwm_api/src/test_pwm.c
+++ b/tests/drivers/pwm/pwm_api/src/test_pwm.c
@@ -12,7 +12,7 @@
* through usec or cycle.
* @details
* - Test Steps
- * -# Bind PWM port 0.
+ * -# Bind PWM_0 port 0 (This case uses port 1 on D2000).
* -# Set PWM period and pulse using pwm_pin_set_cycles() or
* pwm_pin_set_usec().
* -# Use multimeter or other instruments to measure the output
@@ -34,12 +34,20 @@
#define PWM_DEV_NAME CONFIG_PWM_QMSI_DEV_NAME
-#define DEFAULT_PWM_PORT 0
#define DEFAULT_PERIOD_CYCLE 64000
#define DEFAULT_PULSE_CYCLE 32000
#define DEFAULT_PERIOD_USEC 2000
#define DEFAULT_PULSE_USEC 1000
+#ifdef CONFIG_BOARD_QUARK_D2000_CRB
+#include <pinmux.h>
+#define PINMUX_NAME CONFIG_PINMUX_NAME
+#define PWM1_PIN 24
+#define DEFAULT_PWM_PORT 1
+#else
+#define DEFAULT_PWM_PORT 0
+#endif
+
static int test_task(uint32_t port, uint32_t period, uint32_t pulse, bool cycle)
{
TC_PRINT("[PWM]: %" PRIu8 ", [period]: %" PRIu32 ", [pulse]: %" PRIu32 "\n",
@@ -52,6 +60,32 @@
return TC_FAIL;
}
+#ifdef CONFIG_BOARD_QUARK_D2000_CRB
+ struct device *pinmux = device_get_binding(PINMUX_NAME);
+ uint32_t function;
+
+ if (!pinmux) {
+ TC_PRINT("Cannot get PINMUX\n");
+ return TC_FAIL;
+ }
+
+ if (pinmux_pin_set(pinmux, PWM1_PIN, PINMUX_FUNC_C)) {
+ TC_PRINT("Fail to set pin func, %u : %u\n",
+ PWM1_PIN, PINMUX_FUNC_C);
+ return TC_FAIL;
+ }
+
+ if (pinmux_pin_get(pinmux, PWM1_PIN, &function)) {
+ TC_PRINT("Fail to get pin func\n");
+ return TC_FAIL;
+ }
+
+ if (function != PINMUX_FUNC_C) {
+ TC_PRINT("Error. PINMUX get doesn't match PINMUX set\n");
+ return TC_FAIL;
+ }
+#endif
+
if (cycle) {
/* Verify pwm_pin_set_cycles() */
if (pwm_pin_set_cycles(pwm_dev, port, period, pulse)) {
diff --git a/tests/drivers/pwm/pwm_api/testcase.ini b/tests/drivers/pwm/pwm_api/testcase.ini
index 8ae84e7..68b206b 100644
--- a/tests/drivers/pwm/pwm_api/testcase.ini
+++ b/tests/drivers/pwm/pwm_api/testcase.ini
@@ -1,3 +1,8 @@
[test_pwm]
tags = drivers
-platform_whitelist = quark_se_c1000_devboard quark_se_c1000_ss_devboard_quark_d2000_crb arduino_101 arduino_101_sss
+platform_whitelist = quark_se_c1000_devboard quark_se_c1000_ss_devboard arduino_101 arduino_101_sss
+
+[test_pwm_d2000_crb]
+tags = drivers
+extra_args = CONF_FILE=prj_d2000.conf
+platform_whitelist = quark_d2000_crb