diff options
author | 2023-10-10 14:33:42 +0000 | |
---|---|---|
committer | 2023-10-10 14:33:42 +0000 | |
commit | af1a266670d040d2f4083ff309d732d648afba2a (patch) | |
tree | 2fc46203448ddcc6f81546d379abfaeb323575e9 /roms/u-boot/drivers/cpu/cpu_sandbox.c | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'roms/u-boot/drivers/cpu/cpu_sandbox.c')
-rw-r--r-- | roms/u-boot/drivers/cpu/cpu_sandbox.c | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/roms/u-boot/drivers/cpu/cpu_sandbox.c b/roms/u-boot/drivers/cpu/cpu_sandbox.c new file mode 100644 index 000000000..fe6772ba5 --- /dev/null +++ b/roms/u-boot/drivers/cpu/cpu_sandbox.c @@ -0,0 +1,96 @@ +// 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> + +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; +} + +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; + info->address_width = IS_ENABLED(CONFIG_PHYS_64BIT) ? 64 : 32; + + return 0; +} + +static int cpu_sandbox_get_count(const struct udevice *dev) +{ + return 42; +} + +static int cpu_sandbox_get_vendor(const struct udevice *dev, char *buf, + int size) +{ + snprintf(buf, size, "Languid Example Garbage Inc."); + + return 0; +} + +static const char *cpu_current = "cpu-test1"; + +void cpu_sandbox_set_current(const char *name) +{ + cpu_current = name; +} + +static int cpu_sandbox_is_current(struct udevice *dev) +{ + if (!strcmp(dev->name, cpu_current)) + return 1; + + 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, + .is_current = cpu_sandbox_is_current, +}; + +static int cpu_sandbox_bind(struct udevice *dev) +{ + int ret; + struct cpu_plat *plat = dev_get_parent_plat(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; +} + +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, + .bind = cpu_sandbox_bind, + .probe = cpu_sandbox_probe, +}; |