xref: /linux/arch/powerpc/platforms/85xx/mpc85xx_ds.c (revision 905e75c46dba5f3061049277e4eb7110beedba43)
116d24060SKumar Gala /*
27f50382dSKumar Gala  * MPC85xx DS Board Setup
316d24060SKumar Gala  *
416d24060SKumar Gala  * Author Xianghua Xiao (x.xiao@freescale.com)
516d24060SKumar Gala  * Roy Zang <tie-fei.zang@freescale.com>
616d24060SKumar Gala  * 	- Add PCI/PCI Exprees support
716d24060SKumar Gala  * Copyright 2007 Freescale Semiconductor Inc.
816d24060SKumar Gala  *
916d24060SKumar Gala  * This program is free software; you can redistribute  it and/or modify it
1016d24060SKumar Gala  * under  the terms of  the GNU General  Public License as published by the
1116d24060SKumar Gala  * Free Software Foundation;  either version 2 of the  License, or (at your
1216d24060SKumar Gala  * option) any later version.
1316d24060SKumar Gala  */
1416d24060SKumar Gala 
1516d24060SKumar Gala #include <linux/stddef.h>
1616d24060SKumar Gala #include <linux/kernel.h>
1716d24060SKumar Gala #include <linux/pci.h>
1816d24060SKumar Gala #include <linux/kdev_t.h>
1916d24060SKumar Gala #include <linux/delay.h>
2016d24060SKumar Gala #include <linux/seq_file.h>
2116d24060SKumar Gala #include <linux/interrupt.h>
221028d4f1SSebastian Siewior #include <linux/of_platform.h>
2316d24060SKumar Gala 
2416d24060SKumar Gala #include <asm/time.h>
2516d24060SKumar Gala #include <asm/machdep.h>
2616d24060SKumar Gala #include <asm/pci-bridge.h>
2716d24060SKumar Gala #include <mm/mmu_decl.h>
2816d24060SKumar Gala #include <asm/prom.h>
2916d24060SKumar Gala #include <asm/udbg.h>
3016d24060SKumar Gala #include <asm/mpic.h>
3116d24060SKumar Gala #include <asm/i8259.h>
32152d0182SKumar Gala #include <asm/swiotlb.h>
3316d24060SKumar Gala 
3416d24060SKumar Gala #include <sysdev/fsl_soc.h>
3516d24060SKumar Gala #include <sysdev/fsl_pci.h>
36582d3e09SKyle Moffett #include "smp.h"
3716d24060SKumar Gala 
38543a07b1SDmitry Eremin-Solenikov #include "mpc85xx.h"
39543a07b1SDmitry Eremin-Solenikov 
4016d24060SKumar Gala #undef DEBUG
4116d24060SKumar Gala 
4216d24060SKumar Gala #ifdef DEBUG
43e48b1b45SHarvey Harrison #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
4416d24060SKumar Gala #else
4516d24060SKumar Gala #define DBG(fmt, args...)
4616d24060SKumar Gala #endif
4716d24060SKumar Gala 
4816d24060SKumar Gala #ifdef CONFIG_PPC_I8259
497f50382dSKumar Gala static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
5016d24060SKumar Gala {
51ec775d0eSThomas Gleixner 	struct irq_chip *chip = irq_desc_get_chip(desc);
5216d24060SKumar Gala 	unsigned int cascade_irq = i8259_irq();
5316d24060SKumar Gala 
5416d24060SKumar Gala 	if (cascade_irq != NO_IRQ) {
5516d24060SKumar Gala 		generic_handle_irq(cascade_irq);
5616d24060SKumar Gala 	}
57712d5d79SLennert Buytenhek 	chip->irq_eoi(&desc->irq_data);
5816d24060SKumar Gala }
5916d24060SKumar Gala #endif	/* CONFIG_PPC_I8259 */
6016d24060SKumar Gala 
617f50382dSKumar Gala void __init mpc85xx_ds_pic_init(void)
6216d24060SKumar Gala {
6316d24060SKumar Gala 	struct mpic *mpic;
6416d24060SKumar Gala #ifdef CONFIG_PPC_I8259
65996983b7SKyle Moffett 	struct device_node *np;
6616d24060SKumar Gala 	struct device_node *cascade_node = NULL;
6716d24060SKumar Gala 	int cascade_irq;
6816d24060SKumar Gala #endif
6906be64a3SHaiying Wang 	unsigned long root = of_get_flat_dt_root();
7016d24060SKumar Gala 
7106be64a3SHaiying Wang 	if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
72996983b7SKyle Moffett 		mpic = mpic_alloc(NULL, 0,
73e55d7f73SKyle Moffett 			MPIC_NO_RESET |
745019609fSKyle Moffett 			MPIC_BIG_ENDIAN |
75a63e23b9SFabio Baltieri 			MPIC_SINGLE_DEST_CPU,
7606be64a3SHaiying Wang 			0, 256, " OpenPIC  ");
7706be64a3SHaiying Wang 	} else {
78996983b7SKyle Moffett 		mpic = mpic_alloc(NULL, 0,
795019609fSKyle Moffett 			  MPIC_BIG_ENDIAN |
803c10c9c4SKumar Gala 			  MPIC_SINGLE_DEST_CPU,
8116d24060SKumar Gala 			0, 256, " OpenPIC  ");
8206be64a3SHaiying Wang 	}
8306be64a3SHaiying Wang 
8416d24060SKumar Gala 	BUG_ON(mpic == NULL);
8516d24060SKumar Gala 	mpic_init(mpic);
8616d24060SKumar Gala 
8716d24060SKumar Gala #ifdef CONFIG_PPC_I8259
8816d24060SKumar Gala 	/* Initialize the i8259 controller */
8916d24060SKumar Gala 	for_each_node_by_type(np, "interrupt-controller")
9016d24060SKumar Gala 	    if (of_device_is_compatible(np, "chrp,iic")) {
9116d24060SKumar Gala 		cascade_node = np;
9216d24060SKumar Gala 		break;
9316d24060SKumar Gala 	}
9416d24060SKumar Gala 
9516d24060SKumar Gala 	if (cascade_node == NULL) {
9616d24060SKumar Gala 		printk(KERN_DEBUG "Could not find i8259 PIC\n");
9716d24060SKumar Gala 		return;
9816d24060SKumar Gala 	}
9916d24060SKumar Gala 
10016d24060SKumar Gala 	cascade_irq = irq_of_parse_and_map(cascade_node, 0);
10116d24060SKumar Gala 	if (cascade_irq == NO_IRQ) {
10216d24060SKumar Gala 		printk(KERN_ERR "Failed to map cascade interrupt\n");
10316d24060SKumar Gala 		return;
10416d24060SKumar Gala 	}
10516d24060SKumar Gala 
1067f50382dSKumar Gala 	DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
10716d24060SKumar Gala 
10816d24060SKumar Gala 	i8259_init(cascade_node, 0);
10916d24060SKumar Gala 	of_node_put(cascade_node);
11016d24060SKumar Gala 
111ec775d0eSThomas Gleixner 	irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
11216d24060SKumar Gala #endif	/* CONFIG_PPC_I8259 */
11316d24060SKumar Gala }
11416d24060SKumar Gala 
11516d24060SKumar Gala #ifdef CONFIG_PCI
11616d24060SKumar Gala extern int uli_exclude_device(struct pci_controller *hose,
11716d24060SKumar Gala 				u_char bus, u_char devfn);
11816d24060SKumar Gala 
11991a6f347SScott Wood static struct device_node *pci_with_uli;
12091a6f347SScott Wood 
12116d24060SKumar Gala static int mpc85xx_exclude_device(struct pci_controller *hose,
12216d24060SKumar Gala 				   u_char bus, u_char devfn)
12316d24060SKumar Gala {
12491a6f347SScott Wood 	if (hose->dn == pci_with_uli)
12516d24060SKumar Gala 		return uli_exclude_device(hose, bus, devfn);
12616d24060SKumar Gala 
12716d24060SKumar Gala 	return PCIBIOS_SUCCESSFUL;
12816d24060SKumar Gala }
12916d24060SKumar Gala #endif	/* CONFIG_PCI */
13016d24060SKumar Gala 
131*905e75c4SJia Hongtao static void __init mpc85xx_ds_uli_init(void)
13291a6f347SScott Wood {
13391a6f347SScott Wood #ifdef CONFIG_PCI
13491a6f347SScott Wood 	struct device_node *node;
13591a6f347SScott Wood 
13691a6f347SScott Wood 	/* See if we have a ULI under the primary */
13791a6f347SScott Wood 
13891a6f347SScott Wood 	node = of_find_node_by_name(NULL, "uli1575");
13991a6f347SScott Wood 	while ((pci_with_uli = of_get_parent(node))) {
14091a6f347SScott Wood 		of_node_put(node);
14191a6f347SScott Wood 		node = pci_with_uli;
14291a6f347SScott Wood 
14391a6f347SScott Wood 		if (pci_with_uli == fsl_pci_primary) {
14491a6f347SScott Wood 			ppc_md.pci_exclude_device = mpc85xx_exclude_device;
14591a6f347SScott Wood 			break;
14691a6f347SScott Wood 		}
14791a6f347SScott Wood 	}
14891a6f347SScott Wood #endif
14991a6f347SScott Wood }
15091a6f347SScott Wood 
15116d24060SKumar Gala /*
15216d24060SKumar Gala  * Setup the architecture
15316d24060SKumar Gala  */
1547f50382dSKumar Gala static void __init mpc85xx_ds_setup_arch(void)
15516d24060SKumar Gala {
15616d24060SKumar Gala 	if (ppc_md.progress)
1577f50382dSKumar Gala 		ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
15816d24060SKumar Gala 
159688ba1dbSJia Hongtao 	swiotlb_detect_4g();
160*905e75c4SJia Hongtao 	fsl_pci_assign_primary();
161*905e75c4SJia Hongtao 	mpc85xx_ds_uli_init();
1628bd3947aSKumar Gala 	mpc85xx_smp_init();
1638bd3947aSKumar Gala 
1647f50382dSKumar Gala 	printk("MPC85xx DS board from Freescale Semiconductor\n");
16516d24060SKumar Gala }
16616d24060SKumar Gala 
16716d24060SKumar Gala /*
16816d24060SKumar Gala  * Called very early, device-tree isn't unflattened
16916d24060SKumar Gala  */
17016d24060SKumar Gala static int __init mpc8544_ds_probe(void)
17116d24060SKumar Gala {
17216d24060SKumar Gala 	unsigned long root = of_get_flat_dt_root();
17316d24060SKumar Gala 
17491a6f347SScott Wood 	return !!of_flat_dt_is_compatible(root, "MPC8544DS");
17516d24060SKumar Gala }
17616d24060SKumar Gala 
177*905e75c4SJia Hongtao machine_arch_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
178*905e75c4SJia Hongtao machine_arch_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
179*905e75c4SJia Hongtao machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices);
1801028d4f1SSebastian Siewior 
181152d0182SKumar Gala machine_arch_initcall(mpc8544_ds, swiotlb_setup_bus_notifier);
182152d0182SKumar Gala machine_arch_initcall(mpc8572_ds, swiotlb_setup_bus_notifier);
183152d0182SKumar Gala machine_arch_initcall(p2020_ds, swiotlb_setup_bus_notifier);
184152d0182SKumar Gala 
1855d54ddcbSKumar Gala /*
1865d54ddcbSKumar Gala  * Called very early, device-tree isn't unflattened
1875d54ddcbSKumar Gala  */
1885d54ddcbSKumar Gala static int __init mpc8572_ds_probe(void)
1895d54ddcbSKumar Gala {
1905d54ddcbSKumar Gala 	unsigned long root = of_get_flat_dt_root();
1915d54ddcbSKumar Gala 
19291a6f347SScott Wood 	return !!of_flat_dt_is_compatible(root, "fsl,MPC8572DS");
1935d54ddcbSKumar Gala }
19401af9507SKumar Gala 
19501af9507SKumar Gala /*
19601af9507SKumar Gala  * Called very early, device-tree isn't unflattened
19701af9507SKumar Gala  */
19801af9507SKumar Gala static int __init p2020_ds_probe(void)
19901af9507SKumar Gala {
20001af9507SKumar Gala 	unsigned long root = of_get_flat_dt_root();
20101af9507SKumar Gala 
20291a6f347SScott Wood 	return !!of_flat_dt_is_compatible(root, "fsl,P2020DS");
2035d54ddcbSKumar Gala }
2045d54ddcbSKumar Gala 
20516d24060SKumar Gala define_machine(mpc8544_ds) {
20616d24060SKumar Gala 	.name			= "MPC8544 DS",
20716d24060SKumar Gala 	.probe			= mpc8544_ds_probe,
2087f50382dSKumar Gala 	.setup_arch		= mpc85xx_ds_setup_arch,
2097f50382dSKumar Gala 	.init_IRQ		= mpc85xx_ds_pic_init,
21016d24060SKumar Gala #ifdef CONFIG_PCI
21116d24060SKumar Gala 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
21216d24060SKumar Gala #endif
21316d24060SKumar Gala 	.get_irq		= mpic_get_irq,
214e1c1575fSKumar Gala 	.restart		= fsl_rstcr_restart,
21516d24060SKumar Gala 	.calibrate_decr		= generic_calibrate_decr,
21616d24060SKumar Gala 	.progress		= udbg_progress,
21716d24060SKumar Gala };
2185d54ddcbSKumar Gala 
2195d54ddcbSKumar Gala define_machine(mpc8572_ds) {
2205d54ddcbSKumar Gala 	.name			= "MPC8572 DS",
2215d54ddcbSKumar Gala 	.probe			= mpc8572_ds_probe,
2225d54ddcbSKumar Gala 	.setup_arch		= mpc85xx_ds_setup_arch,
2235d54ddcbSKumar Gala 	.init_IRQ		= mpc85xx_ds_pic_init,
2245d54ddcbSKumar Gala #ifdef CONFIG_PCI
2255d54ddcbSKumar Gala 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
2265d54ddcbSKumar Gala #endif
2275d54ddcbSKumar Gala 	.get_irq		= mpic_get_irq,
228e1c1575fSKumar Gala 	.restart		= fsl_rstcr_restart,
2295d54ddcbSKumar Gala 	.calibrate_decr		= generic_calibrate_decr,
2305d54ddcbSKumar Gala 	.progress		= udbg_progress,
2315d54ddcbSKumar Gala };
23201af9507SKumar Gala 
23301af9507SKumar Gala define_machine(p2020_ds) {
23401af9507SKumar Gala 	.name			= "P2020 DS",
23501af9507SKumar Gala 	.probe			= p2020_ds_probe,
23601af9507SKumar Gala 	.setup_arch		= mpc85xx_ds_setup_arch,
23701af9507SKumar Gala 	.init_IRQ		= mpc85xx_ds_pic_init,
23801af9507SKumar Gala #ifdef CONFIG_PCI
23901af9507SKumar Gala 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
24001af9507SKumar Gala #endif
24101af9507SKumar Gala 	.get_irq		= mpic_get_irq,
24201af9507SKumar Gala 	.restart		= fsl_rstcr_restart,
24301af9507SKumar Gala 	.calibrate_decr		= generic_calibrate_decr,
24401af9507SKumar Gala 	.progress		= udbg_progress,
24501af9507SKumar Gala };
246