44a542d2f827446a0b2bbc4f6ac78725c97713df
[lede.git] / target / linux / brcm63xx-2.6 / files / arch / mips / bcm963xx / prom.c
1 /*
2 <:copyright-gpl
3  Copyright 2004 Broadcom Corp. All Rights Reserved.
4
5  This program is free software; you can distribute it and/or modify it
6  under the terms of the GNU General Public License (Version 2) as
7  published by the Free Software Foundation.
8
9  This program is distributed in the hope it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  for more details.
13
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 :>
18 */
19 /*
20  * prom.c: PROM library initialization code.
21  *
22  */
23 #include <linux/init.h>
24 #include <linux/mm.h>
25 #include <linux/sched.h>
26 #include <linux/bootmem.h>
27 #include <linux/blkdev.h>
28 #include <asm/addrspace.h>
29 #include <asm/bootinfo.h>
30 #include <asm/cpu.h>
31 #include <asm/time.h>
32
33 #include <bcm_map_part.h>
34 #include <board.h>
35 #include "boardparms.h"
36 #include "softdsl/AdslCoreDefs.h"
37
38
39 //char arcs_cmdline[CL_SIZE] __initdata = {0};
40 /* inv_xde */
41 int boot_loader_type;
42 int prom_argc;
43 char **prom_argv, **prom_envp;
44
45 extern int  do_syslog(int, char *, int);
46 extern void serial_init(void);
47 extern void __init InitNvramInfo( void );
48 extern void kerSysFlashInit( void );
49 extern unsigned long get_nvram_start_addr(void);
50 void __init create_root_nfs_cmdline( char *cmdline );
51
52 #define MACH_BCM                    MACH_BCM96348
53
54 const char *get_system_type(void)
55 {
56     /*PNVRAM_DATA pNvramData = (PNVRAM_DATA) get_nvram_start_addr();
57
58     return( pNvramData->szBoardId );*/
59     return "brcm63xx";
60 }
61
62 unsigned long getMemorySize(void)
63 {
64     unsigned long ulSdramType = BOARD_SDRAM_TYPE;
65
66     unsigned long ulSdramSize;
67
68     switch( ulSdramType )
69     {
70     case BP_MEMORY_16MB_1_CHIP:
71     case BP_MEMORY_16MB_2_CHIP:
72         ulSdramSize = 16 * 1024 * 1024;
73         break;
74     case BP_MEMORY_32MB_1_CHIP:
75     case BP_MEMORY_32MB_2_CHIP:
76         ulSdramSize = 32 * 1024 * 1024;
77         break;
78     case BP_MEMORY_64MB_2_CHIP:
79         ulSdramSize = 64 * 1024 * 1024;
80         break;
81     default:
82         ulSdramSize = 8 * 1024 * 1024;
83         break;
84     }
85     if (boot_loader_type == BOOT_CFE)
86       return ulSdramSize;
87     else
88       // assume that there is one contiguous memory map
89       return boot_mem_map.map[0].size;
90 }
91
92 /* --------------------------------------------------------------------------
93     Name: prom_init
94  -------------------------------------------------------------------------- */
95 void __init prom_init(void)
96 {
97     extern ulong r4k_interval;
98
99     serial_init();
100
101     prom_argc = fw_arg0;
102     prom_argv = (char **) fw_arg1;
103     prom_envp = (char **) fw_arg2;
104
105     if ((prom_argv > 0x80000000) && (prom_argv < 0x82000000)) {
106       strncpy(arcs_cmdline, prom_argv[1], CL_SIZE);
107     }
108
109     if (strncmp(arcs_cmdline, "boot_loader=RedBoot", 19) != 0) {
110       boot_loader_type =  BOOT_CFE;
111     }
112     else {
113       boot_loader_type = BOOT_REDBOOT;
114     }
115
116     do_syslog(8, NULL, 8);
117
118     printk( "%s prom init\n", get_system_type() );
119
120     PERF->IrqMask = 0;
121
122     arcs_cmdline[0] = '\0';
123
124        if (boot_loader_type == BOOT_CFE)
125       add_memory_region(0, (getMemorySize() - ADSL_SDRAM_IMAGE_SIZE), BOOT_MEM_RAM);
126     else
127        add_memory_region(0, (0x01000000 - ADSL_SDRAM_IMAGE_SIZE), BOOT_MEM_RAM);
128
129     mips_machgroup = MACH_GROUP_BRCM;
130     mips_machtype = MACH_BCM;
131
132        BpSetBoardId("96348GW-10");
133 }
134
135 /* --------------------------------------------------------------------------
136     Name: prom_free_prom_memory
137 Abstract:
138  -------------------------------------------------------------------------- */
139 void __init prom_free_prom_memory(void)
140 {
141
142 }
143