usb.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. void __init setup_usb(unsigned mA, unsigned potpgt_msec)
  71. {
  72. usb_data.power = mA / 2;
  73. usb_data.potpgt = potpgt_msec / 2;
  74. platform_device_register(&usb_dev);
  75. }
  76. #else
  77. void __init setup_usb(unsigned mA, unsigned potpgt_msec)
  78. {
  79. }
  80. #endif /* CONFIG_USB_MUSB_HDRC */