aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2018-08-03 01:14:42 -0700
committerSimon Glass <sjg@chromium.org>2018-08-08 12:49:31 +0100
commit3839b4e8b7dee02c13bd20237dc84b5022e8bdd4 (patch)
tree6ca816b8dd3132079954d3856342aacf148cc5aa /test
parentdee4d752be4cbad2216f9285470588004c5d154e (diff)
downloadu-boot-3839b4e8b7dee02c13bd20237dc84b5022e8bdd4.zip
u-boot-3839b4e8b7dee02c13bd20237dc84b5022e8bdd4.tar.gz
u-boot-3839b4e8b7dee02c13bd20237dc84b5022e8bdd4.tar.bz2
test: dm: pci: Add tests for configuration space access
So far we missed the testing for PCI configuration space access. This adds tests for it, as well as removing some redundant asserts. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/pci.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/test/dm/pci.c b/test/dm/pci.c
index 727ec34..089b72e 100644
--- a/test/dm/pci.c
+++ b/test/dm/pci.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <dm.h>
#include <asm/io.h>
+#include <asm/test.h>
#include <dm/test.h>
#include <test/ut.h>
@@ -24,27 +25,32 @@ DM_TEST(dm_test_pci_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
static int dm_test_pci_busdev(struct unit_test_state *uts)
{
struct udevice *bus;
- struct udevice *emul, *swap;
+ struct udevice *swap;
+ u16 vendor, device;
/* Test bus#0 and its devices */
ut_assertok(uclass_get_device_by_seq(UCLASS_PCI, 0, &bus));
- ut_assertok(uclass_get_device(UCLASS_PCI_EMUL, 0, &emul));
ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(0, 0x00, 0), &swap));
- ut_assert(device_active(swap));
- ut_assertok(uclass_get_device(UCLASS_PCI_EMUL, 1, &emul));
+ vendor = 0;
+ ut_assertok(dm_pci_read_config16(swap, PCI_VENDOR_ID, &vendor));
+ ut_asserteq(SANDBOX_PCI_VENDOR_ID, vendor);
ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(0, 0x1f, 0), &swap));
- ut_assert(device_active(swap));
+ device = 0;
+ ut_assertok(dm_pci_read_config16(swap, PCI_DEVICE_ID, &device));
+ ut_asserteq(SANDBOX_PCI_DEVICE_ID, device);
/* Test bus#1 and its devices */
ut_assertok(uclass_get_device_by_seq(UCLASS_PCI, 1, &bus));
- ut_assertok(uclass_get_device(UCLASS_PCI_EMUL, 2, &emul));
ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x08, 0), &swap));
- ut_assert(device_active(swap));
- ut_assertok(uclass_get_device(UCLASS_PCI_EMUL, 3, &emul));
+ vendor = 0;
+ ut_assertok(dm_pci_read_config16(swap, PCI_VENDOR_ID, &vendor));
+ ut_asserteq(SANDBOX_PCI_VENDOR_ID, vendor);
ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x0c, 0), &swap));
- ut_assert(device_active(swap));
+ device = 0;
+ ut_assertok(dm_pci_read_config16(swap, PCI_DEVICE_ID, &device));
+ ut_asserteq(SANDBOX_PCI_DEVICE_ID, device);
return 0;
}