/*1* Copyright (C) 2007 Felix Fietkau <[email protected]>2* Copyright (C) 2007 Eugene Konev <[email protected]>3*4* This program is free software; you can redistribute it and/or modify5* it under the terms of the GNU General Public License as published by6* the Free Software Foundation; either version 2 of the License, or7* (at your option) any later version.8*9* This program is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12* GNU General Public License for more details.13*14* You should have received a copy of the GNU General Public License15* along with this program; if not, write to the Free Software16* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA17*/18#include <linux/bootmem.h>19#include <linux/init.h>20#include <linux/mm.h>21#include <linux/module.h>22#include <linux/pfn.h>23#include <linux/proc_fs.h>24#include <linux/string.h>25#include <linux/swap.h>2627#include <asm/bootinfo.h>28#include <asm/page.h>29#include <asm/sections.h>3031#include <asm/mach-ar7/ar7.h>32#include <asm/mips-boards/prom.h>3334static int __init memsize(void)35{36u32 size = (64 << 20);37u32 *addr = (u32 *)KSEG1ADDR(AR7_SDRAM_BASE + size - 4);38u32 *kernel_end = (u32 *)KSEG1ADDR(CPHYSADDR((u32)&_end));39u32 *tmpaddr = addr;4041while (tmpaddr > kernel_end) {42*tmpaddr = (u32)tmpaddr;43size >>= 1;44tmpaddr -= size >> 2;45}4647do {48tmpaddr += size >> 2;49if (*tmpaddr != (u32)tmpaddr)50break;51size <<= 1;52} while (size < (64 << 20));5354writel((u32)tmpaddr, &addr);5556return size;57}5859void __init prom_meminit(void)60{61unsigned long pages;6263pages = memsize() >> PAGE_SHIFT;64add_memory_region(PHYS_OFFSET, pages << PAGE_SHIFT, BOOT_MEM_RAM);65}6667void __init prom_free_prom_memory(void)68{69/* Nothing to free */70}717273