It's useful to have the reset status of the SoC printed out during reset (e.g. to learn whether the reset was caused by software or a watchdog).
As a first step to implement this, add a get_status method to the sysreset class, which enables the caller to get printable information about the reset status (akin to get_desc in the CPU uclass). Signed-off-by: Mario Six <mario....@gdsys.cc> --- v1 -> v2: New in v2 --- drivers/sysreset/sysreset-uclass.c | 10 ++++++++++ include/sysreset.h | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c index 0747c52b60..771a325b46 100644 --- a/drivers/sysreset/sysreset-uclass.c +++ b/drivers/sysreset/sysreset-uclass.c @@ -25,6 +25,16 @@ int sysreset_request(struct udevice *dev, enum sysreset_t type) return ops->request(dev, type); } +int sysreset_get_status(struct udevice *dev, char *buf, int size) +{ + struct sysreset_ops *ops = sysreset_get_ops(dev); + + if (!ops->get_status) + return -ENOSYS; + + return ops->get_status(dev, buf, size); +} + int sysreset_walk(enum sysreset_t type) { struct udevice *dev; diff --git a/include/sysreset.h b/include/sysreset.h index 393c7be3d8..9e326fefeb 100644 --- a/include/sysreset.h +++ b/include/sysreset.h @@ -29,6 +29,14 @@ struct sysreset_ops { * (in which case this method will not actually return) */ int (*request)(struct udevice *dev, enum sysreset_t type); + /** + * get_status() - get printable reset status information + * + * @buf: Buffer to receive the textual reset information + * @size: Size of the passed buffer + * @return 0 if OK, -ve on error + */ + int (*get_status)(struct udevice *dev, char *buf, int size); }; #define sysreset_get_ops(dev) ((struct sysreset_ops *)(dev)->driver->ops) @@ -41,6 +49,15 @@ struct sysreset_ops { */ int sysreset_request(struct udevice *dev, enum sysreset_t type); +/** + * get_status() - get printable reset status information + * + * @buf: Buffer to receive the textual reset information + * @size: Size of the passed buffer + * @return 0 if OK, -ve on error + */ +int sysreset_get_status(struct udevice *dev, char *buf, int size); + /** * sysreset_walk() - cause a system reset * -- 2.16.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot