1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2021, Bin Meng <bmeng.cn@gmail.com>
4  */
5 
6 #include <dm.h>
7 #include <dm/test.h>
8 #include <dm/simple_bus.h>
9 #include <dm/uclass-internal.h>
10 #include <test/ut.h>
11 
dm_test_simple_bus(struct unit_test_state * uts)12 static int dm_test_simple_bus(struct unit_test_state *uts)
13 {
14 	struct udevice *dev;
15 	struct simple_bus_plat *plat;
16 
17 	/* locate the dummy device @ translation-test node */
18 	ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, &dev));
19 	ut_asserteq_str("dev@0,0", dev->name);
20 
21 	/* locate the parent node which is a simple-bus */
22 	ut_assertnonnull(dev = dev_get_parent(dev));
23 	ut_asserteq_str("translation-test@8000", dev->name);
24 
25 	ut_assertnonnull(plat = dev_get_uclass_plat(dev));
26 	ut_asserteq(0, plat->base);
27 	ut_asserteq(0x8000, plat->target);
28 	ut_asserteq(0x1000, plat->size);
29 
30 	return 0;
31 }
32 DM_TEST(dm_test_simple_bus, UTF_SCAN_FDT | UTF_FLAT_TREE);
33