1 // SPDX-License-Identifier: GPL-2.0+
13 #include <test/test.h>
16 /* Test that sandbox AXI works correctly */
17 static int dm_test_axi_base(struct unit_test_state *uts)
21 ut_assertok(uclass_get_device(UCLASS_AXI, 0, &bus));
26 DM_TEST(dm_test_axi_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
28 /* Test that sandbox PCI bus numbering works correctly */
29 static int dm_test_axi_busnum(struct unit_test_state *uts)
33 ut_assertok(uclass_get_device_by_seq(UCLASS_AXI, 0, &bus));
38 DM_TEST(dm_test_axi_busnum, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
40 /* Test that we can use the store device correctly */
41 static int dm_test_axi_store(struct unit_test_state *uts)
43 struct udevice *store;
44 u8 tdata1[] = {0x55, 0x66, 0x77, 0x88};
45 u8 tdata2[] = {0xaa, 0xbb, 0xcc, 0xdd};
49 /* Check that asking for the device automatically fires up AXI */
50 ut_assertok(uclass_get_device(UCLASS_AXI_EMUL, 0, &store));
51 ut_assert(device_active(store));
53 axi_get_store(store, &data);
56 memcpy(data, tdata1, ARRAY_SIZE(tdata1));
57 axi_read(store, 0, &val, AXI_SIZE_32);
58 ut_asserteq(0x55667788, val);
60 memcpy(data + 3, tdata2, ARRAY_SIZE(tdata2));
61 axi_read(store, 3, &val, AXI_SIZE_32);
62 ut_asserteq(0xaabbccdd, val);
64 /* Reset data store */
69 axi_write(store, 0, &val, AXI_SIZE_32);
70 ut_asserteq_mem(data, tdata1, ARRAY_SIZE(tdata1));
73 axi_write(store, 3, &val, AXI_SIZE_32);
74 ut_asserteq_mem(data + 3, tdata2, ARRAY_SIZE(tdata1));
79 DM_TEST(dm_test_axi_store, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);