mbox series

[0/2] TI AM64/J7: USB Errata i2409 workaround

Message ID 20240514092421.20897-1-r-gunasekaran@ti.com
Headers show
Series TI AM64/J7: USB Errata i2409 workaround | expand

Message

Ravi Gunasekaran May 14, 2024, 9:24 a.m. UTC
This series adds workaround for all TI platforms using
cdns3,usb IP. i.e. AM64/J7x

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      |  9 ++++++++-
 drivers/usb/cdns3/drd.h      |  3 +++
 4 files changed, 26 insertions(+), 2 deletions(-)


base-commit: 6ba6c795dc73c22ce2c86006f17c4aa802db2a60

Comments

Peter Chen May 15, 2024, 1:38 a.m. UTC | #1
On 24-05-14 14:54:20, 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>
> ---
>  drivers/usb/cdns3/core.h | 1 +
>  drivers/usb/cdns3/drd.c  | 9 ++++++++-
>  drivers/usb/cdns3/drd.h  | 3 +++
>  3 files changed, 12 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..de0d25a072b4 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);
> @@ -439,6 +439,13 @@ int cdns_drd_init(struct cdns *cdns)
>  			return -EINVAL;
>  		}
>  
> +		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);
> +		}
> +

It is better put this above (just above code cdns->version  =
CDNS3_CONTROLLER_V1;)

Peter
>  		dev_dbg(cdns->dev, "DRD version v1 (ID: %08x, rev: %08x)\n",
>  			 readl(&cdns->otg_v1_regs->did),
>  			 readl(&cdns->otg_v1_regs->rid));
> 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
>
Ravi Gunasekaran May 15, 2024, 4:22 a.m. UTC | #2
On 5/15/24 7:08 AM, Peter Chen wrote:
> On 24-05-14 14:54:20, 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>
>> ---

[...]

>>  	regs = devm_ioremap_resource(cdns->dev, &cdns->otg_res);
>> @@ -439,6 +439,13 @@ int cdns_drd_init(struct cdns *cdns)
>>  			return -EINVAL;
>>  		}
>>  
>> +		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);
>> +		}
>> +
> 
> It is better put this above (just above code cdns->version  =
> CDNS3_CONTROLLER_V1;)
> 

You mean here, to group it with CDNS3 v1?

else if (OTG_CDNS3_CHECK_DID(state)) {                                               
      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);
+     }
      dns->version  = CDNS3_CONTROLLER_V1;
} else

> Peter
>>  		dev_dbg(cdns->dev, "DRD version v1 (ID: %08x, rev: %08x)\n",
>>  			 readl(&cdns->otg_v1_regs->did),
>>  			 readl(&cdns->otg_v1_regs->rid));
>> 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
>>
>
Peter Chen May 16, 2024, 1:39 a.m. UTC | #3
On 24-05-15 09:52:57, Ravi Gunasekaran wrote:
> 
> 
> On 5/15/24 7:08 AM, Peter Chen wrote:
> > On 24-05-14 14:54:20, 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>
> >> ---
> 
> [...]
> 
> >>  	regs = devm_ioremap_resource(cdns->dev, &cdns->otg_res);
> >> @@ -439,6 +439,13 @@ int cdns_drd_init(struct cdns *cdns)
> >>  			return -EINVAL;
> >>  		}
> >>  
> >> +		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);
> >> +		}
> >> +
> > 
> > It is better put this above (just above code cdns->version  =
> > CDNS3_CONTROLLER_V1;)
> > 
> 
> You mean here, to group it with CDNS3 v1?
> 
> else if (OTG_CDNS3_CHECK_DID(state)) {                                               
>       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);
> +     }
>       dns->version  = CDNS3_CONTROLLER_V1;

Yes.

Peter

> } else
> 
> > Peter
> >>  		dev_dbg(cdns->dev, "DRD version v1 (ID: %08x, rev: %08x)\n",
> >>  			 readl(&cdns->otg_v1_regs->did),
> >>  			 readl(&cdns->otg_v1_regs->rid));
> >> 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
> >>
> > 
> 
> -- 
> Regards,
> Ravi