Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 43b4156 | 2017-04-16 21:01:11 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2017 Google, Inc |
Simon Glass | 43b4156 | 2017-04-16 21:01:11 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
| 8 | #include <pwm.h> |
| 9 | #include <dm/test.h> |
Simon Glass | 0e1fad4 | 2020-07-19 10:15:37 -0600 | [diff] [blame] | 10 | #include <test/test.h> |
Simon Glass | 43b4156 | 2017-04-16 21:01:11 -0600 | [diff] [blame] | 11 | #include <test/ut.h> |
| 12 | |
Simon Glass | 43b4156 | 2017-04-16 21:01:11 -0600 | [diff] [blame] | 13 | /* Basic test of the pwm uclass */ |
| 14 | static int dm_test_pwm_base(struct unit_test_state *uts) |
| 15 | { |
| 16 | struct udevice *dev; |
| 17 | |
| 18 | ut_assertok(uclass_get_device(UCLASS_PWM, 0, &dev)); |
Simon Glass | 1a596c4 | 2017-06-07 10:28:38 -0600 | [diff] [blame] | 19 | ut_assertnonnull(dev); |
Simon Glass | 43b4156 | 2017-04-16 21:01:11 -0600 | [diff] [blame] | 20 | ut_assertok(pwm_set_config(dev, 0, 100, 50)); |
| 21 | ut_assertok(pwm_set_enable(dev, 0, true)); |
| 22 | ut_assertok(pwm_set_enable(dev, 1, true)); |
| 23 | ut_assertok(pwm_set_enable(dev, 2, true)); |
| 24 | ut_asserteq(-ENOSPC, pwm_set_enable(dev, 3, true)); |
Kever Yang | 5540e25 | 2017-04-24 10:27:52 +0800 | [diff] [blame] | 25 | ut_assertok(pwm_set_invert(dev, 0, true)); |
Simon Glass | 43b4156 | 2017-04-16 21:01:11 -0600 | [diff] [blame] | 26 | |
| 27 | ut_assertok(uclass_get_device(UCLASS_PWM, 1, &dev)); |
| 28 | ut_asserteq(-ENODEV, uclass_get_device(UCLASS_PWM, 2, &dev)); |
| 29 | |
| 30 | return 0; |
| 31 | } |
Simon Glass | e180c2b | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 32 | DM_TEST(dm_test_pwm_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |