usb.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * USB
  3. */
  4. #include <linux/kernel.h>
  5. #include <linux/module.h>
  6. #include <linux/init.h>
  7. #include <linux/platform_device.h>
  8. #include <linux/dma-mapping.h>
  9. #include <linux/usb/musb.h>
  10. #include <linux/usb/otg.h>
  11. #include <mach/common.h>
  12. #include <mach/hardware.h>
  13. #include <mach/irqs.h>
  14. #define DAVINCI_USB_OTG_BASE 0x01C64000
  15. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  16. static struct musb_hdrc_eps_bits musb_eps[] = {
  17. { "ep1_tx", 8, },
  18. { "ep1_rx", 8, },
  19. { "ep2_tx", 8, },
  20. { "ep2_rx", 8, },
  21. { "ep3_tx", 5, },
  22. { "ep3_rx", 5, },
  23. { "ep4_tx", 5, },
  24. { "ep4_rx", 5, },
  25. };
  26. static struct musb_hdrc_config musb_config = {
  27. .multipoint = true,
  28. .dyn_fifo = true,
  29. .soft_con = true,
  30. .dma = true,
  31. .num_eps = 5,
  32. .dma_channels = 8,
  33. .ram_bits = 10,
  34. .eps_bits = musb_eps,
  35. };
  36. static struct musb_hdrc_platform_data usb_data = {
  37. #if defined(CONFIG_USB_MUSB_OTG)
  38. /* OTG requires a Mini-AB connector */
  39. .mode = MUSB_OTG,
  40. #elif defined(CONFIG_USB_MUSB_PERIPHERAL)
  41. .mode = MUSB_PERIPHERAL,
  42. #elif defined(CONFIG_USB_MUSB_HOST)
  43. .mode = MUSB_HOST,
  44. #endif
  45. .clock = "usb",
  46. .config = &musb_config,
  47. };
  48. static struct resource usb_resources[] = {
  49. {
  50. /* physical address */
  51. .start = DAVINCI_USB_OTG_BASE,
  52. .end = DAVINCI_USB_OTG_BASE + 0x5ff,
  53. .flags = IORESOURCE_MEM,
  54. },
  55. {
  56. .start = IRQ_USBINT,
  57. .flags = IORESOURCE_IRQ,
  58. },
  59. };
  60. static u64 usb_dmamask = DMA_BIT_MASK(32);
  61. static struct platform_device usb_dev = {
  62. .name = "musb_hdrc",
  63. .id = -1,
  64. .dev = {
  65. .platform_data = &usb_data,
  66. .dma_mask = &usb_dmamask,
  67. .coherent_dma_mask = DMA_BIT_MASK(32),
  68. },
  69. .resource = usb_resources,
  70. .num_resources = ARRAY_SIZE(usb_resources),
  71. };
  72. void __init setup_usb(unsigned mA, unsigned potpgt_msec)
  73. {
  74. usb_data.power = mA / 2;
  75. usb_data.potpgt = potpgt_msec / 2;
  76. platform_device_register(&usb_dev);
  77. }
  78. #else
  79. void __init setup_usb(unsigned mA, unsigned potpgt_msec)
  80. {
  81. }
  82. #endif /* CONFIG_USB_MUSB_HDRC */