Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 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 | |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 14 | #include <linux/stddef.h> |
| 15 | #include <linux/kernel.h> |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 16 | #include <linux/pci.h> |
| 17 | #include <linux/kdev_t.h> |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 18 | #include <linux/delay.h> |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 19 | #include <linux/seq_file.h> |
| 20 | #include <linux/root_dev.h> |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 21 | |
| 22 | #include <asm/system.h> |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 23 | #include <asm/time.h> |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 24 | #include <asm/machdep.h> |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 25 | #include <asm/pci-bridge.h> |
| 26 | #include <asm/mpc85xx.h> |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 27 | #include <asm/prom.h> |
| 28 | #include <asm/mpic.h> |
| 29 | #include <mm/mmu_decl.h> |
| 30 | #include <asm/udbg.h> |
| 31 | |
| 32 | #include <sysdev/fsl_soc.h> |
| 33 | #include "mpc85xx.h" |
| 34 | |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 35 | #ifdef CONFIG_CPM2 |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 36 | #include <linux/fs_enet_pd.h> |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 37 | #include <asm/cpm2.h> |
| 38 | #include <sysdev/cpm2_pic.h> |
| 39 | #include <asm/fs_pd.h> |
| 40 | #endif |
| 41 | |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 42 | #ifndef CONFIG_PCI |
| 43 | unsigned long isa_io_base = 0; |
| 44 | unsigned long isa_mem_base = 0; |
| 45 | #endif |
| 46 | |
Andy Fleming | 8080d54 | 2006-02-10 17:01:06 -0600 | [diff] [blame] | 47 | #ifdef CONFIG_PCI |
Andy Fleming | 8080d54 | 2006-02-10 17:01:06 -0600 | [diff] [blame] | 48 | int |
| 49 | mpc85xx_exclude_device(u_char bus, u_char devfn) |
| 50 | { |
| 51 | if (bus == 0 && PCI_SLOT(devfn) == 0) |
| 52 | return PCIBIOS_DEVICE_NOT_FOUND; |
| 53 | else |
| 54 | return PCIBIOS_SUCCESSFUL; |
| 55 | } |
| 56 | |
Andy Fleming | 4c86cd9 | 2006-08-18 18:03:08 -0500 | [diff] [blame] | 57 | void __init |
| 58 | mpc85xx_pcibios_fixup(void) |
| 59 | { |
| 60 | struct pci_dev *dev = NULL; |
| 61 | |
| 62 | for_each_pci_dev(dev) |
| 63 | pci_read_irq_line(dev); |
| 64 | } |
Andy Fleming | 8080d54 | 2006-02-10 17:01:06 -0600 | [diff] [blame] | 65 | #endif /* CONFIG_PCI */ |
| 66 | |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 67 | #ifdef CONFIG_CPM2 |
| 68 | |
| 69 | static void cpm2_cascade(unsigned int irq, struct irq_desc *desc, |
| 70 | struct pt_regs *regs) |
| 71 | { |
| 72 | int cascade_irq; |
| 73 | |
| 74 | while ((cascade_irq = cpm2_get_irq(regs)) >= 0) { |
| 75 | generic_handle_irq(cascade_irq, regs); |
| 76 | } |
| 77 | desc->chip->eoi(irq); |
| 78 | } |
| 79 | |
| 80 | #endif /* CONFIG_CPM2 */ |
Andy Fleming | 8080d54 | 2006-02-10 17:01:06 -0600 | [diff] [blame] | 81 | |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 82 | void __init mpc85xx_ads_pic_init(void) |
| 83 | { |
Andy Fleming | 4c86cd9 | 2006-08-18 18:03:08 -0500 | [diff] [blame] | 84 | struct mpic *mpic; |
| 85 | struct resource r; |
| 86 | struct device_node *np = NULL; |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 87 | #ifdef CONFIG_CPM2 |
| 88 | int irq; |
| 89 | #endif |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 90 | |
Andy Fleming | 4c86cd9 | 2006-08-18 18:03:08 -0500 | [diff] [blame] | 91 | np = of_find_node_by_type(np, "open-pic"); |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 92 | |
Andy Fleming | 4c86cd9 | 2006-08-18 18:03:08 -0500 | [diff] [blame] | 93 | if (np == NULL) { |
| 94 | printk(KERN_ERR "Could not find open-pic node\n"); |
| 95 | return; |
| 96 | } |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 97 | |
Andy Fleming | 4c86cd9 | 2006-08-18 18:03:08 -0500 | [diff] [blame] | 98 | if(of_address_to_resource(np, 0, &r)) { |
| 99 | printk(KERN_ERR "Could not map mpic register space\n"); |
| 100 | of_node_put(np); |
| 101 | return; |
| 102 | } |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 103 | |
Andy Fleming | 4c86cd9 | 2006-08-18 18:03:08 -0500 | [diff] [blame] | 104 | mpic = mpic_alloc(np, r.start, |
| 105 | MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN, |
| 106 | 4, 0, " OpenPIC "); |
| 107 | BUG_ON(mpic == NULL); |
| 108 | of_node_put(np); |
| 109 | |
| 110 | mpic_assign_isu(mpic, 0, r.start + 0x10200); |
| 111 | mpic_assign_isu(mpic, 1, r.start + 0x10280); |
| 112 | mpic_assign_isu(mpic, 2, r.start + 0x10300); |
| 113 | mpic_assign_isu(mpic, 3, r.start + 0x10380); |
| 114 | mpic_assign_isu(mpic, 4, r.start + 0x10400); |
| 115 | mpic_assign_isu(mpic, 5, r.start + 0x10480); |
| 116 | mpic_assign_isu(mpic, 6, r.start + 0x10500); |
| 117 | mpic_assign_isu(mpic, 7, r.start + 0x10580); |
| 118 | |
| 119 | /* Unused on this platform (leave room for 8548) */ |
| 120 | mpic_assign_isu(mpic, 8, r.start + 0x10600); |
| 121 | mpic_assign_isu(mpic, 9, r.start + 0x10680); |
| 122 | mpic_assign_isu(mpic, 10, r.start + 0x10700); |
| 123 | mpic_assign_isu(mpic, 11, r.start + 0x10780); |
| 124 | |
| 125 | /* External Interrupts */ |
| 126 | mpic_assign_isu(mpic, 12, r.start + 0x10000); |
| 127 | mpic_assign_isu(mpic, 13, r.start + 0x10080); |
| 128 | mpic_assign_isu(mpic, 14, r.start + 0x10100); |
| 129 | |
| 130 | mpic_init(mpic); |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 131 | |
| 132 | #ifdef CONFIG_CPM2 |
| 133 | /* Setup CPM2 PIC */ |
| 134 | np = of_find_node_by_type(NULL, "cpm-pic"); |
| 135 | if (np == NULL) { |
| 136 | printk(KERN_ERR "PIC init: can not find cpm-pic node\n"); |
| 137 | return; |
| 138 | } |
| 139 | irq = irq_of_parse_and_map(np, 0); |
| 140 | |
| 141 | cpm2_pic_init(np); |
| 142 | set_irq_chained_handler(irq, cpm2_cascade); |
| 143 | #endif |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 144 | } |
| 145 | |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 146 | /* |
| 147 | * Setup the architecture |
| 148 | */ |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 149 | #ifdef CONFIG_CPM2 |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 150 | void init_fcc_ioports(struct fs_platform_info *fpi) |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 151 | { |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 152 | struct io_port *io = cpm2_map(im_ioport); |
| 153 | int fcc_no = fs_get_fcc_index(fpi->fs_no); |
| 154 | int target; |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 155 | u32 tempval; |
| 156 | |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 157 | switch(fcc_no) { |
| 158 | case 1: |
| 159 | tempval = in_be32(&io->iop_pdirb); |
| 160 | tempval &= ~PB2_DIRB0; |
| 161 | tempval |= PB2_DIRB1; |
| 162 | out_be32(&io->iop_pdirb, tempval); |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 163 | |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 164 | tempval = in_be32(&io->iop_psorb); |
| 165 | tempval &= ~PB2_PSORB0; |
| 166 | tempval |= PB2_PSORB1; |
| 167 | out_be32(&io->iop_psorb, tempval); |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 168 | |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 169 | tempval = in_be32(&io->iop_pparb); |
| 170 | tempval |= (PB2_DIRB0 | PB2_DIRB1); |
| 171 | out_be32(&io->iop_pparb, tempval); |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 172 | |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 173 | target = CPM_CLK_FCC2; |
| 174 | break; |
| 175 | case 2: |
| 176 | tempval = in_be32(&io->iop_pdirb); |
| 177 | tempval &= ~PB3_DIRB0; |
| 178 | tempval |= PB3_DIRB1; |
| 179 | out_be32(&io->iop_pdirb, tempval); |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 180 | |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 181 | tempval = in_be32(&io->iop_psorb); |
| 182 | tempval &= ~PB3_PSORB0; |
| 183 | tempval |= PB3_PSORB1; |
| 184 | out_be32(&io->iop_psorb, tempval); |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 185 | |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 186 | tempval = in_be32(&io->iop_pparb); |
| 187 | tempval |= (PB3_DIRB0 | PB3_DIRB1); |
| 188 | out_be32(&io->iop_pparb, tempval); |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 189 | |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 190 | tempval = in_be32(&io->iop_pdirc); |
| 191 | tempval |= PC3_DIRC1; |
| 192 | out_be32(&io->iop_pdirc, tempval); |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 193 | |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 194 | tempval = in_be32(&io->iop_pparc); |
| 195 | tempval |= PC3_DIRC1; |
| 196 | out_be32(&io->iop_pparc, tempval); |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 197 | |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 198 | target = CPM_CLK_FCC3; |
| 199 | break; |
| 200 | default: |
| 201 | printk(KERN_ERR "init_fcc_ioports: invalid FCC number\n"); |
| 202 | return; |
| 203 | } |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 204 | |
| 205 | /* Port C has clocks...... */ |
| 206 | tempval = in_be32(&io->iop_psorc); |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 207 | tempval &= ~(PC_CLK(fpi->clk_rx - 8) | PC_CLK(fpi->clk_tx - 8)); |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 208 | out_be32(&io->iop_psorc, tempval); |
| 209 | |
| 210 | tempval = in_be32(&io->iop_pdirc); |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 211 | tempval &= ~(PC_CLK(fpi->clk_rx - 8) | PC_CLK(fpi->clk_tx - 8)); |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 212 | out_be32(&io->iop_pdirc, tempval); |
| 213 | tempval = in_be32(&io->iop_pparc); |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 214 | tempval |= (PC_CLK(fpi->clk_rx - 8) | PC_CLK(fpi->clk_tx - 8)); |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 215 | out_be32(&io->iop_pparc, tempval); |
| 216 | |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 217 | cpm2_unmap(io); |
| 218 | |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 219 | /* Configure Serial Interface clock routing. |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 220 | * First, clear FCC bits to zero, |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 221 | * then set the ones we want. |
| 222 | */ |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame^] | 223 | cpm2_clk_setup(target, fpi->clk_rx, CPM_CLK_RX); |
| 224 | cpm2_clk_setup(target, fpi->clk_tx, CPM_CLK_TX); |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 225 | } |
| 226 | #endif |
| 227 | |
Becky Bruce | fbc94e7 | 2006-02-07 21:29:42 -0600 | [diff] [blame] | 228 | static void __init mpc85xx_ads_setup_arch(void) |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 229 | { |
| 230 | struct device_node *cpu; |
Andy Fleming | 4c86cd9 | 2006-08-18 18:03:08 -0500 | [diff] [blame] | 231 | #ifdef CONFIG_PCI |
Andy Fleming | 8080d54 | 2006-02-10 17:01:06 -0600 | [diff] [blame] | 232 | struct device_node *np; |
Andy Fleming | 4c86cd9 | 2006-08-18 18:03:08 -0500 | [diff] [blame] | 233 | #endif |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 234 | |
| 235 | if (ppc_md.progress) |
| 236 | ppc_md.progress("mpc85xx_ads_setup_arch()", 0); |
| 237 | |
| 238 | cpu = of_find_node_by_type(NULL, "cpu"); |
| 239 | if (cpu != 0) { |
Jeremy Kerr | 8efca49 | 2006-07-12 15:39:42 +1000 | [diff] [blame] | 240 | const unsigned int *fp; |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 241 | |
Jeremy Kerr | 8efca49 | 2006-07-12 15:39:42 +1000 | [diff] [blame] | 242 | fp = get_property(cpu, "clock-frequency", NULL); |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 243 | if (fp != 0) |
| 244 | loops_per_jiffy = *fp / HZ; |
| 245 | else |
| 246 | loops_per_jiffy = 50000000 / HZ; |
| 247 | of_node_put(cpu); |
| 248 | } |
Andy Fleming | 8080d54 | 2006-02-10 17:01:06 -0600 | [diff] [blame] | 249 | |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 250 | #ifdef CONFIG_CPM2 |
| 251 | cpm2_reset(); |
Vitaly Bordug | 902f392 | 2006-09-21 22:31:26 +0400 | [diff] [blame] | 252 | #endif |
| 253 | |
Andy Fleming | 8080d54 | 2006-02-10 17:01:06 -0600 | [diff] [blame] | 254 | #ifdef CONFIG_PCI |
| 255 | for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) |
| 256 | add_bridge(np); |
| 257 | |
Andy Fleming | 4c86cd9 | 2006-08-18 18:03:08 -0500 | [diff] [blame] | 258 | ppc_md.pcibios_fixup = mpc85xx_pcibios_fixup; |
Andy Fleming | 8080d54 | 2006-02-10 17:01:06 -0600 | [diff] [blame] | 259 | ppc_md.pci_exclude_device = mpc85xx_exclude_device; |
| 260 | #endif |
| 261 | |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 262 | #ifdef CONFIG_ROOT_NFS |
| 263 | ROOT_DEV = Root_NFS; |
| 264 | #else |
| 265 | ROOT_DEV = Root_HDA1; |
| 266 | #endif |
| 267 | } |
| 268 | |
Becky Bruce | fbc94e7 | 2006-02-07 21:29:42 -0600 | [diff] [blame] | 269 | void mpc85xx_ads_show_cpuinfo(struct seq_file *m) |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 270 | { |
| 271 | uint pvid, svid, phid1; |
| 272 | uint memsize = total_memory; |
| 273 | |
| 274 | pvid = mfspr(SPRN_PVR); |
| 275 | svid = mfspr(SPRN_SVR); |
| 276 | |
| 277 | seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n"); |
| 278 | seq_printf(m, "Machine\t\t: mpc85xx\n"); |
| 279 | seq_printf(m, "PVR\t\t: 0x%x\n", pvid); |
| 280 | seq_printf(m, "SVR\t\t: 0x%x\n", svid); |
| 281 | |
| 282 | /* Display cpu Pll setting */ |
| 283 | phid1 = mfspr(SPRN_HID1); |
| 284 | seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f)); |
| 285 | |
| 286 | /* Display the amount of memory */ |
| 287 | seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024)); |
| 288 | } |
| 289 | |
Kumar Gala | 72d2c3e | 2006-03-30 23:39:57 -0600 | [diff] [blame] | 290 | /* |
| 291 | * Called very early, device-tree isn't unflattened |
| 292 | */ |
| 293 | static int __init mpc85xx_ads_probe(void) |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 294 | { |
Kumar Gala | 72d2c3e | 2006-03-30 23:39:57 -0600 | [diff] [blame] | 295 | /* We always match for now, eventually we should look at the flat |
| 296 | dev tree to ensure this is the board we are suppose to run on |
| 297 | */ |
| 298 | return 1; |
Becky Bruce | 63dafe5 | 2006-01-14 16:57:39 -0600 | [diff] [blame] | 299 | } |
Kumar Gala | 72d2c3e | 2006-03-30 23:39:57 -0600 | [diff] [blame] | 300 | |
| 301 | define_machine(mpc85xx_ads) { |
| 302 | .name = "MPC85xx ADS", |
| 303 | .probe = mpc85xx_ads_probe, |
| 304 | .setup_arch = mpc85xx_ads_setup_arch, |
| 305 | .init_IRQ = mpc85xx_ads_pic_init, |
| 306 | .show_cpuinfo = mpc85xx_ads_show_cpuinfo, |
| 307 | .get_irq = mpic_get_irq, |
| 308 | .restart = mpc85xx_restart, |
| 309 | .calibrate_decr = generic_calibrate_decr, |
| 310 | .progress = udbg_progress, |
| 311 | }; |