1
2
3
4
5
6
7
8
9
10
11
12
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#include <linux/lmb.h>
23
24#include <asm/system.h>
25#include <asm/time.h>
26#include <asm/machdep.h>
27#include <asm/pci-bridge.h>
28#include <asm/prom.h>
29#include <mm/mmu_decl.h>
30#include <asm/udbg.h>
31#include <asm/swiotlb.h>
32
33#include <asm/mpic.h>
34
35#include <sysdev/fsl_pci.h>
36#include <sysdev/fsl_soc.h>
37
38#include "mpc86xx.h"
39
40#undef DEBUG
41
42#ifdef DEBUG
43#define DBG(fmt...) do { printk(KERN_ERR fmt); } while(0)
44#else
45#define DBG(fmt...) do { } while(0)
46#endif
47
48#ifdef CONFIG_PCI
49extern int uli_exclude_device(struct pci_controller *hose,
50 u_char bus, u_char devfn);
51
52static int mpc86xx_exclude_device(struct pci_controller *hose,
53 u_char bus, u_char devfn)
54{
55 struct device_node* node;
56 struct resource rsrc;
57
58 node = hose->dn;
59 of_address_to_resource(node, 0, &rsrc);
60
61 if ((rsrc.start & 0xfffff) == 0x8000) {
62 return uli_exclude_device(hose, bus, devfn);
63 }
64
65 return PCIBIOS_SUCCESSFUL;
66}
67#endif
68
69
70static void __init
71mpc86xx_hpcn_setup_arch(void)
72{
73#ifdef CONFIG_PCI
74 struct device_node *np;
75 struct pci_controller *hose;
76#endif
77 dma_addr_t max = 0xffffffff;
78
79 if (ppc_md.progress)
80 ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
81
82#ifdef CONFIG_PCI
83 for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
84 struct resource rsrc;
85 of_address_to_resource(np, 0, &rsrc);
86 if ((rsrc.start & 0xfffff) == 0x8000)
87 fsl_add_bridge(np, 1);
88 else
89 fsl_add_bridge(np, 0);
90 hose = pci_find_hose_for_OF_device(np);
91 max = min(max, hose->dma_window_base_cur +
92 hose->dma_window_size);
93 }
94
95 ppc_md.pci_exclude_device = mpc86xx_exclude_device;
96
97#endif
98
99 printk("MPC86xx HPCN board from Freescale Semiconductor\n");
100
101#ifdef CONFIG_SMP
102 mpc86xx_smp_init();
103#endif
104
105#ifdef CONFIG_SWIOTLB
106 if (lmb_end_of_DRAM() > max) {
107 ppc_swiotlb_enable = 1;
108 set_pci_dma_ops(&swiotlb_dma_ops);
109 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
110 }
111#endif
112}
113
114
115static void
116mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
117{
118 uint svid = mfspr(SPRN_SVR);
119
120 seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
121
122 seq_printf(m, "SVR\t\t: 0x%x\n", svid);
123}
124
125
126
127
128
129static int __init mpc86xx_hpcn_probe(void)
130{
131 unsigned long root = of_get_flat_dt_root();
132
133 if (of_flat_dt_is_compatible(root, "fsl,mpc8641hpcn"))
134 return 1;
135
136
137 if (of_flat_dt_is_compatible(root, "mpc86xx")) {
138 pr_warning("WARNING: your dts/dtb is old. You must update before the next kernel release\n");
139 return 1;
140 }
141
142 return 0;
143}
144
145static long __init
146mpc86xx_time_init(void)
147{
148 unsigned int temp;
149
150
151 mtspr(SPRN_TBWL, 0);
152 mtspr(SPRN_TBWU, 0);
153
154 temp = mfspr(SPRN_HID0);
155 temp |= HID0_TBEN;
156 mtspr(SPRN_HID0, temp);
157 asm volatile("isync");
158
159 return 0;
160}
161
162static __initdata struct of_device_id of_bus_ids[] = {
163 { .compatible = "simple-bus", },
164 { .compatible = "fsl,rapidio-delta", },
165 { .compatible = "gianfar", },
166 {},
167};
168
169static int __init declare_of_platform_devices(void)
170{
171 of_platform_bus_probe(NULL, of_bus_ids, NULL);
172
173 return 0;
174}
175machine_device_initcall(mpc86xx_hpcn, declare_of_platform_devices);
176machine_arch_initcall(mpc86xx_hpcn, swiotlb_setup_bus_notifier);
177
178define_machine(mpc86xx_hpcn) {
179 .name = "MPC86xx HPCN",
180 .probe = mpc86xx_hpcn_probe,
181 .setup_arch = mpc86xx_hpcn_setup_arch,
182 .init_IRQ = mpc86xx_init_irq,
183 .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo,
184 .get_irq = mpic_get_irq,
185 .restart = fsl_rstcr_restart,
186 .time_init = mpc86xx_time_init,
187 .calibrate_decr = generic_calibrate_decr,
188 .progress = udbg_progress,
189#ifdef CONFIG_PCI
190 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
191#endif
192};
193