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 board_type = 500;
46 EXPORT_SYMBOL(board_type);
47 unsigned int gpio_bootup_state = 0;
48 EXPORT_SYMBOL(gpio_bootup_state);
51 char mips_mac_address[18] = "08:00:06:05:40:01";
52 EXPORT_SYMBOL(mips_mac_address);
54 /* what to append to cmdline when button is [not] pressed */
55 #define GPIO_INIT_NOBUTTON ""
56 #define GPIO_INIT_BUTTON " 2"
58 #ifdef CONFIG_MIKROTIK_RB500
59 unsigned soft_reboot = 0;
60 EXPORT_SYMBOL(soft_reboot);
63 #define SR_NMI 0x00180000 /* NMI */
64 #define SERIAL_SPEED_ENTRY 0x00000001
66 #ifdef CONFIG_REMOTE_DEBUG
67 extern int remote_debug;
70 extern unsigned long mips_machgroup;
71 extern unsigned long mips_machtype;
73 #define FREQ_TAG "HZ="
74 #define GPIO_TAG "gpio="
75 #define KMAC_TAG "kmac="
76 #define MEM_TAG "mem="
77 #define BOARD_TAG "board="
78 #define IGNORE_CMDLINE_MEM 1
81 void parse_soft_settings(unsigned *ptr, unsigned size);
82 void parse_hard_settings(unsigned *ptr, unsigned size);
84 void __init prom_setup_cmdline(void);
86 void __init prom_init(void)
88 DDR_t ddr = (DDR_t) DDR_VirtualAddress; /* define the pointer to the DDR registers */
89 phys_t memsize = 0-ddr->ddrmask;
91 /* this should be the very first message, even before serial is properly initialized */
95 mips_machgroup = MACH_GROUP_MIKROTIK;
96 soft_reboot = read_c0_status() & SR_NMI;
100 * give all RAM to boot allocator,
101 * except for the first 0x400 and the last 0x200 bytes
103 add_memory_region(ddr->ddrbase + 0x400, memsize - 0x600, BOOT_MEM_RAM);
106 void prom_free_prom_memory(void)
111 void __init prom_setup_cmdline(void){
112 char cmd_line[CL_SIZE];
115 char **prom_argv, **prom_envp;
119 prom_argv = (char **) fw_arg1;
120 prom_envp = (char **) fw_arg2;
123 /* Note: it is common that parameters start at argv[1] and not argv[0],
124 however, our elf loader starts at [0] */
125 for(i=0;i<prom_argc;i++){
126 if (strncmp(prom_argv[i], FREQ_TAG, sizeof(FREQ_TAG) - 1) == 0) {
127 idt_cpu_freq = simple_strtoul(prom_argv[i] + sizeof(FREQ_TAG) - 1, 0, 10);
130 #ifdef IGNORE_CMDLINE_MEM
131 /* parses out the "mem=xx" arg */
132 if (strncmp(prom_argv[i], MEM_TAG, sizeof(MEM_TAG) - 1) == 0) {
136 if (i>0) *(cp++) = ' ';
137 if (strncmp(prom_argv[i], BOARD_TAG, sizeof(BOARD_TAG) - 1) == 0) {
138 board_type = simple_strtoul(prom_argv[i] + sizeof(BOARD_TAG) - 1, 0, 10);
140 if (strncmp(prom_argv[i], GPIO_TAG, sizeof(GPIO_TAG) - 1) == 0) {
141 gpio_bootup_state = simple_strtoul(prom_argv[i] + sizeof(GPIO_TAG) - 1, 0, 10);
143 strcpy(cp,prom_argv[i]);
144 cp+=strlen(prom_argv[i]);
147 i=strlen(arcs_cmdline);
150 strcpy(cp,arcs_cmdline);
151 cp+=strlen(arcs_cmdline);
153 if (gpio_bootup_state&0x02)
154 strcpy(cp,GPIO_INIT_NOBUTTON);
156 strcpy(cp,GPIO_INIT_BUTTON);
157 cmd_line[CL_SIZE-1] = '\0';
159 strcpy(arcs_cmdline,cmd_line);