renesas_usbhs.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. * Phy reset for platform
  65. */
  66. void (*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. /*
  79. * parameters for renesas usbhs
  80. *
  81. * some register needs USB chip specific parameters.
  82. * This struct show it to driver
  83. */
  84. struct renesas_usbhs_driver_param {
  85. /*
  86. * pipe settings
  87. */
  88. u32 *pipe_type; /* array of USB_ENDPOINT_XFER_xxx (from ep0) */
  89. int pipe_size; /* pipe_type array size */
  90. /*
  91. * option:
  92. *
  93. * for BUSWAIT :: BWAIT
  94. * */
  95. int buswait_bwait;
  96. /*
  97. * option:
  98. *
  99. * delay time from notify_hotplug callback
  100. */
  101. int detection_delay;
  102. /*
  103. * option:
  104. *
  105. * dma id for dmaengine
  106. */
  107. int d0_tx_id;
  108. int d0_rx_id;
  109. int d1_tx_id;
  110. int d1_rx_id;
  111. /*
  112. * option:
  113. *
  114. * pio <--> dma border.
  115. */
  116. int pio_dma_border; /* default is 64byte */
  117. };
  118. /*
  119. * option:
  120. *
  121. * platform information for renesas_usbhs driver.
  122. */
  123. struct renesas_usbhs_platform_info {
  124. /*
  125. * option:
  126. *
  127. * platform set these functions before
  128. * call platform_add_devices if needed
  129. */
  130. struct renesas_usbhs_platform_callback platform_callback;
  131. /*
  132. * driver set these callback functions pointer.
  133. * platform can use it on callback functions
  134. */
  135. struct renesas_usbhs_driver_callback driver_callback;
  136. /*
  137. * option:
  138. *
  139. * driver use these param for some register
  140. */
  141. struct renesas_usbhs_driver_param driver_param;
  142. };
  143. /*
  144. * macro for platform
  145. */
  146. #define renesas_usbhs_get_info(pdev)\
  147. ((struct renesas_usbhs_platform_info *)(pdev)->dev.platform_data)
  148. #define renesas_usbhs_call_notify_hotplug(pdev) \
  149. ({ \
  150. struct renesas_usbhs_driver_callback *dc; \
  151. dc = &(renesas_usbhs_get_info(pdev)->driver_callback); \
  152. if (dc && dc->notify_hotplug) \
  153. dc->notify_hotplug(pdev); \
  154. })
  155. #endif /* RENESAS_USB_H */