65a094cc35da0cc09cdd059f852b99218da76cde
[openwrt/svn-archive/archive.git] / target / linux / ar7 / files / arch / mips / ar7 / memory.c
1 /*
2 * Copyright (C) 2007 OpenWrt.org
3 *
4 * Based on arch/mips/mm/init.c
5 * Copyright (C) 1994 - 2000 Ralf Baechle
6 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
7 * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
8 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24 #include <linux/bootmem.h>
25 #include <linux/init.h>
26 #include <linux/mm.h>
27 #include <linux/module.h>
28 #include <linux/pfn.h>
29 #include <linux/proc_fs.h>
30 #include <linux/string.h>
31 #include <linux/swap.h>
32
33 #include <asm/bootinfo.h>
34 #include <asm/page.h>
35 #include <asm/sections.h>
36
37 #include <asm/mips-boards/prom.h>
38
39 static int __init memsize(void)
40 {
41 u32 size = (64 << 20);
42 volatile u32 *addr = (u32 *)KSEG1ADDR(0x14000000 + size - 4);
43 u32 *kernel_end = (u32 *)KSEG1ADDR(CPHYSADDR((u32)&_end));
44
45 while (addr > kernel_end) {
46 *addr = (u32)addr;
47 size >>= 1;
48 addr -= size >> 2;
49 }
50
51 do {
52 addr += size >> 2;
53 if (*addr != (u32)addr)
54 break;
55 size <<= 1;
56 } while (size < (64 << 20));
57
58 return size;
59 }
60
61 void __init prom_meminit(void)
62 {
63 unsigned long pages;
64
65 pages = memsize() >> PAGE_SHIFT;
66 add_memory_region(PHYS_OFFSET, pages << PAGE_SHIFT,
67 BOOT_MEM_RAM);
68 }
69
70 void __init prom_free_prom_memory(void)
71 {
72 return;
73 }