]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
sysreset: Add get_status method
authorMario Six <mario.six@gdsys.cc>
Mon, 6 Aug 2018 08:23:32 +0000 (10:23 +0200)
committerSimon Glass <sjg@chromium.org>
Tue, 18 Sep 2018 06:01:18 +0000 (00:01 -0600)
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>
drivers/sysreset/sysreset-uclass.c
include/sysreset.h

index b918365e73a8f608d84facd611b28d102c382493..06ef0ed96c77605d1b853d6a9722ff953da4066b 100644 (file)
@@ -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;
index 81318bdbf5d3a2fb25f49be67335201bbb56b047..a5c0b74a4736e387e14516bf8a424d5f621fa7d7 100644 (file)
@@ -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)
@@ -40,6 +48,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
  *