Bin Meng | be3f06b | 2015-06-12 14:52:20 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <cpu.h> |
| 9 | #include <dm.h> |
| 10 | #include <errno.h> |
| 11 | #include <asm/cpu.h> |
| 12 | |
| 13 | int cpu_x86_bind(struct udevice *dev) |
| 14 | { |
| 15 | struct cpu_platdata *plat = dev_get_parent_platdata(dev); |
| 16 | |
| 17 | plat->cpu_id = fdtdec_get_int(gd->fdt_blob, dev->of_offset, |
| 18 | "intel,apic-id", -1); |
| 19 | |
| 20 | return 0; |
| 21 | } |
| 22 | |
| 23 | int cpu_x86_get_desc(struct udevice *dev, char *buf, int size) |
| 24 | { |
| 25 | if (size < CPU_MAX_NAME_LEN) |
| 26 | return -ENOSPC; |
| 27 | |
| 28 | cpu_get_name(buf); |
| 29 | |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | static const struct cpu_ops cpu_x86_ops = { |
| 34 | .get_desc = cpu_x86_get_desc, |
| 35 | }; |
| 36 | |
| 37 | static const struct udevice_id cpu_x86_ids[] = { |
| 38 | { .compatible = "cpu-x86" }, |
| 39 | { } |
| 40 | }; |
| 41 | |
| 42 | U_BOOT_DRIVER(cpu_x86_drv) = { |
| 43 | .name = "cpu_x86", |
| 44 | .id = UCLASS_CPU, |
| 45 | .of_match = cpu_x86_ids, |
| 46 | .bind = cpu_x86_bind, |
| 47 | .ops = &cpu_x86_ops, |
| 48 | }; |