aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@mvista.com>2010-06-08 05:55:57 -0400
committerKumar Gala <galak@kernel.crashing.org>2010-08-04 15:16:12 -0400
commit99d8238f5fb1dfe225042aea708337fcb7e8de55 (patch)
treeb114d2edfb2b20ea5cde6a592161e47046c99e13 /arch/powerpc/platforms
parentdee9ad718b4f0009a4170c178f7171c7b1f06f92 (diff)
powerpc/85xx: Cleanup QE initialization for MPC85xxMDS boards
The mpc85xx_mds_setup_arch() function is incomprehensible and unmaintainable. Factor out all QE specific stuff into mpc85xx_mds_qe_init() and mpc85xx_mds_reset_ucc_phys(). Also move QE stuff out of mpc85xx_mds_pic_init(). The diff is unreadable, but only because the code was so. ;-) It should be better now, and less indented. Signed-off-by: Anton Vorontsov <avorontsov@mvista.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_mds.c272
1 files changed, 143 insertions, 129 deletions
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 9dadcffd9947..c8be7b528bb0 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -177,63 +177,89 @@ static void __init mpc85xx_publish_qe_devices(void)
177 177
178 of_platform_bus_probe(NULL, mpc85xx_qe_ids, NULL); 178 of_platform_bus_probe(NULL, mpc85xx_qe_ids, NULL);
179} 179}
180#else
181static void __init mpc85xx_publish_qe_devices(void) { }
182#endif /* CONFIG_QUICC_ENGINE */
183 180
184static void __init mpc85xx_mds_setup_arch(void) 181static void __init mpc85xx_mds_reset_ucc_phys(void)
185{ 182{
186 struct device_node *np; 183 struct device_node *np;
187 static u8 __iomem *bcsr_regs = NULL; 184 static u8 __iomem *bcsr_regs;
188#ifdef CONFIG_PCI
189 struct pci_controller *hose;
190#endif
191 dma_addr_t max = 0xffffffff;
192
193 if (ppc_md.progress)
194 ppc_md.progress("mpc85xx_mds_setup_arch()", 0);
195 185
196 /* Map BCSR area */ 186 /* Map BCSR area */
197 np = of_find_node_by_name(NULL, "bcsr"); 187 np = of_find_node_by_name(NULL, "bcsr");
198 if (np != NULL) { 188 if (!np)
199 struct resource res; 189 return;
200 190
201 of_address_to_resource(np, 0, &res); 191 bcsr_regs = of_iomap(np, 0);
202 bcsr_regs = ioremap(res.start, res.end - res.start +1); 192 of_node_put(np);
203 of_node_put(np); 193 if (!bcsr_regs)
204 } 194 return;
205 195
206#ifdef CONFIG_PCI 196 if (machine_is(mpc8568_mds)) {
207 for_each_node_by_type(np, "pci") { 197#define BCSR_UCC1_GETH_EN (0x1 << 7)
208 if (of_device_is_compatible(np, "fsl,mpc8540-pci") || 198#define BCSR_UCC2_GETH_EN (0x1 << 7)
209 of_device_is_compatible(np, "fsl,mpc8548-pcie")) { 199#define BCSR_UCC1_MODE_MSK (0x3 << 4)
210 struct resource rsrc; 200#define BCSR_UCC2_MODE_MSK (0x3 << 0)
211 of_address_to_resource(np, 0, &rsrc);
212 if ((rsrc.start & 0xfffff) == 0x8000)
213 fsl_add_bridge(np, 1);
214 else
215 fsl_add_bridge(np, 0);
216 201
217 hose = pci_find_hose_for_OF_device(np); 202 /* Turn off UCC1 & UCC2 */
218 max = min(max, hose->dma_window_base_cur + 203 clrbits8(&bcsr_regs[8], BCSR_UCC1_GETH_EN);
219 hose->dma_window_size); 204 clrbits8(&bcsr_regs[9], BCSR_UCC2_GETH_EN);
205
206 /* Mode is RGMII, all bits clear */
207 clrbits8(&bcsr_regs[11], BCSR_UCC1_MODE_MSK |
208 BCSR_UCC2_MODE_MSK);
209
210 /* Turn UCC1 & UCC2 on */
211 setbits8(&bcsr_regs[8], BCSR_UCC1_GETH_EN);
212 setbits8(&bcsr_regs[9], BCSR_UCC2_GETH_EN);
213 } else if (machine_is(mpc8569_mds)) {
214#define BCSR7_UCC12_GETHnRST (0x1 << 2)
215#define BCSR8_UEM_MARVELL_RST (0x1 << 1)
216#define BCSR_UCC_RGMII (0x1 << 6)
217#define BCSR_UCC_RTBI (0x1 << 5)
218 /*
219 * U-Boot mangles interrupt polarity for Marvell PHYs,
220 * so reset built-in and UEM Marvell PHYs, this puts
221 * the PHYs into their normal state.
222 */
223 clrbits8(&bcsr_regs[7], BCSR7_UCC12_GETHnRST);
224 setbits8(&bcsr_regs[8], BCSR8_UEM_MARVELL_RST);
225
226 setbits8(&bcsr_regs[7], BCSR7_UCC12_GETHnRST);
227 clrbits8(&bcsr_regs[8], BCSR8_UEM_MARVELL_RST);
228
229 for (np = NULL; (np = of_find_compatible_node(np,
230 "network",
231 "ucc_geth")) != NULL;) {
232 const unsigned int *prop;
233 int ucc_num;
234
235 prop = of_get_property(np, "cell-index", NULL);
236 if (prop == NULL)
237 continue;
238
239 ucc_num = *prop - 1;
240
241 prop = of_get_property(np, "phy-connection-type", NULL);
242 if (prop == NULL)
243 continue;
244
245 if (strcmp("rtbi", (const char *)prop) == 0)
246 clrsetbits_8(&bcsr_regs[7 + ucc_num],
247 BCSR_UCC_RGMII, BCSR_UCC_RTBI);
220 } 248 }
249 } else if (machine_is(p1021_mds)) {
250#define BCSR11_ENET_MICRST (0x1 << 5)
251 /* Reset Micrel PHY */
252 clrbits8(&bcsr_regs[11], BCSR11_ENET_MICRST);
253 setbits8(&bcsr_regs[11], BCSR11_ENET_MICRST);
221 } 254 }
222#endif
223 255
224#ifdef CONFIG_SMP 256 iounmap(bcsr_regs);
225 mpc85xx_smp_init(); 257}
226#endif
227 258
228#ifdef CONFIG_SWIOTLB 259static void __init mpc85xx_mds_qe_init(void)
229 if (lmb_end_of_DRAM() > max) { 260{
230 ppc_swiotlb_enable = 1; 261 struct device_node *np;
231 set_pci_dma_ops(&swiotlb_dma_ops);
232 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
233 }
234#endif
235 262
236#ifdef CONFIG_QUICC_ENGINE
237 np = of_find_compatible_node(NULL, NULL, "fsl,qe"); 263 np = of_find_compatible_node(NULL, NULL, "fsl,qe");
238 if (!np) { 264 if (!np) {
239 np = of_find_node_by_name(NULL, "qe"); 265 np = of_find_node_by_name(NULL, "qe");
@@ -260,70 +286,7 @@ static void __init mpc85xx_mds_setup_arch(void)
260 par_io_of_config(ucc); 286 par_io_of_config(ucc);
261 } 287 }
262 288
263 if (bcsr_regs) { 289 mpc85xx_mds_reset_ucc_phys();
264 if (machine_is(mpc8568_mds)) {
265#define BCSR_UCC1_GETH_EN (0x1 << 7)
266#define BCSR_UCC2_GETH_EN (0x1 << 7)
267#define BCSR_UCC1_MODE_MSK (0x3 << 4)
268#define BCSR_UCC2_MODE_MSK (0x3 << 0)
269
270 /* Turn off UCC1 & UCC2 */
271 clrbits8(&bcsr_regs[8], BCSR_UCC1_GETH_EN);
272 clrbits8(&bcsr_regs[9], BCSR_UCC2_GETH_EN);
273
274 /* Mode is RGMII, all bits clear */
275 clrbits8(&bcsr_regs[11], BCSR_UCC1_MODE_MSK |
276 BCSR_UCC2_MODE_MSK);
277
278 /* Turn UCC1 & UCC2 on */
279 setbits8(&bcsr_regs[8], BCSR_UCC1_GETH_EN);
280 setbits8(&bcsr_regs[9], BCSR_UCC2_GETH_EN);
281 } else if (machine_is(mpc8569_mds)) {
282#define BCSR7_UCC12_GETHnRST (0x1 << 2)
283#define BCSR8_UEM_MARVELL_RST (0x1 << 1)
284#define BCSR_UCC_RGMII (0x1 << 6)
285#define BCSR_UCC_RTBI (0x1 << 5)
286 /*
287 * U-Boot mangles interrupt polarity for Marvell PHYs,
288 * so reset built-in and UEM Marvell PHYs, this puts
289 * the PHYs into their normal state.
290 */
291 clrbits8(&bcsr_regs[7], BCSR7_UCC12_GETHnRST);
292 setbits8(&bcsr_regs[8], BCSR8_UEM_MARVELL_RST);
293
294 setbits8(&bcsr_regs[7], BCSR7_UCC12_GETHnRST);
295 clrbits8(&bcsr_regs[8], BCSR8_UEM_MARVELL_RST);
296
297 for (np = NULL; (np = of_find_compatible_node(np,
298 "network",
299 "ucc_geth")) != NULL;) {
300 const unsigned int *prop;
301 int ucc_num;
302
303 prop = of_get_property(np, "cell-index", NULL);
304 if (prop == NULL)
305 continue;
306
307 ucc_num = *prop - 1;
308
309 prop = of_get_property(np, "phy-connection-type", NULL);
310 if (prop == NULL)
311 continue;
312
313 if (strcmp("rtbi", (const char *)prop) == 0)
314 clrsetbits_8(&bcsr_regs[7 + ucc_num],
315 BCSR_UCC_RGMII, BCSR_UCC_RTBI);
316 }
317
318 } else if (machine_is(p1021_mds)) {
319#define BCSR11_ENET_MICRST (0x1 << 5)
320 /* Reset Micrel PHY */
321 clrbits8(&bcsr_regs[11], BCSR11_ENET_MICRST);
322 setbits8(&bcsr_regs[11], BCSR11_ENET_MICRST);
323 }
324
325 iounmap(bcsr_regs);
326 }
327 290
328 if (machine_is(p1021_mds)) { 291 if (machine_is(p1021_mds)) {
329#define MPC85xx_PMUXCR_OFFSET 0x60 292#define MPC85xx_PMUXCR_OFFSET 0x60
@@ -358,7 +321,79 @@ static void __init mpc85xx_mds_setup_arch(void)
358 } 321 }
359 322
360 } 323 }
324}
325
326static void __init mpc85xx_mds_qeic_init(void)
327{
328 struct device_node *np;
329
330 np = of_find_compatible_node(NULL, NULL, "fsl,qe");
331 if (!of_device_is_available(np)) {
332 of_node_put(np);
333 return;
334 }
335
336 np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
337 if (!np) {
338 np = of_find_node_by_type(NULL, "qeic");
339 if (!np)
340 return;
341 }
342
343 if (machine_is(p1021_mds))
344 qe_ic_init(np, 0, qe_ic_cascade_low_mpic,
345 qe_ic_cascade_high_mpic);
346 else
347 qe_ic_init(np, 0, qe_ic_cascade_muxed_mpic, NULL);
348 of_node_put(np);
349}
350#else
351static void __init mpc85xx_publish_qe_devices(void) { }
352static void __init mpc85xx_mds_qe_init(void) { }
353static void __init mpc85xx_mds_qeic_init(void) { }
361#endif /* CONFIG_QUICC_ENGINE */ 354#endif /* CONFIG_QUICC_ENGINE */
355
356static void __init mpc85xx_mds_setup_arch(void)
357{
358#ifdef CONFIG_PCI
359 struct pci_controller *hose;
360#endif
361 dma_addr_t max = 0xffffffff;
362
363 if (ppc_md.progress)
364 ppc_md.progress("mpc85xx_mds_setup_arch()", 0);
365
366#ifdef CONFIG_PCI
367 for_each_node_by_type(np, "pci") {
368 if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
369 of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
370 struct resource rsrc;
371 of_address_to_resource(np, 0, &rsrc);
372 if ((rsrc.start & 0xfffff) == 0x8000)
373 fsl_add_bridge(np, 1);
374 else
375 fsl_add_bridge(np, 0);
376
377 hose = pci_find_hose_for_OF_device(np);
378 max = min(max, hose->dma_window_base_cur +
379 hose->dma_window_size);
380 }
381 }
382#endif
383
384#ifdef CONFIG_SMP
385 mpc85xx_smp_init();
386#endif
387
388 mpc85xx_mds_qe_init();
389
390#ifdef CONFIG_SWIOTLB
391 if (lmb_end_of_DRAM() > max) {
392 ppc_swiotlb_enable = 1;
393 set_pci_dma_ops(&swiotlb_dma_ops);
394 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
395 }
396#endif
362} 397}
363 398
364 399
@@ -465,28 +500,7 @@ static void __init mpc85xx_mds_pic_init(void)
465 of_node_put(np); 500 of_node_put(np);
466 501
467 mpic_init(mpic); 502 mpic_init(mpic);
468 503 mpc85xx_mds_qeic_init();
469#ifdef CONFIG_QUICC_ENGINE
470 np = of_find_compatible_node(NULL, NULL, "fsl,qe");
471 if (!of_device_is_available(np)) {
472 of_node_put(np);
473 return;
474 }
475
476 np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
477 if (!np) {
478 np = of_find_node_by_type(NULL, "qeic");
479 if (!np)
480 return;
481 }
482
483 if (machine_is(p1021_mds))
484 qe_ic_init(np, 0, qe_ic_cascade_low_mpic,
485 qe_ic_cascade_high_mpic);
486 else
487 qe_ic_init(np, 0, qe_ic_cascade_muxed_mpic, NULL);
488 of_node_put(np);
489#endif /* CONFIG_QUICC_ENGINE */
490} 504}
491 505
492static int __init mpc85xx_mds_probe(void) 506static int __init mpc85xx_mds_probe(void)