mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-29 08:00:26 +09:00
test: dm: pci: Add tests for mixed static and dynamic devices on the same bus
In the Sandbox test configuration, PCI bus#0 only has static devices while bus#1 only has dynamic devices. Create a bus#2 that has both types of devices and test such. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
841f3216c2
commit
3ed214ac9b
@ -16,6 +16,7 @@
|
|||||||
mmc1 = "/mmc1";
|
mmc1 = "/mmc1";
|
||||||
pci0 = &pci0;
|
pci0 = &pci0;
|
||||||
pci1 = &pci1;
|
pci1 = &pci1;
|
||||||
|
pci2 = &pci2;
|
||||||
remoteproc1 = &rproc_1;
|
remoteproc1 = &rproc_1;
|
||||||
remoteproc2 = &rproc_2;
|
remoteproc2 = &rproc_2;
|
||||||
rtc0 = &rtc_0;
|
rtc0 = &rtc_0;
|
||||||
@ -330,6 +331,23 @@
|
|||||||
0x0c 0x00 0x1234 0x5678>;
|
0x0c 0x00 0x1234 0x5678>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pci2: pci-controller2 {
|
||||||
|
compatible = "sandbox,pci";
|
||||||
|
device_type = "pci";
|
||||||
|
#address-cells = <3>;
|
||||||
|
#size-cells = <2>;
|
||||||
|
ranges = <0x02000000 0 0x50000000 0x50000000 0 0x2000
|
||||||
|
0x01000000 0 0x60000000 0x60000000 0 0x2000>;
|
||||||
|
sandbox,dev-info = <0x08 0x00 0x1234 0x5678>;
|
||||||
|
pci@1f,0 {
|
||||||
|
compatible = "pci-generic";
|
||||||
|
reg = <0xf800 0 0 0 0>;
|
||||||
|
emul@1f,0 {
|
||||||
|
compatible = "sandbox,swap-case";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
probing {
|
probing {
|
||||||
compatible = "simple-bus";
|
compatible = "simple-bus";
|
||||||
test1 {
|
test1 {
|
||||||
|
@ -125,3 +125,66 @@ static int dm_test_pci_drvdata(struct unit_test_state *uts)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DM_TEST(dm_test_pci_drvdata, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
|
DM_TEST(dm_test_pci_drvdata, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
|
||||||
|
|
||||||
|
/* Test that devices on PCI bus#2 can be accessed correctly */
|
||||||
|
static int dm_test_pci_mixed(struct unit_test_state *uts)
|
||||||
|
{
|
||||||
|
/* PCI bus#2 has both statically and dynamic declared devices */
|
||||||
|
struct udevice *bus, *swap;
|
||||||
|
u16 vendor, device;
|
||||||
|
ulong io_addr, mem_addr;
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
|
ut_assertok(uclass_get_device_by_seq(UCLASS_PCI, 2, &bus));
|
||||||
|
|
||||||
|
/* Test the dynamic device */
|
||||||
|
ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(2, 0x08, 0), &swap));
|
||||||
|
vendor = 0;
|
||||||
|
ut_assertok(dm_pci_read_config16(swap, PCI_VENDOR_ID, &vendor));
|
||||||
|
ut_asserteq(SANDBOX_PCI_VENDOR_ID, vendor);
|
||||||
|
|
||||||
|
/* First test I/O */
|
||||||
|
io_addr = dm_pci_read_bar32(swap, 0);
|
||||||
|
outb(2, io_addr);
|
||||||
|
ut_asserteq(2, inb(io_addr));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now test memory mapping - note we must unmap and remap to cause
|
||||||
|
* the swapcase emulation to see our data and response.
|
||||||
|
*/
|
||||||
|
mem_addr = dm_pci_read_bar32(swap, 1);
|
||||||
|
ptr = map_sysmem(mem_addr, 30);
|
||||||
|
strcpy(ptr, "This is a TesT oN dYNAMIc");
|
||||||
|
unmap_sysmem(ptr);
|
||||||
|
|
||||||
|
ptr = map_sysmem(mem_addr, 30);
|
||||||
|
ut_asserteq_str("tHIS IS A tESt On DynamiC", ptr);
|
||||||
|
unmap_sysmem(ptr);
|
||||||
|
|
||||||
|
/* Test the static device */
|
||||||
|
ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(2, 0x1f, 0), &swap));
|
||||||
|
device = 0;
|
||||||
|
ut_assertok(dm_pci_read_config16(swap, PCI_DEVICE_ID, &device));
|
||||||
|
ut_asserteq(SANDBOX_PCI_DEVICE_ID, device);
|
||||||
|
|
||||||
|
/* First test I/O */
|
||||||
|
io_addr = dm_pci_read_bar32(swap, 0);
|
||||||
|
outb(2, io_addr);
|
||||||
|
ut_asserteq(2, inb(io_addr));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now test memory mapping - note we must unmap and remap to cause
|
||||||
|
* the swapcase emulation to see our data and response.
|
||||||
|
*/
|
||||||
|
mem_addr = dm_pci_read_bar32(swap, 1);
|
||||||
|
ptr = map_sysmem(mem_addr, 30);
|
||||||
|
strcpy(ptr, "This is a TesT oN sTATIc");
|
||||||
|
unmap_sysmem(ptr);
|
||||||
|
|
||||||
|
ptr = map_sysmem(mem_addr, 30);
|
||||||
|
ut_asserteq_str("tHIS IS A tESt On StatiC", ptr);
|
||||||
|
unmap_sysmem(ptr);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
DM_TEST(dm_test_pci_mixed, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
|
||||||
|
Loading…
Reference in New Issue
Block a user