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