[U-Boot] [PATCH 6/8] cpu: Add cpu_print_info function

Mario Six mario.six at gdsys.cc
Wed Mar 28 12:38:30 UTC 2018


Add a cpu_print_info function to the CPU uclass to emulate the behavior
of some current non-DM drivers (e.g. MPC83xx) to print CPU information
during startup.

Signed-off-by: Mario Six <mario.six at gdsys.cc>
---
 drivers/cpu/cpu-uclass.c | 10 ++++++++++
 include/cpu.h            | 15 +++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c
index 73e4853939..854cedd1b0 100644
--- a/drivers/cpu/cpu-uclass.c
+++ b/drivers/cpu/cpu-uclass.c
@@ -54,6 +54,16 @@ int cpu_get_vendor(struct udevice *dev, char *buf, int size)
 	return ops->get_vendor(dev, buf, size);
 }
 
+int cpu_print_info(struct udevice *dev)
+{
+	struct cpu_ops *ops = cpu_get_ops(dev);
+
+	if (!ops->get_vendor)
+		return -ENOSYS;
+
+	return ops->print_info(dev);
+}
+
 U_BOOT_DRIVER(cpu_bus) = {
 	.name	= "cpu_bus",
 	.id	= UCLASS_SIMPLE_BUS,
diff --git a/include/cpu.h b/include/cpu.h
index 954257715a..37ff000bf9 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -83,6 +83,14 @@ struct cpu_ops {
 	 * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
 	 */
 	int (*get_vendor)(struct udevice *dev, char *buf, int size);
+
+	/**
+	 * print_info() - Print information about a CPU
+	 *
+	 * @dev:	Device to check (UCLASS_CPU)
+	 * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
+	 */
+	int (*print_info)(struct udevice *dev);
 };
 
 #define cpu_get_ops(dev)        ((struct cpu_ops *)(dev)->driver->ops)
@@ -124,4 +132,11 @@ int cpu_get_count(struct udevice *dev);
  */
 int cpu_get_vendor(struct udevice *dev, char *buf, int size);
 
+/**
+ * cpu_print_info() - Print information about a CPU
+ *
+ * @dev:	Device to check (UCLASS_CPU)
+ * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
+ */
+int cpu_print_info(struct udevice *dev);
 #endif
-- 
2.16.1



More information about the U-Boot mailing list