Re: [PATCH 2/2] [RFC] usb: dwc3: using the maximum_speed to determine if the usb3 phy is needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 07/10/2013 06:46 AM, Felipe Balbi wrote:
Hi,

On Sat, Jul 06, 2013 at 07:53:57AM -0500, Ruchika Kharwar wrote:
     When the initialization of usb3 phy fails, when enabled in the system
     the dwc3_probe deferral is further qualified by the maximum speed.
     In devices such as dra7xx, there are multiple dwc3 instances where the
     maximum_speed is different between the instances.

     This patch depends on http://www.spinics.net/lists/linux-usb/msg88627.html

Signed-off-by: Ruchika Kharwar <ruchika@xxxxxx>
---
  drivers/usb/dwc3/core.c |    7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 7b98e4f..05f2205 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -460,8 +460,11 @@ static int dwc3_probe(struct platform_device *pdev)
  		if (ret == -ENXIO)
  			return ret;
- dev_err(dev, "no usb3 phy configured\n");
-		return -EPROBE_DEFER;
+		if (dwc->maximum_speed == USB_SPEED_SUPER) {
+                       dev_err(dev, "no usb3 phy configured\n");
+                       return -EPROBE_DEFER;
+               } else
+                       dev_dbg(dev, "maximum speed is < super\n");
I don't think this is enough. We don't even want to try getting the PHY
if maximum-speed isn't SuperSpeed. I have written this patch a couple
weeks back and have been meaning to send, but still didn't. It's also
available on my testing branch at [1]

[1] http://git.kernel.org/cgit/linux/kernel/git/balbi/usb.git/commit/?h=testing&id=d7e39d414310e098540605be2051d5187797be34

commit d7e39d414310e098540605be2051d5187797be34
Author: Felipe Balbi <balbi@xxxxxx>
Date:   Sun Jun 30 18:39:23 2013 +0300

     usb: dwc3: core: make USB3 PHY optional
If we want a port to work at any speed lower
     than Superspeed, it makes no sense to even
     initialize/power up the USB3 transceiver,
     provided it won't be used.
We can use the oportunity to save some power
     and leave the superspeed transceiver powered
     off.
There is at least one such case which is
     Texas Instruments' AM437x which has one
     of its USB3 ports without a matching USB3
     PHY (that port is hardwired to work on USB2
     only).
Signed-off-by: Felipe Balbi <balbi@xxxxxx>

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 9893301..c86ae12 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -411,15 +411,33 @@ static int dwc3_probe(struct platform_device *pdev)
  	if (node) {
  		dwc->maximum_speed = of_usb_get_maximum_speed(node);
- dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0);
-		dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1);
+		switch (dwc->maximum_speed) {
+		case USB_SPEED_SUPER:
+			dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0);
+			dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1);
+			break;
+		case USB_SPEED_HIGH:
+		case USB_SPEED_FULL:
+		case USB_SPEED_LOW:
+			dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0);
+			break;
+		}
dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize");
  	} else {
  		dwc->maximum_speed = pdata->maximum_speed;
- dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
-		dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
+		switch (dwc->maximum_speed) {
+		case USB_SPEED_SUPER:
+			dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+			dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
+			break;
+		case USB_SPEED_HIGH:
+		case USB_SPEED_FULL:
+		case USB_SPEED_LOW:
+			dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+			break;
+		}
This is definitely better..
  		dwc->needs_fifo_resize = pdata->tx_fifo_resize;
  	}
@@ -443,19 +461,21 @@ static int dwc3_probe(struct platform_device *pdev)
  		return -EPROBE_DEFER;
  	}
- if (IS_ERR(dwc->usb3_phy)) {
-		ret = PTR_ERR(dwc->usb2_phy);
+	if (dwc->maximum_speed == USB_SPEED_SUPER) {
+		if (IS_ERR(dwc->usb3_phy)) {
+			ret = PTR_ERR(dwc->usb2_phy);
- /*
-		 * if -ENXIO is returned, it means PHY layer wasn't
-		 * enabled, so it makes no sense to return -EPROBE_DEFER
-		 * in that case, since no PHY driver will ever probe.
-		 */
-		if (ret == -ENXIO)
-			return ret;
+			/*
+			 * if -ENXIO is returned, it means PHY layer wasn't
+			 * enabled, so it makes no sense to return -EPROBE_DEFER
+			 * in that case, since no PHY driver will ever probe.
+			 */
+			if (ret == -ENXIO)
+				return ret;
- dev_err(dev, "no usb3 phy configured\n");
-		return -EPROBE_DEFER;
+			dev_err(dev, "no usb3 phy configured\n");
+			return -EPROBE_DEFER;
+		}
  	}
usb_phy_set_suspend(dwc->usb2_phy, 0);
Ack!!

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux