Skip to content
Snippets Groups Projects
Commit cc8d698f authored by Hans de Goede's avatar Hans de Goede Committed by Tom Rini
Browse files

Revert "common/memsize.c: Simplify RAM size detection"


This commit breaks bootup on sunxi boards, the get stuck
when running the main u-boot binary at:

CPU:   Allwinner H3 (SUN8I)
I2C:   ready
DRAM:

This reverts commit 8e7cba04.

Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent c82ce04a
No related branches found
No related tags found
No related merge requests found
...@@ -33,28 +33,38 @@ long get_ram_size(long *base, long maxsize) ...@@ -33,28 +33,38 @@ long get_ram_size(long *base, long maxsize)
long size; long size;
int i = 0; int i = 0;
for (cnt = (maxsize / sizeof(long)) >> 1; cnt >= 0; cnt >>= 1) { for (cnt = (maxsize / sizeof(long)) >> 1; cnt > 0; cnt >>= 1) {
addr = base + cnt; /* pointer arith! */ addr = base + cnt; /* pointer arith! */
sync(); sync();
save[i] = *addr; save[i++] = *addr;
sync(); sync();
if (cnt) { *addr = ~cnt;
i++;
*addr = ~cnt;
} else {
*addr = 0;
}
} }
addr = base;
sync();
save[i] = *addr;
sync();
*addr = 0;
sync(); sync();
cnt = 0; if ((val = *addr) != 0) {
do { /* 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);
}
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
addr = base + cnt; /* pointer arith! */ addr = base + cnt; /* pointer arith! */
val = *addr; val = *addr;
*addr = save[i--]; *addr = save[--i];
sync(); if (val != ~cnt) {
if (((cnt == 0) && (val != 0)) ||
((cnt != 0) && (val != ~cnt))) {
size = cnt * sizeof(long); size = cnt * sizeof(long);
/* /*
* Restore the original data * Restore the original data
...@@ -64,16 +74,11 @@ long get_ram_size(long *base, long maxsize) ...@@ -64,16 +74,11 @@ long get_ram_size(long *base, long maxsize)
cnt < maxsize / sizeof(long); cnt < maxsize / sizeof(long);
cnt <<= 1) { cnt <<= 1) {
addr = base + cnt; addr = base + cnt;
*addr = save[i--]; *addr = save[--i];
} }
return (size); return (size);
} }
}
if (cnt)
cnt = cnt << 1;
else
cnt = 1;
} while (cnt < maxsize / sizeof(long));
return (maxsize); return (maxsize);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment