[kernel] add missing configuration symbol (for rdc)
[openwrt.git] / target / linux / rb532 / files-2.6.24 / arch / mips / rb500 / prom.c
1 /*
2 * prom.c
3 **********************************************************************
4 * P . Sadik Oct 10, 2003
5 *
6 * Started change log
7 * idt_cpu_freq is make a kernel configuration parameter
8 * idt_cpu_freq is exported so that other modules can use it.
9 * Code cleanup
10 **********************************************************************
11 * P. Sadik Oct 20, 2003
12 *
13 * Removed NVRAM code from here, since they are already available under
14 * nvram directory.
15 * Added serial port initialisation.
16 **********************************************************************
17 **********************************************************************
18 * P. Sadik Oct 30, 2003
19 *
20 * Added reset_cons_port
21 **********************************************************************
22
23 P.Christeas, 2005-2006
24 Port to 2.6, add 2.6 cmdline parsing
25
26 */
27
28 #include <linux/autoconf.h>
29 #include <linux/init.h>
30 #include <linux/mm.h>
31 #include <linux/module.h>
32 #include <linux/string.h>
33 #include <linux/console.h>
34 #include <asm/bootinfo.h>
35 #include <linux/bootmem.h>
36 #include <linux/ioport.h>
37 #include <linux/blkdev.h>
38 #include <asm/rc32434/ddr.h>
39
40 #define PROM_ENTRY(x) (0xbfc00000+((x)*8))
41 extern void __init setup_serial_port(void);
42
43 unsigned int idt_cpu_freq = 132000000;
44 EXPORT_SYMBOL(idt_cpu_freq);
45 unsigned int gpio_bootup_state = 0;
46 EXPORT_SYMBOL(gpio_bootup_state);
47
48 char mips_mac_address[18] = "08:00:06:05:40:01";
49 EXPORT_SYMBOL(mips_mac_address);
50
51 /* what to append to cmdline when button is [not] pressed */
52 #define GPIO_INIT_NOBUTTON ""
53 #define GPIO_INIT_BUTTON " 2"
54
55 #ifdef CONFIG_MIKROTIK_RB500
56 unsigned soft_reboot = 0;
57 EXPORT_SYMBOL(soft_reboot);
58 #endif
59
60 #define SR_NMI 0x00180000 /* NMI */
61 #define SERIAL_SPEED_ENTRY 0x00000001
62
63 #ifdef CONFIG_REMOTE_DEBUG
64 extern int remote_debug;
65 #endif
66
67 #define FREQ_TAG "HZ="
68 #define GPIO_TAG "gpio="
69 #define KMAC_TAG "kmac="
70 #define MEM_TAG "mem="
71 #define BOARD_TAG "board="
72 #define IGNORE_CMDLINE_MEM 1
73 #define DEBUG_DDR
74
75 #define BOARD_RB532 "500"
76 #define BOARD_RB532A "500r5"
77
78 void parse_soft_settings(unsigned *ptr, unsigned size);
79 void parse_hard_settings(unsigned *ptr, unsigned size);
80
81 void __init prom_setup_cmdline(void);
82
83 void __init prom_init(void)
84 {
85 DDR_t ddr = (DDR_t) DDR_VirtualAddress; /* define the pointer to the DDR registers */
86 phys_t memsize = 0-ddr->ddrmask;
87
88 /* this should be the very first message, even before serial is properly initialized */
89 prom_setup_cmdline();
90 setup_serial_port();
91
92 soft_reboot = read_c0_status() & SR_NMI;
93 pm_power_off = NULL;
94
95 /*
96 * give all RAM to boot allocator,
97 * except for the first 0x400 and the last 0x200 bytes
98 */
99 add_memory_region(ddr->ddrbase + 0x400, memsize - 0x600, BOOT_MEM_RAM);
100 }
101
102 void __init prom_free_prom_memory(void)
103 {
104 /* No prom memory to free */
105 }
106
107 static inline int match_tag(char *arg, const char *tag)
108 {
109 return (strncmp(arg, tag, strlen(tag)) == 0);
110 }
111
112 static inline unsigned long tag2ul(char *arg, const char *tag)
113 {
114 char *num = arg+strlen(tag);
115 return simple_strtoul(num, 0, 10);
116 }
117
118 extern char _image_cmdline;
119 void __init prom_setup_cmdline(void){
120 char cmd_line[CL_SIZE];
121 char *cp;
122 int prom_argc;
123 char **prom_argv, **prom_envp;
124 int i;
125
126 prom_argc = fw_arg0;
127 prom_argv = (char **) fw_arg1;
128 prom_envp = (char **) fw_arg2;
129
130 cp=cmd_line;
131 /* Note: it is common that parameters start at argv[1] and not argv[0],
132 however, our elf loader starts at [0] */
133 for(i=0;i<prom_argc;i++){
134 if (match_tag(prom_argv[i], FREQ_TAG)) {
135 idt_cpu_freq = tag2ul(prom_argv[i], FREQ_TAG);
136 continue;
137 }
138 #ifdef IGNORE_CMDLINE_MEM
139 /* parses out the "mem=xx" arg */
140 if (match_tag(prom_argv[i], MEM_TAG)) {
141 continue;
142 }
143 #endif
144 if (i>0) *(cp++) = ' ';
145 if (match_tag(prom_argv[i], BOARD_TAG)) {
146 char *board = prom_argv[i] + strlen(BOARD_TAG);
147 if (match_tag(board, BOARD_RB532A))
148 mips_machtype = MACH_MIKROTIK_RB532A;
149 else
150 mips_machtype = MACH_MIKROTIK_RB532;
151 }
152
153 if (match_tag(prom_argv[i], GPIO_TAG)) {
154 gpio_bootup_state = tag2ul(prom_argv[i], GPIO_TAG);
155 }
156 strcpy(cp,prom_argv[i]);
157 cp+=strlen(prom_argv[i]);
158 }
159 *(cp++) = ' ';
160 strcpy(cp,(&_image_cmdline + 8));
161 cp += strlen(&_image_cmdline);
162
163 i=strlen(arcs_cmdline);
164 if (i>0){
165 *(cp++) = ' ';
166 strcpy(cp,arcs_cmdline);
167 cp+=strlen(arcs_cmdline);
168 }
169 if (gpio_bootup_state&0x02)
170 strcpy(cp,GPIO_INIT_NOBUTTON);
171 else
172 strcpy(cp,GPIO_INIT_BUTTON);
173 cmd_line[CL_SIZE-1] = '\0';
174
175 strcpy(arcs_cmdline,cmd_line);
176 }
177
This page took 0.050547 seconds and 5 git commands to generate.