[U-Boot] [PATCH 1/9] kmp204x: support for QRIO1 bootcounter

Valentin Longchamp valentin.longchamp at keymile.com
Mon Jan 13 17:29:09 CET 2014


From: Rainer Boschung <rainer.boschung at keymile.com>

- make use of the QRIO1 32bit register at 0x20 as bootcounter register
- check for BOOTCOUNT_MAGIC pattern when before bootcounter value is read

Signed-off-by: Rainer Boschung <rainer.boschung at keymile.com>
Signed-off-by: Valentin Longchamp <valentin.longchamp at keymile.com>
Acked-by: Valentin Longchamp <valentin.longchamp at keymile.com>
---

 board/keymile/kmp204x/kmp204x.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/board/keymile/kmp204x/kmp204x.c b/board/keymile/kmp204x/kmp204x.c
index f02642a..b41929a 100644
--- a/board/keymile/kmp204x/kmp204x.c
+++ b/board/keymile/kmp204x/kmp204x.c
@@ -134,22 +134,25 @@ void qrio_prstcfg(u8 bit, u8 mode)
 }
 
 
-#define BOOTCOUNT_OFF	0x12
+#define BOOTCOUNT_OFF	0x20
 
 void bootcount_store(ulong counter)
 {
-	u8 val;
 	void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE;
 
-	val = (counter <= 255) ? (u8)counter : 255;
-	out_8(qrio_base + BOOTCOUNT_OFF, val);
+	out_be32(qrio_base + BOOTCOUNT_OFF, counter);
 }
 
 ulong bootcount_load(void)
 {
-	u8 val;
+	u32 val;
 	void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE;
-	val = in_8(qrio_base + BOOTCOUNT_OFF);
+	val = in_be32(qrio_base + BOOTCOUNT_OFF + 4);
+
+	if (val == BOOTCOUNT_MAGIC)
+		val = in_be32(qrio_base + BOOTCOUNT_OFF);
+	else
+		val = 0;
 	return val;
 }
 
-- 
1.8.0.1



More information about the U-Boot mailing list