usb.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. },
  59. {
  60. /* placeholder for the dedicated CPPI IRQ */
  61. .flags = IORESOURCE_IRQ,
  62. },
  63. };
  64. static u64 usb_dmamask = DMA_BIT_MASK(32);
  65. static struct platform_device usb_dev = {
  66. .name = "musb_hdrc",
  67. .id = -1,
  68. .dev = {
  69. .platform_data = &usb_data,
  70. .dma_mask = &usb_dmamask,
  71. .coherent_dma_mask = DMA_BIT_MASK(32),
  72. },
  73. .resource = usb_resources,
  74. .num_resources = ARRAY_SIZE(usb_resources),
  75. };
  76. void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
  77. {
  78. usb_data.power = mA > 510 ? 255 : mA / 2;
  79. usb_data.potpgt = (potpgt_ms + 1) / 2;
  80. if (cpu_is_davinci_dm646x()) {
  81. /* Override the defaults as DM6467 uses different IRQs. */
  82. usb_dev.resource[1].start = IRQ_DM646X_USBINT;
  83. usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT;
  84. } else /* other devices don't have dedicated CPPI IRQ */
  85. usb_dev.num_resources = 2;
  86. platform_device_register(&usb_dev);
  87. }
  88. #ifdef CONFIG_ARCH_DAVINCI_DA8XX
  89. static struct resource da8xx_usb20_resources[] = {
  90. {
  91. .start = DA8XX_USB0_BASE,
  92. .end = DA8XX_USB0_BASE + SZ_64K - 1,
  93. .flags = IORESOURCE_MEM,
  94. },
  95. {
  96. .start = IRQ_DA8XX_USB_INT,
  97. .flags = IORESOURCE_IRQ,
  98. },
  99. };
  100. int __init da8xx_register_usb20(unsigned mA, unsigned potpgt)
  101. {
  102. usb_data.clock = "usb20";
  103. usb_data.power = mA > 510 ? 255 : mA / 2;
  104. usb_data.potpgt = (potpgt + 1) / 2;
  105. usb_dev.resource = da8xx_usb20_resources;
  106. usb_dev.num_resources = ARRAY_SIZE(da8xx_usb20_resources);
  107. return platform_device_register(&usb_dev);
  108. }
  109. #endif /* CONFIG_DAVINCI_DA8XX */
  110. #else
  111. void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
  112. {
  113. }
  114. #ifdef CONFIG_ARCH_DAVINCI_DA8XX
  115. int __init da8xx_register_usb20(unsigned mA, unsigned potpgt)
  116. {
  117. return 0;
  118. }
  119. #endif
  120. #endif /* CONFIG_USB_MUSB_HDRC */
  121. #ifdef CONFIG_ARCH_DAVINCI_DA8XX
  122. static struct resource da8xx_usb11_resources[] = {
  123. [0] = {
  124. .start = DA8XX_USB1_BASE,
  125. .end = DA8XX_USB1_BASE + SZ_4K - 1,
  126. .flags = IORESOURCE_MEM,
  127. },
  128. [1] = {
  129. .start = IRQ_DA8XX_IRQN,
  130. .end = IRQ_DA8XX_IRQN,
  131. .flags = IORESOURCE_IRQ,
  132. },
  133. };
  134. static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
  135. static struct platform_device da8xx_usb11_device = {
  136. .name = "ohci",
  137. .id = 0,
  138. .dev = {
  139. .dma_mask = &da8xx_usb11_dma_mask,
  140. .coherent_dma_mask = DMA_BIT_MASK(32),
  141. },
  142. .num_resources = ARRAY_SIZE(da8xx_usb11_resources),
  143. .resource = da8xx_usb11_resources,
  144. };
  145. int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
  146. {
  147. da8xx_usb11_device.dev.platform_data = pdata;
  148. return platform_device_register(&da8xx_usb11_device);
  149. }
  150. #endif /* CONFIG_DAVINCI_DA8XX */