]> err.no Git - linux-2.6/blob - arch/powerpc/platforms/85xx/mpc85xx_ads.c
[POWERPC] 85xx: Convert mpc8560ads to the new CPM binding.
[linux-2.6] / arch / powerpc / platforms / 85xx / mpc85xx_ads.c
1 /*
2  * MPC85xx setup and early boot code plus other random bits.
3  *
4  * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5  *
6  * Copyright 2005 Freescale Semiconductor 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/stddef.h>
15 #include <linux/kernel.h>
16 #include <linux/pci.h>
17 #include <linux/kdev_t.h>
18 #include <linux/delay.h>
19 #include <linux/seq_file.h>
20 #include <linux/of_platform.h>
21
22 #include <asm/system.h>
23 #include <asm/time.h>
24 #include <asm/machdep.h>
25 #include <asm/pci-bridge.h>
26 #include <asm/mpc85xx.h>
27 #include <asm/mpic.h>
28 #include <mm/mmu_decl.h>
29 #include <asm/udbg.h>
30
31 #include <sysdev/fsl_soc.h>
32 #include <sysdev/fsl_pci.h>
33
34 #ifdef CONFIG_CPM2
35 #include <asm/cpm2.h>
36 #include <sysdev/cpm2_pic.h>
37 #endif
38
39 #ifdef CONFIG_PCI
40 static int mpc85xx_exclude_device(struct pci_controller *hose,
41                                    u_char bus, u_char devfn)
42 {
43         if (bus == 0 && PCI_SLOT(devfn) == 0)
44                 return PCIBIOS_DEVICE_NOT_FOUND;
45         else
46                 return PCIBIOS_SUCCESSFUL;
47 }
48 #endif /* CONFIG_PCI */
49
50 #ifdef CONFIG_CPM2
51
52 static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
53 {
54         int cascade_irq;
55
56         while ((cascade_irq = cpm2_get_irq()) >= 0) {
57                 generic_handle_irq(cascade_irq);
58         }
59         desc->chip->eoi(irq);
60 }
61
62 #endif /* CONFIG_CPM2 */
63
64 static void __init mpc85xx_ads_pic_init(void)
65 {
66         struct mpic *mpic;
67         struct resource r;
68         struct device_node *np = NULL;
69 #ifdef CONFIG_CPM2
70         int irq;
71 #endif
72
73         np = of_find_node_by_type(np, "open-pic");
74
75         if (np == NULL) {
76                 printk(KERN_ERR "Could not find open-pic node\n");
77                 return;
78         }
79
80         if(of_address_to_resource(np, 0, &r)) {
81                 printk(KERN_ERR "Could not map mpic register space\n");
82                 of_node_put(np);
83                 return;
84         }
85
86         mpic = mpic_alloc(np, r.start,
87                         MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
88                         0, 256, " OpenPIC  ");
89         BUG_ON(mpic == NULL);
90         of_node_put(np);
91
92         mpic_init(mpic);
93
94 #ifdef CONFIG_CPM2
95         /* Setup CPM2 PIC */
96         np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
97         if (np == NULL) {
98                 printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
99                 return;
100         }
101         irq = irq_of_parse_and_map(np, 0);
102
103         cpm2_pic_init(np);
104         set_irq_chained_handler(irq, cpm2_cascade);
105 #endif
106 }
107
108 /*
109  * Setup the architecture
110  */
111 #ifdef CONFIG_CPM2
112 struct cpm_pin {
113         int port, pin, flags;
114 };
115
116 static struct cpm_pin mpc8560_ads_pins[] = {
117         /* SCC1 */
118         {3, 29, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
119         {3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
120         {3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
121
122         /* SCC2 */
123         {3, 26, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
124         {3, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
125         {3, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
126
127         /* FCC2 */
128         {1, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
129         {1, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
130         {1, 20, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
131         {1, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
132         {1, 22, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
133         {1, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
134         {1, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
135         {1, 25, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
136         {1, 26, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
137         {1, 27, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
138         {1, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
139         {1, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
140         {1, 30, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
141         {1, 31, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
142         {2, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK14 */
143         {2, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK13 */
144
145         /* FCC3 */
146         {1, 4, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
147         {1, 5, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
148         {1, 6, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
149         {1, 7, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
150         {1, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
151         {1, 9, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
152         {1, 10, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
153         {1, 11, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
154         {1, 12, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
155         {1, 13, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
156         {1, 14, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
157         {1, 15, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
158         {1, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
159         {1, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
160         {2, 16, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* CLK16 */
161         {2, 17, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* CLK15 */
162 };
163
164 static void __init init_ioports(void)
165 {
166         int i;
167
168         for (i = 0; i < ARRAY_SIZE(mpc8560_ads_pins); i++) {
169                 struct cpm_pin *pin = &mpc8560_ads_pins[i];
170                 cpm2_set_pin(pin->port, pin->pin, pin->flags);
171         }
172
173         cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);
174         cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);
175         cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_RX);
176         cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_TX);
177         cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK13, CPM_CLK_RX);
178         cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK14, CPM_CLK_TX);
179         cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK15, CPM_CLK_RX);
180         cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK16, CPM_CLK_TX);
181 }
182 #endif
183
184 static void __init mpc85xx_ads_setup_arch(void)
185 {
186 #ifdef CONFIG_PCI
187         struct device_node *np;
188 #endif
189
190         if (ppc_md.progress)
191                 ppc_md.progress("mpc85xx_ads_setup_arch()", 0);
192
193 #ifdef CONFIG_CPM2
194         cpm2_reset();
195         init_ioports();
196 #endif
197
198 #ifdef CONFIG_PCI
199         for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
200                 fsl_add_bridge(np, 1);
201
202         ppc_md.pci_exclude_device = mpc85xx_exclude_device;
203 #endif
204 }
205
206 static void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
207 {
208         uint pvid, svid, phid1;
209         uint memsize = total_memory;
210
211         pvid = mfspr(SPRN_PVR);
212         svid = mfspr(SPRN_SVR);
213
214         seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
215         seq_printf(m, "Machine\t\t: mpc85xx\n");
216         seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
217         seq_printf(m, "SVR\t\t: 0x%x\n", svid);
218
219         /* Display cpu Pll setting */
220         phid1 = mfspr(SPRN_HID1);
221         seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
222
223         /* Display the amount of memory */
224         seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
225 }
226
227 static struct of_device_id __initdata of_bus_ids[] = {
228         { .name = "soc", },
229         { .type = "soc", },
230         { .name = "cpm", },
231         { .name = "localbus", },
232         {},
233 };
234
235 static int __init declare_of_platform_devices(void)
236 {
237         if (!machine_is(mpc85xx_ads))
238                 return 0;
239
240         of_platform_bus_probe(NULL, of_bus_ids, NULL);
241         return 0;
242 }
243 device_initcall(declare_of_platform_devices);
244
245 /*
246  * Called very early, device-tree isn't unflattened
247  */
248 static int __init mpc85xx_ads_probe(void)
249 {
250         unsigned long root = of_get_flat_dt_root();
251
252         return of_flat_dt_is_compatible(root, "MPC85xxADS");
253 }
254
255 define_machine(mpc85xx_ads) {
256         .name                   = "MPC85xx ADS",
257         .probe                  = mpc85xx_ads_probe,
258         .setup_arch             = mpc85xx_ads_setup_arch,
259         .init_IRQ               = mpc85xx_ads_pic_init,
260         .show_cpuinfo           = mpc85xx_ads_show_cpuinfo,
261         .get_irq                = mpic_get_irq,
262         .restart                = fsl_rstcr_restart,
263         .calibrate_decr         = generic_calibrate_decr,
264         .progress               = udbg_progress,
265 };