1 // SPDX-License-Identifier: GPL-2.0+
4 * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
14 /* Test that sandbox AXI works correctly */
15 static int dm_test_axi_base(struct unit_test_state *uts)
19 ut_assertok(uclass_get_device(UCLASS_AXI, 0, &bus));
24 DM_TEST(dm_test_axi_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
26 /* Test that sandbox PCI bus numbering works correctly */
27 static int dm_test_axi_busnum(struct unit_test_state *uts)
31 ut_assertok(uclass_get_device_by_seq(UCLASS_AXI, 0, &bus));
36 DM_TEST(dm_test_axi_busnum, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
38 /* Test that we can use the store device correctly */
39 static int dm_test_axi_store(struct unit_test_state *uts)
41 struct udevice *store;
42 u8 tdata1[] = {0x55, 0x66, 0x77, 0x88};
43 u8 tdata2[] = {0xaa, 0xbb, 0xcc, 0xdd};
47 /* Check that asking for the device automatically fires up AXI */
48 ut_assertok(uclass_get_device(UCLASS_AXI_EMUL, 0, &store));
49 ut_assert(device_active(store));
51 axi_get_store(store, &data);
54 memcpy(data, tdata1, ARRAY_SIZE(tdata1));
55 axi_read(store, 0, &val, AXI_SIZE_32);
56 ut_asserteq(0x55667788, val);
58 memcpy(data + 3, tdata2, ARRAY_SIZE(tdata2));
59 axi_read(store, 3, &val, AXI_SIZE_32);
60 ut_asserteq(0xaabbccdd, val);
62 /* Reset data store */
67 axi_write(store, 0, &val, AXI_SIZE_32);
68 ut_asserteq(0, memcmp(data, tdata1, ARRAY_SIZE(tdata1)));
71 axi_write(store, 3, &val, AXI_SIZE_32);
72 ut_asserteq(0, memcmp(data + 3, tdata2, ARRAY_SIZE(tdata1)));
77 DM_TEST(dm_test_axi_store, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);