usb-musb.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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/mux.h>
  29. #include <mach/usb.h>
  30. static struct resource musb_resources[] = {
  31. [0] = { /* start and end set dynamically */
  32. .flags = IORESOURCE_MEM,
  33. },
  34. [1] = { /* general IRQ */
  35. .start = INT_243X_HS_USB_MC,
  36. .flags = IORESOURCE_IRQ,
  37. },
  38. [2] = { /* DMA IRQ */
  39. .start = INT_243X_HS_USB_DMA,
  40. .flags = IORESOURCE_IRQ,
  41. },
  42. };
  43. static int clk_on;
  44. static int musb_set_clock(struct clk *clk, int state)
  45. {
  46. if (state) {
  47. if (clk_on > 0)
  48. return -ENODEV;
  49. clk_enable(clk);
  50. clk_on = 1;
  51. } else {
  52. if (clk_on == 0)
  53. return -ENODEV;
  54. clk_disable(clk);
  55. clk_on = 0;
  56. }
  57. return 0;
  58. }
  59. static struct musb_hdrc_eps_bits musb_eps[] = {
  60. { "ep1_tx", 10, },
  61. { "ep1_rx", 10, },
  62. { "ep2_tx", 9, },
  63. { "ep2_rx", 9, },
  64. { "ep3_tx", 3, },
  65. { "ep3_rx", 3, },
  66. { "ep4_tx", 3, },
  67. { "ep4_rx", 3, },
  68. { "ep5_tx", 3, },
  69. { "ep5_rx", 3, },
  70. { "ep6_tx", 3, },
  71. { "ep6_rx", 3, },
  72. { "ep7_tx", 3, },
  73. { "ep7_rx", 3, },
  74. { "ep8_tx", 2, },
  75. { "ep8_rx", 2, },
  76. { "ep9_tx", 2, },
  77. { "ep9_rx", 2, },
  78. { "ep10_tx", 2, },
  79. { "ep10_rx", 2, },
  80. { "ep11_tx", 2, },
  81. { "ep11_rx", 2, },
  82. { "ep12_tx", 2, },
  83. { "ep12_rx", 2, },
  84. { "ep13_tx", 2, },
  85. { "ep13_rx", 2, },
  86. { "ep14_tx", 2, },
  87. { "ep14_rx", 2, },
  88. { "ep15_tx", 2, },
  89. { "ep15_rx", 2, },
  90. };
  91. static struct musb_hdrc_config musb_config = {
  92. .multipoint = 1,
  93. .dyn_fifo = 1,
  94. .soft_con = 1,
  95. .dma = 1,
  96. .num_eps = 16,
  97. .dma_channels = 7,
  98. .dma_req_chan = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3),
  99. .ram_bits = 12,
  100. .eps_bits = musb_eps,
  101. };
  102. static struct musb_hdrc_platform_data musb_plat = {
  103. #ifdef CONFIG_USB_MUSB_OTG
  104. .mode = MUSB_OTG,
  105. #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
  106. .mode = MUSB_HOST,
  107. #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
  108. .mode = MUSB_PERIPHERAL,
  109. #endif
  110. /* .clock is set dynamically */
  111. .set_clock = musb_set_clock,
  112. .config = &musb_config,
  113. /* REVISIT charge pump on TWL4030 can supply up to
  114. * 100 mA ... but this value is board-specific, like
  115. * "mode", and should be passed to usb_musb_init().
  116. */
  117. .power = 50, /* up to 100 mA */
  118. };
  119. static u64 musb_dmamask = DMA_BIT_MASK(32);
  120. static struct platform_device musb_device = {
  121. .name = "musb_hdrc",
  122. .id = -1,
  123. .dev = {
  124. .dma_mask = &musb_dmamask,
  125. .coherent_dma_mask = DMA_BIT_MASK(32),
  126. .platform_data = &musb_plat,
  127. },
  128. .num_resources = ARRAY_SIZE(musb_resources),
  129. .resource = musb_resources,
  130. };
  131. #ifdef CONFIG_NOP_USB_XCEIV
  132. static u64 nop_xceiv_dmamask = DMA_BIT_MASK(32);
  133. static struct platform_device nop_xceiv_device = {
  134. .name = "nop_usb_xceiv",
  135. .id = -1,
  136. .dev = {
  137. .dma_mask = &nop_xceiv_dmamask,
  138. .coherent_dma_mask = DMA_BIT_MASK(32),
  139. .platform_data = NULL,
  140. },
  141. };
  142. #endif
  143. void __init usb_musb_init(void)
  144. {
  145. if (cpu_is_omap243x())
  146. musb_resources[0].start = OMAP243X_HS_BASE;
  147. else
  148. musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
  149. musb_resources[0].end = musb_resources[0].start + SZ_8K - 1;
  150. /*
  151. * REVISIT: This line can be removed once all the platforms using
  152. * musb_core.c have been converted to use use clkdev.
  153. */
  154. musb_plat.clock = "ick";
  155. #ifdef CONFIG_NOP_USB_XCEIV
  156. if (platform_device_register(&nop_xceiv_device) < 0) {
  157. printk(KERN_ERR "Unable to register NOP-XCEIV device\n");
  158. return;
  159. }
  160. #endif
  161. if (platform_device_register(&musb_device) < 0) {
  162. printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
  163. return;
  164. }
  165. }