summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Six <mario.six@gdsys.cc>2018-08-06 10:23:32 +0200
committerSimon Glass <sjg@chromium.org>2018-09-18 00:01:18 -0600
commit245f5cda69a1332585c2a22a48420f4ca1ab67ad (patch)
tree6c56d4923d5ec2845ff6d3704321e85a08b46d40
parent08f5b0b23a62ac7d1b705241f16df1e3a1cb8ae1 (diff)
downloadu-boot-245f5cda69a1332585c2a22a48420f4ca1ab67ad.tar.gz
u-boot-245f5cda69a1332585c2a22a48420f4ca1ab67ad.tar.bz2
u-boot-245f5cda69a1332585c2a22a48420f4ca1ab67ad.zip
sysreset: Add get_status method
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). Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
-rw-r--r--drivers/sysreset/sysreset-uclass.c10
-rw-r--r--include/sysreset.h17
2 files changed, 27 insertions, 0 deletions
diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c
index b918365e73..06ef0ed96c 100644
--- a/drivers/sysreset/sysreset-uclass.c
+++ b/drivers/sysreset/sysreset-uclass.c
@@ -24,6 +24,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 81318bdbf5..a5c0b74a47 100644
--- a/include/sysreset.h
+++ b/include/sysreset.h
@@ -28,6 +28,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
*
* This works through the available sysreset devices until it finds one that can