1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * Test for pwm command 4 * 5 * Copyright 2020 SiFive, Inc 6 * 7 * Authors: 8 * Pragnesh Patel <pragnesh.patel@sifive.com> 9 */ 10 11 #include <dm.h> 12 #include <dm/test.h> 13 #include <test/test.h> 14 #include <test/ut.h> 15 16 /* Basic test of 'pwm' command */ dm_test_pwm_cmd(struct unit_test_state * uts)17static int dm_test_pwm_cmd(struct unit_test_state *uts) 18 { 19 struct udevice *dev; 20 21 ut_assertok(uclass_get_device(UCLASS_PWM, 0, &dev)); 22 ut_assertnonnull(dev); 23 24 ut_assertok(console_record_reset_enable()); 25 26 /* pwm <invert> <pwm_dev_num> <channel> <polarity> */ 27 ut_assertok(run_command("pwm invert 0 0 1", 0)); 28 ut_assert_console_end(); 29 30 ut_assertok(run_command("pwm invert 0 0 0", 0)); 31 ut_assert_console_end(); 32 33 /* pwm <config> <pwm_dev_num> <channel> <period_ns> <duty_ns> */ 34 ut_assertok(run_command("pwm config 0 0 10 50", 0)); 35 ut_assert_console_end(); 36 37 /* pwm <enable/disable> <pwm_dev_num> <channel> */ 38 ut_assertok(run_command("pwm enable 0 0", 0)); 39 ut_assert_console_end(); 40 41 ut_assertok(run_command("pwm disable 0 0", 0)); 42 ut_assert_console_end(); 43 44 return 0; 45 } 46 47 DM_TEST(dm_test_pwm_cmd, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC); 48