This source file includes following definitions.
- quirk_ppc_currituck_usb_fixup
- avr_halt_system
- avr_power_off_system
- avr_reset_system
- avr_probe
- ppc47x_device_probe
- ppc47x_init_irq
- smp_ppc47x_setup_cpu
- smp_ppc47x_kick_cpu
- ppc47x_smp_init
- ppc47x_smp_init
- ppc47x_setup_arch
- ppc47x_get_board_rev
- ppc47x_pci_irq_fixup
- ppc47x_probe
- define_machine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <linux/init.h>
21 #include <linux/of.h>
22 #include <linux/of_platform.h>
23 #include <linux/rtc.h>
24
25 #include <asm/machdep.h>
26 #include <asm/prom.h>
27 #include <asm/udbg.h>
28 #include <asm/time.h>
29 #include <asm/uic.h>
30 #include <asm/ppc4xx.h>
31 #include <asm/mpic.h>
32 #include <asm/mmu.h>
33 #include <asm/swiotlb.h>
34
35 #include <linux/pci.h>
36 #include <linux/i2c.h>
37
38 static const struct of_device_id ppc47x_of_bus[] __initconst = {
39 { .compatible = "ibm,plb4", },
40 { .compatible = "ibm,plb6", },
41 { .compatible = "ibm,opb", },
42 { .compatible = "ibm,ebc", },
43 {},
44 };
45
46
47
48 static void quirk_ppc_currituck_usb_fixup(struct pci_dev *dev)
49 {
50 if (of_machine_is_compatible("ibm,currituck")) {
51 pci_write_config_dword(dev, 0xe0, 0x0114231f);
52 pci_write_config_dword(dev, 0xe4, 0x00006c40);
53 }
54 }
55 DECLARE_PCI_FIXUP_HEADER(0x1033, 0x0035, quirk_ppc_currituck_usb_fixup);
56
57
58
59
60
61 #define AVR_PWRCTL_CMD (0x26)
62
63
64 #define AVR_PWRCTL_PWROFF (0x01)
65 #define AVR_PWRCTL_RESET (0x02)
66
67 static struct i2c_client *avr_i2c_client;
68 static void __noreturn avr_halt_system(int pwrctl_flags)
69 {
70
71 i2c_smbus_write_byte_data(avr_i2c_client,
72 AVR_PWRCTL_CMD, pwrctl_flags);
73
74
75 while (1)
76 ;
77 }
78
79 static void avr_power_off_system(void)
80 {
81 avr_halt_system(AVR_PWRCTL_PWROFF);
82 }
83
84 static void __noreturn avr_reset_system(char *cmd)
85 {
86 avr_halt_system(AVR_PWRCTL_RESET);
87 }
88
89 static int avr_probe(struct i2c_client *client,
90 const struct i2c_device_id *id)
91 {
92 avr_i2c_client = client;
93 ppc_md.restart = avr_reset_system;
94 pm_power_off = avr_power_off_system;
95 return 0;
96 }
97
98 static const struct i2c_device_id avr_id[] = {
99 { "akebono-avr", 0 },
100 { }
101 };
102
103 static struct i2c_driver avr_driver = {
104 .driver = {
105 .name = "akebono-avr",
106 },
107 .probe = avr_probe,
108 .id_table = avr_id,
109 };
110
111 static int __init ppc47x_device_probe(void)
112 {
113 i2c_add_driver(&avr_driver);
114 of_platform_bus_probe(NULL, ppc47x_of_bus, NULL);
115
116 return 0;
117 }
118 machine_device_initcall(ppc47x, ppc47x_device_probe);
119
120 static void __init ppc47x_init_irq(void)
121 {
122 struct device_node *np;
123
124
125 for_each_node_with_property(np, "interrupt-controller") {
126 if (of_get_property(np, "interrupts", NULL) == NULL)
127 break;
128 }
129 if (np == NULL)
130 panic("Can't find top level interrupt controller");
131
132
133 if (of_device_is_compatible(np, "chrp,open-pic")) {
134
135
136
137 struct mpic *mpic =
138 mpic_alloc(np, 0, MPIC_NO_RESET, 0, 0, " MPIC ");
139 BUG_ON(mpic == NULL);
140 mpic_init(mpic);
141 ppc_md.get_irq = mpic_get_irq;
142 } else
143 panic("Unrecognized top level interrupt controller");
144 }
145
146 #ifdef CONFIG_SMP
147 static void smp_ppc47x_setup_cpu(int cpu)
148 {
149 mpic_setup_this_cpu();
150 }
151
152 static int smp_ppc47x_kick_cpu(int cpu)
153 {
154 struct device_node *cpunode = of_get_cpu_node(cpu, NULL);
155 const u64 *spin_table_addr_prop;
156 u32 *spin_table;
157 extern void start_secondary_47x(void);
158
159 BUG_ON(cpunode == NULL);
160
161
162
163
164
165 spin_table_addr_prop =
166 of_get_property(cpunode, "cpu-release-addr", NULL);
167
168 if (spin_table_addr_prop == NULL) {
169 pr_err("CPU%d: Can't start, missing cpu-release-addr !\n",
170 cpu);
171 return 1;
172 }
173
174
175
176
177
178
179 spin_table = (u32 *)__va(*spin_table_addr_prop);
180 pr_debug("CPU%d: Spin table mapped at %p\n", cpu, spin_table);
181
182 spin_table[3] = cpu;
183 smp_wmb();
184 spin_table[1] = __pa(start_secondary_47x);
185 mb();
186
187 return 0;
188 }
189
190 static struct smp_ops_t ppc47x_smp_ops = {
191 .probe = smp_mpic_probe,
192 .message_pass = smp_mpic_message_pass,
193 .setup_cpu = smp_ppc47x_setup_cpu,
194 .kick_cpu = smp_ppc47x_kick_cpu,
195 .give_timebase = smp_generic_give_timebase,
196 .take_timebase = smp_generic_take_timebase,
197 };
198
199 static void __init ppc47x_smp_init(void)
200 {
201 if (mmu_has_feature(MMU_FTR_TYPE_47x))
202 smp_ops = &ppc47x_smp_ops;
203 }
204
205 #else
206 static void __init ppc47x_smp_init(void) { }
207 #endif
208
209 static void __init ppc47x_setup_arch(void)
210 {
211
212
213
214 swiotlb_detect_4g();
215
216 ppc47x_smp_init();
217 }
218
219 static int board_rev = -1;
220 static int __init ppc47x_get_board_rev(void)
221 {
222 int reg;
223 u8 *fpga;
224 struct device_node *np = NULL;
225
226 if (of_machine_is_compatible("ibm,currituck")) {
227 np = of_find_compatible_node(NULL, NULL, "ibm,currituck-fpga");
228 reg = 0;
229 } else if (of_machine_is_compatible("ibm,akebono")) {
230 np = of_find_compatible_node(NULL, NULL, "ibm,akebono-fpga");
231 reg = 2;
232 }
233
234 if (!np)
235 goto fail;
236
237 fpga = (u8 *) of_iomap(np, 0);
238 of_node_put(np);
239 if (!fpga)
240 goto fail;
241
242 board_rev = ioread8(fpga + reg) & 0x03;
243 pr_info("%s: Found board revision %d\n", __func__, board_rev);
244 iounmap(fpga);
245 return 0;
246
247 fail:
248 pr_info("%s: Unable to find board revision\n", __func__);
249 return 0;
250 }
251 machine_arch_initcall(ppc47x, ppc47x_get_board_rev);
252
253
254 static void ppc47x_pci_irq_fixup(struct pci_dev *dev)
255 {
256 if (dev->vendor == 0x1033 && (dev->device == 0x0035 ||
257 dev->device == 0x00e0)) {
258 if (board_rev == 0) {
259 dev->irq = irq_create_mapping(NULL, 47);
260 pr_info("%s: Mapping irq %d\n", __func__, dev->irq);
261 } else if (board_rev == 2) {
262 dev->irq = irq_create_mapping(NULL, 49);
263 pr_info("%s: Mapping irq %d\n", __func__, dev->irq);
264 } else {
265 pr_alert("%s: Unknown board revision\n", __func__);
266 }
267 }
268 }
269
270
271
272
273 static int __init ppc47x_probe(void)
274 {
275 if (of_machine_is_compatible("ibm,akebono"))
276 return 1;
277
278 if (of_machine_is_compatible("ibm,currituck")) {
279 ppc_md.pci_irq_fixup = ppc47x_pci_irq_fixup;
280 return 1;
281 }
282
283 return 0;
284 }
285
286 define_machine(ppc47x) {
287 .name = "PowerPC 47x",
288 .probe = ppc47x_probe,
289 .progress = udbg_progress,
290 .init_IRQ = ppc47x_init_irq,
291 .setup_arch = ppc47x_setup_arch,
292 .restart = ppc4xx_reset_system,
293 .calibrate_decr = generic_calibrate_decr,
294 };