12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 216d24060SKumar Gala /* 37f50382dSKumar Gala * MPC85xx DS Board Setup 416d24060SKumar Gala * 516d24060SKumar Gala * Author Xianghua Xiao (x.xiao@freescale.com) 616d24060SKumar Gala * Roy Zang <tie-fei.zang@freescale.com> 716d24060SKumar Gala * - Add PCI/PCI Exprees support 816d24060SKumar Gala * Copyright 2007 Freescale Semiconductor Inc. 916d24060SKumar Gala */ 1016d24060SKumar Gala 1116d24060SKumar Gala #include <linux/stddef.h> 1216d24060SKumar Gala #include <linux/kernel.h> 1316d24060SKumar Gala #include <linux/pci.h> 1416d24060SKumar Gala #include <linux/kdev_t.h> 1516d24060SKumar Gala #include <linux/delay.h> 1616d24060SKumar Gala #include <linux/seq_file.h> 1716d24060SKumar Gala #include <linux/interrupt.h> 18e6f6390aSChristophe Leroy #include <linux/of_irq.h> 191028d4f1SSebastian Siewior #include <linux/of_platform.h> 2016d24060SKumar Gala 2116d24060SKumar Gala #include <asm/time.h> 2216d24060SKumar Gala #include <asm/machdep.h> 2316d24060SKumar Gala #include <asm/pci-bridge.h> 2416d24060SKumar Gala #include <mm/mmu_decl.h> 2516d24060SKumar Gala #include <asm/udbg.h> 2616d24060SKumar Gala #include <asm/mpic.h> 2716d24060SKumar Gala #include <asm/i8259.h> 28152d0182SKumar Gala #include <asm/swiotlb.h> 2916d24060SKumar Gala 3016d24060SKumar Gala #include <sysdev/fsl_soc.h> 3116d24060SKumar Gala #include <sysdev/fsl_pci.h> 32582d3e09SKyle Moffett #include "smp.h" 3316d24060SKumar Gala 34543a07b1SDmitry Eremin-Solenikov #include "mpc85xx.h" 35543a07b1SDmitry Eremin-Solenikov 3616d24060SKumar Gala #undef DEBUG 3716d24060SKumar Gala 3816d24060SKumar Gala #ifdef DEBUG 39e48b1b45SHarvey Harrison #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args) 4016d24060SKumar Gala #else 4116d24060SKumar Gala #define DBG(fmt, args...) 4216d24060SKumar Gala #endif 4316d24060SKumar Gala 4416d24060SKumar Gala #ifdef CONFIG_PPC_I8259 45bd0b9ac4SThomas Gleixner static void mpc85xx_8259_cascade(struct irq_desc *desc) 4616d24060SKumar Gala { 47ec775d0eSThomas Gleixner struct irq_chip *chip = irq_desc_get_chip(desc); 4816d24060SKumar Gala unsigned int cascade_irq = i8259_irq(); 4916d24060SKumar Gala 50ef24ba70SMichael Ellerman if (cascade_irq) { 5116d24060SKumar Gala generic_handle_irq(cascade_irq); 5216d24060SKumar Gala } 53712d5d79SLennert Buytenhek chip->irq_eoi(&desc->irq_data); 5416d24060SKumar Gala } 5516d24060SKumar Gala #endif /* CONFIG_PPC_I8259 */ 5616d24060SKumar Gala 577f50382dSKumar Gala void __init mpc85xx_ds_pic_init(void) 5816d24060SKumar Gala { 5916d24060SKumar Gala struct mpic *mpic; 6016d24060SKumar Gala #ifdef CONFIG_PPC_I8259 61996983b7SKyle Moffett struct device_node *np; 6216d24060SKumar Gala struct device_node *cascade_node = NULL; 6316d24060SKumar Gala int cascade_irq; 6416d24060SKumar Gala #endif 655b0f9f83SBenjamin Herrenschmidt if (of_machine_is_compatible("fsl,MPC8572DS-CAMP")) { 66996983b7SKyle Moffett mpic = mpic_alloc(NULL, 0, 67e55d7f73SKyle Moffett MPIC_NO_RESET | 685019609fSKyle Moffett MPIC_BIG_ENDIAN | 69a63e23b9SFabio Baltieri MPIC_SINGLE_DEST_CPU, 7006be64a3SHaiying Wang 0, 256, " OpenPIC "); 7106be64a3SHaiying Wang } else { 72996983b7SKyle Moffett mpic = mpic_alloc(NULL, 0, 735019609fSKyle Moffett MPIC_BIG_ENDIAN | 743c10c9c4SKumar Gala MPIC_SINGLE_DEST_CPU, 7516d24060SKumar Gala 0, 256, " OpenPIC "); 7606be64a3SHaiying Wang } 7706be64a3SHaiying Wang 7816d24060SKumar Gala BUG_ON(mpic == NULL); 7916d24060SKumar Gala mpic_init(mpic); 8016d24060SKumar Gala 8116d24060SKumar Gala #ifdef CONFIG_PPC_I8259 8216d24060SKumar Gala /* Initialize the i8259 controller */ 8316d24060SKumar Gala for_each_node_by_type(np, "interrupt-controller") 8416d24060SKumar Gala if (of_device_is_compatible(np, "chrp,iic")) { 8516d24060SKumar Gala cascade_node = np; 8616d24060SKumar Gala break; 8716d24060SKumar Gala } 8816d24060SKumar Gala 8916d24060SKumar Gala if (cascade_node == NULL) { 9016d24060SKumar Gala printk(KERN_DEBUG "Could not find i8259 PIC\n"); 9116d24060SKumar Gala return; 9216d24060SKumar Gala } 9316d24060SKumar Gala 9416d24060SKumar Gala cascade_irq = irq_of_parse_and_map(cascade_node, 0); 95ef24ba70SMichael Ellerman if (!cascade_irq) { 9616d24060SKumar Gala printk(KERN_ERR "Failed to map cascade interrupt\n"); 9716d24060SKumar Gala return; 9816d24060SKumar Gala } 9916d24060SKumar Gala 1007f50382dSKumar Gala DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq); 10116d24060SKumar Gala 10216d24060SKumar Gala i8259_init(cascade_node, 0); 10316d24060SKumar Gala of_node_put(cascade_node); 10416d24060SKumar Gala 105ec775d0eSThomas Gleixner irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade); 10616d24060SKumar Gala #endif /* CONFIG_PPC_I8259 */ 10716d24060SKumar Gala } 10816d24060SKumar Gala 10916d24060SKumar Gala #ifdef CONFIG_PCI 11016d24060SKumar Gala extern int uli_exclude_device(struct pci_controller *hose, 11116d24060SKumar Gala u_char bus, u_char devfn); 11216d24060SKumar Gala 11391a6f347SScott Wood static struct device_node *pci_with_uli; 11491a6f347SScott Wood 11516d24060SKumar Gala static int mpc85xx_exclude_device(struct pci_controller *hose, 11616d24060SKumar Gala u_char bus, u_char devfn) 11716d24060SKumar Gala { 11891a6f347SScott Wood if (hose->dn == pci_with_uli) 11916d24060SKumar Gala return uli_exclude_device(hose, bus, devfn); 12016d24060SKumar Gala 12116d24060SKumar Gala return PCIBIOS_SUCCESSFUL; 12216d24060SKumar Gala } 12316d24060SKumar Gala #endif /* CONFIG_PCI */ 12416d24060SKumar Gala 125905e75c4SJia Hongtao static void __init mpc85xx_ds_uli_init(void) 12691a6f347SScott Wood { 12791a6f347SScott Wood #ifdef CONFIG_PCI 12891a6f347SScott Wood struct device_node *node; 12991a6f347SScott Wood 13091a6f347SScott Wood /* See if we have a ULI under the primary */ 13191a6f347SScott Wood 13291a6f347SScott Wood node = of_find_node_by_name(NULL, "uli1575"); 13391a6f347SScott Wood while ((pci_with_uli = of_get_parent(node))) { 13491a6f347SScott Wood of_node_put(node); 13591a6f347SScott Wood node = pci_with_uli; 13691a6f347SScott Wood 13791a6f347SScott Wood if (pci_with_uli == fsl_pci_primary) { 13891a6f347SScott Wood ppc_md.pci_exclude_device = mpc85xx_exclude_device; 13991a6f347SScott Wood break; 14091a6f347SScott Wood } 14191a6f347SScott Wood } 14291a6f347SScott Wood #endif 14391a6f347SScott Wood } 14491a6f347SScott Wood 14516d24060SKumar Gala /* 14616d24060SKumar Gala * Setup the architecture 14716d24060SKumar Gala */ 1487f50382dSKumar Gala static void __init mpc85xx_ds_setup_arch(void) 14916d24060SKumar Gala { 15016d24060SKumar Gala if (ppc_md.progress) 1517f50382dSKumar Gala ppc_md.progress("mpc85xx_ds_setup_arch()", 0); 15216d24060SKumar Gala 153688ba1dbSJia Hongtao swiotlb_detect_4g(); 154905e75c4SJia Hongtao fsl_pci_assign_primary(); 155905e75c4SJia Hongtao mpc85xx_ds_uli_init(); 1568bd3947aSKumar Gala mpc85xx_smp_init(); 1578bd3947aSKumar Gala 1587f50382dSKumar Gala printk("MPC85xx DS board from Freescale Semiconductor\n"); 15916d24060SKumar Gala } 16016d24060SKumar Gala 161905e75c4SJia Hongtao machine_arch_initcall(mpc8544_ds, mpc85xx_common_publish_devices); 162905e75c4SJia Hongtao machine_arch_initcall(mpc8572_ds, mpc85xx_common_publish_devices); 163905e75c4SJia Hongtao machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices); 1641028d4f1SSebastian Siewior 16516d24060SKumar Gala define_machine(mpc8544_ds) { 16616d24060SKumar Gala .name = "MPC8544 DS", 167*1c96fcdeSChristophe Leroy .compatible = "MPC8544DS", 1687f50382dSKumar Gala .setup_arch = mpc85xx_ds_setup_arch, 1697f50382dSKumar Gala .init_IRQ = mpc85xx_ds_pic_init, 17016d24060SKumar Gala #ifdef CONFIG_PCI 17116d24060SKumar Gala .pcibios_fixup_bus = fsl_pcibios_fixup_bus, 17248b16180SWang Dongsheng .pcibios_fixup_phb = fsl_pcibios_fixup_phb, 17316d24060SKumar Gala #endif 17416d24060SKumar Gala .get_irq = mpic_get_irq, 17516d24060SKumar Gala .calibrate_decr = generic_calibrate_decr, 17616d24060SKumar Gala .progress = udbg_progress, 17716d24060SKumar Gala }; 1785d54ddcbSKumar Gala 1795d54ddcbSKumar Gala define_machine(mpc8572_ds) { 1805d54ddcbSKumar Gala .name = "MPC8572 DS", 181*1c96fcdeSChristophe Leroy .compatible = "fsl,MPC8572DS", 1825d54ddcbSKumar Gala .setup_arch = mpc85xx_ds_setup_arch, 1835d54ddcbSKumar Gala .init_IRQ = mpc85xx_ds_pic_init, 1845d54ddcbSKumar Gala #ifdef CONFIG_PCI 1855d54ddcbSKumar Gala .pcibios_fixup_bus = fsl_pcibios_fixup_bus, 18648b16180SWang Dongsheng .pcibios_fixup_phb = fsl_pcibios_fixup_phb, 1875d54ddcbSKumar Gala #endif 1885d54ddcbSKumar Gala .get_irq = mpic_get_irq, 1895d54ddcbSKumar Gala .calibrate_decr = generic_calibrate_decr, 1905d54ddcbSKumar Gala .progress = udbg_progress, 1915d54ddcbSKumar Gala }; 19201af9507SKumar Gala 19301af9507SKumar Gala define_machine(p2020_ds) { 19401af9507SKumar Gala .name = "P2020 DS", 195*1c96fcdeSChristophe Leroy .compatible = "fsl,P2020DS", 19601af9507SKumar Gala .setup_arch = mpc85xx_ds_setup_arch, 19701af9507SKumar Gala .init_IRQ = mpc85xx_ds_pic_init, 19801af9507SKumar Gala #ifdef CONFIG_PCI 19901af9507SKumar Gala .pcibios_fixup_bus = fsl_pcibios_fixup_bus, 20048b16180SWang Dongsheng .pcibios_fixup_phb = fsl_pcibios_fixup_phb, 20101af9507SKumar Gala #endif 20201af9507SKumar Gala .get_irq = mpic_get_irq, 20301af9507SKumar Gala .calibrate_decr = generic_calibrate_decr, 20401af9507SKumar Gala .progress = udbg_progress, 20501af9507SKumar Gala }; 206