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