blob: cccd1ad16204d5c991768dc7d5211aff6d914469 [file] [log] [blame]
Simon Glasse62f4be2017-04-16 21:01:11 -06001/*
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
Simon Glasse62f4be2017-04-16 21:01:11 -060013/* Basic test of the pwm uclass */
14static 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 Glass680e9322017-06-07 10:28:38 -060019 ut_assertnonnull(dev);
Simon Glasse62f4be2017-04-16 21:01:11 -060020 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 Yang809c3e62017-04-24 10:27:52 +080025 ut_assertok(pwm_set_invert(dev, 0, true));
Simon Glasse62f4be2017-04-16 21:01:11 -060026
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}
32DM_TEST(dm_test_pwm_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);