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 | |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 24 | #include <asm/time.h> |
| 25 | #include <asm/machdep.h> |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 26 | #include <asm/pci-bridge.h> |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 27 | #include <mm/mmu_decl.h> |
| 28 | #include <asm/prom.h> |
| 29 | #include <asm/udbg.h> |
| 30 | #include <asm/mpic.h> |
| 31 | #include <asm/i8259.h> |
Kumar Gala | 152d018 | 2009-05-15 00:37:35 -0500 | [diff] [blame] | 32 | #include <asm/swiotlb.h> |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 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> |
Kyle Moffett | 582d3e0 | 2011-12-02 06:27:58 +0000 | [diff] [blame] | 36 | #include "smp.h" |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 37 | |
Dmitry Eremin-Solenikov | 543a07b | 2011-11-17 21:56:16 +0400 | [diff] [blame] | 38 | #include "mpc85xx.h" |
| 39 | |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 40 | #undef DEBUG |
| 41 | |
| 42 | #ifdef DEBUG |
Harvey Harrison | e48b1b4 | 2008-03-29 08:21:07 +1100 | [diff] [blame] | 43 | #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args) |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 44 | #else |
| 45 | #define DBG(fmt, args...) |
| 46 | #endif |
| 47 | |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 48 | #ifdef CONFIG_PPC_I8259 |
Thomas Gleixner | bd0b9ac | 2015-09-14 10:42:37 +0200 | [diff] [blame] | 49 | static void mpc85xx_8259_cascade(struct irq_desc *desc) |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 50 | { |
Thomas Gleixner | ec775d0 | 2011-03-25 16:45:20 +0100 | [diff] [blame] | 51 | struct irq_chip *chip = irq_desc_get_chip(desc); |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 52 | unsigned int cascade_irq = i8259_irq(); |
| 53 | |
| 54 | if (cascade_irq != NO_IRQ) { |
| 55 | generic_handle_irq(cascade_irq); |
| 56 | } |
Lennert Buytenhek | 712d5d7 | 2011-03-07 13:59:19 +0000 | [diff] [blame] | 57 | chip->irq_eoi(&desc->irq_data); |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 58 | } |
| 59 | #endif /* CONFIG_PPC_I8259 */ |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 60 | |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 61 | void __init mpc85xx_ds_pic_init(void) |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 62 | { |
| 63 | struct mpic *mpic; |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 64 | #ifdef CONFIG_PPC_I8259 |
Kyle Moffett | 996983b | 2011-12-02 06:28:02 +0000 | [diff] [blame] | 65 | struct device_node *np; |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 66 | struct device_node *cascade_node = NULL; |
| 67 | int cascade_irq; |
| 68 | #endif |
Haiying Wang | 06be64a | 2008-11-13 07:46:12 -0600 | [diff] [blame] | 69 | unsigned long root = of_get_flat_dt_root(); |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 70 | |
Haiying Wang | 06be64a | 2008-11-13 07:46:12 -0600 | [diff] [blame] | 71 | if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) { |
Kyle Moffett | 996983b | 2011-12-02 06:28:02 +0000 | [diff] [blame] | 72 | mpic = mpic_alloc(NULL, 0, |
Kyle Moffett | e55d7f7 | 2011-12-22 10:19:14 +0000 | [diff] [blame] | 73 | MPIC_NO_RESET | |
Kyle Moffett | 5019609 | 2011-12-22 10:19:12 +0000 | [diff] [blame] | 74 | MPIC_BIG_ENDIAN | |
Fabio Baltieri | a63e23b | 2011-07-12 09:49:43 +0200 | [diff] [blame] | 75 | MPIC_SINGLE_DEST_CPU, |
Haiying Wang | 06be64a | 2008-11-13 07:46:12 -0600 | [diff] [blame] | 76 | 0, 256, " OpenPIC "); |
| 77 | } else { |
Kyle Moffett | 996983b | 2011-12-02 06:28:02 +0000 | [diff] [blame] | 78 | mpic = mpic_alloc(NULL, 0, |
Kyle Moffett | 5019609 | 2011-12-22 10:19:12 +0000 | [diff] [blame] | 79 | MPIC_BIG_ENDIAN | |
Kumar Gala | 3c10c9c | 2008-10-28 18:01:39 +0000 | [diff] [blame] | 80 | MPIC_SINGLE_DEST_CPU, |
Kumar Gala | b533f8a | 2007-07-03 02:35:35 -0500 | [diff] [blame] | 81 | 0, 256, " OpenPIC "); |
Haiying Wang | 06be64a | 2008-11-13 07:46:12 -0600 | [diff] [blame] | 82 | } |
| 83 | |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 84 | BUG_ON(mpic == NULL); |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 85 | mpic_init(mpic); |
| 86 | |
| 87 | #ifdef CONFIG_PPC_I8259 |
| 88 | /* Initialize the i8259 controller */ |
| 89 | for_each_node_by_type(np, "interrupt-controller") |
Stephen Rothwell | 55b61fe | 2007-05-03 17:26:52 +1000 | [diff] [blame] | 90 | if (of_device_is_compatible(np, "chrp,iic")) { |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 91 | cascade_node = np; |
| 92 | break; |
| 93 | } |
| 94 | |
| 95 | if (cascade_node == NULL) { |
| 96 | printk(KERN_DEBUG "Could not find i8259 PIC\n"); |
| 97 | return; |
| 98 | } |
| 99 | |
| 100 | cascade_irq = irq_of_parse_and_map(cascade_node, 0); |
| 101 | if (cascade_irq == NO_IRQ) { |
| 102 | printk(KERN_ERR "Failed to map cascade interrupt\n"); |
| 103 | return; |
| 104 | } |
| 105 | |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 106 | DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq); |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 107 | |
| 108 | i8259_init(cascade_node, 0); |
| 109 | of_node_put(cascade_node); |
| 110 | |
Thomas Gleixner | ec775d0 | 2011-03-25 16:45:20 +0100 | [diff] [blame] | 111 | irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade); |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 112 | #endif /* CONFIG_PPC_I8259 */ |
| 113 | } |
| 114 | |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 115 | #ifdef CONFIG_PCI |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 116 | extern int uli_exclude_device(struct pci_controller *hose, |
| 117 | u_char bus, u_char devfn); |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 118 | |
Scott Wood | 91a6f34 | 2012-07-10 19:26:49 -0500 | [diff] [blame] | 119 | static struct device_node *pci_with_uli; |
| 120 | |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 121 | static int mpc85xx_exclude_device(struct pci_controller *hose, |
| 122 | u_char bus, u_char devfn) |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 123 | { |
Scott Wood | 91a6f34 | 2012-07-10 19:26:49 -0500 | [diff] [blame] | 124 | if (hose->dn == pci_with_uli) |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 125 | return uli_exclude_device(hose, bus, devfn); |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 126 | |
| 127 | return PCIBIOS_SUCCESSFUL; |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 128 | } |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 129 | #endif /* CONFIG_PCI */ |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 130 | |
Jia Hongtao | 905e75c | 2012-08-28 15:44:08 +0800 | [diff] [blame] | 131 | static void __init mpc85xx_ds_uli_init(void) |
Scott Wood | 91a6f34 | 2012-07-10 19:26:49 -0500 | [diff] [blame] | 132 | { |
| 133 | #ifdef CONFIG_PCI |
| 134 | struct device_node *node; |
| 135 | |
Scott Wood | 91a6f34 | 2012-07-10 19:26:49 -0500 | [diff] [blame] | 136 | /* See if we have a ULI under the primary */ |
| 137 | |
| 138 | node = of_find_node_by_name(NULL, "uli1575"); |
| 139 | while ((pci_with_uli = of_get_parent(node))) { |
| 140 | of_node_put(node); |
| 141 | node = pci_with_uli; |
| 142 | |
| 143 | if (pci_with_uli == fsl_pci_primary) { |
| 144 | ppc_md.pci_exclude_device = mpc85xx_exclude_device; |
| 145 | break; |
| 146 | } |
| 147 | } |
| 148 | #endif |
| 149 | } |
| 150 | |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 151 | /* |
| 152 | * Setup the architecture |
| 153 | */ |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 154 | static void __init mpc85xx_ds_setup_arch(void) |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 155 | { |
| 156 | if (ppc_md.progress) |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 157 | ppc_md.progress("mpc85xx_ds_setup_arch()", 0); |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 158 | |
Jia Hongtao | 688ba1d | 2012-08-03 18:14:10 +0800 | [diff] [blame] | 159 | swiotlb_detect_4g(); |
Jia Hongtao | 905e75c | 2012-08-28 15:44:08 +0800 | [diff] [blame] | 160 | fsl_pci_assign_primary(); |
| 161 | mpc85xx_ds_uli_init(); |
Kumar Gala | 8bd3947 | 2008-11-19 09:25:29 -0600 | [diff] [blame] | 162 | mpc85xx_smp_init(); |
Kumar Gala | 8bd3947 | 2008-11-19 09:25:29 -0600 | [diff] [blame] | 163 | |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 164 | printk("MPC85xx DS board from Freescale Semiconductor\n"); |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 165 | } |
| 166 | |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 167 | /* |
| 168 | * Called very early, device-tree isn't unflattened |
| 169 | */ |
| 170 | static int __init mpc8544_ds_probe(void) |
| 171 | { |
| 172 | unsigned long root = of_get_flat_dt_root(); |
| 173 | |
Scott Wood | 91a6f34 | 2012-07-10 19:26:49 -0500 | [diff] [blame] | 174 | return !!of_flat_dt_is_compatible(root, "MPC8544DS"); |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 175 | } |
| 176 | |
Jia Hongtao | 905e75c | 2012-08-28 15:44:08 +0800 | [diff] [blame] | 177 | machine_arch_initcall(mpc8544_ds, mpc85xx_common_publish_devices); |
| 178 | machine_arch_initcall(mpc8572_ds, mpc85xx_common_publish_devices); |
| 179 | machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices); |
Sebastian Siewior | 1028d4f | 2008-03-15 00:01:30 +0100 | [diff] [blame] | 180 | |
Kumar Gala | 152d018 | 2009-05-15 00:37:35 -0500 | [diff] [blame] | 181 | machine_arch_initcall(mpc8544_ds, swiotlb_setup_bus_notifier); |
| 182 | machine_arch_initcall(mpc8572_ds, swiotlb_setup_bus_notifier); |
| 183 | machine_arch_initcall(p2020_ds, swiotlb_setup_bus_notifier); |
| 184 | |
Kumar Gala | 5d54ddc | 2007-09-11 01:25:43 -0500 | [diff] [blame] | 185 | /* |
| 186 | * Called very early, device-tree isn't unflattened |
| 187 | */ |
| 188 | static int __init mpc8572_ds_probe(void) |
| 189 | { |
| 190 | unsigned long root = of_get_flat_dt_root(); |
| 191 | |
Scott Wood | 91a6f34 | 2012-07-10 19:26:49 -0500 | [diff] [blame] | 192 | return !!of_flat_dt_is_compatible(root, "fsl,MPC8572DS"); |
Kumar Gala | 01af950 | 2009-04-15 14:38:40 -0500 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | /* |
| 196 | * Called very early, device-tree isn't unflattened |
| 197 | */ |
| 198 | static int __init p2020_ds_probe(void) |
| 199 | { |
| 200 | unsigned long root = of_get_flat_dt_root(); |
| 201 | |
Scott Wood | 91a6f34 | 2012-07-10 19:26:49 -0500 | [diff] [blame] | 202 | return !!of_flat_dt_is_compatible(root, "fsl,P2020DS"); |
Kumar Gala | 5d54ddc | 2007-09-11 01:25:43 -0500 | [diff] [blame] | 203 | } |
| 204 | |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 205 | define_machine(mpc8544_ds) { |
| 206 | .name = "MPC8544 DS", |
| 207 | .probe = mpc8544_ds_probe, |
Kumar Gala | 7f50382 | 2007-08-17 09:26:40 -0500 | [diff] [blame] | 208 | .setup_arch = mpc85xx_ds_setup_arch, |
| 209 | .init_IRQ = mpc85xx_ds_pic_init, |
Kumar Gala | 2af8569 | 2007-09-10 14:30:33 -0500 | [diff] [blame] | 210 | #ifdef CONFIG_PCI |
Roy Zang | f16dab9 | 2007-07-13 18:05:08 +0800 | [diff] [blame] | 211 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
Wang Dongsheng | 48b1618 | 2014-03-20 11:19:37 +0800 | [diff] [blame] | 212 | .pcibios_fixup_phb = fsl_pcibios_fixup_phb, |
Kumar Gala | 2af8569 | 2007-09-10 14:30:33 -0500 | [diff] [blame] | 213 | #endif |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 214 | .get_irq = mpic_get_irq, |
Kumar Gala | e1c1575 | 2007-10-04 01:04:57 -0500 | [diff] [blame] | 215 | .restart = fsl_rstcr_restart, |
Jon Loeliger | d93daf8 | 2007-03-20 11:19:10 -0500 | [diff] [blame] | 216 | .calibrate_decr = generic_calibrate_decr, |
| 217 | .progress = udbg_progress, |
| 218 | }; |
Kumar Gala | 5d54ddc | 2007-09-11 01:25:43 -0500 | [diff] [blame] | 219 | |
| 220 | define_machine(mpc8572_ds) { |
| 221 | .name = "MPC8572 DS", |
| 222 | .probe = mpc8572_ds_probe, |
| 223 | .setup_arch = mpc85xx_ds_setup_arch, |
| 224 | .init_IRQ = mpc85xx_ds_pic_init, |
| 225 | #ifdef CONFIG_PCI |
| 226 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
Wang Dongsheng | 48b1618 | 2014-03-20 11:19:37 +0800 | [diff] [blame] | 227 | .pcibios_fixup_phb = fsl_pcibios_fixup_phb, |
Kumar Gala | 5d54ddc | 2007-09-11 01:25:43 -0500 | [diff] [blame] | 228 | #endif |
| 229 | .get_irq = mpic_get_irq, |
Kumar Gala | e1c1575 | 2007-10-04 01:04:57 -0500 | [diff] [blame] | 230 | .restart = fsl_rstcr_restart, |
Kumar Gala | 5d54ddc | 2007-09-11 01:25:43 -0500 | [diff] [blame] | 231 | .calibrate_decr = generic_calibrate_decr, |
| 232 | .progress = udbg_progress, |
| 233 | }; |
Kumar Gala | 01af950 | 2009-04-15 14:38:40 -0500 | [diff] [blame] | 234 | |
| 235 | define_machine(p2020_ds) { |
| 236 | .name = "P2020 DS", |
| 237 | .probe = p2020_ds_probe, |
| 238 | .setup_arch = mpc85xx_ds_setup_arch, |
| 239 | .init_IRQ = mpc85xx_ds_pic_init, |
| 240 | #ifdef CONFIG_PCI |
| 241 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
Wang Dongsheng | 48b1618 | 2014-03-20 11:19:37 +0800 | [diff] [blame] | 242 | .pcibios_fixup_phb = fsl_pcibios_fixup_phb, |
Kumar Gala | 01af950 | 2009-04-15 14:38:40 -0500 | [diff] [blame] | 243 | #endif |
| 244 | .get_irq = mpic_get_irq, |
| 245 | .restart = fsl_rstcr_restart, |
| 246 | .calibrate_decr = generic_calibrate_decr, |
| 247 | .progress = udbg_progress, |
| 248 | }; |