linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] usb: cdns3: fixes for 5.4-rc
@ 2019-10-16 10:04 Roger Quadros
  2019-10-16 10:04 ` [PATCH v2 1/2] usb: cdns3: fix cdns3_core_init_role() Roger Quadros
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Roger Quadros @ 2019-10-16 10:04 UTC (permalink / raw)
  To: felipe.balbi, gregkh
  Cc: pawell, peter.chen, nsekhar, kurahul, linux-usb, linux-kernel,
	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(-)

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] usb: cdns3: fix cdns3_core_init_role()
  2019-10-16 10:04 [PATCH v2 0/2] usb: cdns3: fixes for 5.4-rc Roger Quadros
@ 2019-10-16 10:04 ` Roger Quadros
  2019-10-16 10:04 ` [PATCH v2 2/2] usb: cdns3: gadget: Fix full-speed mode Roger Quadros
  2019-10-16 10:08 ` [PATCH v2 0/2] usb: cdns3: fixes for 5.4-rc Roger Quadros
  2 siblings, 0 replies; 6+ messages in thread
From: Roger Quadros @ 2019-10-16 10:04 UTC (permalink / raw)
  To: felipe.balbi, gregkh
  Cc: pawell, peter.chen, nsekhar, kurahul, linux-usb, linux-kernel,
	Roger Quadros

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.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Reviewed-by: Pawel Laszczak <pawell@cadence.com>
Tested-by: Pawel Laszczak <pawell@cadence.com>
---
 drivers/usb/cdns3/core.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index 06f1e105be4e..c2123ef8d8a3 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -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;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] usb: cdns3: gadget: Fix full-speed mode
  2019-10-16 10:04 [PATCH v2 0/2] usb: cdns3: fixes for 5.4-rc Roger Quadros
  2019-10-16 10:04 ` [PATCH v2 1/2] usb: cdns3: fix cdns3_core_init_role() Roger Quadros
@ 2019-10-16 10:04 ` Roger Quadros
  2019-10-16 10:08 ` [PATCH v2 0/2] usb: cdns3: fixes for 5.4-rc Roger Quadros
  2 siblings, 0 replies; 6+ messages in thread
From: Roger Quadros @ 2019-10-16 10:04 UTC (permalink / raw)
  To: felipe.balbi, gregkh
  Cc: pawell, peter.chen, nsekhar, kurahul, linux-usb, linux-kernel,
	Roger Quadros

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

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Reviewed-by: Peter Chen <peter.chen@nxp.com>
Reviewed-by: Pawel Laszczak <pawell@cadence.com>
---
 drivers/usb/cdns3/gadget.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index 228cdc4ab886..157536753b8c 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -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);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/2] usb: cdns3: fixes for 5.4-rc
  2019-10-16 10:04 [PATCH v2 0/2] usb: cdns3: fixes for 5.4-rc Roger Quadros
  2019-10-16 10:04 ` [PATCH v2 1/2] usb: cdns3: fix cdns3_core_init_role() Roger Quadros
  2019-10-16 10:04 ` [PATCH v2 2/2] usb: cdns3: gadget: Fix full-speed mode Roger Quadros
@ 2019-10-16 10:08 ` Roger Quadros
  2019-10-16 13:18   ` Greg KH
  2 siblings, 1 reply; 6+ messages in thread
From: Roger Quadros @ 2019-10-16 10:08 UTC (permalink / raw)
  To: felipe.balbi, gregkh
  Cc: pawell, peter.chen, nsekhar, kurahul, linux-usb, linux-kernel

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

On 16/10/2019 13:04, Roger Quadros wrote:
> 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(-)
> 

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/2] usb: cdns3: fixes for 5.4-rc
  2019-10-16 10:08 ` [PATCH v2 0/2] usb: cdns3: fixes for 5.4-rc Roger Quadros
@ 2019-10-16 13:18   ` Greg KH
  2019-10-17  7:58     ` [PATCH] usb: cdns3: Error out if USB_DR_MODE_UNKNOWN in cdns3_core_init_role() Roger Quadros
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2019-10-16 13:18 UTC (permalink / raw)
  To: Roger Quadros
  Cc: felipe.balbi, pawell, peter.chen, nsekhar, kurahul, linux-usb,
	linux-kernel

On Wed, Oct 16, 2019 at 01:08:57PM +0300, Roger Quadros wrote:
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] usb: cdns3: Error out if USB_DR_MODE_UNKNOWN in cdns3_core_init_role()
  2019-10-16 13:18   ` Greg KH
@ 2019-10-17  7:58     ` Roger Quadros
  0 siblings, 0 replies; 6+ messages in thread
From: Roger Quadros @ 2019-10-17  7:58 UTC (permalink / raw)
  To: felipe.balbi, gregkh
  Cc: pawell, peter.chen, nsekhar, kurahul, linux-usb, linux-kernel,
	Roger Quadros

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()")
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/usb/cdns3/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index 1109dc5a4c39..c2123ef8d8a3 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -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;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-10-17  7:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16 10:04 [PATCH v2 0/2] usb: cdns3: fixes for 5.4-rc Roger Quadros
2019-10-16 10:04 ` [PATCH v2 1/2] usb: cdns3: fix cdns3_core_init_role() Roger Quadros
2019-10-16 10:04 ` [PATCH v2 2/2] usb: cdns3: gadget: Fix full-speed mode Roger Quadros
2019-10-16 10:08 ` [PATCH v2 0/2] usb: cdns3: fixes for 5.4-rc Roger Quadros
2019-10-16 13:18   ` Greg KH
2019-10-17  7:58     ` [PATCH] usb: cdns3: Error out if USB_DR_MODE_UNKNOWN in cdns3_core_init_role() Roger Quadros

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).