diff mbox series

[4/5] sysreset: mpc83xx: add output in case of cold boot

Message ID 20200501145516.18168-5-rasmus.villemoes@prevas.dk
State Deferred
Delegated to: Tom Rini
Headers show
Series some sysreset patches (mostly for mpc83xx) | expand

Commit Message

Rasmus Villemoes May 1, 2020, 2:55 p.m. UTC
For a powercycle/cold boot, none of the RSR_* bits in the reset status
register are set, so one gets an empty

  Reset Status:

line. Print an indication that this was likely a cold boot.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 drivers/sysreset/sysreset_mpc83xx.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/sysreset/sysreset_mpc83xx.c b/drivers/sysreset/sysreset_mpc83xx.c
index 631ae6a5dc..6457d73418 100644
--- a/drivers/sysreset/sysreset_mpc83xx.c
+++ b/drivers/sysreset/sysreset_mpc83xx.c
@@ -149,20 +149,28 @@  static int mpc83xx_sysreset_get_status(struct udevice *dev, char *buf, int size)
 	ulong rsr = gd->arch.reset_status;
 	int i;
 	char *sep;
+	ulong known_bits = RSR_SWSR | RSR_SWHR | RSR_JSRS | RSR_CSHR |
+		RSR_SWRS | RSR_BMRS | RSR_SRS | RSR_HRS;
 
 	res = scnprintf(buf, size, "Reset Status:");
 	buf += res;
 	size -= res;
 
-	sep = " ";
-	for (i = 0; i < ARRAY_SIZE(bits); i++)
-		/* Print description of set bits */
-		if (rsr & bits[i].mask) {
-			res = scnprintf(buf, size, "%s%s", sep, bits[i].desc);
-			buf += res;
-			size -= res;
-			sep = ", ";
-		}
+	if (rsr & known_bits) {
+		sep = " ";
+		for (i = 0; i < ARRAY_SIZE(bits); i++)
+			/* Print description of set bits */
+			if (rsr & bits[i].mask) {
+				res = scnprintf(buf, size, "%s%s", sep, bits[i].desc);
+				buf += res;
+				size -= res;
+				sep = ", ";
+			}
+	} else {
+		res = scnprintf(buf, size, " Unknown/Cold boot");
+		buf += res;
+		size -= res;
+	}
 
 	res = scnprintf(buf, size, "\n");
 	buf += res;