]> git.ipfire.org Git - thirdparty/u-boot.git/blame - test/dm/phys2bus.c
test: Remove <common.h> and add needed includes
[thirdparty/u-boot.git] / test / dm / phys2bus.c
CommitLineData
30b20e6b
NSJ
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (c) 2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
4 */
5
30b20e6b
NSJ
6#include <dm.h>
7#include <mapmem.h>
8#include <phys2bus.h>
9#include <dm/device.h>
10#include <dm/ofnode.h>
11#include <dm/root.h>
12#include <dm/test.h>
13#include <dm/uclass-internal.h>
14#include <test/ut.h>
15
16static int dm_test_phys_to_bus(struct unit_test_state *uts)
17{
18 struct udevice *dev;
19 ofnode node;
20
21 node = ofnode_path("/mmio-bus@0");
22 ut_assert(ofnode_valid(node));
23 ut_assertok(uclass_get_device_by_ofnode(UCLASS_TEST_BUS, node, &dev));
24 /* In this case it should be transparent, no dma-ranges in parent bus */
25 ut_asserteq_addr((void*)0xfffffULL, (void*)dev_phys_to_bus(dev, 0xfffff));
26 ut_asserteq_addr((void*)0xfffffULL, (void*)(ulong)dev_bus_to_phys(dev, 0xfffff));
27
28 node = ofnode_path("/mmio-bus@0/subnode@0");
29 ut_assert(ofnode_valid(node));
30 ut_assertok(uclass_get_device_by_ofnode(UCLASS_TEST_FDT, node, &dev));
31 ut_asserteq_addr((void*)0x100fffffULL, (void*)dev_phys_to_bus(dev, 0xfffff));
32 ut_asserteq_addr((void*)0xfffffULL, (void*)(ulong)dev_bus_to_phys(dev, 0x100fffff));
33
34 return 0;
35}
36DM_TEST(dm_test_phys_to_bus, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);