xref: /linux/arch/powerpc/platforms/85xx/mpc85xx_ds.c (revision 15c6ba7992993fecdac52a424ce35b6e4a272c75)
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>
29821b3a47SChristophe Leroy #include <asm/ppc-pci.h>
3016d24060SKumar Gala 
3116d24060SKumar Gala #include <sysdev/fsl_soc.h>
3216d24060SKumar Gala #include <sysdev/fsl_pci.h>
33582d3e09SKyle Moffett #include "smp.h"
3416d24060SKumar Gala 
35543a07b1SDmitry Eremin-Solenikov #include "mpc85xx.h"
36543a07b1SDmitry Eremin-Solenikov 
3716d24060SKumar Gala #ifdef CONFIG_PPC_I8259
38bd0b9ac4SThomas Gleixner static void mpc85xx_8259_cascade(struct irq_desc *desc)
3916d24060SKumar Gala {
40ec775d0eSThomas Gleixner 	struct irq_chip *chip = irq_desc_get_chip(desc);
4116d24060SKumar Gala 	unsigned int cascade_irq = i8259_irq();
4216d24060SKumar Gala 
43ef24ba70SMichael Ellerman 	if (cascade_irq) {
4416d24060SKumar Gala 		generic_handle_irq(cascade_irq);
4516d24060SKumar Gala 	}
46712d5d79SLennert Buytenhek 	chip->irq_eoi(&desc->irq_data);
4716d24060SKumar Gala }
4816d24060SKumar Gala #endif	/* CONFIG_PPC_I8259 */
4916d24060SKumar Gala 
507f50382dSKumar Gala void __init mpc85xx_ds_pic_init(void)
5116d24060SKumar Gala {
5216d24060SKumar Gala 	struct mpic *mpic;
530abc1eadSChristophe Leroy 	int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU;
5416d24060SKumar Gala #ifdef CONFIG_PPC_I8259
55996983b7SKyle Moffett 	struct device_node *np;
5616d24060SKumar Gala 	struct device_node *cascade_node = NULL;
5716d24060SKumar Gala 	int cascade_irq;
5816d24060SKumar Gala #endif
590abc1eadSChristophe Leroy 
600abc1eadSChristophe Leroy 	if (of_machine_is_compatible("fsl,MPC8572DS-CAMP"))
610abc1eadSChristophe Leroy 		flags |= MPIC_NO_RESET;
620abc1eadSChristophe Leroy 
630abc1eadSChristophe Leroy 	mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC  ");
6406be64a3SHaiying Wang 
651bca2f82SChristophe Leroy 	if (WARN_ON(!mpic))
661bca2f82SChristophe Leroy 		return;
671bca2f82SChristophe Leroy 
6816d24060SKumar Gala 	mpic_init(mpic);
6916d24060SKumar Gala 
7016d24060SKumar Gala #ifdef CONFIG_PPC_I8259
7116d24060SKumar Gala 	/* Initialize the i8259 controller */
7216d24060SKumar Gala 	for_each_node_by_type(np, "interrupt-controller")
7316d24060SKumar Gala 	    if (of_device_is_compatible(np, "chrp,iic")) {
7416d24060SKumar Gala 		cascade_node = np;
7516d24060SKumar Gala 		break;
7616d24060SKumar Gala 	}
7716d24060SKumar Gala 
7816d24060SKumar Gala 	if (cascade_node == NULL) {
79*15c6ba79SChristophe Leroy 		pr_debug("Could not find i8259 PIC\n");
8016d24060SKumar Gala 		return;
8116d24060SKumar Gala 	}
8216d24060SKumar Gala 
8316d24060SKumar Gala 	cascade_irq = irq_of_parse_and_map(cascade_node, 0);
84ef24ba70SMichael Ellerman 	if (!cascade_irq) {
85*15c6ba79SChristophe Leroy 		pr_err("Failed to map cascade interrupt\n");
8616d24060SKumar Gala 		return;
8716d24060SKumar Gala 	}
8816d24060SKumar Gala 
896faab5d7SChristophe Leroy 	pr_debug("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
9016d24060SKumar Gala 
9116d24060SKumar Gala 	i8259_init(cascade_node, 0);
9216d24060SKumar Gala 	of_node_put(cascade_node);
9316d24060SKumar Gala 
94ec775d0eSThomas Gleixner 	irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
9516d24060SKumar Gala #endif	/* CONFIG_PPC_I8259 */
9616d24060SKumar Gala }
9716d24060SKumar Gala 
9816d24060SKumar Gala /*
9916d24060SKumar Gala  * Setup the architecture
10016d24060SKumar Gala  */
1017f50382dSKumar Gala static void __init mpc85xx_ds_setup_arch(void)
10216d24060SKumar Gala {
10316d24060SKumar Gala 	if (ppc_md.progress)
1047f50382dSKumar Gala 		ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
10516d24060SKumar Gala 
106688ba1dbSJia Hongtao 	swiotlb_detect_4g();
107905e75c4SJia Hongtao 	fsl_pci_assign_primary();
108c4f6d866SPali Rohár 	uli_init();
1098bd3947aSKumar Gala 	mpc85xx_smp_init();
1108bd3947aSKumar Gala 
111*15c6ba79SChristophe Leroy 	pr_info("MPC85xx DS board from Freescale Semiconductor\n");
11216d24060SKumar Gala }
11316d24060SKumar Gala 
114905e75c4SJia Hongtao machine_arch_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
115905e75c4SJia Hongtao machine_arch_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
116905e75c4SJia Hongtao machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices);
1171028d4f1SSebastian Siewior 
11816d24060SKumar Gala define_machine(mpc8544_ds) {
11916d24060SKumar Gala 	.name			= "MPC8544 DS",
1201c96fcdeSChristophe Leroy 	.compatible		= "MPC8544DS",
1217f50382dSKumar Gala 	.setup_arch		= mpc85xx_ds_setup_arch,
1227f50382dSKumar Gala 	.init_IRQ		= mpc85xx_ds_pic_init,
12316d24060SKumar Gala #ifdef CONFIG_PCI
12416d24060SKumar Gala 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
12548b16180SWang Dongsheng 	.pcibios_fixup_phb      = fsl_pcibios_fixup_phb,
12616d24060SKumar Gala #endif
12716d24060SKumar Gala 	.get_irq		= mpic_get_irq,
12816d24060SKumar Gala 	.progress		= udbg_progress,
12916d24060SKumar Gala };
1305d54ddcbSKumar Gala 
1315d54ddcbSKumar Gala define_machine(mpc8572_ds) {
1325d54ddcbSKumar Gala 	.name			= "MPC8572 DS",
1331c96fcdeSChristophe Leroy 	.compatible		= "fsl,MPC8572DS",
1345d54ddcbSKumar Gala 	.setup_arch		= mpc85xx_ds_setup_arch,
1355d54ddcbSKumar Gala 	.init_IRQ		= mpc85xx_ds_pic_init,
1365d54ddcbSKumar Gala #ifdef CONFIG_PCI
1375d54ddcbSKumar Gala 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
13848b16180SWang Dongsheng 	.pcibios_fixup_phb      = fsl_pcibios_fixup_phb,
1395d54ddcbSKumar Gala #endif
1405d54ddcbSKumar Gala 	.get_irq		= mpic_get_irq,
1415d54ddcbSKumar Gala 	.progress		= udbg_progress,
1425d54ddcbSKumar Gala };
14301af9507SKumar Gala 
14401af9507SKumar Gala define_machine(p2020_ds) {
14501af9507SKumar Gala 	.name			= "P2020 DS",
1461c96fcdeSChristophe Leroy 	.compatible		= "fsl,P2020DS",
14701af9507SKumar Gala 	.setup_arch		= mpc85xx_ds_setup_arch,
14801af9507SKumar Gala 	.init_IRQ		= mpc85xx_ds_pic_init,
14901af9507SKumar Gala #ifdef CONFIG_PCI
15001af9507SKumar Gala 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
15148b16180SWang Dongsheng 	.pcibios_fixup_phb      = fsl_pcibios_fixup_phb,
15201af9507SKumar Gala #endif
15301af9507SKumar Gala 	.get_irq		= mpic_get_irq,
15401af9507SKumar Gala 	.progress		= udbg_progress,
15501af9507SKumar Gala };
156