From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mario Six Date: Wed, 28 Mar 2018 14:38:30 +0200 Subject: [U-Boot] [PATCH 6/8] cpu: Add cpu_print_info function In-Reply-To: <20180328123832.16401-1-mario.six@gdsys.cc> References: <20180328123832.16401-1-mario.six@gdsys.cc> Message-ID: <20180328123832.16401-6-mario.six@gdsys.cc> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- 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