renesas_usbhs.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. // SPDX-License-Identifier: GPL-1.0+
  2. /*
  3. * Renesas USB
  4. *
  5. * Copyright (C) 2011 Renesas Solutions Corp.
  6. * Copyright (C) 2019 Renesas Electronics Corporation
  7. * Kuninori Morimoto <[email protected]>
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. *
  18. */
  19. #ifndef RENESAS_USB_H
  20. #define RENESAS_USB_H
  21. #include <linux/notifier.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/usb/ch9.h>
  24. /*
  25. * module type
  26. *
  27. * it will be return value from get_id
  28. */
  29. enum {
  30. USBHS_HOST = 0,
  31. USBHS_GADGET,
  32. USBHS_MAX,
  33. };
  34. /*
  35. * callback functions for platform
  36. *
  37. * These functions are called from driver for platform
  38. */
  39. struct renesas_usbhs_platform_callback {
  40. /*
  41. * option:
  42. *
  43. * Hardware init function for platform.
  44. * it is called when driver was probed.
  45. */
  46. int (*hardware_init)(struct platform_device *pdev);
  47. /*
  48. * option:
  49. *
  50. * Hardware exit function for platform.
  51. * it is called when driver was removed
  52. */
  53. int (*hardware_exit)(struct platform_device *pdev);
  54. /*
  55. * option:
  56. *
  57. * for board specific clock control
  58. */
  59. int (*power_ctrl)(struct platform_device *pdev,
  60. void __iomem *base, int enable);
  61. /*
  62. * option:
  63. *
  64. * Phy reset for platform
  65. */
  66. int (*phy_reset)(struct platform_device *pdev);
  67. /*
  68. * get USB ID function
  69. * - USBHS_HOST
  70. * - USBHS_GADGET
  71. */
  72. int (*get_id)(struct platform_device *pdev);
  73. /*
  74. * get VBUS status function.
  75. */
  76. int (*get_vbus)(struct platform_device *pdev);
  77. /*
  78. * option:
  79. *
  80. * VBUS control is needed for Host
  81. */
  82. int (*set_vbus)(struct platform_device *pdev, int enable);
  83. /*
  84. * option:
  85. * extcon notifier to set host/peripheral mode.
  86. */
  87. int (*notifier)(struct notifier_block *nb, unsigned long event,
  88. void *data);
  89. };
  90. /*
  91. * parameters for renesas usbhs
  92. *
  93. * some register needs USB chip specific parameters.
  94. * This struct show it to driver
  95. */
  96. struct renesas_usbhs_driver_pipe_config {
  97. u8 type; /* USB_ENDPOINT_XFER_xxx */
  98. u16 bufsize;
  99. u8 bufnum;
  100. bool double_buf;
  101. };
  102. #define RENESAS_USBHS_PIPE(_type, _size, _num, _double_buf) { \
  103. .type = (_type), \
  104. .bufsize = (_size), \
  105. .bufnum = (_num), \
  106. .double_buf = (_double_buf), \
  107. }
  108. struct renesas_usbhs_driver_param {
  109. /*
  110. * pipe settings
  111. */
  112. struct renesas_usbhs_driver_pipe_config *pipe_configs;
  113. int pipe_size; /* pipe_configs array size */
  114. /*
  115. * option:
  116. *
  117. * for BUSWAIT :: BWAIT
  118. * see
  119. * renesas_usbhs/common.c :: usbhsc_set_buswait()
  120. * */
  121. int buswait_bwait;
  122. /*
  123. * option:
  124. *
  125. * delay time from notify_hotplug callback
  126. */
  127. int detection_delay; /* msec */
  128. /*
  129. * option:
  130. *
  131. * dma id for dmaengine
  132. * The data transfer direction on D0FIFO/D1FIFO should be
  133. * fixed for keeping consistency.
  134. * So, the platform id settings will be..
  135. * .d0_tx_id = xx_TX,
  136. * .d1_rx_id = xx_RX,
  137. * or
  138. * .d1_tx_id = xx_TX,
  139. * .d0_rx_id = xx_RX,
  140. */
  141. int d0_tx_id;
  142. int d0_rx_id;
  143. int d1_tx_id;
  144. int d1_rx_id;
  145. int d2_tx_id;
  146. int d2_rx_id;
  147. int d3_tx_id;
  148. int d3_rx_id;
  149. /*
  150. * option:
  151. *
  152. * pio <--> dma border.
  153. */
  154. int pio_dma_border; /* default is 64byte */
  155. /*
  156. * option:
  157. */
  158. u32 has_usb_dmac:1; /* for USB-DMAC */
  159. u32 runtime_pwctrl:1;
  160. u32 has_cnen:1;
  161. u32 cfifo_byte_addr:1; /* CFIFO is byte addressable */
  162. #define USBHS_USB_DMAC_XFER_SIZE 32 /* hardcode the xfer size */
  163. u32 multi_clks:1;
  164. u32 has_new_pipe_configs:1;
  165. };
  166. /*
  167. * option:
  168. *
  169. * platform information for renesas_usbhs driver.
  170. */
  171. struct renesas_usbhs_platform_info {
  172. /*
  173. * option:
  174. *
  175. * platform set these functions before
  176. * call platform_add_devices if needed
  177. */
  178. struct renesas_usbhs_platform_callback platform_callback;
  179. /*
  180. * option:
  181. *
  182. * driver use these param for some register
  183. */
  184. struct renesas_usbhs_driver_param driver_param;
  185. };
  186. /*
  187. * macro for platform
  188. */
  189. #define renesas_usbhs_get_info(pdev)\
  190. ((struct renesas_usbhs_platform_info *)(pdev)->dev.platform_data)
  191. #endif /* RENESAS_USB_H */