From patchwork Fri May 1 14:55:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 244749 List-Id: U-Boot discussion From: rasmus.villemoes at prevas.dk (Rasmus Villemoes) Date: Fri, 1 May 2020 16:55:15 +0200 Subject: [PATCH 4/5] sysreset: mpc83xx: add output in case of cold boot In-Reply-To: <20200501145516.18168-1-rasmus.villemoes@prevas.dk> References: <20200501145516.18168-1-rasmus.villemoes@prevas.dk> Message-ID: <20200501145516.18168-5-rasmus.villemoes@prevas.dk> 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 --- drivers/sysreset/sysreset_mpc83xx.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) 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;