diff options
author | Bin Meng <bmeng.cn@gmail.com> | 2018-08-03 11:14:53 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-08-08 14:49:31 +0300 |
commit | 95e11069b5e10c38cc966a2ff9c16748d017df52 (patch) | |
tree | ff0e63317c69c332d4ddb76725042cb7f6d958a2 /test/dm | |
parent | dac01fd89d41d98cd4ce040a0d10eb67c523f63a (diff) | |
download | u-boot-95e11069b5e10c38cc966a2ff9c16748d017df52.tar.xz |
test: dm: pci: Add cases for finding PCI capability APIs
Add several PCI capability and extended capability ID registers
in the swap_case driver, so that we can add test case for
dm_pci_find_capability() and dm_pci_find_ext_capability().
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm')
-rw-r--r-- | test/dm/pci.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/dm/pci.c b/test/dm/pci.c index e03f6ba671..869970072d 100644 --- a/test/dm/pci.c +++ b/test/dm/pci.c @@ -188,3 +188,35 @@ static int dm_test_pci_mixed(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_pci_mixed, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test looking up PCI capability and extended capability */ +static int dm_test_pci_cap(struct unit_test_state *uts) +{ + struct udevice *bus, *swap; + int cap; + + ut_assertok(uclass_get_device_by_seq(UCLASS_PCI, 0, &bus)); + ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(0, 0x1f, 0), &swap)); + + /* look up PCI_CAP_ID_EXP */ + cap = dm_pci_find_capability(swap, PCI_CAP_ID_EXP); + ut_asserteq(PCI_CAP_ID_EXP_OFFSET, cap); + + /* look up PCI_CAP_ID_PCIX */ + cap = dm_pci_find_capability(swap, PCI_CAP_ID_PCIX); + ut_asserteq(0, cap); + + ut_assertok(uclass_get_device_by_seq(UCLASS_PCI, 1, &bus)); + ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x08, 0), &swap)); + + /* look up PCI_EXT_CAP_ID_DSN */ + cap = dm_pci_find_ext_capability(swap, PCI_EXT_CAP_ID_DSN); + ut_asserteq(PCI_EXT_CAP_ID_DSN_OFFSET, cap); + + /* look up PCI_EXT_CAP_ID_SRIOV */ + cap = dm_pci_find_ext_capability(swap, PCI_EXT_CAP_ID_SRIOV); + ut_asserteq(0, cap); + + return 0; +} +DM_TEST(dm_test_pci_cap, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |