Simon Glass | e62f4be | 2017-04-16 21:01:11 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 Google, Inc |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
| 9 | #include <pwm.h> |
| 10 | #include <dm/test.h> |
| 11 | #include <test/ut.h> |
| 12 | |
| 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
| 15 | /* Basic test of the pwm uclass */ |
| 16 | static int dm_test_pwm_base(struct unit_test_state *uts) |
| 17 | { |
| 18 | struct udevice *dev; |
| 19 | |
| 20 | ut_assertok(uclass_get_device(UCLASS_PWM, 0, &dev)); |
Simon Glass | 680e932 | 2017-06-07 10:28:38 -0600 | [diff] [blame] | 21 | ut_assertnonnull(dev); |
Simon Glass | e62f4be | 2017-04-16 21:01:11 -0600 | [diff] [blame] | 22 | ut_assertok(pwm_set_config(dev, 0, 100, 50)); |
| 23 | ut_assertok(pwm_set_enable(dev, 0, true)); |
| 24 | ut_assertok(pwm_set_enable(dev, 1, true)); |
| 25 | ut_assertok(pwm_set_enable(dev, 2, true)); |
| 26 | ut_asserteq(-ENOSPC, pwm_set_enable(dev, 3, true)); |
Kever Yang | 809c3e6 | 2017-04-24 10:27:52 +0800 | [diff] [blame] | 27 | ut_assertok(pwm_set_invert(dev, 0, true)); |
Simon Glass | e62f4be | 2017-04-16 21:01:11 -0600 | [diff] [blame] | 28 | |
| 29 | ut_assertok(uclass_get_device(UCLASS_PWM, 1, &dev)); |
| 30 | ut_asserteq(-ENODEV, uclass_get_device(UCLASS_PWM, 2, &dev)); |
| 31 | |
| 32 | return 0; |
| 33 | } |
| 34 | DM_TEST(dm_test_pwm_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |