Mario Six | dea5df7 | 2018-08-06 10:23:44 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * (C) Copyright 2018 |
| 4 | * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
| 9 | #include <cpu.h> |
| 10 | |
Tom Rini | 5a9ecb2 | 2020-07-24 08:42:06 -0400 | [diff] [blame] | 11 | int cpu_sandbox_get_desc(struct udevice *dev, char *buf, int size) |
Mario Six | dea5df7 | 2018-08-06 10:23:44 +0200 | [diff] [blame] | 12 | { |
| 13 | snprintf(buf, size, "LEG Inc. SuperMegaUltraTurbo CPU No. 1"); |
| 14 | |
| 15 | return 0; |
| 16 | } |
| 17 | |
Tom Rini | 5a9ecb2 | 2020-07-24 08:42:06 -0400 | [diff] [blame] | 18 | int cpu_sandbox_get_info(struct udevice *dev, struct cpu_info *info) |
Mario Six | dea5df7 | 2018-08-06 10:23:44 +0200 | [diff] [blame] | 19 | { |
| 20 | info->cpu_freq = 42 * 42 * 42 * 42 * 42; |
| 21 | info->features = 0x42424242; |
Simon Glass | c35854a | 2020-04-08 16:57:20 -0600 | [diff] [blame] | 22 | info->address_width = IS_ENABLED(CONFIG_PHYS_64BIT) ? 64 : 32; |
Mario Six | dea5df7 | 2018-08-06 10:23:44 +0200 | [diff] [blame] | 23 | |
| 24 | return 0; |
| 25 | } |
| 26 | |
Tom Rini | 5a9ecb2 | 2020-07-24 08:42:06 -0400 | [diff] [blame] | 27 | int cpu_sandbox_get_count(struct udevice *dev) |
Mario Six | dea5df7 | 2018-08-06 10:23:44 +0200 | [diff] [blame] | 28 | { |
| 29 | return 42; |
| 30 | } |
| 31 | |
Tom Rini | 5a9ecb2 | 2020-07-24 08:42:06 -0400 | [diff] [blame] | 32 | int cpu_sandbox_get_vendor(struct udevice *dev, char *buf, int size) |
Mario Six | dea5df7 | 2018-08-06 10:23:44 +0200 | [diff] [blame] | 33 | { |
| 34 | snprintf(buf, size, "Languid Example Garbage Inc."); |
| 35 | |
| 36 | return 0; |
| 37 | } |
| 38 | |
Peng Fan | 35c589a | 2020-05-03 21:58:48 +0800 | [diff] [blame] | 39 | int cpu_sandbox_is_current(struct udevice *dev) |
| 40 | { |
| 41 | if (!strcmp(dev->name, "cpu-test1")) |
| 42 | return 1; |
| 43 | |
| 44 | return 0; |
| 45 | } |
| 46 | |
Mario Six | dea5df7 | 2018-08-06 10:23:44 +0200 | [diff] [blame] | 47 | static const struct cpu_ops cpu_sandbox_ops = { |
| 48 | .get_desc = cpu_sandbox_get_desc, |
| 49 | .get_info = cpu_sandbox_get_info, |
| 50 | .get_count = cpu_sandbox_get_count, |
| 51 | .get_vendor = cpu_sandbox_get_vendor, |
Peng Fan | 35c589a | 2020-05-03 21:58:48 +0800 | [diff] [blame] | 52 | .is_current = cpu_sandbox_is_current, |
Mario Six | dea5df7 | 2018-08-06 10:23:44 +0200 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | int cpu_sandbox_probe(struct udevice *dev) |
| 56 | { |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | static const struct udevice_id cpu_sandbox_ids[] = { |
| 61 | { .compatible = "sandbox,cpu_sandbox" }, |
| 62 | { } |
| 63 | }; |
| 64 | |
| 65 | U_BOOT_DRIVER(cpu_sandbox) = { |
| 66 | .name = "cpu_sandbox", |
| 67 | .id = UCLASS_CPU, |
| 68 | .ops = &cpu_sandbox_ops, |
| 69 | .of_match = cpu_sandbox_ids, |
| 70 | .probe = cpu_sandbox_probe, |
| 71 | }; |