]>
git.ipfire.org Git - people/ms/u-boot.git/blob - test/dm/pci.c
2 * Copyright (C) 2015 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
13 /* Test that sandbox PCI works correctly */
14 static int dm_test_pci_base(struct unit_test_state
*uts
)
18 ut_assertok(uclass_get_device(UCLASS_PCI
, 0, &bus
));
22 DM_TEST(dm_test_pci_base
, DM_TESTF_SCAN_PDATA
| DM_TESTF_SCAN_FDT
);
24 /* Test that sandbox PCI bus numbering works correctly */
25 static int dm_test_pci_busnum(struct unit_test_state
*uts
)
29 ut_assertok(uclass_get_device_by_seq(UCLASS_PCI
, 0, &bus
));
33 DM_TEST(dm_test_pci_busnum
, DM_TESTF_SCAN_PDATA
| DM_TESTF_SCAN_FDT
);
35 /* Test that we can use the swapcase device correctly */
36 static int dm_test_pci_swapcase(struct unit_test_state
*uts
)
38 struct udevice
*emul
, *swap
;
39 ulong io_addr
, mem_addr
;
42 /* Check that asking for the device automatically fires up PCI */
43 ut_assertok(uclass_get_device(UCLASS_PCI_EMUL
, 0, &emul
));
44 ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(0, 0x1f, 0), &swap
));
45 ut_assert(device_active(swap
));
48 io_addr
= dm_pci_read_bar32(swap
, 0);
50 ut_asserteq(2, inb(io_addr
));
53 * Now test memory mapping - note we must unmap and remap to cause
54 * the swapcase emulation to see our data and response.
56 mem_addr
= dm_pci_read_bar32(swap
, 1);
57 ptr
= map_sysmem(mem_addr
, 20);
58 strcpy(ptr
, "This is a TesT");
61 ptr
= map_sysmem(mem_addr
, 20);
62 ut_asserteq_str("tHIS IS A tESt", ptr
);
67 DM_TEST(dm_test_pci_swapcase
, DM_TESTF_SCAN_PDATA
| DM_TESTF_SCAN_FDT
);