Merge branch 'for-linus' of git://neil.brown.name/md
[pandora-kernel.git] / arch / powerpc / platforms / 86xx / mpc86xx_hpcn.c
1 /*
2  * MPC86xx HPCN board specific routines
3  *
4  * Recode: ZHANG WEI <wei.zhang@freescale.com>
5  * Initial author: Xianghua Xiao <x.xiao@freescale.com>
6  *
7  * Copyright 2006 Freescale Semiconductor Inc.
8  *
9  * This program is free software; you can redistribute  it and/or modify it
10  * under  the terms of  the GNU General  Public License as published by the
11  * Free Software Foundation;  either version 2 of the  License, or (at your
12  * option) any later version.
13  */
14
15 #include <linux/stddef.h>
16 #include <linux/kernel.h>
17 #include <linux/pci.h>
18 #include <linux/kdev_t.h>
19 #include <linux/delay.h>
20 #include <linux/seq_file.h>
21 #include <linux/of_platform.h>
22
23 #include <asm/system.h>
24 #include <asm/time.h>
25 #include <asm/machdep.h>
26 #include <asm/pci-bridge.h>
27 #include <asm/mpc86xx.h>
28 #include <asm/prom.h>
29 #include <mm/mmu_decl.h>
30 #include <asm/udbg.h>
31
32 #include <asm/mpic.h>
33
34 #include <sysdev/fsl_pci.h>
35 #include <sysdev/fsl_soc.h>
36
37 #include "mpc86xx.h"
38
39 #undef DEBUG
40
41 #ifdef DEBUG
42 #define DBG(fmt...) do { printk(KERN_ERR fmt); } while(0)
43 #else
44 #define DBG(fmt...) do { } while(0)
45 #endif
46
47 #ifdef CONFIG_PCI
48 extern int uses_fsl_uli_m1575;
49 extern int uli_exclude_device(struct pci_controller *hose,
50                                 u_char bus, u_char devfn);
51
52 static int mpc86xx_exclude_device(struct pci_controller *hose,
53                                    u_char bus, u_char devfn)
54 {
55         struct device_node* node;       
56         struct resource rsrc;
57
58         node = hose->dn;
59         of_address_to_resource(node, 0, &rsrc);
60
61         if ((rsrc.start & 0xfffff) == 0x8000) {
62                 return uli_exclude_device(hose, bus, devfn);
63         }
64
65         return PCIBIOS_SUCCESSFUL;
66 }
67 #endif /* CONFIG_PCI */
68
69
70 static void __init
71 mpc86xx_hpcn_setup_arch(void)
72 {
73 #ifdef CONFIG_PCI
74         struct device_node *np;
75 #endif
76
77         if (ppc_md.progress)
78                 ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
79
80 #ifdef CONFIG_PCI
81         for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
82                 struct resource rsrc;
83                 of_address_to_resource(np, 0, &rsrc);
84                 if ((rsrc.start & 0xfffff) == 0x8000)
85                         fsl_add_bridge(np, 1);
86                 else
87                         fsl_add_bridge(np, 0);
88         }
89
90         uses_fsl_uli_m1575 = 1;
91         ppc_md.pci_exclude_device = mpc86xx_exclude_device;
92
93 #endif
94
95         printk("MPC86xx HPCN board from Freescale Semiconductor\n");
96
97 #ifdef CONFIG_SMP
98         mpc86xx_smp_init();
99 #endif
100 }
101
102
103 static void
104 mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
105 {
106         struct device_node *root;
107         uint memsize = total_memory;
108         const char *model = "";
109         uint svid = mfspr(SPRN_SVR);
110
111         seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
112
113         root = of_find_node_by_path("/");
114         if (root)
115                 model = of_get_property(root, "model", NULL);
116         seq_printf(m, "Machine\t\t: %s\n", model);
117         of_node_put(root);
118
119         seq_printf(m, "SVR\t\t: 0x%x\n", svid);
120         seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
121 }
122
123
124 /*
125  * Called very early, device-tree isn't unflattened
126  */
127 static int __init mpc86xx_hpcn_probe(void)
128 {
129         unsigned long root = of_get_flat_dt_root();
130
131         if (of_flat_dt_is_compatible(root, "fsl,mpc8641hpcn"))
132                 return 1;       /* Looks good */
133
134         /* Be nice and don't give silent boot death.  Delete this in 2.6.27 */
135         if (of_flat_dt_is_compatible(root, "mpc86xx")) {
136                 pr_warning("WARNING: your dts/dtb is old. You must update before the next kernel release\n");
137                 return 1;
138         }
139
140         return 0;
141 }
142
143 static long __init
144 mpc86xx_time_init(void)
145 {
146         unsigned int temp;
147
148         /* Set the time base to zero */
149         mtspr(SPRN_TBWL, 0);
150         mtspr(SPRN_TBWU, 0);
151
152         temp = mfspr(SPRN_HID0);
153         temp |= HID0_TBEN;
154         mtspr(SPRN_HID0, temp);
155         asm volatile("isync");
156
157         return 0;
158 }
159
160 static __initdata struct of_device_id of_bus_ids[] = {
161         { .compatible = "simple-bus", },
162         { .compatible = "fsl,rapidio-delta", },
163         {},
164 };
165
166 static int __init declare_of_platform_devices(void)
167 {
168         of_platform_bus_probe(NULL, of_bus_ids, NULL);
169
170         return 0;
171 }
172 machine_device_initcall(mpc86xx_hpcn, declare_of_platform_devices);
173
174 define_machine(mpc86xx_hpcn) {
175         .name                   = "MPC86xx HPCN",
176         .probe                  = mpc86xx_hpcn_probe,
177         .setup_arch             = mpc86xx_hpcn_setup_arch,
178         .init_IRQ               = mpc86xx_init_irq,
179         .show_cpuinfo           = mpc86xx_hpcn_show_cpuinfo,
180         .get_irq                = mpic_get_irq,
181         .restart                = fsl_rstcr_restart,
182         .time_init              = mpc86xx_time_init,
183         .calibrate_decr         = generic_calibrate_decr,
184         .progress               = udbg_progress,
185 #ifdef CONFIG_PCI
186         .pcibios_fixup_bus      = fsl_pcibios_fixup_bus,
187 #endif
188 };