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