blob: 196d947d929afcf39362aaa1069ee83b01e17ae7 [file] [log] [blame]
Wu Zhangjinbd92aa02009-07-02 23:22:36 +08001/*
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 * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
13 * Author: Wu Zhangjin, wuzj@lemote.com
14 *
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.
19 */
Wu Zhangjinf8ede0f2009-11-17 01:32:59 +080020#include <linux/module.h>
21
Wu Zhangjinbd92aa02009-07-02 23:22:36 +080022#include <asm/bootinfo.h>
23
Wu Zhangjin5e983ff2009-07-02 23:23:03 +080024#include <loongson.h>
25
Wu Zhangjinbd92aa02009-07-02 23:22:36 +080026unsigned long bus_clock, cpu_clock_freq;
Wu Zhangjinf8ede0f2009-11-17 01:32:59 +080027EXPORT_SYMBOL(cpu_clock_freq);
Wu Zhangjinbd92aa02009-07-02 23:22:36 +080028unsigned long memsize, highmemsize;
29
30/* pmon passes arguments in 32bit pointers */
31int *_prom_envp;
32
33#define parse_even_earlier(res, option, p) \
34do { \
35 if (strncmp(option, (char *)p, strlen(option)) == 0) \
36 strict_strtol((char *)p + strlen(option"="), \
37 10, &res); \
38} while (0)
39
40void __init prom_init_env(void)
41{
42 long l;
43
44 /* firmware arguments are initialized in head.S */
45 _prom_envp = (int *)fw_arg2;
46
47 l = (long)*_prom_envp;
48 while (l != 0) {
49 parse_even_earlier(bus_clock, "busclock", l);
50 parse_even_earlier(cpu_clock_freq, "cpuclock", l);
51 parse_even_earlier(memsize, "memsize", l);
52 parse_even_earlier(highmemsize, "highmemsize", l);
53 _prom_envp++;
54 l = (long)*_prom_envp;
55 }
56 if (memsize == 0)
57 memsize = 256;
58
59 pr_info("busclock=%ld, cpuclock=%ld, memsize=%ld, highmemsize=%ld\n",
60 bus_clock, cpu_clock_freq, memsize, highmemsize);
61}