usb.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  15. static struct musb_hdrc_eps_bits musb_eps[] = {
  16. { "ep1_tx", 8, },
  17. { "ep1_rx", 8, },
  18. { "ep2_tx", 8, },
  19. { "ep2_rx", 8, },
  20. { "ep3_tx", 5, },
  21. { "ep3_rx", 5, },
  22. { "ep4_tx", 5, },
  23. { "ep4_rx", 5, },
  24. };
  25. static struct musb_hdrc_config musb_config = {
  26. .multipoint = true,
  27. .dyn_fifo = true,
  28. .soft_con = true,
  29. .dma = true,
  30. .num_eps = 5,
  31. .dma_channels = 8,
  32. .ram_bits = 10,
  33. .eps_bits = musb_eps,
  34. };
  35. static struct musb_hdrc_platform_data usb_data = {
  36. #if defined(CONFIG_USB_MUSB_OTG)
  37. /* OTG requires a Mini-AB connector */
  38. .mode = MUSB_OTG,
  39. #elif defined(CONFIG_USB_MUSB_PERIPHERAL)
  40. .mode = MUSB_PERIPHERAL,
  41. #elif defined(CONFIG_USB_MUSB_HOST)
  42. .mode = MUSB_HOST,
  43. #endif
  44. .config = &musb_config,
  45. };
  46. static struct resource usb_resources[] = {
  47. {
  48. /* physical address */
  49. .start = DAVINCI_USB_OTG_BASE,
  50. .end = DAVINCI_USB_OTG_BASE + 0x5ff,
  51. .flags = IORESOURCE_MEM,
  52. },
  53. {
  54. .start = IRQ_USBINT,
  55. .flags = IORESOURCE_IRQ,
  56. },
  57. };
  58. static u64 usb_dmamask = DMA_32BIT_MASK;
  59. static struct platform_device usb_dev = {
  60. .name = "musb_hdrc",
  61. .id = -1,
  62. .dev = {
  63. .platform_data = &usb_data,
  64. .dma_mask = &usb_dmamask,
  65. .coherent_dma_mask = DMA_32BIT_MASK,
  66. },
  67. .resource = usb_resources,
  68. .num_resources = ARRAY_SIZE(usb_resources),
  69. };
  70. #ifdef CONFIG_USB_MUSB_OTG
  71. static struct otg_transceiver *xceiv;
  72. struct otg_transceiver *otg_get_transceiver(void)
  73. {
  74. if (xceiv)
  75. get_device(xceiv->dev);
  76. return xceiv;
  77. }
  78. EXPORT_SYMBOL(otg_get_transceiver);
  79. int otg_set_transceiver(struct otg_transceiver *x)
  80. {
  81. if (xceiv && x)
  82. return -EBUSY;
  83. xceiv = x;
  84. return 0;
  85. }
  86. EXPORT_SYMBOL(otg_set_transceiver);
  87. #endif
  88. void __init setup_usb(unsigned mA, unsigned potpgt_msec)
  89. {
  90. usb_data.power = mA / 2;
  91. usb_data.potpgt = potpgt_msec / 2;
  92. platform_device_register(&usb_dev);
  93. }
  94. #else
  95. void __init setup_usb(unsigned mA, unsigned potpgt_msec)
  96. {
  97. }
  98. #endif /* CONFIG_USB_MUSB_HDRC */