Skip to contentSkip to conversation

usb: cdns3: fixes for 5.4-rc

PATCH In review Roger Quadros 2 participants 6 messages Oct 16, 2019 – Oct 17, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover usb: cdns3: fixes for 5.4-rc

Hi,

Here are 2 fixes we found while testing the cdns3 driver on our platform.

The first one fixes a corner case where super-speed in host mode doesn't work if device was plugged before the cdns3 driver probes.

The second one fixes the case when gadget driver is limited to full-speed.

cheers,
-roger

Changelog:
v2
- treat USB_DR_MODE_UNKNOWN as error case

Roger Quadros (2):
usb: cdns3: fix cdns3_core_init_role()
usb: cdns3: gadget: Fix full-speed mode

 drivers/usb/cdns3/core.c   | 22 +++++++++++++++++++++-
 drivers/usb/cdns3/gadget.c |  1 +
 2 files changed, 22 insertions(+), 1 deletion(-)
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#1 lore raw

PATCH v2 1/2 usb: cdns3: fix cdns3_core_init_role()

At startup we should trigger the HW state machine only if it is OTG mode. Otherwise we should just start the respective role.

Initialize idle role by default. If we don't do this then cdns3_idle_role_stop() is not called when switching to host/device role and so lane switch mechanism doesn't work. This results to super-speed device not working in one orientation if it was plugged before driver probe.

---
 drivers/usb/cdns3/core.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/usb/cdns3/core.c +21 -1
index 06f1e105be4e..c2123ef8d8a3 100644
@@ -160,10 +160,30 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
 	if (ret)
 		goto err;
 
-	if (cdns->dr_mode != USB_DR_MODE_OTG) {
+	/* Initialize idle role to start with */
+	ret = cdns3_role_start(cdns, USB_ROLE_NONE);
+	if (ret)
+		goto err;
+
+	switch (cdns->dr_mode) {
+	case USB_DR_MODE_OTG:
 		ret = cdns3_hw_role_switch(cdns);
 		if (ret)
 			goto err;
+		break;
+	case USB_DR_MODE_PERIPHERAL:
+		ret = cdns3_role_start(cdns, USB_ROLE_DEVICE);
+		if (ret)
+			goto err;
+		break;
+	case USB_DR_MODE_HOST:
+		ret = cdns3_role_start(cdns, USB_ROLE_HOST);
+		if (ret)
+			goto err;
+		break;
+	default:
+		ret = -EINVAL;
+		goto err;
 	}
 
 	return ret;
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#2 lore raw

PATCH v2 2/2 usb: cdns3: gadget: Fix full-speed mode

In reply to Roger Quadros

We need to disable USB3 PHY for full-speed mode else gadget mode is broken.

---
 drivers/usb/cdns3/gadget.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/cdns3/gadget.c +1 -0
index 228cdc4ab886..157536753b8c 100644
@@ -2571,6 +2571,7 @@ static int cdns3_gadget_start(struct cdns3 *cdns)
 	switch (max_speed) {
 	case USB_SPEED_FULL:
 		writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf);
+		writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
 		break;
 	case USB_SPEED_HIGH:
 		writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#3 lore raw
In reply to Roger Quadros

Hi, Greg

I see that you've already picked up v1.
V2 is a very minor fix and this series can be ignored.

cheers,
-roger

Quoted 26 lines · Roger Quadros

Hi,

Here are 2 fixes we found while testing the cdns3 driver on our platform.

The first one fixes a corner case where super-speed in host mode doesn't work if device was plugged before the cdns3 driver probes.

The second one fixes the case when gadget driver is limited to full-speed.

cheers,
-roger

Changelog:
v2
- treat USB_DR_MODE_UNKNOWN as error case

Roger Quadros (2):
usb: cdns3: fix cdns3_core_init_role()
usb: cdns3: gadget: Fix full-speed mode

  drivers/usb/cdns3/core.c   | 22 +++++++++++++++++++++-
  drivers/usb/cdns3/gadget.c |  1 +
  2 files changed, 22 insertions(+), 1 deletion(-)
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
maintainer
#4 lore raw
Quoted 4 lines · Roger Quadros

Hi, Greg

I see that you've already picked up v1.
V2 is a very minor fix and this series can be ignored.

Can you send the difference as a stand-alone patch so that I can apply it?

thanks,

greg k-h

#5 lore raw

PATCH 1/1 usb: cdns3: Error out if USB_DR_MODE_UNKNOWN in cdns3_core_init_role()

USB_DR_MODE_UNKNOWN should be treated as error as it is done in cdns3_drd_update_mode().

Fixes 02ffc26df96b ("usb: cdns3: fix cdns3_core_init_role()")
---
 drivers/usb/cdns3/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/cdns3/core.c +3 -1
index 1109dc5a4c39..c2123ef8d8a3 100644
@@ -166,7 +166,6 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
 		goto err;
 
 	switch (cdns->dr_mode) {
-	case USB_DR_MODE_UNKNOWN:
 	case USB_DR_MODE_OTG:
 		ret = cdns3_hw_role_switch(cdns);
 		if (ret)
@@ -182,6 +181,9 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
 		if (ret)
 			goto err;
 		break;
+	default:
+		ret = -EINVAL;
+		goto err;
 	}
 
 	return ret;
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki