renesas_usbhs.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. int (*hardware_exit)(struct platform_device *pdev);
  61. /*
  62. * option:
  63. *
  64. * for board specific clock control
  65. */
  66. int (*power_ctrl)(struct platform_device *pdev,
  67. void __iomem *base, int enable);
  68. /*
  69. * option:
  70. *
  71. * Phy reset for platform
  72. */
  73. int (*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_pipe_config {
  98. u8 type; /* USB_ENDPOINT_XFER_xxx */
  99. u16 bufsize;
  100. u8 bufnum;
  101. bool double_buf;
  102. };
  103. #define RENESAS_USBHS_PIPE(_type, _size, _num, _double_buf) { \
  104. .type = (_type), \
  105. .bufsize = (_size), \
  106. .bufnum = (_num), \
  107. .double_buf = (_double_buf), \
  108. }
  109. struct renesas_usbhs_driver_param {
  110. /*
  111. * pipe settings
  112. */
  113. struct renesas_usbhs_driver_pipe_config *pipe_configs;
  114. int pipe_size; /* pipe_configs array size */
  115. /*
  116. * option:
  117. *
  118. * for BUSWAIT :: BWAIT
  119. * see
  120. * renesas_usbhs/common.c :: usbhsc_set_buswait()
  121. * */
  122. int buswait_bwait;
  123. /*
  124. * option:
  125. *
  126. * delay time from notify_hotplug callback
  127. */
  128. int detection_delay; /* msec */
  129. /*
  130. * option:
  131. *
  132. * dma id for dmaengine
  133. * The data transfer direction on D0FIFO/D1FIFO should be
  134. * fixed for keeping consistency.
  135. * So, the platform id settings will be..
  136. * .d0_tx_id = xx_TX,
  137. * .d1_rx_id = xx_RX,
  138. * or
  139. * .d1_tx_id = xx_TX,
  140. * .d0_rx_id = xx_RX,
  141. */
  142. int d0_tx_id;
  143. int d0_rx_id;
  144. int d1_tx_id;
  145. int d1_rx_id;
  146. int d2_tx_id;
  147. int d2_rx_id;
  148. int d3_tx_id;
  149. int d3_rx_id;
  150. /*
  151. * option:
  152. *
  153. * pio <--> dma border.
  154. */
  155. int pio_dma_border; /* default is 64byte */
  156. uintptr_t type;
  157. u32 enable_gpio;
  158. /*
  159. * option:
  160. */
  161. u32 has_otg:1; /* for controlling PWEN/EXTLP */
  162. u32 has_sudmac:1; /* for SUDMAC */
  163. u32 has_usb_dmac:1; /* for USB-DMAC */
  164. #define USBHS_USB_DMAC_XFER_SIZE 32 /* hardcode the xfer size */
  165. };
  166. #define USBHS_TYPE_RCAR_GEN2 1
  167. #define USBHS_TYPE_RCAR_GEN3 2
  168. /*
  169. * option:
  170. *
  171. * platform information for renesas_usbhs driver.
  172. */
  173. struct renesas_usbhs_platform_info {
  174. /*
  175. * option:
  176. *
  177. * platform set these functions before
  178. * call platform_add_devices if needed
  179. */
  180. struct renesas_usbhs_platform_callback platform_callback;
  181. /*
  182. * driver set these callback functions pointer.
  183. * platform can use it on callback functions
  184. */
  185. struct renesas_usbhs_driver_callback driver_callback;
  186. /*
  187. * option:
  188. *
  189. * driver use these param for some register
  190. */
  191. struct renesas_usbhs_driver_param driver_param;
  192. };
  193. /*
  194. * macro for platform
  195. */
  196. #define renesas_usbhs_get_info(pdev)\
  197. ((struct renesas_usbhs_platform_info *)(pdev)->dev.platform_data)
  198. #define renesas_usbhs_call_notify_hotplug(pdev) \
  199. ({ \
  200. struct renesas_usbhs_driver_callback *dc; \
  201. dc = &(renesas_usbhs_get_info(pdev)->driver_callback); \
  202. if (dc && dc->notify_hotplug) \
  203. dc->notify_hotplug(pdev); \
  204. })
  205. #endif /* RENESAS_USB_H */