MIPS: Loongson: Remove existing early_printk implementation
[pandora-kernel.git] / arch / mips / lemote / lm2e / prom.c
1 /*
2  * Based on Ocelot Linux port, which is
3  * Copyright 2001 MontaVista Software Inc.
4  * Author: jsun@mvista.com or jsun@junsun.net
5  *
6  * Copyright 2003 ICT CAS
7  * Author: Michael Guo <guoyi@ict.ac.cn>
8  *
9  * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology
10  * Author: Fuxin Zhang, zhangfx@lemote.com
11  *
12  * This program is free software; you can redistribute  it and/or modify it
13  * under  the terms of  the GNU General  Public License as published by the
14  * Free Software Foundation;  either version 2 of the  License, or (at your
15  * option) any later version.
16  */
17 #include <linux/init.h>
18 #include <linux/bootmem.h>
19 #include <asm/bootinfo.h>
20
21 extern unsigned long bus_clock;
22 extern unsigned long cpu_clock_freq;
23 extern unsigned int memsize, highmemsize;
24
25 static int argc;
26 /* pmon passes arguments in 32bit pointers */
27 static int *arg;
28 static int *env;
29
30 const char *get_system_type(void)
31 {
32         return "lemote-fulong";
33 }
34
35 void __init prom_init_cmdline(void)
36 {
37         int i;
38         long l;
39
40         /* arg[0] is "g", the rest is boot parameters */
41         arcs_cmdline[0] = '\0';
42         for (i = 1; i < argc; i++) {
43                 l = (long)arg[i];
44                 if (strlen(arcs_cmdline) + strlen(((char *)l) + 1)
45                     >= sizeof(arcs_cmdline))
46                         break;
47                 strcat(arcs_cmdline, ((char *)l));
48                 strcat(arcs_cmdline, " ");
49         }
50 }
51
52 void __init prom_init(void)
53 {
54         long l;
55         argc = fw_arg0;
56         arg = (int *)fw_arg1;
57         env = (int *)fw_arg2;
58
59         prom_init_cmdline();
60
61         if ((strstr(arcs_cmdline, "console=")) == NULL)
62                 strcat(arcs_cmdline, " console=ttyS0,115200");
63         if ((strstr(arcs_cmdline, "root=")) == NULL)
64                 strcat(arcs_cmdline, " root=/dev/hda1");
65
66 #define parse_even_earlier(res, option, p)                              \
67 do {                                                                    \
68         if (strncmp(option, (char *)p, strlen(option)) == 0)            \
69                 res = simple_strtol((char *)p + strlen(option"="),      \
70                                     NULL, 10);                          \
71 } while (0)
72
73         l = (long)*env;
74         while (l != 0) {
75                 parse_even_earlier(bus_clock, "busclock", l);
76                 parse_even_earlier(cpu_clock_freq, "cpuclock", l);
77                 parse_even_earlier(memsize, "memsize", l);
78                 parse_even_earlier(highmemsize, "highmemsize", l);
79                 env++;
80                 l = (long)*env;
81         }
82         if (memsize == 0)
83                 memsize = 256;
84
85         pr_info("busclock=%ld, cpuclock=%ld,memsize=%d,highmemsize=%d\n",
86                bus_clock, cpu_clock_freq, memsize, highmemsize);
87 }
88
89 void __init prom_free_prom_memory(void)
90 {
91 }