blob: ab18ee2ea9346415af7ba0924929ac31dfb698a5 [file] [log] [blame]
Simon Glass11f4dc12015-04-28 20:25:09 -06001/*
2 * Copyright (C) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
9#include <cpu.h>
10#include <dm.h>
11#include <dm/lists.h>
12#include <dm/root.h>
13
14int cpu_get_desc(struct udevice *dev, char *buf, int size)
15{
16 struct cpu_ops *ops = cpu_get_ops(dev);
17
18 if (!ops->get_desc)
19 return -ENOSYS;
20
21 return ops->get_desc(dev, buf, size);
22}
23
24int cpu_get_info(struct udevice *dev, struct cpu_info *info)
25{
26 struct cpu_ops *ops = cpu_get_ops(dev);
27
28 if (!ops->get_desc)
29 return -ENOSYS;
30
31 return ops->get_info(dev, info);
32}
33
34U_BOOT_DRIVER(cpu_bus) = {
35 .name = "cpu_bus",
36 .id = UCLASS_SIMPLE_BUS,
37 .per_child_platdata_auto_alloc_size = sizeof(struct cpu_platdata),
38};
39
40static int uclass_cpu_init(struct uclass *uc)
41{
42 struct udevice *dev;
43 int node;
44 int ret;
45
46 node = fdt_path_offset(gd->fdt_blob, "/cpus");
47 if (node < 0)
48 return 0;
49
50 ret = device_bind_driver_to_node(dm_root(), "cpu_bus", "cpus", node,
51 &dev);
52
53 return ret;
54}
55
56UCLASS_DRIVER(cpu) = {
57 .id = UCLASS_CPU,
58 .name = "cpu",
59 .flags = DM_UC_FLAG_SEQ_ALIAS,
60 .init = uclass_cpu_init,
61};