]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - cpu/mpc5xxx/cpu.c
Adding bootlimit/bootcount feature for MPC5XXX on TQM5200 Boards
[karo-tx-uboot.git] / cpu / mpc5xxx / cpu.c
index ace16535ff618ce1f43b926e98029881bd5e9ecb..d87f42ca29e454af1c819fc7e5cf7e9bf268a52c 100644 (file)
@@ -135,3 +135,23 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 #endif
 }
 #endif
+
+#ifdef CONFIG_BOOTCOUNT_LIMIT
+
+void bootcount_store (ulong a)
+{
+     volatile ulong *save_addr = (volatile ulong *)(MPC5XXX_CDM_BRDCRMB);
+
+     *save_addr = (BOOTCOUNT_MAGIC & 0xffff0000) | a;
+}
+
+ulong bootcount_load (void)
+{
+     volatile ulong *save_addr = (volatile ulong *)(MPC5XXX_CDM_BRDCRMB);
+
+     if ((*save_addr & 0xffff0000) != (BOOTCOUNT_MAGIC & 0xffff0000))
+             return 0;
+     else
+             return (*save_addr & 0x0000ffff);
+}
+#endif /* CONFIG_BOOTCOUNT_LIMIT */