Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee13...
[pandora-kernel.git] / arch / powerpc / platforms / 82xx / mpc82xx.c
1 /*
2  * MPC82xx setup and early boot code plus other random bits.
3  *
4  * Author: Vitaly Bordug <vbordug@ru.mvista.com>
5  *
6  * Copyright (c) 2006 MontaVista Software, Inc.
7  *
8  * This program is free software; you can redistribute  it and/or modify it
9  * under  the terms of  the GNU General  Public License as published by the
10  * Free Software Foundation;  either version 2 of the  License, or (at your
11  * option) any later version.
12  */
13
14 #include <linux/config.h>
15 #include <linux/stddef.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/errno.h>
19 #include <linux/reboot.h>
20 #include <linux/pci.h>
21 #include <linux/interrupt.h>
22 #include <linux/kdev_t.h>
23 #include <linux/major.h>
24 #include <linux/console.h>
25 #include <linux/delay.h>
26 #include <linux/seq_file.h>
27 #include <linux/root_dev.h>
28 #include <linux/initrd.h>
29 #include <linux/module.h>
30 #include <linux/fsl_devices.h>
31 #include <linux/fs_uart_pd.h>
32
33 #include <asm/system.h>
34 #include <asm/pgtable.h>
35 #include <asm/page.h>
36 #include <asm/atomic.h>
37 #include <asm/time.h>
38 #include <asm/io.h>
39 #include <asm/machdep.h>
40 #include <asm/bootinfo.h>
41 #include <asm/pci-bridge.h>
42 #include <asm/mpc8260.h>
43 #include <asm/irq.h>
44 #include <mm/mmu_decl.h>
45 #include <asm/prom.h>
46 #include <asm/cpm2.h>
47 #include <asm/udbg.h>
48 #include <asm/i8259.h>
49 #include <linux/fs_enet_pd.h>
50
51 #include <sysdev/fsl_soc.h>
52 #include <sysdev/cpm2_pic.h>
53
54 #include "pq2ads_pd.h"
55
56 static int __init get_freq(char *name, unsigned long *val)
57 {
58         struct device_node *cpu;
59         unsigned int *fp;
60         int found = 0;
61
62         /* The cpu node should have timebase and clock frequency properties */
63         cpu = of_find_node_by_type(NULL, "cpu");
64
65         if (cpu) {
66                 fp = (unsigned int *)get_property(cpu, name, NULL);
67                 if (fp) {
68                         found = 1;
69                         *val = *fp++;
70                 }
71
72                 of_node_put(cpu);
73         }
74
75         return found;
76 }
77
78 void __init m82xx_calibrate_decr(void)
79 {
80         ppc_tb_freq = 125000000;
81         if (!get_freq("bus-frequency", &ppc_tb_freq)) {
82                 printk(KERN_ERR "WARNING: Estimating decrementer frequency "
83                                 "(not found)\n");
84         }
85         ppc_tb_freq /= 4;
86         ppc_proc_freq = 1000000000;
87         if (!get_freq("clock-frequency", &ppc_proc_freq))
88                 printk(KERN_ERR "WARNING: Estimating processor frequency"
89                                 "(not found)\n");
90 }
91
92 void mpc82xx_ads_show_cpuinfo(struct seq_file *m)
93 {
94         uint pvid, svid, phid1;
95         uint memsize = total_memory;
96
97         pvid = mfspr(SPRN_PVR);
98         svid = mfspr(SPRN_SVR);
99
100         seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
101         seq_printf(m, "Machine\t\t: %s\n", CPUINFO_MACHINE);
102         seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
103         seq_printf(m, "SVR\t\t: 0x%x\n", svid);
104
105         /* Display cpu Pll setting */
106         phid1 = mfspr(SPRN_HID1);
107         seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
108
109         /* Display the amount of memory */
110         seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
111 }