xref: /OK3568_Linux_fs/kernel/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-or-later
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * MPC86xx HPCN board specific routines
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Recode: ZHANG WEI <wei.zhang@freescale.com>
6*4882a593Smuzhiyun  * Initial author: Xianghua Xiao <x.xiao@freescale.com>
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Copyright 2006 Freescale Semiconductor Inc.
9*4882a593Smuzhiyun  */
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #include <linux/stddef.h>
12*4882a593Smuzhiyun #include <linux/kernel.h>
13*4882a593Smuzhiyun #include <linux/pci.h>
14*4882a593Smuzhiyun #include <linux/kdev_t.h>
15*4882a593Smuzhiyun #include <linux/delay.h>
16*4882a593Smuzhiyun #include <linux/seq_file.h>
17*4882a593Smuzhiyun #include <linux/of_platform.h>
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #include <asm/time.h>
20*4882a593Smuzhiyun #include <asm/machdep.h>
21*4882a593Smuzhiyun #include <asm/pci-bridge.h>
22*4882a593Smuzhiyun #include <asm/prom.h>
23*4882a593Smuzhiyun #include <mm/mmu_decl.h>
24*4882a593Smuzhiyun #include <asm/udbg.h>
25*4882a593Smuzhiyun #include <asm/swiotlb.h>
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #include <asm/mpic.h>
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun #include <sysdev/fsl_pci.h>
30*4882a593Smuzhiyun #include <sysdev/fsl_soc.h>
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun #include "mpc86xx.h"
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun #undef DEBUG
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun #ifdef DEBUG
37*4882a593Smuzhiyun #define DBG(fmt...) do { printk(KERN_ERR fmt); } while(0)
38*4882a593Smuzhiyun #else
39*4882a593Smuzhiyun #define DBG(fmt...) do { } while(0)
40*4882a593Smuzhiyun #endif
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun #ifdef CONFIG_PCI
43*4882a593Smuzhiyun extern int uli_exclude_device(struct pci_controller *hose,
44*4882a593Smuzhiyun 				u_char bus, u_char devfn);
45*4882a593Smuzhiyun 
mpc86xx_exclude_device(struct pci_controller * hose,u_char bus,u_char devfn)46*4882a593Smuzhiyun static int mpc86xx_exclude_device(struct pci_controller *hose,
47*4882a593Smuzhiyun 				   u_char bus, u_char devfn)
48*4882a593Smuzhiyun {
49*4882a593Smuzhiyun 	if (hose->dn == fsl_pci_primary)
50*4882a593Smuzhiyun 		return uli_exclude_device(hose, bus, devfn);
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun 	return PCIBIOS_SUCCESSFUL;
53*4882a593Smuzhiyun }
54*4882a593Smuzhiyun #endif /* CONFIG_PCI */
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun static void __init
mpc86xx_hpcn_setup_arch(void)58*4882a593Smuzhiyun mpc86xx_hpcn_setup_arch(void)
59*4882a593Smuzhiyun {
60*4882a593Smuzhiyun 	if (ppc_md.progress)
61*4882a593Smuzhiyun 		ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun #ifdef CONFIG_PCI
64*4882a593Smuzhiyun 	ppc_md.pci_exclude_device = mpc86xx_exclude_device;
65*4882a593Smuzhiyun #endif
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun 	printk("MPC86xx HPCN board from Freescale Semiconductor\n");
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun #ifdef CONFIG_SMP
70*4882a593Smuzhiyun 	mpc86xx_smp_init();
71*4882a593Smuzhiyun #endif
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun 	fsl_pci_assign_primary();
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun 	swiotlb_detect_4g();
76*4882a593Smuzhiyun }
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun static void
mpc86xx_hpcn_show_cpuinfo(struct seq_file * m)80*4882a593Smuzhiyun mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
81*4882a593Smuzhiyun {
82*4882a593Smuzhiyun 	uint svid = mfspr(SPRN_SVR);
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun 	seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun 	seq_printf(m, "SVR\t\t: 0x%x\n", svid);
87*4882a593Smuzhiyun }
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun 
90*4882a593Smuzhiyun /*
91*4882a593Smuzhiyun  * Called very early, device-tree isn't unflattened
92*4882a593Smuzhiyun  */
mpc86xx_hpcn_probe(void)93*4882a593Smuzhiyun static int __init mpc86xx_hpcn_probe(void)
94*4882a593Smuzhiyun {
95*4882a593Smuzhiyun 	if (of_machine_is_compatible("fsl,mpc8641hpcn"))
96*4882a593Smuzhiyun 		return 1;	/* Looks good */
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun 	/* Be nice and don't give silent boot death.  Delete this in 2.6.27 */
99*4882a593Smuzhiyun 	if (of_machine_is_compatible("mpc86xx")) {
100*4882a593Smuzhiyun 		pr_warn("WARNING: your dts/dtb is old. You must update before the next kernel release.\n");
101*4882a593Smuzhiyun 		return 1;
102*4882a593Smuzhiyun 	}
103*4882a593Smuzhiyun 
104*4882a593Smuzhiyun 	return 0;
105*4882a593Smuzhiyun }
106*4882a593Smuzhiyun 
107*4882a593Smuzhiyun static const struct of_device_id of_bus_ids[] __initconst = {
108*4882a593Smuzhiyun 	{ .compatible = "fsl,srio", },
109*4882a593Smuzhiyun 	{},
110*4882a593Smuzhiyun };
111*4882a593Smuzhiyun 
declare_of_platform_devices(void)112*4882a593Smuzhiyun static int __init declare_of_platform_devices(void)
113*4882a593Smuzhiyun {
114*4882a593Smuzhiyun 	mpc86xx_common_publish_devices();
115*4882a593Smuzhiyun 	of_platform_bus_probe(NULL, of_bus_ids, NULL);
116*4882a593Smuzhiyun 
117*4882a593Smuzhiyun 	return 0;
118*4882a593Smuzhiyun }
119*4882a593Smuzhiyun machine_arch_initcall(mpc86xx_hpcn, declare_of_platform_devices);
120*4882a593Smuzhiyun 
define_machine(mpc86xx_hpcn)121*4882a593Smuzhiyun define_machine(mpc86xx_hpcn) {
122*4882a593Smuzhiyun 	.name			= "MPC86xx HPCN",
123*4882a593Smuzhiyun 	.probe			= mpc86xx_hpcn_probe,
124*4882a593Smuzhiyun 	.setup_arch		= mpc86xx_hpcn_setup_arch,
125*4882a593Smuzhiyun 	.init_IRQ		= mpc86xx_init_irq,
126*4882a593Smuzhiyun 	.show_cpuinfo		= mpc86xx_hpcn_show_cpuinfo,
127*4882a593Smuzhiyun 	.get_irq		= mpic_get_irq,
128*4882a593Smuzhiyun 	.time_init		= mpc86xx_time_init,
129*4882a593Smuzhiyun 	.calibrate_decr		= generic_calibrate_decr,
130*4882a593Smuzhiyun 	.progress		= udbg_progress,
131*4882a593Smuzhiyun #ifdef CONFIG_PCI
132*4882a593Smuzhiyun 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
133*4882a593Smuzhiyun #endif
134*4882a593Smuzhiyun };
135