Skip to content

Commit

Permalink
usb: dwc3: core: Check maximum_speed SSP genXxY
Browse files Browse the repository at this point in the history
The DWC_usb32 controller supports dual-lane SuperSpeed Plus. Check the
maximum_speed property for any limitation in the HW to initialize and
validate the maximum number of lanes and speed the device will operate.

Currently the controller has no visibility into the HW parameter to
determine the maximum number of lanes the HW supports. If the number of
lanes is not specified for SSP, then set the default rate to gen2x2 for
DWC_usb32 and gen2x1 for DWC_usb31.

Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/08d43f2a99198bed84895c272340449a6d03710e.1611106162.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Thinh Nguyen authored and Greg Kroah-Hartman committed Feb 6, 2021
1 parent 52c2d15 commit 6784814
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
37 changes: 37 additions & 0 deletions drivers/usb/dwc3/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,7 @@ static void dwc3_get_properties(struct dwc3 *dwc)
hird_threshold = 12;

dwc->maximum_speed = usb_get_maximum_speed(dev);
dwc->max_ssp_rate = usb_get_maximum_ssp_rate(dev);
dwc->dr_mode = usb_get_dr_mode(dev);
dwc->hsphy_mode = of_usb_get_phy_mode(dev->of_node);

Expand Down Expand Up @@ -1423,6 +1424,42 @@ static void dwc3_check_params(struct dwc3 *dwc)
}
break;
}

/*
* Currently the controller does not have visibility into the HW
* parameter to determine the maximum number of lanes the HW supports.
* If the number of lanes is not specified in the device property, then
* set the default to support dual-lane for DWC_usb32 and single-lane
* for DWC_usb31 for super-speed-plus.
*/
if (dwc->maximum_speed == USB_SPEED_SUPER_PLUS) {
switch (dwc->max_ssp_rate) {
case USB_SSP_GEN_2x1:
if (hwparam_gen == DWC3_GHWPARAMS3_SSPHY_IFC_GEN1)
dev_warn(dev, "UDC only supports Gen 1\n");
break;
case USB_SSP_GEN_1x2:
case USB_SSP_GEN_2x2:
if (DWC3_IP_IS(DWC31))
dev_warn(dev, "UDC only supports single lane\n");
break;
case USB_SSP_GEN_UNKNOWN:
default:
switch (hwparam_gen) {
case DWC3_GHWPARAMS3_SSPHY_IFC_GEN2:
if (DWC3_IP_IS(DWC32))
dwc->max_ssp_rate = USB_SSP_GEN_2x2;
else
dwc->max_ssp_rate = USB_SSP_GEN_2x1;
break;
case DWC3_GHWPARAMS3_SSPHY_IFC_GEN1:
if (DWC3_IP_IS(DWC32))
dwc->max_ssp_rate = USB_SSP_GEN_1x2;
break;
}
break;
}
}
}

static int dwc3_probe(struct platform_device *pdev)
Expand Down
2 changes: 2 additions & 0 deletions drivers/usb/dwc3/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,7 @@ struct dwc3_scratchpad_array {
* @nr_scratch: number of scratch buffers
* @u1u2: only used on revisions <1.83a for workaround
* @maximum_speed: maximum speed requested (mainly for testing purposes)
* @max_ssp_rate: SuperSpeed Plus maximum signaling rate and lane count
* @gadget_max_speed: maximum gadget speed requested
* @ip: controller's ID
* @revision: controller's version of an IP
Expand Down Expand Up @@ -1128,6 +1129,7 @@ struct dwc3 {
u32 u1u2;
u32 maximum_speed;
u32 gadget_max_speed;
enum usb_ssp_rate max_ssp_rate;

u32 ip;

Expand Down
1 change: 1 addition & 0 deletions drivers/usb/dwc3/gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -3888,6 +3888,7 @@ int dwc3_gadget_init(struct dwc3 *dwc)
dwc->revision);

dwc->gadget->max_speed = dwc->maximum_speed;
dwc->gadget->max_ssp_rate = dwc->max_ssp_rate;

/*
* REVISIT: Here we should clear all pending IRQs to be
Expand Down

0 comments on commit 6784814

Please sign in to comment.