2 * MPC85xx setup and early boot code plus other random bits.
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
6 * Copyright 2005 Freescale Semiconductor Inc.
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.
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/root_dev.h>
22 #include <asm/system.h>
24 #include <asm/machdep.h>
25 #include <asm/pci-bridge.h>
26 #include <asm/mpc85xx.h>
29 #include <mm/mmu_decl.h>
32 #include <sysdev/fsl_soc.h>
37 #include <sysdev/cpm2_pic.h>
38 #include <asm/fs_pd.h>
42 unsigned long isa_io_base = 0;
43 unsigned long isa_mem_base = 0;
48 mpc85xx_exclude_device(u_char bus, u_char devfn)
50 if (bus == 0 && PCI_SLOT(devfn) == 0)
51 return PCIBIOS_DEVICE_NOT_FOUND;
53 return PCIBIOS_SUCCESSFUL;
57 mpc85xx_pcibios_fixup(void)
59 struct pci_dev *dev = NULL;
62 pci_read_irq_line(dev);
64 #endif /* CONFIG_PCI */
68 static void cpm2_cascade(unsigned int irq, struct irq_desc *desc,
73 while ((cascade_irq = cpm2_get_irq(regs)) >= 0) {
74 generic_handle_irq(cascade_irq, regs);
79 #endif /* CONFIG_CPM2 */
81 void __init mpc85xx_ads_pic_init(void)
85 struct device_node *np = NULL;
90 np = of_find_node_by_type(np, "open-pic");
93 printk(KERN_ERR "Could not find open-pic node\n");
97 if(of_address_to_resource(np, 0, &r)) {
98 printk(KERN_ERR "Could not map mpic register space\n");
103 mpic = mpic_alloc(np, r.start,
104 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
106 BUG_ON(mpic == NULL);
109 mpic_assign_isu(mpic, 0, r.start + 0x10200);
110 mpic_assign_isu(mpic, 1, r.start + 0x10280);
111 mpic_assign_isu(mpic, 2, r.start + 0x10300);
112 mpic_assign_isu(mpic, 3, r.start + 0x10380);
113 mpic_assign_isu(mpic, 4, r.start + 0x10400);
114 mpic_assign_isu(mpic, 5, r.start + 0x10480);
115 mpic_assign_isu(mpic, 6, r.start + 0x10500);
116 mpic_assign_isu(mpic, 7, r.start + 0x10580);
118 /* Unused on this platform (leave room for 8548) */
119 mpic_assign_isu(mpic, 8, r.start + 0x10600);
120 mpic_assign_isu(mpic, 9, r.start + 0x10680);
121 mpic_assign_isu(mpic, 10, r.start + 0x10700);
122 mpic_assign_isu(mpic, 11, r.start + 0x10780);
124 /* External Interrupts */
125 mpic_assign_isu(mpic, 12, r.start + 0x10000);
126 mpic_assign_isu(mpic, 13, r.start + 0x10080);
127 mpic_assign_isu(mpic, 14, r.start + 0x10100);
133 np = of_find_node_by_type(NULL, "cpm-pic");
135 printk(KERN_ERR "PIC init: can not find cpm-pic node\n");
138 irq = irq_of_parse_and_map(np, 0);
141 set_irq_chained_handler(irq, cpm2_cascade);
146 * Setup the architecture
149 static void init_fcc_ioports(void)
157 io = &immap->im_ioport;
158 /* FCC2/3 are on the ports B/C. */
159 tempval = in_be32(&io->iop_pdirb);
160 tempval &= ~PB2_DIRB0;
161 tempval |= PB2_DIRB1;
162 out_be32(&io->iop_pdirb, tempval);
164 tempval = in_be32(&io->iop_psorb);
165 tempval &= ~PB2_PSORB0;
166 tempval |= PB2_PSORB1;
167 out_be32(&io->iop_psorb, tempval);
169 tempval = in_be32(&io->iop_pparb);
170 tempval |= (PB2_DIRB0 | PB2_DIRB1);
171 out_be32(&io->iop_pparb, tempval);
173 tempval = in_be32(&io->iop_pdirb);
174 tempval &= ~PB3_DIRB0;
175 tempval |= PB3_DIRB1;
176 out_be32(&io->iop_pdirb, tempval);
178 tempval = in_be32(&io->iop_psorb);
179 tempval &= ~PB3_PSORB0;
180 tempval |= PB3_PSORB1;
181 out_be32(&io->iop_psorb, tempval);
183 tempval = in_be32(&io->iop_pparb);
184 tempval |= (PB3_DIRB0 | PB3_DIRB1);
185 out_be32(&io->iop_pparb, tempval);
187 tempval = in_be32(&io->iop_pdirc);
188 tempval |= PC3_DIRC1;
189 out_be32(&io->iop_pdirc, tempval);
191 tempval = in_be32(&io->iop_pparc);
192 tempval |= PC3_DIRC1;
193 out_be32(&io->iop_pparc, tempval);
195 /* Port C has clocks...... */
196 tempval = in_be32(&io->iop_psorc);
197 tempval &= ~(CLK_TRX);
198 out_be32(&io->iop_psorc, tempval);
200 tempval = in_be32(&io->iop_pdirc);
201 tempval &= ~(CLK_TRX);
202 out_be32(&io->iop_pdirc, tempval);
203 tempval = in_be32(&io->iop_pparc);
204 tempval |= (CLK_TRX);
205 out_be32(&io->iop_pparc, tempval);
207 /* Configure Serial Interface clock routing.
208 * First, clear all FCC bits to zero,
209 * then set the ones we want.
211 immap->im_cpmux.cmx_fcr &= ~(CPMUX_CLK_MASK);
212 immap->im_cpmux.cmx_fcr |= CPMUX_CLK_ROUTE;
216 static void __init mpc85xx_ads_setup_arch(void)
218 struct device_node *cpu;
220 struct device_node *np;
224 ppc_md.progress("mpc85xx_ads_setup_arch()", 0);
226 cpu = of_find_node_by_type(NULL, "cpu");
228 const unsigned int *fp;
230 fp = get_property(cpu, "clock-frequency", NULL);
232 loops_per_jiffy = *fp / HZ;
234 loops_per_jiffy = 50000000 / HZ;
244 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
247 ppc_md.pcibios_fixup = mpc85xx_pcibios_fixup;
248 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
251 #ifdef CONFIG_ROOT_NFS
254 ROOT_DEV = Root_HDA1;
258 void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
260 uint pvid, svid, phid1;
261 uint memsize = total_memory;
263 pvid = mfspr(SPRN_PVR);
264 svid = mfspr(SPRN_SVR);
266 seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
267 seq_printf(m, "Machine\t\t: mpc85xx\n");
268 seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
269 seq_printf(m, "SVR\t\t: 0x%x\n", svid);
271 /* Display cpu Pll setting */
272 phid1 = mfspr(SPRN_HID1);
273 seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
275 /* Display the amount of memory */
276 seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
280 * Called very early, device-tree isn't unflattened
282 static int __init mpc85xx_ads_probe(void)
284 /* We always match for now, eventually we should look at the flat
285 dev tree to ensure this is the board we are suppose to run on
290 define_machine(mpc85xx_ads) {
291 .name = "MPC85xx ADS",
292 .probe = mpc85xx_ads_probe,
293 .setup_arch = mpc85xx_ads_setup_arch,
294 .init_IRQ = mpc85xx_ads_pic_init,
295 .show_cpuinfo = mpc85xx_ads_show_cpuinfo,
296 .get_irq = mpic_get_irq,
297 .restart = mpc85xx_restart,
298 .calibrate_decr = generic_calibrate_decr,
299 .progress = udbg_progress,