]> Git Repo - J-u-boot.git/blame - drivers/cpu/cpu_sandbox.c
gpio: npcm: Add persist feature to sgpio module
[J-u-boot.git] / drivers / cpu / cpu_sandbox.c
CommitLineData
fa44b533
MS
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2018
4 * Mario Six, Guntermann & Drunck GmbH, [email protected]
5 */
6
fa44b533
MS
7#include <dm.h>
8#include <cpu.h>
9
7616e368 10static int cpu_sandbox_get_desc(const struct udevice *dev, char *buf, int size)
fa44b533
MS
11{
12 snprintf(buf, size, "LEG Inc. SuperMegaUltraTurbo CPU No. 1");
13
14 return 0;
15}
16
7616e368
SA
17static int cpu_sandbox_get_info(const struct udevice *dev,
18 struct cpu_info *info)
fa44b533
MS
19{
20 info->cpu_freq = 42 * 42 * 42 * 42 * 42;
21 info->features = 0x42424242;
600f584d 22 info->address_width = IS_ENABLED(CONFIG_PHYS_64BIT) ? 64 : 32;
fa44b533
MS
23
24 return 0;
25}
26
7616e368 27static int cpu_sandbox_get_count(const struct udevice *dev)
fa44b533
MS
28{
29 return 42;
30}
31
7616e368
SA
32static int cpu_sandbox_get_vendor(const struct udevice *dev, char *buf,
33 int size)
fa44b533
MS
34{
35 snprintf(buf, size, "Languid Example Garbage Inc.");
36
37 return 0;
38}
39
8ae8da10 40static const char *cpu_current = "cpu@1";
7616e368
SA
41
42void cpu_sandbox_set_current(const char *name)
b1e894ff 43{
7616e368
SA
44 cpu_current = name;
45}
46
3694edca
HZ
47static int cpu_sandbox_release_core(const struct udevice *dev, phys_addr_t addr)
48{
49 return 0;
50}
51
7616e368
SA
52static int cpu_sandbox_is_current(struct udevice *dev)
53{
54 if (!strcmp(dev->name, cpu_current))
b1e894ff
PF
55 return 1;
56
57 return 0;
58}
59
fa44b533
MS
60static const struct cpu_ops cpu_sandbox_ops = {
61 .get_desc = cpu_sandbox_get_desc,
62 .get_info = cpu_sandbox_get_info,
63 .get_count = cpu_sandbox_get_count,
64 .get_vendor = cpu_sandbox_get_vendor,
b1e894ff 65 .is_current = cpu_sandbox_is_current,
3694edca 66 .release_core = cpu_sandbox_release_core,
fa44b533
MS
67};
68
7616e368
SA
69static int cpu_sandbox_bind(struct udevice *dev)
70{
71 int ret;
8a8d24bd 72 struct cpu_plat *plat = dev_get_parent_plat(dev);
7616e368
SA
73
74 /* first examine the property in current cpu node */
75 ret = dev_read_u32(dev, "timebase-frequency", &plat->timebase_freq);
76 /* if not found, then look at the parent /cpus node */
77 if (ret)
78 ret = dev_read_u32(dev->parent, "timebase-frequency",
79 &plat->timebase_freq);
80
81 return ret;
82}
83
84static int cpu_sandbox_probe(struct udevice *dev)
fa44b533
MS
85{
86 return 0;
87}
88
89static const struct udevice_id cpu_sandbox_ids[] = {
90 { .compatible = "sandbox,cpu_sandbox" },
91 { }
92};
93
94U_BOOT_DRIVER(cpu_sandbox) = {
95 .name = "cpu_sandbox",
96 .id = UCLASS_CPU,
97 .ops = &cpu_sandbox_ops,
98 .of_match = cpu_sandbox_ids,
7616e368 99 .bind = cpu_sandbox_bind,
fa44b533
MS
100 .probe = cpu_sandbox_probe,
101};
This page took 0.164972 seconds and 4 git commands to generate.