public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ramon Fried <ramon.fried@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 4/4] test: pci_ep: add basic pci_ep tests
Date: Wed, 24 Apr 2019 21:53:47 +0300	[thread overview]
Message-ID: <20190424185347.13586-5-ramon.fried@gmail.com> (raw)
In-Reply-To: <20190424185347.13586-1-ramon.fried@gmail.com>

Add basic PCI endpoint sandbox testing.

Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
---

 test/dm/Makefile |  1 +
 test/dm/pci_ep.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 test/dm/pci_ep.c

diff --git a/test/dm/Makefile b/test/dm/Makefile
index 49857c5092..fe36f8df47 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -30,6 +30,7 @@ obj-y += ofnode.o
 obj-$(CONFIG_OSD) += osd.o
 obj-$(CONFIG_DM_VIDEO) += panel.o
 obj-$(CONFIG_DM_PCI) += pci.o
+obj-$(CONFIG_PCI_ENDPOINT) += pci_ep.o
 obj-$(CONFIG_PCH) += pch.o
 obj-$(CONFIG_PHY) += phy.o
 obj-$(CONFIG_POWER_DOMAIN) += power-domain.o
diff --git a/test/dm/pci_ep.c b/test/dm/pci_ep.c
new file mode 100644
index 0000000000..5f2153e393
--- /dev/null
+++ b/test/dm/pci_ep.c
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Ramon Fried
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <asm/io.h>
+#include <asm/test.h>
+#include <dm/test.h>
+#include <test/ut.h>
+#include <pci_ep.h>
+
+/* Test that sandbox PCI EP works correctly */
+static int dm_test_pci_ep_base(struct unit_test_state *uts)
+{
+	struct udevice *bus;
+	struct pci_ep_header ep_header = {
+		.vendorid = 0x1234,
+		.deviceid = 0x2020,
+		.revid = 1,
+		.interrupt_pin = PCI_INTERRUPT_INTA,
+	};
+
+	struct pci_bar bar = {
+		.phys_addr = 0x80000000,
+		.size = 0x100000,
+		.barno = BAR_0,
+		.flags = PCI_BASE_ADDRESS_MEM_TYPE_64 |
+			PCI_BASE_ADDRESS_MEM_PREFETCH,
+	};
+
+	ut_assertok(uclass_get_device(UCLASS_PCI_EP, 0, &bus));
+	ut_assertnonnull(bus);
+
+	ut_assertok(pci_ep_write_header(bus, 0, &ep_header));
+	ut_assertok(pci_ep_set_msi(bus, 0, 4));
+	ut_assertok(pci_ep_set_msix(bus, 0, 360));
+	ut_assertok(pci_ep_set_bar(bus, 0, &bar));
+
+	return 0;
+}
+
+DM_TEST(dm_test_pci_ep_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
-- 
2.21.0

      parent reply	other threads:[~2019-04-24 18:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-24 18:53 [U-Boot] [PATCH v2 0/4] Add Cadence PCIe endpoint driver with new uclass Ramon Fried
2019-04-24 18:53 ` [U-Boot] [PATCH v2 1/4] drivers: pci_ep: Introduce UCLASS_PCI_EP uclass Ramon Fried
2019-04-24 23:33   ` Simon Glass
2019-04-24 18:53 ` [U-Boot] [PATCH v2 2/4] pci_ep: add Cadence PCIe endpoint driver Ramon Fried
2019-04-24 23:35   ` Simon Glass
2019-04-24 18:53 ` [U-Boot] [PATCH v2 3/4] pci_ep: add pci_ep sandbox driver Ramon Fried
2019-04-24 23:29   ` Simon Glass
2019-04-25 11:35     ` Ramon Fried
2019-04-26  1:11       ` Simon Glass
2019-04-24 18:53 ` Ramon Fried [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190424185347.13586-5-ramon.fried@gmail.com \
    --to=ramon.fried@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox