renesas_usbhs.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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_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. * The data transfer direction on D0FIFO/D1FIFO should be
  122. * fixed for keeping consistency.
  123. * So, the platform id settings will be..
  124. * .d0_tx_id = xx_TX,
  125. * .d1_rx_id = xx_RX,
  126. * or
  127. * .d1_tx_id = xx_TX,
  128. * .d0_rx_id = xx_RX,
  129. */
  130. int d0_tx_id;
  131. int d0_rx_id;
  132. int d1_tx_id;
  133. int d1_rx_id;
  134. int d2_tx_id;
  135. int d2_rx_id;
  136. int d3_tx_id;
  137. int d3_rx_id;
  138. /*
  139. * option:
  140. *
  141. * pio <--> dma border.
  142. */
  143. int pio_dma_border; /* default is 64byte */
  144. uintptr_t type;
  145. u32 enable_gpio;
  146. /*
  147. * option:
  148. */
  149. u32 has_otg:1; /* for controlling PWEN/EXTLP */
  150. u32 has_sudmac:1; /* for SUDMAC */
  151. u32 has_usb_dmac:1; /* for USB-DMAC */
  152. #define USBHS_USB_DMAC_XFER_SIZE 32 /* hardcode the xfer size */
  153. };
  154. #define USBHS_TYPE_RCAR_GEN2 1
  155. /*
  156. * option:
  157. *
  158. * platform information for renesas_usbhs driver.
  159. */
  160. struct renesas_usbhs_platform_info {
  161. /*
  162. * option:
  163. *
  164. * platform set these functions before
  165. * call platform_add_devices if needed
  166. */
  167. struct renesas_usbhs_platform_callback platform_callback;
  168. /*
  169. * driver set these callback functions pointer.
  170. * platform can use it on callback functions
  171. */
  172. struct renesas_usbhs_driver_callback driver_callback;
  173. /*
  174. * option:
  175. *
  176. * driver use these param for some register
  177. */
  178. struct renesas_usbhs_driver_param driver_param;
  179. };
  180. /*
  181. * macro for platform
  182. */
  183. #define renesas_usbhs_get_info(pdev)\
  184. ((struct renesas_usbhs_platform_info *)(pdev)->dev.platform_data)
  185. #define renesas_usbhs_call_notify_hotplug(pdev) \
  186. ({ \
  187. struct renesas_usbhs_driver_callback *dc; \
  188. dc = &(renesas_usbhs_get_info(pdev)->driver_callback); \
  189. if (dc && dc->notify_hotplug) \
  190. dc->notify_hotplug(pdev); \
  191. })
  192. #endif /* RENESAS_USB_H */