mtu3_dr.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * mtu3_dr.h - dual role switch and host glue layer header
  4. *
  5. * Copyright (C) 2016 MediaTek Inc.
  6. *
  7. * Author: Chunfeng Yun <[email protected]>
  8. */
  9. #ifndef _MTU3_DR_H_
  10. #define _MTU3_DR_H_
  11. #if IS_ENABLED(CONFIG_USB_MTU3_HOST) || IS_ENABLED(CONFIG_USB_MTU3_DUAL_ROLE)
  12. int ssusb_host_init(struct ssusb_mtk *ssusb, struct device_node *parent_dn);
  13. void ssusb_host_exit(struct ssusb_mtk *ssusb);
  14. int ssusb_wakeup_of_property_parse(struct ssusb_mtk *ssusb,
  15. struct device_node *dn);
  16. int ssusb_host_resume(struct ssusb_mtk *ssusb, bool p0_skipped);
  17. int ssusb_host_suspend(struct ssusb_mtk *ssusb);
  18. void ssusb_wakeup_set(struct ssusb_mtk *ssusb, bool enable);
  19. #else
  20. static inline int ssusb_host_init(struct ssusb_mtk *ssusb,
  21. struct device_node *parent_dn)
  22. {
  23. return 0;
  24. }
  25. static inline void ssusb_host_exit(struct ssusb_mtk *ssusb)
  26. {}
  27. static inline int ssusb_wakeup_of_property_parse(
  28. struct ssusb_mtk *ssusb, struct device_node *dn)
  29. {
  30. return 0;
  31. }
  32. static inline int ssusb_host_resume(struct ssusb_mtk *ssusb, bool p0_skipped)
  33. {
  34. return 0;
  35. }
  36. static inline int ssusb_host_suspend(struct ssusb_mtk *ssusb)
  37. {
  38. return 0;
  39. }
  40. static inline void ssusb_wakeup_set(struct ssusb_mtk *ssusb, bool enable)
  41. {}
  42. #endif
  43. #if IS_ENABLED(CONFIG_USB_MTU3_GADGET) || IS_ENABLED(CONFIG_USB_MTU3_DUAL_ROLE)
  44. int ssusb_gadget_init(struct ssusb_mtk *ssusb);
  45. void ssusb_gadget_exit(struct ssusb_mtk *ssusb);
  46. int ssusb_gadget_suspend(struct ssusb_mtk *ssusb, pm_message_t msg);
  47. int ssusb_gadget_resume(struct ssusb_mtk *ssusb, pm_message_t msg);
  48. bool ssusb_gadget_ip_sleep_check(struct ssusb_mtk *ssusb);
  49. #else
  50. static inline int ssusb_gadget_init(struct ssusb_mtk *ssusb)
  51. {
  52. return 0;
  53. }
  54. static inline void ssusb_gadget_exit(struct ssusb_mtk *ssusb)
  55. {}
  56. static inline int
  57. ssusb_gadget_suspend(struct ssusb_mtk *ssusb, pm_message_t msg)
  58. {
  59. return 0;
  60. }
  61. static inline int
  62. ssusb_gadget_resume(struct ssusb_mtk *ssusb, pm_message_t msg)
  63. {
  64. return 0;
  65. }
  66. static inline bool ssusb_gadget_ip_sleep_check(struct ssusb_mtk *ssusb)
  67. {
  68. return true;
  69. }
  70. #endif
  71. #if IS_ENABLED(CONFIG_USB_MTU3_DUAL_ROLE)
  72. int ssusb_otg_switch_init(struct ssusb_mtk *ssusb);
  73. void ssusb_otg_switch_exit(struct ssusb_mtk *ssusb);
  74. void ssusb_mode_switch(struct ssusb_mtk *ssusb, int to_host);
  75. int ssusb_set_vbus(struct otg_switch_mtk *otg_sx, int is_on);
  76. void ssusb_set_force_mode(struct ssusb_mtk *ssusb,
  77. enum mtu3_dr_force_mode mode);
  78. #else
  79. static inline int ssusb_otg_switch_init(struct ssusb_mtk *ssusb)
  80. {
  81. return 0;
  82. }
  83. static inline void ssusb_otg_switch_exit(struct ssusb_mtk *ssusb)
  84. {}
  85. static inline void ssusb_mode_switch(struct ssusb_mtk *ssusb, int to_host)
  86. {}
  87. static inline int ssusb_set_vbus(struct otg_switch_mtk *otg_sx, int is_on)
  88. {
  89. return 0;
  90. }
  91. static inline void
  92. ssusb_set_force_mode(struct ssusb_mtk *ssusb, enum mtu3_dr_force_mode mode)
  93. {}
  94. #endif
  95. #endif /* _MTU3_DR_H_ */