1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <linux/module.h>
21
22#include <asm/bootinfo.h>
23
24#include <loongson.h>
25
26unsigned long cpu_clock_freq;
27EXPORT_SYMBOL(cpu_clock_freq);
28unsigned long memsize, highmemsize;
29
30#define parse_even_earlier(res, option, p) \
31do { \
32 unsigned int tmp __maybe_unused; \
33 \
34 if (strncmp(option, (char *)p, strlen(option)) == 0) \
35 tmp = strict_strtol((char *)p + strlen(option"="), 10, &res); \
36} while (0)
37
38void __init prom_init_env(void)
39{
40
41 int *_prom_envp;
42 unsigned long bus_clock;
43 unsigned int processor_id;
44 long l;
45
46
47 _prom_envp = (int *)fw_arg2;
48
49 l = (long)*_prom_envp;
50 while (l != 0) {
51 parse_even_earlier(bus_clock, "busclock", l);
52 parse_even_earlier(cpu_clock_freq, "cpuclock", l);
53 parse_even_earlier(memsize, "memsize", l);
54 parse_even_earlier(highmemsize, "highmemsize", l);
55 _prom_envp++;
56 l = (long)*_prom_envp;
57 }
58 if (memsize == 0)
59 memsize = 256;
60 if (bus_clock == 0)
61 bus_clock = 66000000;
62 if (cpu_clock_freq == 0) {
63 processor_id = (¤t_cpu_data)->processor_id;
64 switch (processor_id & PRID_REV_MASK) {
65 case PRID_REV_LOONGSON2E:
66 cpu_clock_freq = 533080000;
67 break;
68 case PRID_REV_LOONGSON2F:
69 cpu_clock_freq = 797000000;
70 break;
71 default:
72 cpu_clock_freq = 100000000;
73 break;
74 }
75 }
76
77 pr_info("busclock=%ld, cpuclock=%ld, memsize=%ld, highmemsize=%ld\n",
78 bus_clock, cpu_clock_freq, memsize, highmemsize);
79}
80