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