blob: 8a730ba2fce4d3f43fdc634899ead786260ffdab [file] [log] [blame]
Bin Meng524a92c2021-03-14 20:15:03 +08001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2021, Bin Meng <bmeng.cn@gmail.com>
4 */
5
Bin Meng524a92c2021-03-14 20:15:03 +08006#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
12static 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}
32DM_TEST(dm_test_simple_bus, UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);