xref: /linux/arch/powerpc/platforms/85xx/mpc85xx_ds.c (revision f435f67024cbee223083aa843f9b69888c8de8a8)
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 
37bd0b9ac4SThomas Gleixner static void mpc85xx_8259_cascade(struct irq_desc *desc)
3816d24060SKumar Gala {
39ec775d0eSThomas Gleixner 	struct irq_chip *chip = irq_desc_get_chip(desc);
4016d24060SKumar Gala 	unsigned int cascade_irq = i8259_irq();
4116d24060SKumar Gala 
42ef24ba70SMichael Ellerman 	if (cascade_irq) {
4316d24060SKumar Gala 		generic_handle_irq(cascade_irq);
4416d24060SKumar Gala 	}
45712d5d79SLennert Buytenhek 	chip->irq_eoi(&desc->irq_data);
4616d24060SKumar Gala }
4716d24060SKumar Gala 
48*f435f670SChristophe Leroy static void __init mpc85xx_8259_init(void)
4916d24060SKumar Gala {
50996983b7SKyle Moffett 	struct device_node *np;
5116d24060SKumar Gala 	struct device_node *cascade_node = NULL;
5216d24060SKumar Gala 	int cascade_irq;
530abc1eadSChristophe Leroy 
54*f435f670SChristophe Leroy 	if (!IS_ENABLED(CONFIG_PPC_I8259))
551bca2f82SChristophe Leroy 		return;
561bca2f82SChristophe Leroy 
5716d24060SKumar Gala 	/* Initialize the i8259 controller */
5816d24060SKumar Gala 	for_each_node_by_type(np, "interrupt-controller")
5916d24060SKumar Gala 	    if (of_device_is_compatible(np, "chrp,iic")) {
6016d24060SKumar Gala 		cascade_node = np;
6116d24060SKumar Gala 		break;
6216d24060SKumar Gala 	}
6316d24060SKumar Gala 
6416d24060SKumar Gala 	if (cascade_node == NULL) {
6515c6ba79SChristophe Leroy 		pr_debug("Could not find i8259 PIC\n");
6616d24060SKumar Gala 		return;
6716d24060SKumar Gala 	}
6816d24060SKumar Gala 
6916d24060SKumar Gala 	cascade_irq = irq_of_parse_and_map(cascade_node, 0);
70ef24ba70SMichael Ellerman 	if (!cascade_irq) {
7115c6ba79SChristophe Leroy 		pr_err("Failed to map cascade interrupt\n");
7216d24060SKumar Gala 		return;
7316d24060SKumar Gala 	}
7416d24060SKumar Gala 
756faab5d7SChristophe Leroy 	pr_debug("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
7616d24060SKumar Gala 
7716d24060SKumar Gala 	i8259_init(cascade_node, 0);
7816d24060SKumar Gala 	of_node_put(cascade_node);
7916d24060SKumar Gala 
80ec775d0eSThomas Gleixner 	irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
81*f435f670SChristophe Leroy }
82*f435f670SChristophe Leroy 
83*f435f670SChristophe Leroy void __init mpc85xx_ds_pic_init(void)
84*f435f670SChristophe Leroy {
85*f435f670SChristophe Leroy 	struct mpic *mpic;
86*f435f670SChristophe Leroy 	int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU;
87*f435f670SChristophe Leroy 
88*f435f670SChristophe Leroy 	if (of_machine_is_compatible("fsl,MPC8572DS-CAMP"))
89*f435f670SChristophe Leroy 		flags |= MPIC_NO_RESET;
90*f435f670SChristophe Leroy 
91*f435f670SChristophe Leroy 	mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC  ");
92*f435f670SChristophe Leroy 
93*f435f670SChristophe Leroy 	if (WARN_ON(!mpic))
94*f435f670SChristophe Leroy 		return;
95*f435f670SChristophe Leroy 
96*f435f670SChristophe Leroy 	mpic_init(mpic);
97*f435f670SChristophe Leroy 
98*f435f670SChristophe Leroy 	mpc85xx_8259_init();
9916d24060SKumar Gala }
10016d24060SKumar Gala 
10116d24060SKumar Gala /*
10216d24060SKumar Gala  * Setup the architecture
10316d24060SKumar Gala  */
1047f50382dSKumar Gala static void __init mpc85xx_ds_setup_arch(void)
10516d24060SKumar Gala {
10616d24060SKumar Gala 	if (ppc_md.progress)
1077f50382dSKumar Gala 		ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
10816d24060SKumar Gala 
109688ba1dbSJia Hongtao 	swiotlb_detect_4g();
110905e75c4SJia Hongtao 	fsl_pci_assign_primary();
111c4f6d866SPali Rohár 	uli_init();
1128bd3947aSKumar Gala 	mpc85xx_smp_init();
1138bd3947aSKumar Gala 
11415c6ba79SChristophe Leroy 	pr_info("MPC85xx DS board from Freescale Semiconductor\n");
11516d24060SKumar Gala }
11616d24060SKumar Gala 
117905e75c4SJia Hongtao machine_arch_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
118905e75c4SJia Hongtao machine_arch_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
119905e75c4SJia Hongtao machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices);
1201028d4f1SSebastian Siewior 
12116d24060SKumar Gala define_machine(mpc8544_ds) {
12216d24060SKumar Gala 	.name			= "MPC8544 DS",
1231c96fcdeSChristophe Leroy 	.compatible		= "MPC8544DS",
1247f50382dSKumar Gala 	.setup_arch		= mpc85xx_ds_setup_arch,
1257f50382dSKumar Gala 	.init_IRQ		= mpc85xx_ds_pic_init,
12616d24060SKumar Gala #ifdef CONFIG_PCI
12716d24060SKumar Gala 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
12848b16180SWang Dongsheng 	.pcibios_fixup_phb      = fsl_pcibios_fixup_phb,
12916d24060SKumar Gala #endif
13016d24060SKumar Gala 	.get_irq		= mpic_get_irq,
13116d24060SKumar Gala 	.progress		= udbg_progress,
13216d24060SKumar Gala };
1335d54ddcbSKumar Gala 
1345d54ddcbSKumar Gala define_machine(mpc8572_ds) {
1355d54ddcbSKumar Gala 	.name			= "MPC8572 DS",
1361c96fcdeSChristophe Leroy 	.compatible		= "fsl,MPC8572DS",
1375d54ddcbSKumar Gala 	.setup_arch		= mpc85xx_ds_setup_arch,
1385d54ddcbSKumar Gala 	.init_IRQ		= mpc85xx_ds_pic_init,
1395d54ddcbSKumar Gala #ifdef CONFIG_PCI
1405d54ddcbSKumar Gala 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
14148b16180SWang Dongsheng 	.pcibios_fixup_phb      = fsl_pcibios_fixup_phb,
1425d54ddcbSKumar Gala #endif
1435d54ddcbSKumar Gala 	.get_irq		= mpic_get_irq,
1445d54ddcbSKumar Gala 	.progress		= udbg_progress,
1455d54ddcbSKumar Gala };
14601af9507SKumar Gala 
14701af9507SKumar Gala define_machine(p2020_ds) {
14801af9507SKumar Gala 	.name			= "P2020 DS",
1491c96fcdeSChristophe Leroy 	.compatible		= "fsl,P2020DS",
15001af9507SKumar Gala 	.setup_arch		= mpc85xx_ds_setup_arch,
15101af9507SKumar Gala 	.init_IRQ		= mpc85xx_ds_pic_init,
15201af9507SKumar Gala #ifdef CONFIG_PCI
15301af9507SKumar Gala 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
15448b16180SWang Dongsheng 	.pcibios_fixup_phb      = fsl_pcibios_fixup_phb,
15501af9507SKumar Gala #endif
15601af9507SKumar Gala 	.get_irq		= mpic_get_irq,
15701af9507SKumar Gala 	.progress		= udbg_progress,
15801af9507SKumar Gala };
159