Nicolas Saenz Julienne | 3524a5e | 2021-01-12 13:55:27 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (c) 2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de> |
| 4 | */ |
| 5 | |
Nicolas Saenz Julienne | 3524a5e | 2021-01-12 13:55:27 +0100 | [diff] [blame] | 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 | |
| 16 | static 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 | } |
Simon Glass | 1a92f83 | 2024-08-22 07:57:48 -0600 | [diff] [blame] | 36 | DM_TEST(dm_test_phys_to_bus, UTF_SCAN_PDATA | UTF_SCAN_FDT); |