blob: b52ee21a69eca3c975cdad0b870bda7f487d6e2b [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass43b41562017-04-16 21:01:11 -06002/*
3 * Copyright (C) 2017 Google, Inc
Simon Glass43b41562017-04-16 21:01:11 -06004 */
5
6#include <common.h>
7#include <dm.h>
8#include <pwm.h>
9#include <dm/test.h>
10#include <test/ut.h>
11
Simon Glass43b41562017-04-16 21:01:11 -060012/* Basic test of the pwm uclass */
13static int dm_test_pwm_base(struct unit_test_state *uts)
14{
15 struct udevice *dev;
16
17 ut_assertok(uclass_get_device(UCLASS_PWM, 0, &dev));
Simon Glass1a596c42017-06-07 10:28:38 -060018 ut_assertnonnull(dev);
Simon Glass43b41562017-04-16 21:01:11 -060019 ut_assertok(pwm_set_config(dev, 0, 100, 50));
20 ut_assertok(pwm_set_enable(dev, 0, true));
21 ut_assertok(pwm_set_enable(dev, 1, true));
22 ut_assertok(pwm_set_enable(dev, 2, true));
23 ut_asserteq(-ENOSPC, pwm_set_enable(dev, 3, true));
Kever Yang5540e252017-04-24 10:27:52 +080024 ut_assertok(pwm_set_invert(dev, 0, true));
Simon Glass43b41562017-04-16 21:01:11 -060025
26 ut_assertok(uclass_get_device(UCLASS_PWM, 1, &dev));
27 ut_asserteq(-ENODEV, uclass_get_device(UCLASS_PWM, 2, &dev));
28
29 return 0;
30}
31DM_TEST(dm_test_pwm_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);