diff options
author | Kumar Gala <galak@kernel.crashing.org> | 2006-02-02 13:31:00 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-02-07 06:38:41 -0500 |
commit | 4b10cfd40e3fa1c1663b9c9fa22260d41e669c6f (patch) | |
tree | 46720a0b4527ba0b940430344cae649bfc55a07c | |
parent | 158daa4cc827bda9f7206279a1dc55de2cb9c902 (diff) |
[PATCH] powerpc: Add platform support for MPC834x USB controllers
Setup the platform devices needed by the Freescale EHCI USB
host controllers based on a flat device tree
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r-- | arch/powerpc/sysdev/fsl_soc.c | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index e0887d5c3bb1..ceb584682fa3 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c | |||
@@ -351,3 +351,143 @@ nodev: | |||
351 | 351 | ||
352 | arch_initcall(mpc83xx_wdt_init); | 352 | arch_initcall(mpc83xx_wdt_init); |
353 | #endif | 353 | #endif |
354 | |||
355 | static enum fsl_usb2_phy_modes determine_usb_phy(char * phy_type) | ||
356 | { | ||
357 | if (!phy_type) | ||
358 | return FSL_USB2_PHY_NONE; | ||
359 | if (!strcasecmp(phy_type, "ulpi")) | ||
360 | return FSL_USB2_PHY_ULPI; | ||
361 | if (!strcasecmp(phy_type, "utmi")) | ||
362 | return FSL_USB2_PHY_UTMI; | ||
363 | if (!strcasecmp(phy_type, "utmi_wide")) | ||
364 | return FSL_USB2_PHY_UTMI_WIDE; | ||
365 | if (!strcasecmp(phy_type, "serial")) | ||
366 | return FSL_USB2_PHY_SERIAL; | ||
367 | |||
368 | return FSL_USB2_PHY_NONE; | ||
369 | } | ||
370 | |||
371 | static int __init fsl_usb_of_init(void) | ||
372 | { | ||
373 | struct device_node *np; | ||
374 | unsigned int i; | ||
375 | struct platform_device *usb_dev; | ||
376 | int ret; | ||
377 | |||
378 | for (np = NULL, i = 0; | ||
379 | (np = of_find_compatible_node(np, "usb", "fsl-usb2-mph")) != NULL; | ||
380 | i++) { | ||
381 | struct resource r[2]; | ||
382 | struct fsl_usb2_platform_data usb_data; | ||
383 | unsigned char *prop = NULL; | ||
384 | |||
385 | memset(&r, 0, sizeof(r)); | ||
386 | memset(&usb_data, 0, sizeof(usb_data)); | ||
387 | |||
388 | ret = of_address_to_resource(np, 0, &r[0]); | ||
389 | if (ret) | ||
390 | goto err; | ||
391 | |||
392 | r[1].start = np->intrs[0].line; | ||
393 | r[1].end = np->intrs[0].line; | ||
394 | r[1].flags = IORESOURCE_IRQ; | ||
395 | |||
396 | usb_dev = | ||
397 | platform_device_register_simple("fsl-usb2-mph", i, r, 2); | ||
398 | if (IS_ERR(usb_dev)) { | ||
399 | ret = PTR_ERR(usb_dev); | ||
400 | goto err; | ||
401 | } | ||
402 | |||
403 | usb_dev->dev.coherent_dma_mask = 0xffffffffUL; | ||
404 | usb_dev->dev.dma_mask = &usb_dev->dev.coherent_dma_mask; | ||
405 | |||
406 | usb_data.operating_mode = FSL_USB2_MPH_HOST; | ||
407 | |||
408 | prop = get_property(np, "port0", NULL); | ||
409 | if (prop) | ||
410 | usb_data.port_enables |= FSL_USB2_PORT0_ENABLED; | ||
411 | |||
412 | prop = get_property(np, "port1", NULL); | ||
413 | if (prop) | ||
414 | usb_data.port_enables |= FSL_USB2_PORT1_ENABLED; | ||
415 | |||
416 | prop = get_property(np, "phy_type", NULL); | ||
417 | usb_data.phy_mode = determine_usb_phy(prop); | ||
418 | |||
419 | ret = | ||
420 | platform_device_add_data(usb_dev, &usb_data, | ||
421 | sizeof(struct | ||
422 | fsl_usb2_platform_data)); | ||
423 | if (ret) | ||
424 | goto unreg; | ||
425 | } | ||
426 | |||
427 | return 0; | ||
428 | |||
429 | unreg: | ||
430 | platform_device_unregister(usb_dev); | ||
431 | err: | ||
432 | return ret; | ||
433 | } | ||
434 | |||
435 | arch_initcall(fsl_usb_of_init); | ||
436 | |||
437 | static int __init fsl_usb_dr_of_init(void) | ||
438 | { | ||
439 | struct device_node *np; | ||
440 | unsigned int i; | ||
441 | struct platform_device *usb_dev; | ||
442 | int ret; | ||
443 | |||
444 | for (np = NULL, i = 0; | ||
445 | (np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) != NULL; | ||
446 | i++) { | ||
447 | struct resource r[2]; | ||
448 | struct fsl_usb2_platform_data usb_data; | ||
449 | unsigned char *prop = NULL; | ||
450 | |||
451 | memset(&r, 0, sizeof(r)); | ||
452 | memset(&usb_data, 0, sizeof(usb_data)); | ||
453 | |||
454 | ret = of_address_to_resource(np, 0, &r[0]); | ||
455 | if (ret) | ||
456 | goto err; | ||
457 | |||
458 | r[1].start = np->intrs[0].line; | ||
459 | r[1].end = np->intrs[0].line; | ||
460 | r[1].flags = IORESOURCE_IRQ; | ||
461 | |||
462 | usb_dev = | ||
463 | platform_device_register_simple("fsl-usb2-dr", i, r, 2); | ||
464 | if (IS_ERR(usb_dev)) { | ||
465 | ret = PTR_ERR(usb_dev); | ||
466 | goto err; | ||
467 | } | ||
468 | |||
469 | usb_dev->dev.coherent_dma_mask = 0xffffffffUL; | ||
470 | usb_dev->dev.dma_mask = &usb_dev->dev.coherent_dma_mask; | ||
471 | |||
472 | usb_data.operating_mode = FSL_USB2_DR_HOST; | ||
473 | |||
474 | prop = get_property(np, "phy_type", NULL); | ||
475 | usb_data.phy_mode = determine_usb_phy(prop); | ||
476 | |||
477 | ret = | ||
478 | platform_device_add_data(usb_dev, &usb_data, | ||
479 | sizeof(struct | ||
480 | fsl_usb2_platform_data)); | ||
481 | if (ret) | ||
482 | goto unreg; | ||
483 | } | ||
484 | |||
485 | return 0; | ||
486 | |||
487 | unreg: | ||
488 | platform_device_unregister(usb_dev); | ||
489 | err: | ||
490 | return ret; | ||
491 | } | ||
492 | |||
493 | arch_initcall(fsl_usb_dr_of_init); | ||