xhci-ssusb-mtk.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (c) 2015 MediaTek Inc.
  3. * Author:
  4. * Zhigang.Wun <zhigang.wei@mediatek.com>
  5. * Chunfeng.Yun <chunfeng.yun@mediatek.com>
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #ifndef _XHCI_MTK_H_
  18. #define _XHCI_MTK_H_
  19. #include "xhci.h"
  20. /**
  21. * To simplify scheduler algorithm, set a upper limit for ESIT,
  22. * if a synchromous ep's ESIT is larger than @XHCI_MTK_MAX_ESIT,
  23. * round down to the limit value, that means allocating more
  24. * bandwidth to it.
  25. */
  26. #define MAX_EP_NUM 32
  27. struct sch_ep {
  28. int rh_port; /* root hub port number */
  29. /* device info */
  30. int speed;
  31. int is_tt;
  32. /* ep info */
  33. int is_in;
  34. int ep_type;
  35. int maxp;
  36. int interval;
  37. int burst;
  38. int mult;
  39. /* scheduling info */
  40. int offset;
  41. int repeat;
  42. int pkts;
  43. int cs_count;
  44. int burst_mode;
  45. /* other */
  46. int bw_cost; /* bandwidth cost in each repeat; including overhead */
  47. struct usb_host_endpoint *ep;
  48. struct xhci_ep_ctx *ep_ctx;
  49. };
  50. /**
  51. * struct mu3h_sch_ep_info
  52. * @esit: unit is 125us, equal to 2 << Interval field in ep-context
  53. * @num_budget_microframes: number of continuous uframes
  54. * (@repeat==1) scheduled within the interval
  55. * @ep: address of usb_host_endpoint
  56. * @offset: which uframe of the interval that transfer should be
  57. * scheduled first time within the interval
  58. * @repeat: the time gap between two uframes that transfers are
  59. * scheduled within a interval. in the simple algorithm, only
  60. * assign 0 or 1 to it; 0 means using only one uframe in a
  61. * interval, and1 means using @num_budget_microframes
  62. * continuous uframes
  63. * @pkts: number of packets to be transferred in the scheduled uframes
  64. * @cs_count: number of CS that host will trigger
  65. */
  66. struct sch_port {
  67. struct sch_ep *ss_out_eps[MAX_EP_NUM];
  68. struct sch_ep *ss_in_eps[MAX_EP_NUM];
  69. struct sch_ep *hs_eps[MAX_EP_NUM]; /* including tt isoc */
  70. struct sch_ep *tt_intr_eps[MAX_EP_NUM];
  71. /* mtk xhci scheduling info */
  72. };
  73. #if IS_ENABLED(CONFIG_SSUSB_MTK_XHCI)
  74. int xhci_mtk_init_quirk(struct xhci_hcd *xhci);
  75. void xhci_mtk_exit_quirk(struct xhci_hcd *xhci);
  76. int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
  77. struct usb_host_endpoint *ep);
  78. int xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
  79. struct usb_host_endpoint *ep);
  80. u32 xhci_mtk_td_remainder_quirk(unsigned int td_running_total,
  81. unsigned trb_buffer_length, struct urb *urb);
  82. #else
  83. static inline int xhci_mtk_init_quirk(struct xhci_hcd *xhci)
  84. {
  85. return 0;
  86. }
  87. static inline void xhci_mtk_exit_quirk(struct xhci_hcd *xhci)
  88. {
  89. }
  90. static inline int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd,
  91. struct usb_device *udev, struct usb_host_endpoint *ep)
  92. {
  93. return 0;
  94. }
  95. static inline int xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd,
  96. struct usb_device *udev, struct usb_host_endpoint *ep)
  97. {
  98. return 0;
  99. }
  100. u32 xhci_mtk_td_remainder_quirk(unsigned int td_running_total,
  101. unsigned trb_buffer_length, struct urb *urb)
  102. {
  103. return 0;
  104. }
  105. #endif
  106. #endif /* _XHCI_MTK_H_ */