@@ -852,6 +852,15 @@ int reserve_arch(void)
return board_walk_opt_phase(BOARD_F_RESERVE_ARCH);
}
+int print_cpuinfo(void)
+{
+#ifdef CONFIG_CPU
+ return cpu_print_info();
+#else
+ return 0;
+#endif
+}
+
#else
/* Architecture-specific memory reservation */
@@ -938,7 +947,7 @@ static const init_fnc_t init_sequence_f[] = {
defined(CONFIG_BOARD_ENABLE)
checkcpu,
#endif
-#if defined(CONFIG_DISPLAY_CPUINFO)
+#if defined(CONFIG_DISPLAY_CPUINFO) || defined(CONFIG_BOARD_ENABLED)
print_cpuinfo, /* display cpu info (and speed) */
#endif
#if defined(CONFIG_DISPLAY_BOARDINFO)
@@ -54,6 +54,25 @@ int cpu_get_vendor(struct udevice *dev, char *buf, int size)
return ops->get_vendor(dev, buf, size);
}
+int cpu_print_info(void)
+{
+ struct udevice *dev;
+ char name[60];
+ int ret;
+
+ ret = uclass_first_device(UCLASS_CPU, &dev);
+ if (ret)
+ return ret;
+ if (!dev)
+ return 0;
+ ret = cpu_get_desc(dev, name, sizeof(name));
+ if (ret)
+ return ret;
+ printf("CPU: %s\n", name);
+
+ return 0;
+}
+
U_BOOT_DRIVER(cpu_bus) = {
.name = "cpu_bus",
.id = UCLASS_SIMPLE_BUS,
@@ -124,4 +124,9 @@ int cpu_get_count(struct udevice *dev);
*/
int cpu_get_vendor(struct udevice *dev, char *buf, int size);
+/**
+ * cpu_print_info() - Print information about the first CPU
+ */
+int cpu_print_info(void);
+
#endif
With driver model we can obtain CPU information by calling the CPU uclass. This avoids ad-hoc code for each board. Change the code to do this when CONFIG_BOARD is enabled. Signed-off-by: Simon Glass <sjg@chromium.org> --- common/board_f.c | 11 ++++++++++- drivers/cpu/cpu-uclass.c | 19 +++++++++++++++++++ include/cpu.h | 5 +++++ 3 files changed, 34 insertions(+), 1 deletion(-)