6dfa13c77d2be4ce1b77d19acad5028e34baa4d8
[openwrt-10.03/.git] / target / linux / atheros-2.6 / files / arch / mips / atheros / prom.c
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright MontaVista Software Inc
7  * Copyright (C) 2003 Atheros Communications, Inc.,  All Rights Reserved.
8  * Copyright (C) 2006 FON Technology, SL.
9  * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
10  * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
11  */
12
13 /*
14  * Prom setup file for ar531x
15  */
16
17 #include <linux/init.h>
18 #include <linux/autoconf.h>
19 #include <linux/kernel.h>
20 #include <linux/string.h>
21 #include <linux/mm.h>
22 #include <linux/bootmem.h>
23
24 #include <asm/bootinfo.h>
25 #include <asm/addrspace.h>
26 #include "ar531x.h"
27
28 void __init prom_init(void)
29 {
30         u32 memsize, memcfg;
31
32         mips_machgroup = MACH_GROUP_ATHEROS;
33         mips_machtype = -1;
34
35         /*                                                                             
36          * Atheros CPUs before the AR2315 are using MIPS 4Kc core, later designs are
37          * using MIPS 4KEc R2 core. This makes it easy to determine the board at runtime.
38          */
39                                                                             
40         if (current_cpu_data.cputype == CPU_4KEC) {
41                 mips_machtype = MACH_ATHEROS_AR5315;
42                 
43                 memcfg = sysRegRead(AR5315_MEM_CFG);
44                 memsize   = 1 + ((memcfg & SDRAM_DATA_WIDTH_M) >> SDRAM_DATA_WIDTH_S);
45                 memsize <<= 1 + ((memcfg & SDRAM_COL_WIDTH_M) >> SDRAM_COL_WIDTH_S);
46                 memsize <<= 1 + ((memcfg & SDRAM_ROW_WIDTH_M) >> SDRAM_ROW_WIDTH_S);
47                 memsize <<= 3;
48         } else {
49                 int bank0AC, bank1AC;
50
51                 mips_machtype = MACH_ATHEROS_AR5312;
52
53                 memcfg = sysRegRead(AR531X_MEM_CFG1);
54                 bank0AC = (memcfg & MEM_CFG1_AC0) >> MEM_CFG1_AC0_S;
55                 bank1AC = (memcfg & MEM_CFG1_AC1) >> MEM_CFG1_AC1_S;
56                 memsize = (bank0AC ? (1 << (bank0AC+1)) : 0)
57                         + (bank1AC ? (1 << (bank1AC+1)) : 0);
58                 memsize <<= 20;
59         }
60
61         add_memory_region(0, memsize, BOOT_MEM_RAM);
62         strcpy(arcs_cmdline, "console=ttyS0,9600 rootfstype=squashfs,jffs2");
63 }
64
65 void __init prom_free_prom_memory(void)
66 {
67 }