Merge branch 'upstream' of git://lost.foo-projects.org/~ahkok/git/netdev-2.6 into...
[pandora-kernel.git] / arch / mips / mips-boards / generic / memory.c
index 32c9210..c89fcf9 100644 (file)
  * PROM library functions for acquiring/using memory descriptors given to
  * us from the YAMON.
  */
-#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/bootmem.h>
+#include <linux/pfn.h>
 #include <linux/string.h>
 
 #include <asm/bootinfo.h>
 #include <asm/page.h>
+#include <asm/sections.h>
 
 #include <asm/mips-boards/prom.h>
 
@@ -46,9 +47,6 @@ static char *mtypes[3] = {
 };
 #endif
 
-/* References to section boundaries */
-extern char _end;
-
 struct prom_pmemblock * __init prom_getmdesc(void)
 {
        char *memsize_str;
@@ -77,6 +75,15 @@ struct prom_pmemblock * __init prom_getmdesc(void)
                        memsize = simple_strtol(memsize_str, NULL, 0);
                }
        }
+
+#ifdef CONFIG_CPU_BIG_ENDIAN
+       /*
+        * SOC-it swaps, or perhaps doesn't swap, when DMA'ing the last
+        * word of physical memory
+        */
+       memsize -= PAGE_SIZE;
+#endif
+
        memset(mdesc, 0, sizeof(mdesc));
 
        mdesc[0].type = yamon_dontuse;
@@ -106,10 +113,10 @@ struct prom_pmemblock * __init prom_getmdesc(void)
 
        mdesc[3].type = yamon_dontuse;
        mdesc[3].base = 0x00100000;
-       mdesc[3].size = CPHYSADDR(PAGE_ALIGN(&_end)) - mdesc[3].base;
+       mdesc[3].size = CPHYSADDR(PFN_ALIGN((unsigned long)&_end)) - mdesc[3].base;
 
        mdesc[4].type = yamon_free;
-       mdesc[4].base = CPHYSADDR(PAGE_ALIGN(&_end));
+       mdesc[4].base = CPHYSADDR(PFN_ALIGN(&_end));
        mdesc[4].size = memsize - mdesc[4].base;
 
        return &mdesc[0];