summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMario Six <mario.six@gdsys.cc>2018-08-06 10:23:44 +0200
committerSimon Glass <sjg@chromium.org>2018-09-18 08:12:21 -0600
commitfa44b53398d3a7f5ed28cb83493a70cde11f8188 (patch)
tree0750fe7a155f5ecd261987cb0120d85c83bfbd1e /drivers
parent57370de377340b0fcb81d90a187aa8b8f3494447 (diff)
test: Add tests for CPU uclass
Add a sandbox CPU driver, and some tests for the CPU uclass. Signed-off-by: Mario Six <mario.six@gdsys.cc>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/cpu/Makefile1
-rw-r--r--drivers/cpu/cpu_sandbox.c61
2 files changed, 62 insertions, 0 deletions
diff --git a/drivers/cpu/Makefile b/drivers/cpu/Makefile
index db515f6f17..980c68f44d 100644
--- a/drivers/cpu/Makefile
+++ b/drivers/cpu/Makefile
@@ -7,3 +7,4 @@
obj-$(CONFIG_CPU) += cpu-uclass.o
obj-$(CONFIG_ARCH_BMIPS) += bmips_cpu.o
+obj-$(CONFIG_SANDBOX) += cpu_sandbox.o
diff --git a/drivers/cpu/cpu_sandbox.c b/drivers/cpu/cpu_sandbox.c
new file mode 100644
index 0000000000..ff87e8adca
--- /dev/null
+++ b/drivers/cpu/cpu_sandbox.c
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2018
+ * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <cpu.h>
+
+int cpu_sandbox_get_desc(struct udevice *dev, char *buf, int size)
+{
+ snprintf(buf, size, "LEG Inc. SuperMegaUltraTurbo CPU No. 1");
+
+ return 0;
+}
+
+int cpu_sandbox_get_info(struct udevice *dev, struct cpu_info *info)
+{
+ info->cpu_freq = 42 * 42 * 42 * 42 * 42;
+ info->features = 0x42424242;
+
+ return 0;
+}
+
+int cpu_sandbox_get_count(struct udevice *dev)
+{
+ return 42;
+}
+
+int cpu_sandbox_get_vendor(struct udevice *dev, char *buf, int size)
+{
+ snprintf(buf, size, "Languid Example Garbage Inc.");
+
+ return 0;
+}
+
+static const struct cpu_ops cpu_sandbox_ops = {
+ .get_desc = cpu_sandbox_get_desc,
+ .get_info = cpu_sandbox_get_info,
+ .get_count = cpu_sandbox_get_count,
+ .get_vendor = cpu_sandbox_get_vendor,
+};
+
+int cpu_sandbox_probe(struct udevice *dev)
+{
+ return 0;
+}
+
+static const struct udevice_id cpu_sandbox_ids[] = {
+ { .compatible = "sandbox,cpu_sandbox" },
+ { }
+};
+
+U_BOOT_DRIVER(cpu_sandbox) = {
+ .name = "cpu_sandbox",
+ .id = UCLASS_CPU,
+ .ops = &cpu_sandbox_ops,
+ .of_match = cpu_sandbox_ids,
+ .probe = cpu_sandbox_probe,
+};