aboutsummaryrefslogtreecommitdiff
path: root/drivers/pch
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-02-16 20:24:50 -0700
committerBin Meng <bmeng.cn@gmail.com>2019-02-20 15:26:36 +0800
commitb45c833c71f1ce26e0db6c30f96dc3228051cd15 (patch)
tree2e4e0a7357882a7b40ed03607c64ef5975b10882 /drivers/pch
parentc882163b09b8a2c52e3dd8acd7d296d6d06d1f2e (diff)
downloadu-boot-b45c833c71f1ce26e0db6c30f96dc3228051cd15.zip
u-boot-b45c833c71f1ce26e0db6c30f96dc3228051cd15.tar.gz
u-boot-b45c833c71f1ce26e0db6c30f96dc3228051cd15.tar.bz2
sandbox: pch: Add a test for the PCH uclass
This uclass currently has no tests. Add a sandbox driver and some simple tests to provide basic coverage. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> [bmeng: Use "sandbox,pch" for the compatible string, for consistency] Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/pch')
-rw-r--r--drivers/pch/Makefile1
-rw-r--r--drivers/pch/sandbox_pch.c69
2 files changed, 70 insertions, 0 deletions
diff --git a/drivers/pch/Makefile b/drivers/pch/Makefile
index 696cdff..8ea6b78 100644
--- a/drivers/pch/Makefile
+++ b/drivers/pch/Makefile
@@ -3,3 +3,4 @@
obj-y += pch-uclass.o
obj-y += pch7.o
obj-y += pch9.o
+obj-$(CONFIG_SANDBOX) += sandbox_pch.o
diff --git a/drivers/pch/sandbox_pch.c b/drivers/pch/sandbox_pch.c
new file mode 100644
index 0000000..81f8156
--- /dev/null
+++ b/drivers/pch/sandbox_pch.c
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 Google LLC
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <pch.h>
+
+struct sandbox_pch_priv {
+ bool protect;
+};
+
+int sandbox_get_pch_spi_protect(struct udevice *dev)
+{
+ struct sandbox_pch_priv *priv = dev_get_priv(dev);
+
+ return priv->protect;
+}
+
+static int sandbox_pch_get_spi_base(struct udevice *dev, ulong *sbasep)
+{
+ *sbasep = 0x10;
+
+ return 0;
+}
+
+static int sandbox_pch_set_spi_protect(struct udevice *dev, bool protect)
+{
+ struct sandbox_pch_priv *priv = dev_get_priv(dev);
+
+ priv->protect = protect;
+
+ return 0;
+}
+
+static int sandbox_pch_get_gpio_base(struct udevice *dev, u32 *gbasep)
+{
+ *gbasep = 0x20;
+
+ return 0;
+}
+
+static int sandbox_pch_get_io_base(struct udevice *dev, u32 *iobasep)
+{
+ *iobasep = 0x30;
+
+ return 0;
+}
+
+static const struct pch_ops sandbox_pch_ops = {
+ .get_spi_base = sandbox_pch_get_spi_base,
+ .set_spi_protect = sandbox_pch_set_spi_protect,
+ .get_gpio_base = sandbox_pch_get_gpio_base,
+ .get_io_base = sandbox_pch_get_io_base,
+};
+
+static const struct udevice_id sandbox_pch_ids[] = {
+ { .compatible = "sandbox,pch" },
+ { }
+};
+
+U_BOOT_DRIVER(sandbox_pch_drv) = {
+ .name = "sandbox-pch",
+ .id = UCLASS_PCH,
+ .of_match = sandbox_pch_ids,
+ .ops = &sandbox_pch_ops,
+ .priv_auto_alloc_size = sizeof(struct sandbox_pch_priv),
+};