1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2015 Thomas Chou <thomas@wytron.com.tw>
10 #include <dm/device-internal.h>
11 #include <test/test.h>
16 * Basic test of the timer uclass.
18 static int dm_test_timer_base(struct unit_test_state *uts)
22 ut_assertok(uclass_get_device_by_name(UCLASS_TIMER, "timer@0", &dev));
23 ut_asserteq(1000000, timer_get_rate(dev));
27 DM_TEST(dm_test_timer_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
30 * Test of timebase fallback
32 static int dm_test_timer_timebase_fallback(struct unit_test_state *uts)
36 cpu_sandbox_set_current("cpu-test1");
37 ut_assertok(uclass_get_device_by_name(UCLASS_TIMER, "timer@1", &dev));
38 ut_asserteq(3000000, timer_get_rate(dev));
39 ut_assertok(device_remove(dev, DM_REMOVE_NORMAL));
41 cpu_sandbox_set_current("cpu-test2");
42 ut_assertok(uclass_get_device_by_name(UCLASS_TIMER, "timer@1", &dev));
43 ut_asserteq(2000000, timer_get_rate(dev));
45 cpu_sandbox_set_current("cpu-test1");
49 DM_TEST(dm_test_timer_timebase_fallback,
50 UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);