usb.c 2.3 KB

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