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