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