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>
21 #include <asm/system.h>
23 #include <asm/machdep.h>
24 #include <asm/pci-bridge.h>
25 #include <asm/mpc85xx.h>
28 #include <mm/mmu_decl.h>
31 #include <sysdev/fsl_soc.h>
32 #include <sysdev/fsl_pci.h>
36 #include <linux/fs_enet_pd.h>
38 #include <sysdev/cpm2_pic.h>
39 #include <asm/fs_pd.h>
43 static int mpc85xx_exclude_device(struct pci_controller *hose,
44 u_char bus, u_char devfn)
46 if (bus == 0 && PCI_SLOT(devfn) == 0)
47 return PCIBIOS_DEVICE_NOT_FOUND;
49 return PCIBIOS_SUCCESSFUL;
51 #endif /* CONFIG_PCI */
55 static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
59 while ((cascade_irq = cpm2_get_irq()) >= 0) {
60 generic_handle_irq(cascade_irq);
65 #endif /* CONFIG_CPM2 */
67 static void __init mpc85xx_ads_pic_init(void)
71 struct device_node *np = NULL;
76 np = of_find_node_by_type(np, "open-pic");
79 printk(KERN_ERR "Could not find open-pic node\n");
83 if(of_address_to_resource(np, 0, &r)) {
84 printk(KERN_ERR "Could not map mpic register space\n");
89 mpic = mpic_alloc(np, r.start,
90 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
99 np = of_find_node_by_type(NULL, "cpm-pic");
101 printk(KERN_ERR "PIC init: can not find cpm-pic node\n");
104 irq = irq_of_parse_and_map(np, 0);
107 set_irq_chained_handler(irq, cpm2_cascade);
112 * Setup the architecture
115 void init_fcc_ioports(struct fs_platform_info *fpi)
117 struct io_port *io = cpm2_map(im_ioport);
118 int fcc_no = fs_get_fcc_index(fpi->fs_no);
124 tempval = in_be32(&io->iop_pdirb);
125 tempval &= ~PB2_DIRB0;
126 tempval |= PB2_DIRB1;
127 out_be32(&io->iop_pdirb, tempval);
129 tempval = in_be32(&io->iop_psorb);
130 tempval &= ~PB2_PSORB0;
131 tempval |= PB2_PSORB1;
132 out_be32(&io->iop_psorb, tempval);
134 tempval = in_be32(&io->iop_pparb);
135 tempval |= (PB2_DIRB0 | PB2_DIRB1);
136 out_be32(&io->iop_pparb, tempval);
138 target = CPM_CLK_FCC2;
141 tempval = in_be32(&io->iop_pdirb);
142 tempval &= ~PB3_DIRB0;
143 tempval |= PB3_DIRB1;
144 out_be32(&io->iop_pdirb, tempval);
146 tempval = in_be32(&io->iop_psorb);
147 tempval &= ~PB3_PSORB0;
148 tempval |= PB3_PSORB1;
149 out_be32(&io->iop_psorb, tempval);
151 tempval = in_be32(&io->iop_pparb);
152 tempval |= (PB3_DIRB0 | PB3_DIRB1);
153 out_be32(&io->iop_pparb, tempval);
155 tempval = in_be32(&io->iop_pdirc);
156 tempval |= PC3_DIRC1;
157 out_be32(&io->iop_pdirc, tempval);
159 tempval = in_be32(&io->iop_pparc);
160 tempval |= PC3_DIRC1;
161 out_be32(&io->iop_pparc, tempval);
163 target = CPM_CLK_FCC3;
166 printk(KERN_ERR "init_fcc_ioports: invalid FCC number\n");
170 /* Port C has clocks...... */
171 tempval = in_be32(&io->iop_psorc);
172 tempval &= ~(PC_CLK(fpi->clk_rx - 8) | PC_CLK(fpi->clk_tx - 8));
173 out_be32(&io->iop_psorc, tempval);
175 tempval = in_be32(&io->iop_pdirc);
176 tempval &= ~(PC_CLK(fpi->clk_rx - 8) | PC_CLK(fpi->clk_tx - 8));
177 out_be32(&io->iop_pdirc, tempval);
178 tempval = in_be32(&io->iop_pparc);
179 tempval |= (PC_CLK(fpi->clk_rx - 8) | PC_CLK(fpi->clk_tx - 8));
180 out_be32(&io->iop_pparc, tempval);
184 /* Configure Serial Interface clock routing.
185 * First, clear FCC bits to zero,
186 * then set the ones we want.
188 cpm2_clk_setup(target, fpi->clk_rx, CPM_CLK_RX);
189 cpm2_clk_setup(target, fpi->clk_tx, CPM_CLK_TX);
193 static void __init mpc85xx_ads_setup_arch(void)
195 struct device_node *cpu;
197 struct device_node *np;
201 ppc_md.progress("mpc85xx_ads_setup_arch()", 0);
203 cpu = of_find_node_by_type(NULL, "cpu");
205 const unsigned int *fp;
207 fp = of_get_property(cpu, "clock-frequency", NULL);
209 loops_per_jiffy = *fp / HZ;
211 loops_per_jiffy = 50000000 / HZ;
220 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
221 fsl_add_bridge(np, 1);
222 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
226 static void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
228 uint pvid, svid, phid1;
229 uint memsize = total_memory;
231 pvid = mfspr(SPRN_PVR);
232 svid = mfspr(SPRN_SVR);
234 seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
235 seq_printf(m, "Machine\t\t: mpc85xx\n");
236 seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
237 seq_printf(m, "SVR\t\t: 0x%x\n", svid);
239 /* Display cpu Pll setting */
240 phid1 = mfspr(SPRN_HID1);
241 seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
243 /* Display the amount of memory */
244 seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
248 * Called very early, device-tree isn't unflattened
250 static int __init mpc85xx_ads_probe(void)
252 unsigned long root = of_get_flat_dt_root();
254 return of_flat_dt_is_compatible(root, "MPC85xxADS");
257 define_machine(mpc85xx_ads) {
258 .name = "MPC85xx ADS",
259 .probe = mpc85xx_ads_probe,
260 .setup_arch = mpc85xx_ads_setup_arch,
261 .init_IRQ = mpc85xx_ads_pic_init,
262 .show_cpuinfo = mpc85xx_ads_show_cpuinfo,
263 .get_irq = mpic_get_irq,
264 .restart = mpc85xx_restart,
265 .calibrate_decr = generic_calibrate_decr,
266 .progress = udbg_progress,