xref: /linux/arch/powerpc/platforms/85xx/mpc85xx_ds.c (revision c4f6d8665cff0abacd164b3cd10afe0385290db2)
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 #undef DEBUG
3816d24060SKumar Gala 
3916d24060SKumar Gala #ifdef DEBUG
40e48b1b45SHarvey Harrison #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
4116d24060SKumar Gala #else
4216d24060SKumar Gala #define DBG(fmt, args...)
4316d24060SKumar Gala #endif
4416d24060SKumar Gala 
4516d24060SKumar Gala #ifdef CONFIG_PPC_I8259
46bd0b9ac4SThomas Gleixner static void mpc85xx_8259_cascade(struct irq_desc *desc)
4716d24060SKumar Gala {
48ec775d0eSThomas Gleixner 	struct irq_chip *chip = irq_desc_get_chip(desc);
4916d24060SKumar Gala 	unsigned int cascade_irq = i8259_irq();
5016d24060SKumar Gala 
51ef24ba70SMichael Ellerman 	if (cascade_irq) {
5216d24060SKumar Gala 		generic_handle_irq(cascade_irq);
5316d24060SKumar Gala 	}
54712d5d79SLennert Buytenhek 	chip->irq_eoi(&desc->irq_data);
5516d24060SKumar Gala }
5616d24060SKumar Gala #endif	/* CONFIG_PPC_I8259 */
5716d24060SKumar Gala 
587f50382dSKumar Gala void __init mpc85xx_ds_pic_init(void)
5916d24060SKumar Gala {
6016d24060SKumar Gala 	struct mpic *mpic;
6116d24060SKumar Gala #ifdef CONFIG_PPC_I8259
62996983b7SKyle Moffett 	struct device_node *np;
6316d24060SKumar Gala 	struct device_node *cascade_node = NULL;
6416d24060SKumar Gala 	int cascade_irq;
6516d24060SKumar Gala #endif
665b0f9f83SBenjamin Herrenschmidt 	if (of_machine_is_compatible("fsl,MPC8572DS-CAMP")) {
67996983b7SKyle Moffett 		mpic = mpic_alloc(NULL, 0,
68e55d7f73SKyle Moffett 			MPIC_NO_RESET |
695019609fSKyle Moffett 			MPIC_BIG_ENDIAN |
70a63e23b9SFabio Baltieri 			MPIC_SINGLE_DEST_CPU,
7106be64a3SHaiying Wang 			0, 256, " OpenPIC  ");
7206be64a3SHaiying Wang 	} else {
73996983b7SKyle Moffett 		mpic = mpic_alloc(NULL, 0,
745019609fSKyle Moffett 			  MPIC_BIG_ENDIAN |
753c10c9c4SKumar Gala 			  MPIC_SINGLE_DEST_CPU,
7616d24060SKumar Gala 			0, 256, " OpenPIC  ");
7706be64a3SHaiying Wang 	}
7806be64a3SHaiying Wang 
7916d24060SKumar Gala 	BUG_ON(mpic == NULL);
8016d24060SKumar Gala 	mpic_init(mpic);
8116d24060SKumar Gala 
8216d24060SKumar Gala #ifdef CONFIG_PPC_I8259
8316d24060SKumar Gala 	/* Initialize the i8259 controller */
8416d24060SKumar Gala 	for_each_node_by_type(np, "interrupt-controller")
8516d24060SKumar Gala 	    if (of_device_is_compatible(np, "chrp,iic")) {
8616d24060SKumar Gala 		cascade_node = np;
8716d24060SKumar Gala 		break;
8816d24060SKumar Gala 	}
8916d24060SKumar Gala 
9016d24060SKumar Gala 	if (cascade_node == NULL) {
9116d24060SKumar Gala 		printk(KERN_DEBUG "Could not find i8259 PIC\n");
9216d24060SKumar Gala 		return;
9316d24060SKumar Gala 	}
9416d24060SKumar Gala 
9516d24060SKumar Gala 	cascade_irq = irq_of_parse_and_map(cascade_node, 0);
96ef24ba70SMichael Ellerman 	if (!cascade_irq) {
9716d24060SKumar Gala 		printk(KERN_ERR "Failed to map cascade interrupt\n");
9816d24060SKumar Gala 		return;
9916d24060SKumar Gala 	}
10016d24060SKumar Gala 
1017f50382dSKumar Gala 	DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
10216d24060SKumar Gala 
10316d24060SKumar Gala 	i8259_init(cascade_node, 0);
10416d24060SKumar Gala 	of_node_put(cascade_node);
10516d24060SKumar Gala 
106ec775d0eSThomas Gleixner 	irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
10716d24060SKumar Gala #endif	/* CONFIG_PPC_I8259 */
10816d24060SKumar Gala }
10916d24060SKumar Gala 
11016d24060SKumar Gala /*
11116d24060SKumar Gala  * Setup the architecture
11216d24060SKumar Gala  */
1137f50382dSKumar Gala static void __init mpc85xx_ds_setup_arch(void)
11416d24060SKumar Gala {
11516d24060SKumar Gala 	if (ppc_md.progress)
1167f50382dSKumar Gala 		ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
11716d24060SKumar Gala 
118688ba1dbSJia Hongtao 	swiotlb_detect_4g();
119905e75c4SJia Hongtao 	fsl_pci_assign_primary();
120*c4f6d866SPali Rohár 	uli_init();
1218bd3947aSKumar Gala 	mpc85xx_smp_init();
1228bd3947aSKumar Gala 
1237f50382dSKumar Gala 	printk("MPC85xx DS board from Freescale Semiconductor\n");
12416d24060SKumar Gala }
12516d24060SKumar Gala 
126905e75c4SJia Hongtao machine_arch_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
127905e75c4SJia Hongtao machine_arch_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
128905e75c4SJia Hongtao machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices);
1291028d4f1SSebastian Siewior 
13016d24060SKumar Gala define_machine(mpc8544_ds) {
13116d24060SKumar Gala 	.name			= "MPC8544 DS",
1321c96fcdeSChristophe Leroy 	.compatible		= "MPC8544DS",
1337f50382dSKumar Gala 	.setup_arch		= mpc85xx_ds_setup_arch,
1347f50382dSKumar Gala 	.init_IRQ		= mpc85xx_ds_pic_init,
13516d24060SKumar Gala #ifdef CONFIG_PCI
13616d24060SKumar Gala 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
13748b16180SWang Dongsheng 	.pcibios_fixup_phb      = fsl_pcibios_fixup_phb,
13816d24060SKumar Gala #endif
13916d24060SKumar Gala 	.get_irq		= mpic_get_irq,
14016d24060SKumar Gala 	.progress		= udbg_progress,
14116d24060SKumar Gala };
1425d54ddcbSKumar Gala 
1435d54ddcbSKumar Gala define_machine(mpc8572_ds) {
1445d54ddcbSKumar Gala 	.name			= "MPC8572 DS",
1451c96fcdeSChristophe Leroy 	.compatible		= "fsl,MPC8572DS",
1465d54ddcbSKumar Gala 	.setup_arch		= mpc85xx_ds_setup_arch,
1475d54ddcbSKumar Gala 	.init_IRQ		= mpc85xx_ds_pic_init,
1485d54ddcbSKumar Gala #ifdef CONFIG_PCI
1495d54ddcbSKumar Gala 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
15048b16180SWang Dongsheng 	.pcibios_fixup_phb      = fsl_pcibios_fixup_phb,
1515d54ddcbSKumar Gala #endif
1525d54ddcbSKumar Gala 	.get_irq		= mpic_get_irq,
1535d54ddcbSKumar Gala 	.progress		= udbg_progress,
1545d54ddcbSKumar Gala };
15501af9507SKumar Gala 
15601af9507SKumar Gala define_machine(p2020_ds) {
15701af9507SKumar Gala 	.name			= "P2020 DS",
1581c96fcdeSChristophe Leroy 	.compatible		= "fsl,P2020DS",
15901af9507SKumar Gala 	.setup_arch		= mpc85xx_ds_setup_arch,
16001af9507SKumar Gala 	.init_IRQ		= mpc85xx_ds_pic_init,
16101af9507SKumar Gala #ifdef CONFIG_PCI
16201af9507SKumar Gala 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
16348b16180SWang Dongsheng 	.pcibios_fixup_phb      = fsl_pcibios_fixup_phb,
16401af9507SKumar Gala #endif
16501af9507SKumar Gala 	.get_irq		= mpic_get_irq,
16601af9507SKumar Gala 	.progress		= udbg_progress,
16701af9507SKumar Gala };
168