renesas_usbhs.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. * Renesas USB
  3. *
  4. * Copyright (C) 2011 Renesas Solutions Corp.
  5. * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. *
  16. */
  17. #ifndef RENESAS_USB_H
  18. #define RENESAS_USB_H
  19. #include <linux/platform_device.h>
  20. #include <linux/usb/ch9.h>
  21. /*
  22. * module type
  23. *
  24. * it will be return value from get_id
  25. */
  26. enum {
  27. USBHS_HOST = 0,
  28. USBHS_GADGET,
  29. USBHS_MAX,
  30. };
  31. /*
  32. * callback functions table for driver
  33. *
  34. * These functions are called from platform for driver.
  35. * Callback function's pointer will be set before
  36. * renesas_usbhs_platform_callback :: hardware_init was called
  37. */
  38. struct renesas_usbhs_driver_callback {
  39. int (*notify_hotplug)(struct platform_device *pdev);
  40. };
  41. /*
  42. * callback functions for platform
  43. *
  44. * These functions are called from driver for platform
  45. */
  46. struct renesas_usbhs_platform_callback {
  47. /*
  48. * option:
  49. *
  50. * Hardware init function for platform.
  51. * it is called when driver was probed.
  52. */
  53. int (*hardware_init)(struct platform_device *pdev);
  54. /*
  55. * option:
  56. *
  57. * Hardware exit function for platform.
  58. * it is called when driver was removed
  59. */
  60. void (*hardware_exit)(struct platform_device *pdev);
  61. /*
  62. * option:
  63. *
  64. * for board specific clock control
  65. */
  66. void (*power_ctrl)(struct platform_device *pdev,
  67. void __iomem *base, int enable);
  68. /*
  69. * option:
  70. *
  71. * Phy reset for platform
  72. */
  73. void (*phy_reset)(struct platform_device *pdev);
  74. /*
  75. * get USB ID function
  76. * - USBHS_HOST
  77. * - USBHS_GADGET
  78. */
  79. int (*get_id)(struct platform_device *pdev);
  80. /*
  81. * get VBUS status function.
  82. */
  83. int (*get_vbus)(struct platform_device *pdev);
  84. /*
  85. * option:
  86. *
  87. * VBUS control is needed for Host
  88. */
  89. int (*set_vbus)(struct platform_device *pdev, int enable);
  90. };
  91. /*
  92. * parameters for renesas usbhs
  93. *
  94. * some register needs USB chip specific parameters.
  95. * This struct show it to driver
  96. */
  97. struct renesas_usbhs_driver_param {
  98. /*
  99. * pipe settings
  100. */
  101. u32 *pipe_type; /* array of USB_ENDPOINT_XFER_xxx (from ep0) */
  102. int pipe_size; /* pipe_type array size */
  103. /*
  104. * option:
  105. *
  106. * for BUSWAIT :: BWAIT
  107. * see
  108. * renesas_usbhs/common.c :: usbhsc_set_buswait()
  109. * */
  110. int buswait_bwait;
  111. /*
  112. * option:
  113. *
  114. * delay time from notify_hotplug callback
  115. */
  116. int detection_delay; /* msec */
  117. /*
  118. * option:
  119. *
  120. * dma id for dmaengine
  121. */
  122. int d0_tx_id;
  123. int d0_rx_id;
  124. int d1_tx_id;
  125. int d1_rx_id;
  126. /*
  127. * option:
  128. *
  129. * pio <--> dma border.
  130. */
  131. int pio_dma_border; /* default is 64byte */
  132. /*
  133. * option:
  134. */
  135. u32 has_otg:1; /* for controlling PWEN/EXTLP */
  136. u32 has_sudmac:1; /* for SUDMAC */
  137. };
  138. /*
  139. * option:
  140. *
  141. * platform information for renesas_usbhs driver.
  142. */
  143. struct renesas_usbhs_platform_info {
  144. /*
  145. * option:
  146. *
  147. * platform set these functions before
  148. * call platform_add_devices if needed
  149. */
  150. struct renesas_usbhs_platform_callback platform_callback;
  151. /*
  152. * driver set these callback functions pointer.
  153. * platform can use it on callback functions
  154. */
  155. struct renesas_usbhs_driver_callback driver_callback;
  156. /*
  157. * option:
  158. *
  159. * driver use these param for some register
  160. */
  161. struct renesas_usbhs_driver_param driver_param;
  162. };
  163. /*
  164. * macro for platform
  165. */
  166. #define renesas_usbhs_get_info(pdev)\
  167. ((struct renesas_usbhs_platform_info *)(pdev)->dev.platform_data)
  168. #define renesas_usbhs_call_notify_hotplug(pdev) \
  169. ({ \
  170. struct renesas_usbhs_driver_callback *dc; \
  171. dc = &(renesas_usbhs_get_info(pdev)->driver_callback); \
  172. if (dc && dc->notify_hotplug) \
  173. dc->notify_hotplug(pdev); \
  174. })
  175. #endif /* RENESAS_USB_H */