summaryrefslogtreecommitdiff
path: root/common/memsize.c
diff options
context:
space:
mode:
authorWolfgang Denk <wd@pollux.denx.de>2006-11-06 17:06:36 +0100
committerWolfgang Denk <wd@denx.de>2006-11-06 17:06:36 +0100
commit91650b3e4de688038d4f71279c44858e3e2c6870 (patch)
tree5e05ac34616bbdfe70ce7ed38e9ef6f383a12aae /common/memsize.c
parentee58ea2689930669678fdcb27bf0cc5c341e18eb (diff)
Sequential accesses to non-existent memory must be synchronized,
at least on G2 cores. This fixes get_ram_size() problems on MPC5200 Rev. B boards.
Diffstat (limited to 'common/memsize.c')
-rw-r--r--common/memsize.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/common/memsize.c b/common/memsize.c
index dbc812dfc51..6c275c9b25f 100644
--- a/common/memsize.c
+++ b/common/memsize.c
@@ -21,6 +21,16 @@
* MA 02111-1307 USA
*/
+#include <config.h>
+#ifdef __PPC__
+/*
+ * At least on G2 PowerPC cores, sequential accesses to non-existent
+ * memory must be synchronized.
+ */
+# include <asm/io.h> /* for sync() */
+#else
+# define sync() /* nothing */
+#endif
/*
* Check memory range for valid RAM. A simple memory test determines
@@ -38,20 +48,27 @@ long get_ram_size(volatile long *base, long maxsize)
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
addr = base + cnt; /* pointer arith! */
+ sync ();
save[i++] = *addr;
+ sync ();
*addr = ~cnt;
}
addr = base;
+ sync ();
save[i] = *addr;
+ sync ();
*addr = 0;
+ sync ();
if ((val = *addr) != 0) {
/* Restore the original data before leaving the function.
*/
+ sync ();
*addr = save[i];
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
addr = base + cnt;
+ sync ();
*addr = save[--i];
}
return (0);