mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Davis <afd@ti.com>
To: Roger Quadros <rogerq@kernel.org>, <Thinh.Nguyen@synopsys.com>
Cc: <gregkh@linuxfoundation.org>, <r-gunasekaran@ti.com>,
	<b-liu@ti.com>, <srk@ti.com>, <linux-usb@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/4] usb: dwc3-am62: add workaround for Errata i2409
Date: Thu, 1 Feb 2024 12:52:44 -0600	[thread overview]
Message-ID: <f35a729b-ff00-474f-903b-ada2704b0382@ti.com> (raw)
In-Reply-To: <20240201121220.5523-5-rogerq@kernel.org>

On 2/1/24 6:12 AM, Roger Quadros wrote:
> All AM62 devices have Errata i2409 [1] due to which
> USB2 PHY may lock up due to short suspend.
> 
> Workaround involves setting bit 5 and 4 PLL_REG12
> in PHY2 register space after USB controller is brought
> out of LPSC reset but before controller initialization.
> 
> Handle this workaround.
> 
> [1] - https://www.ti.com/lit/er/sprz487d/sprz487d.pdf
> 
> Signed-off-by: Roger Quadros <rogerq@kernel.org>
> ---
>   drivers/usb/dwc3/dwc3-am62.c | 29 +++++++++++++++++++++++++++++
>   1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c
> index af1ce934e7fb..35d7a2fb128e 100644
> --- a/drivers/usb/dwc3/dwc3-am62.c
> +++ b/drivers/usb/dwc3/dwc3-am62.c
> @@ -101,11 +101,17 @@
>   #define PHY_CORE_VOLTAGE_MASK	BIT(31)
>   #define PHY_PLL_REFCLK_MASK	GENMASK(3, 0)
>   
> +/* USB PHY2 register offsets */
> +#define	USB_PHY_PLL_REG12		0x130
> +#define	USB_PHY_PLL_LDO_REF_EN		BIT(5)
> +#define	USB_PHY_PLL_LDO_REF_EN_EN	BIT(4)
> +
>   #define DWC3_AM62_AUTOSUSPEND_DELAY	100
>   
>   struct dwc3_am62 {
>   	struct device *dev;
>   	void __iomem *usbss;
> +	void __iomem *phy;

Why do you need this in the driver data? You only use it in probe(),
just have it be a local variable.

>   	struct clk *usb2_refclk;
>   	int rate_code;
>   	struct regmap *syscon;
> @@ -140,6 +146,16 @@ static inline void dwc3_ti_writel(struct dwc3_am62 *am62, u32 offset, u32 value)
>   	writel(value, (am62->usbss) + offset);
>   }
>   
> +static inline u32 dwc3_ti_phy_readl(struct dwc3_am62 *am62, u32 offset)
> +{

Do you really need these one line functions? They add more code than
they save and just hide a single deference? Just do that directly.

Andrew

> +	return readl((am62->phy) + offset);
> +}
> +
> +static inline void dwc3_ti_phy_writel(struct dwc3_am62 *am62, u32 offset, u32 value)
> +{
> +	writel(value, (am62->phy) + offset);
> +}
> +
>   static int phy_syscon_pll_refclk(struct dwc3_am62 *am62)
>   {
>   	struct device *dev = am62->dev;
> @@ -201,6 +217,12 @@ static int dwc3_ti_probe(struct platform_device *pdev)
>   		return PTR_ERR(am62->usbss);
>   	}
>   
> +	am62->phy = devm_platform_ioremap_resource(pdev, 1);
> +	if (IS_ERR(am62->phy)) {
> +		dev_err(dev, "can't map PHY IOMEM resource. Won't apply i2409 fix.\n");
> +		am62->phy = NULL;
> +	}
> +
>   	am62->usb2_refclk = devm_clk_get(dev, "ref");
>   	if (IS_ERR(am62->usb2_refclk)) {
>   		dev_err(dev, "can't get usb2_refclk\n");
> @@ -227,6 +249,13 @@ static int dwc3_ti_probe(struct platform_device *pdev)
>   	if (ret)
>   		return ret;
>   
> +	/* Workaround Errata i2409 */
> +	if (am62->phy) {
> +		reg = dwc3_ti_phy_readl(am62, USB_PHY_PLL_REG12);
> +		reg |= USB_PHY_PLL_LDO_REF_EN | USB_PHY_PLL_LDO_REF_EN_EN;
> +		dwc3_ti_phy_writel(am62, USB_PHY_PLL_REG12, reg);
> +	}
> +
>   	/* VBUS divider select */
>   	am62->vbus_divider = device_property_read_bool(dev, "ti,vbus-divider");
>   	reg = dwc3_ti_readl(am62, USBSS_PHY_CONFIG);

  reply	other threads:[~2024-02-01 18:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 12:12 [PATCH 0/4] usb: dwc3-am62: module removal and errata fixes Roger Quadros
2024-02-01 12:12 ` [PATCH 1/4] usb: dwc3-am62: call of_platform_depopulate in .remove() Roger Quadros
2024-02-01 12:12 ` [PATCH 2/4] usb: dwc3-am62: fix error on module removal Roger Quadros
2024-02-01 12:12 ` [PATCH 3/4] usb: dwc3-am62: Fix PHY core voltage selection Roger Quadros
2024-02-01 12:12 ` [PATCH 4/4] usb: dwc3-am62: add workaround for Errata i2409 Roger Quadros
2024-02-01 18:52   ` Andrew Davis [this message]
2024-02-02  9:38     ` Roger Quadros

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f35a729b-ff00-474f-903b-ada2704b0382@ti.com \
    --to=afd@ti.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=b-liu@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=r-gunasekaran@ti.com \
    --cc=rogerq@kernel.org \
    --cc=srk@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®