Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 1 | /* |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 2 | * MPC85xx DS Board Setup |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 3 | * |
| 4 | * Author Xianghua Xiao (x.xiao@freescale.com) |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 5 | * Roy Zang <tie-fei.zang@freescale.com> |
| 6 | * - Add PCI/PCI Exprees support |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 7 | * Copyright 2007 Freescale Semiconductor Inc. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License as published by the |
| 11 | * Free Software Foundation; either version 2 of the License, or (at your |
| 12 | * option) any later version. |
| 13 | */ |
| 14 | |
| 15 | #include <linux/stddef.h> |
| 16 | #include <linux/kernel.h> |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 17 | #include <linux/pci.h> |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 18 | #include <linux/kdev_t.h> |
| 19 | #include <linux/delay.h> |
| 20 | #include <linux/seq_file.h> |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 21 | #include <linux/interrupt.h> |
Sebastian Siewior | 1028d4f | 2008-03-15 00:01:30 +0100 | [diff] [blame] | 22 | #include <linux/of_platform.h> |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 23 | |
| 24 | #include <asm/system.h> |
| 25 | #include <asm/time.h> |
| 26 | #include <asm/machdep.h> |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 27 | #include <asm/pci-bridge.h> |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 28 | #include <mm/mmu_decl.h> |
| 29 | #include <asm/prom.h> |
| 30 | #include <asm/udbg.h> |
| 31 | #include <asm/mpic.h> |
| 32 | #include <asm/i8259.h> |
| 33 | |
| 34 | #include <sysdev/fsl_soc.h> |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 35 | #include <sysdev/fsl_pci.h> |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 36 | |
| 37 | #undef DEBUG |
| 38 | |
| 39 | #ifdef DEBUG |
Harvey Harrison | e48b1b4 | 2008-03-29 08:21:07 +1100 | [diff] [blame] | 40 | #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args) |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 41 | #else |
| 42 | #define DBG(fmt, args...) |
| 43 | #endif |
| 44 | |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 45 | #ifdef CONFIG_PPC_I8259 |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 46 | static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc) |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 47 | { |
| 48 | unsigned int cascade_irq = i8259_irq(); |
| 49 | |
| 50 | if (cascade_irq != NO_IRQ) { |
| 51 | generic_handle_irq(cascade_irq); |
| 52 | } |
| 53 | desc->chip->eoi(irq); |
| 54 | } |
| 55 | #endif /* CONFIG_PPC_I8259 */ |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 56 | |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 57 | void __init mpc85xx_ds_pic_init(void) |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 58 | { |
| 59 | struct mpic *mpic; |
| 60 | struct resource r; |
Kumar Gala | a712b65 | 2008-07-02 10:00:56 -0500 | [diff] [blame] | 61 | struct device_node *np; |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 62 | #ifdef CONFIG_PPC_I8259 |
| 63 | struct device_node *cascade_node = NULL; |
| 64 | int cascade_irq; |
| 65 | #endif |
| 66 | |
Jason Jin | b93eeba | 2008-07-08 09:21:08 +0800 | [diff] [blame^] | 67 | np = of_find_node_by_type(NULL, "open-pic"); |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 68 | if (np == NULL) { |
| 69 | printk(KERN_ERR "Could not find open-pic node\n"); |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | if (of_address_to_resource(np, 0, &r)) { |
| 74 | printk(KERN_ERR "Failed to map mpic register space\n"); |
| 75 | of_node_put(np); |
| 76 | return; |
| 77 | } |
| 78 | |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 79 | mpic = mpic_alloc(np, r.start, |
Jason Jin | 741edc4 | 2008-05-23 16:32:48 +0800 | [diff] [blame] | 80 | MPIC_PRIMARY | MPIC_WANTS_RESET | |
| 81 | MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS, |
Kumar Gala | b533f8a | 2007-07-03 02:35:35 -0500 | [diff] [blame] | 82 | 0, 256, " OpenPIC "); |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 83 | BUG_ON(mpic == NULL); |
Kumar Gala | a712b65 | 2008-07-02 10:00:56 -0500 | [diff] [blame] | 84 | of_node_put(np); |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 85 | |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 86 | mpic_init(mpic); |
| 87 | |
| 88 | #ifdef CONFIG_PPC_I8259 |
| 89 | /* Initialize the i8259 controller */ |
| 90 | for_each_node_by_type(np, "interrupt-controller") |
Stephen Rothwell | 55b61fe | 2007-05-03 17:26:52 +1000 | [diff] [blame] | 91 | if (of_device_is_compatible(np, "chrp,iic")) { |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 92 | cascade_node = np; |
| 93 | break; |
| 94 | } |
| 95 | |
| 96 | if (cascade_node == NULL) { |
| 97 | printk(KERN_DEBUG "Could not find i8259 PIC\n"); |
| 98 | return; |
| 99 | } |
| 100 | |
| 101 | cascade_irq = irq_of_parse_and_map(cascade_node, 0); |
| 102 | if (cascade_irq == NO_IRQ) { |
| 103 | printk(KERN_ERR "Failed to map cascade interrupt\n"); |
| 104 | return; |
| 105 | } |
| 106 | |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 107 | DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq); |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 108 | |
| 109 | i8259_init(cascade_node, 0); |
| 110 | of_node_put(cascade_node); |
| 111 | |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 112 | set_irq_chained_handler(cascade_irq, mpc85xx_8259_cascade); |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 113 | #endif /* CONFIG_PPC_I8259 */ |
| 114 | } |
| 115 | |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 116 | #ifdef CONFIG_PCI |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 117 | static int primary_phb_addr; |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 118 | extern int uses_fsl_uli_m1575; |
| 119 | extern int uli_exclude_device(struct pci_controller *hose, |
| 120 | u_char bus, u_char devfn); |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 121 | |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 122 | static int mpc85xx_exclude_device(struct pci_controller *hose, |
| 123 | u_char bus, u_char devfn) |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 124 | { |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 125 | struct device_node* node; |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 126 | struct resource rsrc; |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 127 | |
Stephen Rothwell | 44ef339 | 2007-12-10 14:33:21 +1100 | [diff] [blame] | 128 | node = hose->dn; |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 129 | of_address_to_resource(node, 0, &rsrc); |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 130 | |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 131 | if ((rsrc.start & 0xfffff) == primary_phb_addr) { |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 132 | return uli_exclude_device(hose, bus, devfn); |
| 133 | } |
| 134 | |
| 135 | return PCIBIOS_SUCCESSFUL; |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 136 | } |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 137 | #endif /* CONFIG_PCI */ |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 138 | |
| 139 | /* |
| 140 | * Setup the architecture |
| 141 | */ |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 142 | static void __init mpc85xx_ds_setup_arch(void) |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 143 | { |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 144 | #ifdef CONFIG_PCI |
| 145 | struct device_node *np; |
| 146 | #endif |
| 147 | |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 148 | if (ppc_md.progress) |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 149 | ppc_md.progress("mpc85xx_ds_setup_arch()", 0); |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 150 | |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 151 | #ifdef CONFIG_PCI |
Kumar Gala | c9438af | 2007-10-04 00:28:43 -0500 | [diff] [blame] | 152 | for_each_node_by_type(np, "pci") { |
| 153 | if (of_device_is_compatible(np, "fsl,mpc8540-pci") || |
| 154 | of_device_is_compatible(np, "fsl,mpc8548-pcie")) { |
| 155 | struct resource rsrc; |
| 156 | of_address_to_resource(np, 0, &rsrc); |
| 157 | if ((rsrc.start & 0xfffff) == primary_phb_addr) |
| 158 | fsl_add_bridge(np, 1); |
| 159 | else |
| 160 | fsl_add_bridge(np, 0); |
| 161 | } |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 162 | } |
Kumar Gala | c9438af | 2007-10-04 00:28:43 -0500 | [diff] [blame] | 163 | |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 164 | uses_fsl_uli_m1575 = 1; |
| 165 | ppc_md.pci_exclude_device = mpc85xx_exclude_device; |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 166 | #endif |
| 167 | |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 168 | printk("MPC85xx DS board from Freescale Semiconductor\n"); |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 169 | } |
| 170 | |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 171 | /* |
| 172 | * Called very early, device-tree isn't unflattened |
| 173 | */ |
| 174 | static int __init mpc8544_ds_probe(void) |
| 175 | { |
| 176 | unsigned long root = of_get_flat_dt_root(); |
| 177 | |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 178 | if (of_flat_dt_is_compatible(root, "MPC8544DS")) { |
| 179 | #ifdef CONFIG_PCI |
| 180 | primary_phb_addr = 0xb000; |
| 181 | #endif |
| 182 | return 1; |
| 183 | } else { |
| 184 | return 0; |
| 185 | } |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 186 | } |
| 187 | |
Kumar Gala | a712b65 | 2008-07-02 10:00:56 -0500 | [diff] [blame] | 188 | static struct of_device_id __initdata mpc85xxds_ids[] = { |
Sebastian Siewior | 1028d4f | 2008-03-15 00:01:30 +0100 | [diff] [blame] | 189 | { .type = "soc", }, |
| 190 | { .compatible = "soc", }, |
| 191 | {}, |
| 192 | }; |
| 193 | |
| 194 | static int __init mpc85xxds_publish_devices(void) |
| 195 | { |
| 196 | return of_platform_bus_probe(NULL, mpc85xxds_ids, NULL); |
| 197 | } |
| 198 | machine_device_initcall(mpc8544_ds, mpc85xxds_publish_devices); |
Jason Jin | 741edc4 | 2008-05-23 16:32:48 +0800 | [diff] [blame] | 199 | machine_device_initcall(mpc8572_ds, mpc85xxds_publish_devices); |
Sebastian Siewior | 1028d4f | 2008-03-15 00:01:30 +0100 | [diff] [blame] | 200 | |
Kumar Gala | 5d54ddc | 2007-09-11 01:25:43 -0500 | [diff] [blame] | 201 | /* |
| 202 | * Called very early, device-tree isn't unflattened |
| 203 | */ |
| 204 | static int __init mpc8572_ds_probe(void) |
| 205 | { |
| 206 | unsigned long root = of_get_flat_dt_root(); |
| 207 | |
| 208 | if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS")) { |
| 209 | #ifdef CONFIG_PCI |
| 210 | primary_phb_addr = 0x8000; |
| 211 | #endif |
| 212 | return 1; |
| 213 | } else { |
| 214 | return 0; |
| 215 | } |
| 216 | } |
| 217 | |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 218 | define_machine(mpc8544_ds) { |
| 219 | .name = "MPC8544 DS", |
| 220 | .probe = mpc8544_ds_probe, |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 221 | .setup_arch = mpc85xx_ds_setup_arch, |
| 222 | .init_IRQ = mpc85xx_ds_pic_init, |
Kumar Gala | 2af8569 | 2007-09-10 14:30:33 -0500 | [diff] [blame] | 223 | #ifdef CONFIG_PCI |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 224 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
Kumar Gala | 2af8569 | 2007-09-10 14:30:33 -0500 | [diff] [blame] | 225 | #endif |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 226 | .get_irq = mpic_get_irq, |
Kumar Gala | e1c1575 | 2007-10-04 01:04:57 -0500 | [diff] [blame] | 227 | .restart = fsl_rstcr_restart, |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 228 | .calibrate_decr = generic_calibrate_decr, |
| 229 | .progress = udbg_progress, |
| 230 | }; |
Kumar Gala | 5d54ddc | 2007-09-11 01:25:43 -0500 | [diff] [blame] | 231 | |
| 232 | define_machine(mpc8572_ds) { |
| 233 | .name = "MPC8572 DS", |
| 234 | .probe = mpc8572_ds_probe, |
| 235 | .setup_arch = mpc85xx_ds_setup_arch, |
| 236 | .init_IRQ = mpc85xx_ds_pic_init, |
| 237 | #ifdef CONFIG_PCI |
| 238 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
| 239 | #endif |
| 240 | .get_irq = mpic_get_irq, |
Kumar Gala | e1c1575 | 2007-10-04 01:04:57 -0500 | [diff] [blame] | 241 | .restart = fsl_rstcr_restart, |
Kumar Gala | 5d54ddc | 2007-09-11 01:25:43 -0500 | [diff] [blame] | 242 | .calibrate_decr = generic_calibrate_decr, |
| 243 | .progress = udbg_progress, |
| 244 | }; |