usb.c 3.9 KB

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