1 // SPDX-License-Identifier: GPL-2.0
8 #include <dm/device-internal.h>
11 #include <asm/power-domain.h>
13 /* These must match the ids in the device tree */
14 #define TEST_CLOCK_ID 4
15 #define TEST_POWER_ID 1
17 static int dm_test_simple_pm_bus(struct unit_test_state *uts)
19 struct udevice *power;
20 struct udevice *clock;
23 ut_assertok(uclass_get_device_by_name(UCLASS_POWER_DOMAIN,
24 "power-domain", &power));
25 ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-sbox",
27 ut_asserteq(0, sandbox_power_domain_query(power, TEST_POWER_ID));
28 ut_asserteq(0, sandbox_clk_query_enable(clock, TEST_CLOCK_ID));
30 ut_assertok(uclass_get_device_by_name(UCLASS_SIMPLE_BUS, "pm-bus-test",
32 ut_asserteq(1, sandbox_power_domain_query(power, TEST_POWER_ID));
33 ut_asserteq(1, sandbox_clk_query_enable(clock, TEST_CLOCK_ID));
35 ut_assertok(device_remove(bus, DM_REMOVE_NORMAL));
36 /* must re-probe since device_remove also removes the power domain */
37 ut_assertok(uclass_get_device_by_name(UCLASS_POWER_DOMAIN,
38 "power-domain", &power));
39 ut_asserteq(0, sandbox_power_domain_query(power, TEST_POWER_ID));
40 ut_asserteq(0, sandbox_clk_query_enable(clock, TEST_CLOCK_ID));
44 DM_TEST(dm_test_simple_pm_bus, UTF_SCAN_FDT);