2 * Based on Ocelot Linux port, which is
3 * Copyright 2001 MontaVista Software Inc.
4 * Author: jsun@mvista.com or jsun@junsun.net
6 * Copyright 2003 ICT CAS
7 * Author: Michael Guo <guoyi@ict.ac.cn>
9 * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology
10 * Author: Fuxin Zhang, zhangfx@lemote.com
12 * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
13 * Author: Wu Zhangjin, wuzj@lemote.com
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version.
20 #include <linux/module.h>
22 #include <asm/bootinfo.h>
26 unsigned long cpu_clock_freq;
27 EXPORT_SYMBOL(cpu_clock_freq);
28 unsigned long memsize, highmemsize;
30 #define parse_even_earlier(res, option, p) \
32 if (strncmp(option, (char *)p, strlen(option)) == 0) \
33 strict_strtol((char *)p + strlen(option"="), \
37 void __init prom_init_env(void)
39 /* pmon passes arguments in 32bit pointers */
41 unsigned long bus_clock;
42 unsigned int processor_id;
45 /* firmware arguments are initialized in head.S */
46 _prom_envp = (int *)fw_arg2;
48 l = (long)*_prom_envp;
50 parse_even_earlier(bus_clock, "busclock", l);
51 parse_even_earlier(cpu_clock_freq, "cpuclock", l);
52 parse_even_earlier(memsize, "memsize", l);
53 parse_even_earlier(highmemsize, "highmemsize", l);
55 l = (long)*_prom_envp;
61 if (cpu_clock_freq == 0) {
62 processor_id = (¤t_cpu_data)->processor_id;
63 switch (processor_id & PRID_REV_MASK) {
64 case PRID_REV_LOONGSON2E:
65 cpu_clock_freq = 533080000;
67 case PRID_REV_LOONGSON2F:
68 cpu_clock_freq = 797000000;
71 cpu_clock_freq = 100000000;
76 pr_info("busclock=%ld, cpuclock=%ld, memsize=%ld, highmemsize=%ld\n",
77 bus_clock, cpu_clock_freq, memsize, highmemsize);