rewrite memory size detection
authorGabor Juhos <juhosg@openwrt.org>
Thu, 13 Nov 2008 15:55:39 +0000 (15:55 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Thu, 13 Nov 2008 15:55:39 +0000 (15:55 +0000)
SVN-Revision: 13198

target/linux/ar71xx/files/arch/mips/ar71xx/setup.c

index 855497c7d46dfa4e1200319b29bf7ec234093772..fc8652098de2cebc3cf05ae810a3286b52f69579 100644 (file)
@@ -85,28 +85,14 @@ int __init ar71xx_pci_init(unsigned nr_irqs, struct ar71xx_pci_irq *map)
 
 static void __init ar71xx_detect_mem_size(void)
 {
-       volatile u8 *p;
-       u8 memsave;
-       u32 size;
-
-       p = (volatile u8 *) KSEG1ADDR(0);
-       memsave = *p;
-       for (size = AR71XX_MEM_SIZE_MIN;
-            size <= (AR71XX_MEM_SIZE_MAX >> 1); size <<= 1) {
-               volatile u8 *r;
-
-               r = (p + size);
-               *p = 0x55;
-               if (*r == 0x55) {
-                       /* Mirrored data found, try another pattern */
-                       *p = 0xAA;
-                       if (*r == 0xAA) {
-                               /* Mirrored data found again, stop detection */
-                               break;
-                       }
-               }
+       unsigned long size;
+
+       for (size = AR71XX_MEM_SIZE_MIN; size < AR71XX_MEM_SIZE_MAX;
+            size <<= 1 ) {
+               if (!memcmp(ar71xx_detect_mem_size,
+                           ar71xx_detect_mem_size + size, 1024))
+                       break;
        }
-       *p = memsave;
 
        add_memory_region(0, size, BOOT_MEM_RAM);
 }