aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBin Meng2018-10-15 04:21:22 -0500
committerSimon Glass2018-11-14 11:16:28 -0600
commit7a20614eb292c48b4a42c3b5314b26d975aa84b4 (patch)
treeb4640aef36e084ce1749e3ec72a0ce34c301d3bc
parenta8c5f8d3d02807f72d048950d72b0c73d55bd7fb (diff)
downloadu-boot-7a20614eb292c48b4a42c3b5314b26d975aa84b4.tar.gz
u-boot-7a20614eb292c48b4a42c3b5314b26d975aa84b4.tar.xz
u-boot-7a20614eb292c48b4a42c3b5314b26d975aa84b4.zip
test: dm: pci: Add cases for finding next PCI capability APIs
Add test cases to cover the two newly added PCI APIs: dm_pci_find_next_capability() & dm_pci_find_next_ext_capability(). Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/misc/swap_case.c9
-rw-r--r--test/dm/pci.c20
2 files changed, 29 insertions, 0 deletions
diff --git a/drivers/misc/swap_case.c b/drivers/misc/swap_case.c
index bffb809f14..fa608cec1b 100644
--- a/drivers/misc/swap_case.c
+++ b/drivers/misc/swap_case.c
@@ -124,12 +124,21 @@ static int sandbox_swap_case_read_config(struct udevice *emul, uint offset,
124 case PCI_CAP_ID_PM_OFFSET: 124 case PCI_CAP_ID_PM_OFFSET:
125 *valuep = (PCI_CAP_ID_EXP_OFFSET << 8) | PCI_CAP_ID_PM; 125 *valuep = (PCI_CAP_ID_EXP_OFFSET << 8) | PCI_CAP_ID_PM;
126 break; 126 break;
127 case PCI_CAP_ID_PM_OFFSET + PCI_CAP_LIST_NEXT:
128 *valuep = PCI_CAP_ID_EXP_OFFSET;
129 break;
127 case PCI_CAP_ID_EXP_OFFSET: 130 case PCI_CAP_ID_EXP_OFFSET:
128 *valuep = (PCI_CAP_ID_MSIX_OFFSET << 8) | PCI_CAP_ID_EXP; 131 *valuep = (PCI_CAP_ID_MSIX_OFFSET << 8) | PCI_CAP_ID_EXP;
129 break; 132 break;
133 case PCI_CAP_ID_EXP_OFFSET + PCI_CAP_LIST_NEXT:
134 *valuep = PCI_CAP_ID_MSIX_OFFSET;
135 break;
130 case PCI_CAP_ID_MSIX_OFFSET: 136 case PCI_CAP_ID_MSIX_OFFSET:
131 *valuep = PCI_CAP_ID_MSIX; 137 *valuep = PCI_CAP_ID_MSIX;
132 break; 138 break;
139 case PCI_CAP_ID_MSIX_OFFSET + PCI_CAP_LIST_NEXT:
140 *valuep = 0;
141 break;
133 case PCI_EXT_CAP_ID_ERR_OFFSET: 142 case PCI_EXT_CAP_ID_ERR_OFFSET:
134 *valuep = (PCI_EXT_CAP_ID_VC_OFFSET << 20) | PCI_EXT_CAP_ID_ERR; 143 *valuep = (PCI_EXT_CAP_ID_VC_OFFSET << 20) | PCI_EXT_CAP_ID_ERR;
135 break; 144 break;
diff --git a/test/dm/pci.c b/test/dm/pci.c
index a1dedd84a7..a1febd54b7 100644
--- a/test/dm/pci.c
+++ b/test/dm/pci.c
@@ -211,6 +211,16 @@ static int dm_test_pci_cap(struct unit_test_state *uts)
211 cap = dm_pci_find_capability(swap, PCI_CAP_ID_PCIX); 211 cap = dm_pci_find_capability(swap, PCI_CAP_ID_PCIX);
212 ut_asserteq(0, cap); 212 ut_asserteq(0, cap);
213 213
214 /* look up PCI_CAP_ID_MSIX starting from PCI_CAP_ID_PM_OFFSET */
215 cap = dm_pci_find_next_capability(swap, PCI_CAP_ID_PM_OFFSET,
216 PCI_CAP_ID_MSIX);
217 ut_asserteq(PCI_CAP_ID_MSIX_OFFSET, cap);
218
219 /* look up PCI_CAP_ID_VNDR starting from PCI_CAP_ID_EXP_OFFSET */
220 cap = dm_pci_find_next_capability(swap, PCI_CAP_ID_EXP_OFFSET,
221 PCI_CAP_ID_VNDR);
222 ut_asserteq(0, cap);
223
214 ut_assertok(uclass_get_device_by_seq(UCLASS_PCI, 1, &bus)); 224 ut_assertok(uclass_get_device_by_seq(UCLASS_PCI, 1, &bus));
215 ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x08, 0), &swap)); 225 ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x08, 0), &swap));
216 226
@@ -222,6 +232,16 @@ static int dm_test_pci_cap(struct unit_test_state *uts)
222 cap = dm_pci_find_ext_capability(swap, PCI_EXT_CAP_ID_SRIOV); 232 cap = dm_pci_find_ext_capability(swap, PCI_EXT_CAP_ID_SRIOV);
223 ut_asserteq(0, cap); 233 ut_asserteq(0, cap);
224 234
235 /* look up PCI_EXT_CAP_ID_DSN starting from PCI_EXT_CAP_ID_ERR_OFFSET */
236 cap = dm_pci_find_next_ext_capability(swap, PCI_EXT_CAP_ID_ERR_OFFSET,
237 PCI_EXT_CAP_ID_DSN);
238 ut_asserteq(PCI_EXT_CAP_ID_DSN_OFFSET, cap);
239
240 /* look up PCI_EXT_CAP_ID_RCRB starting from PCI_EXT_CAP_ID_VC_OFFSET */
241 cap = dm_pci_find_next_ext_capability(swap, PCI_EXT_CAP_ID_VC_OFFSET,
242 PCI_EXT_CAP_ID_RCRB);
243 ut_asserteq(0, cap);
244
225 return 0; 245 return 0;
226} 246}
227DM_TEST(dm_test_pci_cap, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); 247DM_TEST(dm_test_pci_cap, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);