aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/p2sb_sandbox.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-12-06 21:41:57 -0700
committerBin Meng <bmeng.cn@gmail.com>2019-12-15 11:44:11 +0800
commit3e17ffbb44cd24c53504179ff51a835502b183ed (patch)
tree5e70600eb19d603a8b795eb0fdb8edc6ac745981 /drivers/misc/p2sb_sandbox.c
parent89694de514387e87385aa0f111ed76ab91ba20a3 (diff)
downloadu-boot-3e17ffbb44cd24c53504179ff51a835502b183ed.tar.gz
sandbox: Add PCI driver and test for p2sb
Add a sandbox driver and PCI-device emulator for p2sb. Also add a test which uses a simple 'adder' driver to test the p2sb functionality. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/misc/p2sb_sandbox.c')
-rw-r--r--drivers/misc/p2sb_sandbox.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/misc/p2sb_sandbox.c b/drivers/misc/p2sb_sandbox.c
new file mode 100644
index 00000000000..ce50a9732ee
--- /dev/null
+++ b/drivers/misc/p2sb_sandbox.c
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Sandbox P2SB for testing
+ *
+ * Copyright 2019 Google LLC
+ */
+
+#define LOG_CATEGORY UCLASS_P2SB
+
+#include <common.h>
+#include <dm.h>
+#include <asm/io.h>
+#include <p2sb.h>
+
+struct sandbox_p2sb_priv {
+ ulong base;
+};
+
+static int sandbox_p2sb_probe(struct udevice *dev)
+{
+ struct p2sb_uc_priv *upriv = dev_get_uclass_priv(dev);
+
+ upriv->mmio_base = dm_pci_read_bar32(dev, 0);
+
+ return 0;
+}
+
+static const struct udevice_id sandbox_p2sb_ids[] = {
+ { .compatible = "sandbox,p2sb" },
+ { }
+};
+
+U_BOOT_DRIVER(p2sb_sandbox) = {
+ .name = "p2sb_sandbox",
+ .id = UCLASS_P2SB,
+ .of_match = sandbox_p2sb_ids,
+ .probe = sandbox_p2sb_probe,
+ .priv_auto_alloc_size = sizeof(struct sandbox_p2sb_priv),
+};