usb.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * USB
  3. */
  4. #include <linux/init.h>
  5. #include <linux/platform_device.h>
  6. #include <linux/dma-mapping.h>
  7. #include <linux/usb/musb.h>
  8. #include <mach/common.h>
  9. #include <mach/irqs.h>
  10. #include <mach/cputype.h>
  11. #include <mach/usb.h>
  12. #define DAVINCI_USB_OTG_BASE 0x01c64000
  13. #define DA8XX_USB0_BASE 0x01e00000
  14. #define DA8XX_USB1_BASE 0x01e25000
  15. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  16. static struct musb_hdrc_eps_bits musb_eps[] = {
  17. { "ep1_tx", 8, },
  18. { "ep1_rx", 8, },
  19. { "ep2_tx", 8, },
  20. { "ep2_rx", 8, },
  21. { "ep3_tx", 5, },
  22. { "ep3_rx", 5, },
  23. { "ep4_tx", 5, },
  24. { "ep4_rx", 5, },
  25. };
  26. static struct musb_hdrc_config musb_config = {
  27. .multipoint = true,
  28. .dyn_fifo = true,
  29. .soft_con = true,
  30. .dma = true,
  31. .num_eps = 5,
  32. .dma_channels = 8,
  33. .ram_bits = 10,
  34. .eps_bits = musb_eps,
  35. };
  36. static struct musb_hdrc_platform_data usb_data = {
  37. #if defined(CONFIG_USB_MUSB_OTG)
  38. /* OTG requires a Mini-AB connector */
  39. .mode = MUSB_OTG,
  40. #elif defined(CONFIG_USB_MUSB_PERIPHERAL)
  41. .mode = MUSB_PERIPHERAL,
  42. #elif defined(CONFIG_USB_MUSB_HOST)
  43. .mode = MUSB_HOST,
  44. #endif
  45. .clock = "usb",
  46. .config = &musb_config,
  47. };
  48. static struct resource usb_resources[] = {
  49. {
  50. /* physical address */
  51. .start = DAVINCI_USB_OTG_BASE,
  52. .end = DAVINCI_USB_OTG_BASE + 0x5ff,
  53. .flags = IORESOURCE_MEM,
  54. },
  55. {
  56. .start = IRQ_USBINT,
  57. .flags = IORESOURCE_IRQ,
  58. .name = "mc"
  59. },
  60. {
  61. /* placeholder for the dedicated CPPI IRQ */
  62. .flags = IORESOURCE_IRQ,
  63. .name = "dma"
  64. },
  65. };
  66. static u64 usb_dmamask = DMA_BIT_MASK(32);
  67. static struct platform_device usb_dev = {
  68. .name = "musb-davinci",
  69. .id = -1,
  70. .dev = {
  71. .platform_data = &usb_data,
  72. .dma_mask = &usb_dmamask,
  73. .coherent_dma_mask = DMA_BIT_MASK(32),
  74. },
  75. .resource = usb_resources,
  76. .num_resources = ARRAY_SIZE(usb_resources),
  77. };
  78. void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
  79. {
  80. usb_data.power = mA > 510 ? 255 : mA / 2;
  81. usb_data.potpgt = (potpgt_ms + 1) / 2;
  82. if (cpu_is_davinci_dm646x()) {
  83. /* Override the defaults as DM6467 uses different IRQs. */
  84. usb_dev.resource[1].start = IRQ_DM646X_USBINT;
  85. usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT;
  86. } else /* other devices don't have dedicated CPPI IRQ */
  87. usb_dev.num_resources = 2;
  88. platform_device_register(&usb_dev);
  89. }
  90. #ifdef CONFIG_ARCH_DAVINCI_DA8XX
  91. static struct resource da8xx_usb20_resources[] = {
  92. {
  93. .start = DA8XX_USB0_BASE,
  94. .end = DA8XX_USB0_BASE + SZ_64K - 1,
  95. .flags = IORESOURCE_MEM,
  96. },
  97. {
  98. .start = IRQ_DA8XX_USB_INT,
  99. .flags = IORESOURCE_IRQ,
  100. .name = "mc",
  101. },
  102. };
  103. int __init da8xx_register_usb20(unsigned mA, unsigned potpgt)
  104. {
  105. usb_data.clock = "usb20";
  106. usb_data.power = mA > 510 ? 255 : mA / 2;
  107. usb_data.potpgt = (potpgt + 1) / 2;
  108. usb_dev.resource = da8xx_usb20_resources;
  109. usb_dev.num_resources = ARRAY_SIZE(da8xx_usb20_resources);
  110. usb_dev.name = "musb-da8xx";
  111. return platform_device_register(&usb_dev);
  112. }
  113. #endif /* CONFIG_DAVINCI_DA8XX */
  114. #else
  115. void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
  116. {
  117. }
  118. #ifdef CONFIG_ARCH_DAVINCI_DA8XX
  119. int __init da8xx_register_usb20(unsigned mA, unsigned potpgt)
  120. {
  121. return 0;
  122. }
  123. #endif
  124. #endif /* CONFIG_USB_MUSB_HDRC */
  125. #ifdef CONFIG_ARCH_DAVINCI_DA8XX
  126. static struct resource da8xx_usb11_resources[] = {
  127. [0] = {
  128. .start = DA8XX_USB1_BASE,
  129. .end = DA8XX_USB1_BASE + SZ_4K - 1,
  130. .flags = IORESOURCE_MEM,
  131. },
  132. [1] = {
  133. .start = IRQ_DA8XX_IRQN,
  134. .end = IRQ_DA8XX_IRQN,
  135. .flags = IORESOURCE_IRQ,
  136. },
  137. };
  138. static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
  139. static struct platform_device da8xx_usb11_device = {
  140. .name = "ohci",
  141. .id = 0,
  142. .dev = {
  143. .dma_mask = &da8xx_usb11_dma_mask,
  144. .coherent_dma_mask = DMA_BIT_MASK(32),
  145. },
  146. .num_resources = ARRAY_SIZE(da8xx_usb11_resources),
  147. .resource = da8xx_usb11_resources,
  148. };
  149. int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
  150. {
  151. da8xx_usb11_device.dev.platform_data = pdata;
  152. return platform_device_register(&da8xx_usb11_device);
  153. }
  154. #endif /* CONFIG_DAVINCI_DA8XX */