public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] TI AM64/J7: USB Errata i2409 workaround
@ 2024-05-16  4:45 Ravi Gunasekaran
  2024-05-16  4:45 ` [PATCH v3 1/2] usb: cdns3: Add quirk flag to enable suspend residency Ravi Gunasekaran
  2024-05-16  4:45 ` [PATCH v3 2/2] usb: cdns3-ti: Add workaround for Errata i2409 Ravi Gunasekaran
  0 siblings, 2 replies; 5+ messages in thread
From: Ravi Gunasekaran @ 2024-05-16  4:45 UTC (permalink / raw)
  To: peter.chen, pawell, rogerq
  Cc: gregkh, linux-usb, linux-kernel, srk, r-gunasekaran

This series adds workaround for all TI platforms using
cdns3,usb IP. i.e. AM64/J7x

Change log:
----------
Changes since v2:
----------------
* Fixed the redundant blank line added in v2

Changes since v1:
----------------
* Grouped the susp_ctrl register update along with
  existing CDNS3 snippet as suggested by Peter Chen

v2: https://lore.kernel.org/all/20240516042845.31211-1-r-gunasekaran@ti.com/
v1: https://lore.kernel.org/all/20240514092421.20897-1-r-gunasekaran@ti.com/#t

Roger Quadros (2):
  usb: cdns3: Add quirk flag to enable suspend residency
  usb: cdns3-ti: Add workaround for Errata i2409

 drivers/usb/cdns3/cdns3-ti.c | 15 ++++++++++++++-
 drivers/usb/cdns3/core.h     |  1 +
 drivers/usb/cdns3/drd.c      | 10 +++++++++-
 drivers/usb/cdns3/drd.h      |  3 +++
 4 files changed, 27 insertions(+), 2 deletions(-)


base-commit: 82d92a9a1b9ea0ea52aff27cddd05009b4edad49
-- 
2.17.1


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

* [PATCH v3 1/2] usb: cdns3: Add quirk flag to enable suspend residency
  2024-05-16  4:45 [PATCH v3 0/2] TI AM64/J7: USB Errata i2409 workaround Ravi Gunasekaran
@ 2024-05-16  4:45 ` Ravi Gunasekaran
  2024-05-17  2:20   ` Peter Chen
  2024-05-16  4:45 ` [PATCH v3 2/2] usb: cdns3-ti: Add workaround for Errata i2409 Ravi Gunasekaran
  1 sibling, 1 reply; 5+ messages in thread
From: Ravi Gunasekaran @ 2024-05-16  4:45 UTC (permalink / raw)
  To: peter.chen, pawell, rogerq
  Cc: gregkh, linux-usb, linux-kernel, srk, r-gunasekaran

From: Roger Quadros <rogerq@kernel.org>

Some platforms (e.g. ti,j721e-usb, ti,am64-usb) require
this bit to be set to workaround a lockup issue with PHY
short suspend intervals [1]. Add a platform quirk flag
to indicate if Suspend Residency should be enabled.

[1] - https://www.ti.com/lit/er/sprz457h/sprz457h.pdf
i2409 - USB: USB2 PHY locks up due to short suspend

Signed-off-by: Roger Quadros <rogerq@kernel.org>
Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
---
Change log:
----------
Changes since v2:
----------------
* Fixed the redundant blank line added in v2

Changes since v1:
----------------
* Grouped the susp_ctrl register update along with
  existing CDNS3 snippet as suggested by Peter Chen

v2: https://lore.kernel.org/all/20240516042845.31211-1-r-gunasekaran@ti.com/
v1: https://lore.kernel.org/all/20240514092421.20897-1-r-gunasekaran@ti.com/#t

 drivers/usb/cdns3/core.h |  1 +
 drivers/usb/cdns3/drd.c  | 10 +++++++++-
 drivers/usb/cdns3/drd.h  |  3 +++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/cdns3/core.h b/drivers/usb/cdns3/core.h
index 81a9c9d6be08..57d47348dc19 100644
--- a/drivers/usb/cdns3/core.h
+++ b/drivers/usb/cdns3/core.h
@@ -44,6 +44,7 @@ struct cdns3_platform_data {
 			bool suspend, bool wakeup);
 	unsigned long quirks;
 #define CDNS3_DEFAULT_PM_RUNTIME_ALLOW	BIT(0)
+#define CDNS3_DRD_SUSPEND_RESIDENCY_ENABLE	BIT(1)
 };
 
 /**
diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c
index 8b936a2e93a0..84fb38a5723a 100644
--- a/drivers/usb/cdns3/drd.c
+++ b/drivers/usb/cdns3/drd.c
@@ -389,7 +389,7 @@ static irqreturn_t cdns_drd_irq(int irq, void *data)
 int cdns_drd_init(struct cdns *cdns)
 {
 	void __iomem *regs;
-	u32 state;
+	u32 state, reg;
 	int ret;
 
 	regs = devm_ioremap_resource(cdns->dev, &cdns->otg_res);
@@ -433,6 +433,14 @@ int cdns_drd_init(struct cdns *cdns)
 			cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
 					      &cdns->otg_v1_regs->ien;
 			writel(1, &cdns->otg_v1_regs->simulate);
+
+			if (cdns->pdata &&
+			    (cdns->pdata->quirks & CDNS3_DRD_SUSPEND_RESIDENCY_ENABLE)) {
+				reg = readl(&cdns->otg_v1_regs->susp_ctrl);
+				reg |= SUSP_CTRL_SUSPEND_RESIDENCY_ENABLE;
+				writel(reg, &cdns->otg_v1_regs->susp_ctrl);
+			}
+
 			cdns->version  = CDNS3_CONTROLLER_V1;
 		} else {
 			dev_err(cdns->dev, "not supported DID=0x%08x\n", state);
diff --git a/drivers/usb/cdns3/drd.h b/drivers/usb/cdns3/drd.h
index d72370c321d3..1e2aee14d629 100644
--- a/drivers/usb/cdns3/drd.h
+++ b/drivers/usb/cdns3/drd.h
@@ -193,6 +193,9 @@ struct cdns_otg_irq_regs {
 /* OTGREFCLK - bitmasks */
 #define OTGREFCLK_STB_CLK_SWITCH_EN	BIT(31)
 
+/* SUPS_CTRL - bitmasks */
+#define SUSP_CTRL_SUSPEND_RESIDENCY_ENABLE	BIT(17)
+
 /* OVERRIDE - bitmasks */
 #define OVERRIDE_IDPULLUP		BIT(0)
 /* Only for CDNS3_CONTROLLER_V0 version */
-- 
2.17.1


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

* [PATCH v3 2/2] usb: cdns3-ti: Add workaround for Errata i2409
  2024-05-16  4:45 [PATCH v3 0/2] TI AM64/J7: USB Errata i2409 workaround Ravi Gunasekaran
  2024-05-16  4:45 ` [PATCH v3 1/2] usb: cdns3: Add quirk flag to enable suspend residency Ravi Gunasekaran
@ 2024-05-16  4:45 ` Ravi Gunasekaran
  2024-05-17  2:21   ` Peter Chen
  1 sibling, 1 reply; 5+ messages in thread
From: Ravi Gunasekaran @ 2024-05-16  4:45 UTC (permalink / raw)
  To: peter.chen, pawell, rogerq
  Cc: gregkh, linux-usb, linux-kernel, srk, r-gunasekaran

From: Roger Quadros <rogerq@kernel.org>

TI USB2 PHY is known to have a lockup issue on very short
suspend intervals. Enable the Suspend Residency quirk flag to
workaround this as described in Errata i2409 [1].

[1] - https://www.ti.com/lit/er/sprz457h/sprz457h.pdf

Signed-off-by: Roger Quadros <rogerq@kernel.org>
Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
---
Change log:
----------
Changes since v2:
----------------
* No change

Changes since v1:
----------------
* No change

v2: https://lore.kernel.org/all/20240516042845.31211-1-r-gunasekaran@ti.com/
v1: https://lore.kernel.org/all/20240514092421.20897-1-r-gunasekaran@ti.com/#t

 drivers/usb/cdns3/cdns3-ti.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/cdns3/cdns3-ti.c b/drivers/usb/cdns3/cdns3-ti.c
index 5945c4b1e11f..cfabc12ee0e3 100644
--- a/drivers/usb/cdns3/cdns3-ti.c
+++ b/drivers/usb/cdns3/cdns3-ti.c
@@ -16,6 +16,7 @@
 #include <linux/of_platform.h>
 #include <linux/pm_runtime.h>
 #include <linux/property.h>
+#include "core.h"
 
 /* USB Wrapper register offsets */
 #define USBSS_PID		0x0
@@ -85,6 +86,18 @@ static inline void cdns_ti_writel(struct cdns_ti *data, u32 offset, u32 value)
 	writel(value, data->usbss + offset);
 }
 
+static struct cdns3_platform_data cdns_ti_pdata = {
+	.quirks = CDNS3_DRD_SUSPEND_RESIDENCY_ENABLE,   /* Errata i2409 */
+};
+
+static const struct of_dev_auxdata cdns_ti_auxdata[] = {
+	{
+		.compatible = "cdns,usb3",
+		.platform_data = &cdns_ti_pdata,
+	},
+	{},
+};
+
 static int cdns_ti_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -176,7 +189,7 @@ static int cdns_ti_probe(struct platform_device *pdev)
 	reg |= USBSS_W1_PWRUP_RST;
 	cdns_ti_writel(data, USBSS_W1, reg);
 
-	error = of_platform_populate(node, NULL, NULL, dev);
+	error = of_platform_populate(node, NULL, cdns_ti_auxdata, dev);
 	if (error) {
 		dev_err(dev, "failed to create children: %d\n", error);
 		goto err;
-- 
2.17.1


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

* Re: [PATCH v3 1/2] usb: cdns3: Add quirk flag to enable suspend residency
  2024-05-16  4:45 ` [PATCH v3 1/2] usb: cdns3: Add quirk flag to enable suspend residency Ravi Gunasekaran
@ 2024-05-17  2:20   ` Peter Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Chen @ 2024-05-17  2:20 UTC (permalink / raw)
  To: Ravi Gunasekaran; +Cc: pawell, rogerq, gregkh, linux-usb, linux-kernel, srk

On 24-05-16 10:15:36, Ravi Gunasekaran wrote:
> From: Roger Quadros <rogerq@kernel.org>
> 
> Some platforms (e.g. ti,j721e-usb, ti,am64-usb) require
> this bit to be set to workaround a lockup issue with PHY
> short suspend intervals [1]. Add a platform quirk flag
> to indicate if Suspend Residency should be enabled.
> 
> [1] - https://www.ti.com/lit/er/sprz457h/sprz457h.pdf
> i2409 - USB: USB2 PHY locks up due to short suspend
> 
> Signed-off-by: Roger Quadros <rogerq@kernel.org>
> Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
> ---
> Change log:
> ----------
> Changes since v2:
> ----------------
> * Fixed the redundant blank line added in v2
> 
> Changes since v1:
> ----------------
> * Grouped the susp_ctrl register update along with
>   existing CDNS3 snippet as suggested by Peter Chen
> 
> v2: https://lore.kernel.org/all/20240516042845.31211-1-r-gunasekaran@ti.com/
> v1: https://lore.kernel.org/all/20240514092421.20897-1-r-gunasekaran@ti.com/#t
> 
>  drivers/usb/cdns3/core.h |  1 +
>  drivers/usb/cdns3/drd.c  | 10 +++++++++-
>  drivers/usb/cdns3/drd.h  |  3 +++
>  3 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/cdns3/core.h b/drivers/usb/cdns3/core.h
> index 81a9c9d6be08..57d47348dc19 100644
> --- a/drivers/usb/cdns3/core.h
> +++ b/drivers/usb/cdns3/core.h
> @@ -44,6 +44,7 @@ struct cdns3_platform_data {
>  			bool suspend, bool wakeup);
>  	unsigned long quirks;
>  #define CDNS3_DEFAULT_PM_RUNTIME_ALLOW	BIT(0)
> +#define CDNS3_DRD_SUSPEND_RESIDENCY_ENABLE	BIT(1)
>  };
>  
>  /**
> diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c
> index 8b936a2e93a0..84fb38a5723a 100644
> --- a/drivers/usb/cdns3/drd.c
> +++ b/drivers/usb/cdns3/drd.c
> @@ -389,7 +389,7 @@ static irqreturn_t cdns_drd_irq(int irq, void *data)
>  int cdns_drd_init(struct cdns *cdns)
>  {
>  	void __iomem *regs;
> -	u32 state;
> +	u32 state, reg;
>  	int ret;
>  
>  	regs = devm_ioremap_resource(cdns->dev, &cdns->otg_res);
> @@ -433,6 +433,14 @@ int cdns_drd_init(struct cdns *cdns)
>  			cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
>  					      &cdns->otg_v1_regs->ien;
>  			writel(1, &cdns->otg_v1_regs->simulate);
> +
> +			if (cdns->pdata &&
> +			    (cdns->pdata->quirks & CDNS3_DRD_SUSPEND_RESIDENCY_ENABLE)) {
> +				reg = readl(&cdns->otg_v1_regs->susp_ctrl);
> +				reg |= SUSP_CTRL_SUSPEND_RESIDENCY_ENABLE;
> +				writel(reg, &cdns->otg_v1_regs->susp_ctrl);
> +			}
> +
>  			cdns->version  = CDNS3_CONTROLLER_V1;

Acked-by: Peter Chen <peter.chen@kernel.org>

Peter
>  		} else {
>  			dev_err(cdns->dev, "not supported DID=0x%08x\n", state);
> diff --git a/drivers/usb/cdns3/drd.h b/drivers/usb/cdns3/drd.h
> index d72370c321d3..1e2aee14d629 100644
> --- a/drivers/usb/cdns3/drd.h
> +++ b/drivers/usb/cdns3/drd.h
> @@ -193,6 +193,9 @@ struct cdns_otg_irq_regs {
>  /* OTGREFCLK - bitmasks */
>  #define OTGREFCLK_STB_CLK_SWITCH_EN	BIT(31)
>  
> +/* SUPS_CTRL - bitmasks */
> +#define SUSP_CTRL_SUSPEND_RESIDENCY_ENABLE	BIT(17)
> +
>  /* OVERRIDE - bitmasks */
>  #define OVERRIDE_IDPULLUP		BIT(0)
>  /* Only for CDNS3_CONTROLLER_V0 version */
> -- 
> 2.17.1
> 

-- 

Thanks,
Peter Chen

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

* Re: [PATCH v3 2/2] usb: cdns3-ti: Add workaround for Errata i2409
  2024-05-16  4:45 ` [PATCH v3 2/2] usb: cdns3-ti: Add workaround for Errata i2409 Ravi Gunasekaran
@ 2024-05-17  2:21   ` Peter Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Chen @ 2024-05-17  2:21 UTC (permalink / raw)
  To: Ravi Gunasekaran; +Cc: pawell, rogerq, gregkh, linux-usb, linux-kernel, srk

On 24-05-16 10:15:37, Ravi Gunasekaran wrote:
> From: Roger Quadros <rogerq@kernel.org>
> 
> TI USB2 PHY is known to have a lockup issue on very short
> suspend intervals. Enable the Suspend Residency quirk flag to
> workaround this as described in Errata i2409 [1].
> 
> [1] - https://www.ti.com/lit/er/sprz457h/sprz457h.pdf
> 
> Signed-off-by: Roger Quadros <rogerq@kernel.org>
> Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
> ---
> Change log:
> ----------
> Changes since v2:
> ----------------
> * No change
> 
> Changes since v1:
> ----------------
> * No change
> 
> v2: https://lore.kernel.org/all/20240516042845.31211-1-r-gunasekaran@ti.com/
> v1: https://lore.kernel.org/all/20240514092421.20897-1-r-gunasekaran@ti.com/#t
> 
>  drivers/usb/cdns3/cdns3-ti.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/cdns3/cdns3-ti.c b/drivers/usb/cdns3/cdns3-ti.c
> index 5945c4b1e11f..cfabc12ee0e3 100644
> --- a/drivers/usb/cdns3/cdns3-ti.c
> +++ b/drivers/usb/cdns3/cdns3-ti.c
> @@ -16,6 +16,7 @@
>  #include <linux/of_platform.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/property.h>
> +#include "core.h"
>  
>  /* USB Wrapper register offsets */
>  #define USBSS_PID		0x0
> @@ -85,6 +86,18 @@ static inline void cdns_ti_writel(struct cdns_ti *data, u32 offset, u32 value)
>  	writel(value, data->usbss + offset);
>  }
>  
> +static struct cdns3_platform_data cdns_ti_pdata = {
> +	.quirks = CDNS3_DRD_SUSPEND_RESIDENCY_ENABLE,   /* Errata i2409 */
> +};
> +
> +static const struct of_dev_auxdata cdns_ti_auxdata[] = {
> +	{
> +		.compatible = "cdns,usb3",
> +		.platform_data = &cdns_ti_pdata,
> +	},
> +	{},
> +};
> +
>  static int cdns_ti_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> @@ -176,7 +189,7 @@ static int cdns_ti_probe(struct platform_device *pdev)
>  	reg |= USBSS_W1_PWRUP_RST;
>  	cdns_ti_writel(data, USBSS_W1, reg);
>  
> -	error = of_platform_populate(node, NULL, NULL, dev);
> +	error = of_platform_populate(node, NULL, cdns_ti_auxdata, dev);
>  	if (error) {
>  		dev_err(dev, "failed to create children: %d\n", error);
>  		goto err;
> -- 
> 2.17.1
> 

Acked-by: Peter Chen <peter.chen@kernel.org>

-- 

Thanks,
Peter Chen

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

end of thread, other threads:[~2024-05-17  2:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-16  4:45 [PATCH v3 0/2] TI AM64/J7: USB Errata i2409 workaround Ravi Gunasekaran
2024-05-16  4:45 ` [PATCH v3 1/2] usb: cdns3: Add quirk flag to enable suspend residency Ravi Gunasekaran
2024-05-17  2:20   ` Peter Chen
2024-05-16  4:45 ` [PATCH v3 2/2] usb: cdns3-ti: Add workaround for Errata i2409 Ravi Gunasekaran
2024-05-17  2:21   ` Peter Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox