0109-usb-mtu3-add-support-for-usb3.1-IP.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. From 8f444887e23b9f0ea31aaae74fbc18171714d8d2 Mon Sep 17 00:00:00 2001
  2. From: Chunfeng Yun <[email protected]>
  3. Date: Fri, 13 Oct 2017 17:10:43 +0800
  4. Subject: [PATCH 109/224] usb: mtu3: add support for usb3.1 IP
  5. Support SuperSpeedPlus for usb3.1 device IP
  6. Signed-off-by: Chunfeng Yun <[email protected]>
  7. Signed-off-by: Felipe Balbi <[email protected]>
  8. ---
  9. drivers/usb/mtu3/mtu3.h | 1 +
  10. drivers/usb/mtu3/mtu3_core.c | 14 +++++++++++---
  11. drivers/usb/mtu3/mtu3_gadget.c | 3 ++-
  12. drivers/usb/mtu3/mtu3_gadget_ep0.c | 16 ++++++++--------
  13. drivers/usb/mtu3/mtu3_hw_regs.h | 1 +
  14. 5 files changed, 23 insertions(+), 12 deletions(-)
  15. --- a/drivers/usb/mtu3/mtu3.h
  16. +++ b/drivers/usb/mtu3/mtu3.h
  17. @@ -94,6 +94,7 @@ enum mtu3_speed {
  18. MTU3_SPEED_FULL = 1,
  19. MTU3_SPEED_HIGH = 3,
  20. MTU3_SPEED_SUPER = 4,
  21. + MTU3_SPEED_SUPER_PLUS = 5,
  22. };
  23. /**
  24. --- a/drivers/usb/mtu3/mtu3_core.c
  25. +++ b/drivers/usb/mtu3/mtu3_core.c
  26. @@ -237,7 +237,7 @@ void mtu3_ep_stall_set(struct mtu3_ep *m
  27. void mtu3_dev_on_off(struct mtu3 *mtu, int is_on)
  28. {
  29. - if (mtu->is_u3_ip && (mtu->max_speed == USB_SPEED_SUPER))
  30. + if (mtu->is_u3_ip && mtu->max_speed >= USB_SPEED_SUPER)
  31. mtu3_ss_func_set(mtu, is_on);
  32. else
  33. mtu3_hs_softconn_set(mtu, is_on);
  34. @@ -547,6 +547,9 @@ static void mtu3_set_speed(struct mtu3 *
  35. mtu3_clrbits(mbase, U3D_USB3_CONFIG, USB3_EN);
  36. /* HS/FS detected by HW */
  37. mtu3_setbits(mbase, U3D_POWER_MANAGEMENT, HS_ENABLE);
  38. + } else if (mtu->max_speed == USB_SPEED_SUPER) {
  39. + mtu3_clrbits(mtu->ippc_base, SSUSB_U3_CTRL(0),
  40. + SSUSB_U3_PORT_SSP_SPEED);
  41. }
  42. dev_info(mtu->dev, "max_speed: %s\n",
  43. @@ -624,6 +627,10 @@ static irqreturn_t mtu3_link_isr(struct
  44. udev_speed = USB_SPEED_SUPER;
  45. maxpkt = 512;
  46. break;
  47. + case MTU3_SPEED_SUPER_PLUS:
  48. + udev_speed = USB_SPEED_SUPER_PLUS;
  49. + maxpkt = 512;
  50. + break;
  51. default:
  52. udev_speed = USB_SPEED_UNKNOWN;
  53. break;
  54. @@ -825,14 +832,15 @@ int ssusb_gadget_init(struct ssusb_mtk *
  55. case USB_SPEED_FULL:
  56. case USB_SPEED_HIGH:
  57. case USB_SPEED_SUPER:
  58. + case USB_SPEED_SUPER_PLUS:
  59. break;
  60. default:
  61. dev_err(dev, "invalid max_speed: %s\n",
  62. usb_speed_string(mtu->max_speed));
  63. /* fall through */
  64. case USB_SPEED_UNKNOWN:
  65. - /* default as SS */
  66. - mtu->max_speed = USB_SPEED_SUPER;
  67. + /* default as SSP */
  68. + mtu->max_speed = USB_SPEED_SUPER_PLUS;
  69. break;
  70. }
  71. --- a/drivers/usb/mtu3/mtu3_gadget.c
  72. +++ b/drivers/usb/mtu3/mtu3_gadget.c
  73. @@ -89,6 +89,7 @@ static int mtu3_ep_enable(struct mtu3_ep
  74. switch (mtu->g.speed) {
  75. case USB_SPEED_SUPER:
  76. + case USB_SPEED_SUPER_PLUS:
  77. if (usb_endpoint_xfer_int(desc) ||
  78. usb_endpoint_xfer_isoc(desc)) {
  79. interval = desc->bInterval;
  80. @@ -456,7 +457,7 @@ static int mtu3_gadget_wakeup(struct usb
  81. return -EOPNOTSUPP;
  82. spin_lock_irqsave(&mtu->lock, flags);
  83. - if (mtu->g.speed == USB_SPEED_SUPER) {
  84. + if (mtu->g.speed >= USB_SPEED_SUPER) {
  85. mtu3_setbits(mtu->mac_base, U3D_LINK_POWER_CONTROL, UX_EXIT);
  86. } else {
  87. mtu3_setbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME);
  88. --- a/drivers/usb/mtu3/mtu3_gadget_ep0.c
  89. +++ b/drivers/usb/mtu3/mtu3_gadget_ep0.c
  90. @@ -212,8 +212,8 @@ ep0_get_status(struct mtu3 *mtu, const s
  91. case USB_RECIP_DEVICE:
  92. result[0] = mtu->is_self_powered << USB_DEVICE_SELF_POWERED;
  93. result[0] |= mtu->may_wakeup << USB_DEVICE_REMOTE_WAKEUP;
  94. - /* superspeed only */
  95. - if (mtu->g.speed == USB_SPEED_SUPER) {
  96. +
  97. + if (mtu->g.speed >= USB_SPEED_SUPER) {
  98. result[0] |= mtu->u1_enable << USB_DEV_STAT_U1_ENABLED;
  99. result[0] |= mtu->u2_enable << USB_DEV_STAT_U2_ENABLED;
  100. }
  101. @@ -329,8 +329,8 @@ static int ep0_handle_feature_dev(struct
  102. handled = handle_test_mode(mtu, setup);
  103. break;
  104. case USB_DEVICE_U1_ENABLE:
  105. - if (mtu->g.speed != USB_SPEED_SUPER ||
  106. - mtu->g.state != USB_STATE_CONFIGURED)
  107. + if (mtu->g.speed < USB_SPEED_SUPER ||
  108. + mtu->g.state != USB_STATE_CONFIGURED)
  109. break;
  110. lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL);
  111. @@ -344,8 +344,8 @@ static int ep0_handle_feature_dev(struct
  112. handled = 1;
  113. break;
  114. case USB_DEVICE_U2_ENABLE:
  115. - if (mtu->g.speed != USB_SPEED_SUPER ||
  116. - mtu->g.state != USB_STATE_CONFIGURED)
  117. + if (mtu->g.speed < USB_SPEED_SUPER ||
  118. + mtu->g.state != USB_STATE_CONFIGURED)
  119. break;
  120. lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL);
  121. @@ -384,8 +384,8 @@ static int ep0_handle_feature(struct mtu
  122. break;
  123. case USB_RECIP_INTERFACE:
  124. /* superspeed only */
  125. - if ((value == USB_INTRF_FUNC_SUSPEND)
  126. - && (mtu->g.speed == USB_SPEED_SUPER)) {
  127. + if (value == USB_INTRF_FUNC_SUSPEND &&
  128. + mtu->g.speed >= USB_SPEED_SUPER) {
  129. /*
  130. * forward the request because function drivers
  131. * should handle it
  132. --- a/drivers/usb/mtu3/mtu3_hw_regs.h
  133. +++ b/drivers/usb/mtu3/mtu3_hw_regs.h
  134. @@ -467,6 +467,7 @@
  135. #define SSUSB_VBUS_CHG_INT_B_EN BIT(6)
  136. /* U3D_SSUSB_U3_CTRL_0P */
  137. +#define SSUSB_U3_PORT_SSP_SPEED BIT(9)
  138. #define SSUSB_U3_PORT_HOST_SEL BIT(2)
  139. #define SSUSB_U3_PORT_PDN BIT(1)
  140. #define SSUSB_U3_PORT_DIS BIT(0)