3 **********************************************************************
4 * P . Sadik Oct 10, 2003
7 * idt_cpu_freq is make a kernel configuration parameter
8 * idt_cpu_freq is exported so that other modules can use it.
10 **********************************************************************
11 * P. Sadik Oct 20, 2003
13 * Removed NVRAM code from here, since they are already available under
15 * Added serial port initialisation.
16 **********************************************************************
17 **********************************************************************
18 * P. Sadik Oct 30, 2003
20 * Added reset_cons_port
21 **********************************************************************
23 P.Christeas, 2005-2006
24 Port to 2.6, add 2.6 cmdline parsing
28 #include <linux/autoconf.h>
29 #include <linux/init.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>
40 #define PROM_ENTRY(x) (0xbfc00000+((x)*8))
41 extern void __init
setup_serial_port(void);
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
);
48 char mips_mac_address
[18] = "08:00:06:05:40:01";
49 EXPORT_SYMBOL(mips_mac_address
);
51 /* what to append to cmdline when button is [not] pressed */
52 #define GPIO_INIT_NOBUTTON ""
53 #define GPIO_INIT_BUTTON " 2"
55 #ifdef CONFIG_MIKROTIK_RB500
56 unsigned soft_reboot
= 0;
57 EXPORT_SYMBOL(soft_reboot
);
60 #define SR_NMI 0x00180000 /* NMI */
61 #define SERIAL_SPEED_ENTRY 0x00000001
63 #ifdef CONFIG_REMOTE_DEBUG
64 extern int remote_debug
;
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
75 #define BOARD_RB532 "500"
76 #define BOARD_RB532A "500r5"
78 void parse_soft_settings(unsigned *ptr
, unsigned size
);
79 void parse_hard_settings(unsigned *ptr
, unsigned size
);
81 void __init
prom_setup_cmdline(void);
83 void __init
prom_init(void)
85 DDR_t ddr
= (DDR_t
) DDR_VirtualAddress
; /* define the pointer to the DDR registers */
86 phys_t memsize
= 0-ddr
->ddrmask
;
88 /* this should be the very first message, even before serial is properly initialized */
92 mips_machgroup
= MACH_GROUP_MIKROTIK
;
93 soft_reboot
= read_c0_status() & SR_NMI
;
97 * give all RAM to boot allocator,
98 * except for the first 0x400 and the last 0x200 bytes
100 add_memory_region(ddr
->ddrbase
+ 0x400, memsize
- 0x600, BOOT_MEM_RAM
);
103 void __init
prom_free_prom_memory(void)
105 /* No prom memory to free */
108 static inline int match_tag(char *arg
, const char *tag
)
110 return (strncmp(arg
, tag
, strlen(tag
)) == 0);
113 static inline unsigned long tag2ul(char *arg
, const char *tag
)
115 char *num
= arg
+strlen(tag
);
116 return simple_strtoul(num
, 0, 10);
119 extern char _image_cmdline
;
120 void __init
prom_setup_cmdline(void){
121 char cmd_line
[CL_SIZE
];
124 char **prom_argv
, **prom_envp
;
128 prom_argv
= (char **) fw_arg1
;
129 prom_envp
= (char **) fw_arg2
;
132 /* Note: it is common that parameters start at argv[1] and not argv[0],
133 however, our elf loader starts at [0] */
134 for(i
=0;i
<prom_argc
;i
++){
135 if (match_tag(prom_argv
[i
], FREQ_TAG
)) {
136 idt_cpu_freq
= tag2ul(prom_argv
[i
], FREQ_TAG
);
139 #ifdef IGNORE_CMDLINE_MEM
140 /* parses out the "mem=xx" arg */
141 if (match_tag(prom_argv
[i
], MEM_TAG
)) {
145 if (i
>0) *(cp
++) = ' ';
146 if (match_tag(prom_argv
[i
], BOARD_TAG
)) {
147 char *board
= prom_argv
[i
] + strlen(BOARD_TAG
);
148 if (match_tag(board
, BOARD_RB532A
))
149 mips_machtype
= MACH_MIKROTIK_RB532A
;
151 mips_machtype
= MACH_MIKROTIK_RB532
;
154 if (match_tag(prom_argv
[i
], GPIO_TAG
)) {
155 gpio_bootup_state
= tag2ul(prom_argv
[i
], GPIO_TAG
);
157 strcpy(cp
,prom_argv
[i
]);
158 cp
+=strlen(prom_argv
[i
]);
161 strcpy(cp
,(&_image_cmdline
+ 8));
162 cp
+= strlen(&_image_cmdline
);
164 i
=strlen(arcs_cmdline
);
167 strcpy(cp
,arcs_cmdline
);
168 cp
+=strlen(arcs_cmdline
);
170 if (gpio_bootup_state
&0x02)
171 strcpy(cp
,GPIO_INIT_NOBUTTON
);
173 strcpy(cp
,GPIO_INIT_BUTTON
);
174 cmd_line
[CL_SIZE
-1] = '\0';
176 strcpy(arcs_cmdline
,cmd_line
);
This page took 0.058555 seconds and 5 git commands to generate.