usb-musb.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * linux/arch/arm/mach-omap2/usb-musb.c
  3. *
  4. * This file will contain the board specific details for the
  5. * MENTOR USB OTG controller on OMAP3430
  6. *
  7. * Copyright (C) 2007-2008 Texas Instruments
  8. * Copyright (C) 2008 Nokia Corporation
  9. * Author: Vikram Pandita
  10. *
  11. * Generalization by:
  12. * Felipe Balbi <felipe.balbi@nokia.com>
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation.
  17. */
  18. #include <linux/types.h>
  19. #include <linux/errno.h>
  20. #include <linux/delay.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/clk.h>
  23. #include <linux/dma-mapping.h>
  24. #include <linux/io.h>
  25. #include <linux/usb/musb.h>
  26. #include <mach/hardware.h>
  27. #include <mach/irqs.h>
  28. #include <mach/pm.h>
  29. #include <mach/mux.h>
  30. #include <mach/usb.h>
  31. static struct resource musb_resources[] = {
  32. [0] = { /* start and end set dynamically */
  33. .flags = IORESOURCE_MEM,
  34. },
  35. [1] = { /* general IRQ */
  36. .start = INT_243X_HS_USB_MC,
  37. .flags = IORESOURCE_IRQ,
  38. },
  39. [2] = { /* DMA IRQ */
  40. .start = INT_243X_HS_USB_DMA,
  41. .flags = IORESOURCE_IRQ,
  42. },
  43. };
  44. static int clk_on;
  45. static int musb_set_clock(struct clk *clk, int state)
  46. {
  47. if (state) {
  48. if (clk_on > 0)
  49. return -ENODEV;
  50. clk_enable(clk);
  51. clk_on = 1;
  52. } else {
  53. if (clk_on == 0)
  54. return -ENODEV;
  55. clk_disable(clk);
  56. clk_on = 0;
  57. }
  58. return 0;
  59. }
  60. static struct musb_hdrc_eps_bits musb_eps[] = {
  61. { "ep1_tx", 10, },
  62. { "ep1_rx", 10, },
  63. { "ep2_tx", 9, },
  64. { "ep2_rx", 9, },
  65. { "ep3_tx", 3, },
  66. { "ep3_rx", 3, },
  67. { "ep4_tx", 3, },
  68. { "ep4_rx", 3, },
  69. { "ep5_tx", 3, },
  70. { "ep5_rx", 3, },
  71. { "ep6_tx", 3, },
  72. { "ep6_rx", 3, },
  73. { "ep7_tx", 3, },
  74. { "ep7_rx", 3, },
  75. { "ep8_tx", 2, },
  76. { "ep8_rx", 2, },
  77. { "ep9_tx", 2, },
  78. { "ep9_rx", 2, },
  79. { "ep10_tx", 2, },
  80. { "ep10_rx", 2, },
  81. { "ep11_tx", 2, },
  82. { "ep11_rx", 2, },
  83. { "ep12_tx", 2, },
  84. { "ep12_rx", 2, },
  85. { "ep13_tx", 2, },
  86. { "ep13_rx", 2, },
  87. { "ep14_tx", 2, },
  88. { "ep14_rx", 2, },
  89. { "ep15_tx", 2, },
  90. { "ep15_rx", 2, },
  91. };
  92. static struct musb_hdrc_config musb_config = {
  93. .multipoint = 1,
  94. .dyn_fifo = 1,
  95. .soft_con = 1,
  96. .dma = 1,
  97. .num_eps = 16,
  98. .dma_channels = 7,
  99. .dma_req_chan = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3),
  100. .ram_bits = 12,
  101. .eps_bits = musb_eps,
  102. };
  103. static struct musb_hdrc_platform_data musb_plat = {
  104. #ifdef CONFIG_USB_MUSB_OTG
  105. .mode = MUSB_OTG,
  106. #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
  107. .mode = MUSB_HOST,
  108. #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
  109. .mode = MUSB_PERIPHERAL,
  110. #endif
  111. /* .clock is set dynamically */
  112. .set_clock = musb_set_clock,
  113. .config = &musb_config,
  114. /* REVISIT charge pump on TWL4030 can supply up to
  115. * 100 mA ... but this value is board-specific, like
  116. * "mode", and should be passed to usb_musb_init().
  117. */
  118. .power = 50, /* up to 100 mA */
  119. };
  120. static u64 musb_dmamask = DMA_BIT_MASK(32);
  121. static struct platform_device musb_device = {
  122. .name = "musb_hdrc",
  123. .id = -1,
  124. .dev = {
  125. .dma_mask = &musb_dmamask,
  126. .coherent_dma_mask = DMA_BIT_MASK(32),
  127. .platform_data = &musb_plat,
  128. },
  129. .num_resources = ARRAY_SIZE(musb_resources),
  130. .resource = musb_resources,
  131. };
  132. #ifdef CONFIG_NOP_USB_XCEIV
  133. static u64 nop_xceiv_dmamask = DMA_BIT_MASK(32);
  134. static struct platform_device nop_xceiv_device = {
  135. .name = "nop_usb_xceiv",
  136. .id = -1,
  137. .dev = {
  138. .dma_mask = &nop_xceiv_dmamask,
  139. .coherent_dma_mask = DMA_BIT_MASK(32),
  140. .platform_data = NULL,
  141. },
  142. };
  143. #endif
  144. void __init usb_musb_init(void)
  145. {
  146. if (cpu_is_omap243x())
  147. musb_resources[0].start = OMAP243X_HS_BASE;
  148. else
  149. musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
  150. musb_resources[0].end = musb_resources[0].start + SZ_8K - 1;
  151. /*
  152. * REVISIT: This line can be removed once all the platforms using
  153. * musb_core.c have been converted to use use clkdev.
  154. */
  155. musb_plat.clock = "ick";
  156. #ifdef CONFIG_NOP_USB_XCEIV
  157. if (platform_device_register(&nop_xceiv_device) < 0) {
  158. printk(KERN_ERR "Unable to register NOP-XCEIV device\n");
  159. return;
  160. }
  161. #endif
  162. if (platform_device_register(&musb_device) < 0) {
  163. printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
  164. return;
  165. }
  166. }