usb.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #include <mach/cputype.h>
  15. #define DAVINCI_USB_OTG_BASE 0x01C64000
  16. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  17. static struct musb_hdrc_eps_bits musb_eps[] = {
  18. { "ep1_tx", 8, },
  19. { "ep1_rx", 8, },
  20. { "ep2_tx", 8, },
  21. { "ep2_rx", 8, },
  22. { "ep3_tx", 5, },
  23. { "ep3_rx", 5, },
  24. { "ep4_tx", 5, },
  25. { "ep4_rx", 5, },
  26. };
  27. static struct musb_hdrc_config musb_config = {
  28. .multipoint = true,
  29. .dyn_fifo = true,
  30. .soft_con = true,
  31. .dma = true,
  32. .num_eps = 5,
  33. .dma_channels = 8,
  34. .ram_bits = 10,
  35. .eps_bits = musb_eps,
  36. };
  37. static struct musb_hdrc_platform_data usb_data = {
  38. #if defined(CONFIG_USB_MUSB_OTG)
  39. /* OTG requires a Mini-AB connector */
  40. .mode = MUSB_OTG,
  41. #elif defined(CONFIG_USB_MUSB_PERIPHERAL)
  42. .mode = MUSB_PERIPHERAL,
  43. #elif defined(CONFIG_USB_MUSB_HOST)
  44. .mode = MUSB_HOST,
  45. #endif
  46. .clock = "usb",
  47. .config = &musb_config,
  48. };
  49. static struct resource usb_resources[] = {
  50. {
  51. /* physical address */
  52. .start = DAVINCI_USB_OTG_BASE,
  53. .end = DAVINCI_USB_OTG_BASE + 0x5ff,
  54. .flags = IORESOURCE_MEM,
  55. },
  56. {
  57. .start = IRQ_USBINT,
  58. .flags = IORESOURCE_IRQ,
  59. },
  60. {
  61. /* placeholder for the dedicated CPPI IRQ */
  62. .flags = IORESOURCE_IRQ,
  63. },
  64. };
  65. static u64 usb_dmamask = DMA_BIT_MASK(32);
  66. static struct platform_device usb_dev = {
  67. .name = "musb_hdrc",
  68. .id = -1,
  69. .dev = {
  70. .platform_data = &usb_data,
  71. .dma_mask = &usb_dmamask,
  72. .coherent_dma_mask = DMA_BIT_MASK(32),
  73. },
  74. .resource = usb_resources,
  75. .num_resources = ARRAY_SIZE(usb_resources),
  76. };
  77. void __init setup_usb(unsigned mA, unsigned potpgt_msec)
  78. {
  79. usb_data.power = mA / 2;
  80. usb_data.potpgt = potpgt_msec / 2;
  81. if (cpu_is_davinci_dm646x()) {
  82. /* Override the defaults as DM6467 uses different IRQs. */
  83. usb_dev.resource[1].start = IRQ_DM646X_USBINT;
  84. usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT;
  85. } else /* other devices don't have dedicated CPPI IRQ */
  86. usb_dev.num_resources = 2;
  87. platform_device_register(&usb_dev);
  88. }
  89. #else
  90. void __init setup_usb(unsigned mA, unsigned potpgt_msec)
  91. {
  92. }
  93. #endif /* CONFIG_USB_MUSB_HDRC */