From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Felipe Balbi <balbi@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
linux-usb@vger.kernel.org, Peter Chen <peter.chen@nxp.com>,
Lee Jones <lee.jones@linaro.org>,
Alan Stern <stern@rowland.harvard.edu>,
Dejin Zheng <zhengdejin5@gmail.com>,
Roger Quadros <rogerq@ti.com>
Cc: John Youn <John.Youn@synopsys.com>
Subject: [PATCH v4 04/12] usb: gadget: Set max speed for SSP devices
Date: Sat, 25 Jul 2020 18:36:18 -0700 [thread overview]
Message-ID: <ca08434f44e6649aa3e3fe93e3aa7f3488cd0fb3.1595727196.git.thinhn@synopsys.com> (raw)
In-Reply-To: <cover.1595727196.git.thinhn@synopsys.com>
A super-speed-plus device may operate at different sublink speeds (e.g.
gen2x2, gen1x2, or gen2x1). If the USB device supports different sublink
speeds at super-speed-plus, set the device to operate at the maximum
number of lanes and sublink speed possible. Introduce gadget ops
udc_set_num_lanes_and_speed to set the lane count and sublink speed for
super-speed-plus capable devices.
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
Changes in v4:
- Add identifier name for usb_gadget in gadget ops
(*udc_set_num_lanes_and_speed) to avoid checkpatch warning
Changes in v3:
- None
Changes in v2:
- None
drivers/usb/gadget/udc/core.c | 24 +++++++++++++++++++-----
include/linux/usb/gadget.h | 3 +++
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 4f82bcd31fd3..e5f569dc9ee0 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -1114,12 +1114,26 @@ static inline void usb_gadget_udc_stop(struct usb_udc *udc)
static inline void usb_gadget_udc_set_speed(struct usb_udc *udc,
enum usb_device_speed speed)
{
- if (udc->gadget->ops->udc_set_speed) {
- enum usb_device_speed s;
+ struct usb_gadget *gadget = udc->gadget;
+ enum usb_device_speed s;
- s = min(speed, udc->gadget->max_speed);
- udc->gadget->ops->udc_set_speed(udc->gadget, s);
- }
+ if (speed == USB_SPEED_UNKNOWN)
+ s = gadget->max_speed;
+ else
+ s = min(speed, gadget->max_speed);
+
+ /*
+ * If the UDC supports super-speed-plus and different sublink speeds,
+ * then set the gadget to the max possible sublink speed for
+ * super-speed-plus symmetric lanes.
+ */
+ if (s == USB_SPEED_SUPER_PLUS &&
+ gadget->ops->udc_set_num_lanes_and_speed)
+ gadget->ops->udc_set_num_lanes_and_speed(gadget,
+ gadget->max_num_lanes,
+ gadget->max_speed_ssid);
+ else if (gadget->ops->udc_set_speed)
+ gadget->ops->udc_set_speed(gadget, s);
}
/**
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index d25aefaacba0..3bbd8d7a80ad 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -323,6 +323,9 @@ struct usb_gadget_ops {
struct usb_gadget_driver *);
int (*udc_stop)(struct usb_gadget *);
void (*udc_set_speed)(struct usb_gadget *, enum usb_device_speed);
+ void (*udc_set_num_lanes_and_speed)(struct usb_gadget *gadget,
+ unsigned int num_lanes,
+ unsigned int ssid);
struct usb_ep *(*match_ep)(struct usb_gadget *,
struct usb_endpoint_descriptor *,
struct usb_ss_ep_comp_descriptor *);
--
2.11.0
next prev parent reply other threads:[~2020-07-26 1:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-26 1:35 [PATCH v4 00/12] usb: Handle different sublink speeds Thinh Nguyen
2020-07-26 1:35 ` [PATCH v4 01/12] usb: ch9: Add sublink speed struct Thinh Nguyen
2020-07-26 1:36 ` [PATCH v4 02/12] usb: gadget: composite: Avoid using magic numbers Thinh Nguyen
2020-07-26 1:36 ` [PATCH v4 03/12] usb: gadget: Expose sublink speed attributes Thinh Nguyen
2020-07-26 1:36 ` Thinh Nguyen [this message]
2020-07-26 1:36 ` [PATCH v4 05/12] usb: composite: Properly report sublink speed Thinh Nguyen
2020-07-26 1:36 ` [PATCH v4 06/12] usb: devicetree: Include USB SSP Gen X x Y Thinh Nguyen
2020-07-31 20:21 ` Rob Herring
2020-08-01 2:36 ` Thinh Nguyen
2020-07-26 1:36 ` [PATCH v4 07/12] usb: common: Add and update common functions for SSP speeds Thinh Nguyen
2020-07-26 1:36 ` [PATCH v4 08/12] usb: dwc3: Initialize lane count and sublink speed Thinh Nguyen
2020-07-26 1:36 ` [PATCH v4 09/12] usb: dwc3: gadget: Report sublink speed capability Thinh Nguyen
2020-07-26 1:36 ` [PATCH v4 10/12] usb: dwc3: gadget: Implement setting of sublink speed Thinh Nguyen
2020-07-26 1:37 ` [PATCH v4 11/12] usb: dwc3: gadget: Track connected lane and " Thinh Nguyen
2020-07-26 1:37 ` [PATCH v4 12/12] usb: dwc3: gadget: Set speed only up to the max supported Thinh Nguyen
2020-09-05 0:53 ` [PATCH v4 00/12] usb: Handle different sublink speeds Thinh Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ca08434f44e6649aa3e3fe93e3aa7f3488cd0fb3.1595727196.git.thinhn@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=John.Youn@synopsys.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=lee.jones@linaro.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter.chen@nxp.com \
--cc=rogerq@ti.com \
--cc=stern@rowland.harvard.edu \
--cc=zhengdejin5@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).