72d6668a1a4f8474aaf206c2499a0d84782cdbb9
[15.05/openwrt.git] / target / linux / ar7 / files / 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         volatile u32 *addr = (u32 *)KSEG1ADDR(0x14000000 + size - 4);
41         u32 *kernel_end = (u32 *)KSEG1ADDR(CPHYSADDR((u32)&_end));
42
43         while (addr > kernel_end) {
44                 *addr = (u32)addr;
45                 size >>= 1;
46                 addr -= size >> 2;
47         }
48
49         do {
50                 addr += size >> 2;
51                 if (*addr != (u32)addr)
52                         break;
53                 size <<= 1;
54         } while (size < (64 << 20));
55
56         return size;
57 }
58
59 void __init prom_meminit(void)
60 {
61         unsigned long pages;
62
63         pages = memsize() >> PAGE_SHIFT;
64         add_memory_region(PHYS_OFFSET, pages << PAGE_SHIFT,
65                           BOOT_MEM_RAM);
66 }
67
68 void __init prom_free_prom_memory(void)
69 {
70         return;
71 }