From 57370de377340b0fcb81d90a187aa8b8f3494447 Mon Sep 17 00:00:00 2001 From: Mario Six Date: Mon, 6 Aug 2018 10:23:43 +0200 Subject: [PATCH] cpu: Add cpu_probe_all method Add a method to probe all CPUs of the board. Signed-off-by: Mario Six --- drivers/cpu/cpu-uclass.c | 23 +++++++++++++++++++++++ include/cpu.h | 7 +++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c index f362eb1..457f77b 100644 --- a/drivers/cpu/cpu-uclass.c +++ b/drivers/cpu/cpu-uclass.c @@ -11,6 +11,29 @@ #include #include +int cpu_probe_all(void) +{ + struct udevice *cpu; + int ret; + + ret = uclass_first_device(UCLASS_CPU, &cpu); + if (ret) { + debug("%s: No CPU found (err = %d)\n", __func__, ret); + return ret; + } + + while (cpu) { + ret = uclass_next_device(&cpu); + if (ret) { + debug("%s: Error while probing CPU (err = %d)\n", + __func__, ret); + return ret; + } + } + + return 0; +} + int cpu_get_desc(struct udevice *dev, char *buf, int size) { struct cpu_ops *ops = cpu_get_ops(dev); diff --git a/include/cpu.h b/include/cpu.h index 22467cb..367c5f4 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -125,4 +125,11 @@ int cpu_get_count(struct udevice *dev); */ int cpu_get_vendor(struct udevice *dev, char *buf, int size); +/** + * cpu_probe_all() - Probe all available CPUs + * + * Return: 0 if OK, -ve on error + */ +int cpu_probe_all(void); + #endif