usb.c 3.2 KB

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