1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2020 Sean Anderson <seanga2@gmail.com>
9 #include <dm/device-internal.h>
12 #include <asm/power-domain.h>
14 /* These must match the ids in the device tree */
15 #define TEST_CLOCK_ID 4
16 #define TEST_POWER_ID 1
18 static int dm_test_simple_pm_bus(struct unit_test_state *uts)
20 struct udevice *power;
21 struct udevice *clock;
24 ut_assertok(uclass_get_device_by_name(UCLASS_POWER_DOMAIN,
25 "power-domain", &power));
26 ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-sbox",
28 ut_asserteq(0, sandbox_power_domain_query(power, TEST_POWER_ID));
29 ut_asserteq(0, sandbox_clk_query_enable(clock, TEST_CLOCK_ID));
31 ut_assertok(uclass_get_device_by_name(UCLASS_SIMPLE_BUS, "pm-bus-test",
33 ut_asserteq(1, sandbox_power_domain_query(power, TEST_POWER_ID));
34 ut_asserteq(1, sandbox_clk_query_enable(clock, TEST_CLOCK_ID));
36 ut_assertok(device_remove(bus, DM_REMOVE_NORMAL));
37 /* must re-probe since device_remove also removes the power domain */
38 ut_assertok(uclass_get_device_by_name(UCLASS_POWER_DOMAIN,
39 "power-domain", &power));
40 ut_asserteq(0, sandbox_power_domain_query(power, TEST_POWER_ID));
41 ut_asserteq(0, sandbox_clk_query_enable(clock, TEST_CLOCK_ID));
45 DM_TEST(dm_test_simple_pm_bus, UT_TESTF_SCAN_FDT);