summaryrefslogtreecommitdiff
path: root/drivers/cpu
diff options
context:
space:
mode:
authorSean Anderson <seanga2@gmail.com>2020-09-28 17:52:23 +0300
committerAndes <uboot@andestech.com>2020-09-30 03:54:45 +0300
commit7616e3687e447b5a838f472afb5275fe6a841f5b (patch)
tree805ce147c29cffb9b0c4027a7151f596bc5960ff /drivers/cpu
parent3576121687965ffe580fc44f5dd1d8e9ab434c5b (diff)
downloadu-boot-7616e3687e447b5a838f472afb5275fe6a841f5b.tar.xz
timer: Add a test for timer_timebase_fallback
To test this function, sandbox CPU must set cpu_platdata.timebase_freq on bind. It also needs to expose a method to set the current cpu. I also make some most members of cpu_sandbox_ops static. On the timer side, the device tree property sandbox,timebase-frequency-fallback controls whether sandbox_timer_probe falls back to time_timebase_fallback or to SANDBOX_TIMER_RATE. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/cpu')
-rw-r--r--drivers/cpu/cpu_sandbox.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/drivers/cpu/cpu_sandbox.c b/drivers/cpu/cpu_sandbox.c
index caa26e50f2..4ba0d1b99e 100644
--- a/drivers/cpu/cpu_sandbox.c
+++ b/drivers/cpu/cpu_sandbox.c
@@ -8,14 +8,15 @@
#include <dm.h>
#include <cpu.h>
-int cpu_sandbox_get_desc(const struct udevice *dev, char *buf, int size)
+static int cpu_sandbox_get_desc(const struct udevice *dev, char *buf, int size)
{
snprintf(buf, size, "LEG Inc. SuperMegaUltraTurbo CPU No. 1");
return 0;
}
-int cpu_sandbox_get_info(const struct udevice *dev, struct cpu_info *info)
+static int cpu_sandbox_get_info(const struct udevice *dev,
+ struct cpu_info *info)
{
info->cpu_freq = 42 * 42 * 42 * 42 * 42;
info->features = 0x42424242;
@@ -24,21 +25,29 @@ int cpu_sandbox_get_info(const struct udevice *dev, struct cpu_info *info)
return 0;
}
-int cpu_sandbox_get_count(const struct udevice *dev)
+static int cpu_sandbox_get_count(const struct udevice *dev)
{
return 42;
}
-int cpu_sandbox_get_vendor(const struct udevice *dev, char *buf, int size)
+static int cpu_sandbox_get_vendor(const struct udevice *dev, char *buf,
+ int size)
{
snprintf(buf, size, "Languid Example Garbage Inc.");
return 0;
}
-int cpu_sandbox_is_current(struct udevice *dev)
+static const char *cpu_current = "cpu-test1";
+
+void cpu_sandbox_set_current(const char *name)
{
- if (!strcmp(dev->name, "cpu-test1"))
+ cpu_current = name;
+}
+
+static int cpu_sandbox_is_current(struct udevice *dev)
+{
+ if (!strcmp(dev->name, cpu_current))
return 1;
return 0;
@@ -52,7 +61,22 @@ static const struct cpu_ops cpu_sandbox_ops = {
.is_current = cpu_sandbox_is_current,
};
-int cpu_sandbox_probe(struct udevice *dev)
+static int cpu_sandbox_bind(struct udevice *dev)
+{
+ int ret;
+ struct cpu_platdata *plat = dev_get_parent_platdata(dev);
+
+ /* first examine the property in current cpu node */
+ ret = dev_read_u32(dev, "timebase-frequency", &plat->timebase_freq);
+ /* if not found, then look at the parent /cpus node */
+ if (ret)
+ ret = dev_read_u32(dev->parent, "timebase-frequency",
+ &plat->timebase_freq);
+
+ return ret;
+}
+
+static int cpu_sandbox_probe(struct udevice *dev)
{
return 0;
}
@@ -67,5 +91,6 @@ U_BOOT_DRIVER(cpu_sandbox) = {
.id = UCLASS_CPU,
.ops = &cpu_sandbox_ops,
.of_match = cpu_sandbox_ids,
+ .bind = cpu_sandbox_bind,
.probe = cpu_sandbox_probe,
};