public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v4 0/3] usb: imx8mp: collect some improvement
@ 2024-09-05 20:06 Frank Li
  2024-09-05 20:06 ` [PATCH v4 1/3] usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk Frank Li
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Frank Li @ 2024-09-05 20:06 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Thinh Nguyen, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
  Cc: linux-usb, linux-kernel, imx, linux-arm-kernel, jun.li, Frank Li,
	Xu Yang

Apply two quirk for imx8mp dwc3 host controller:
 usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk
 usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode

Runtime pm and wakeup:
  usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Changes in v4:
- Rebase to usb-test
- Link to v3: https://lore.kernel.org/r/20240904-dwc-mp-v3-0-319947736ec0@nxp.com

Changes in v3:
- see each patch
- Link to v2: https://lore.kernel.org/r/20240821-dwc-mp-v2-0-2a29b6a5c2f4@nxp.com

Changes in v2:
- Remove patch dwc3: core: add a core init flag for device mode resume
The problem can't reproduce in latest kernel. pm_runtime_get() in irq
handle return false because run time pm already disabled at
device_suspend_late(). So runtime_resume will not happen before system
resume.
- Link to v1: https://lore.kernel.org/r/20240712-dwc-mp-v1-0-295e5c4e3ec9@nxp.com

---
Frank Li (2):
      usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk
      usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode

Li Jun (1):
      usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep

 drivers/usb/dwc3/dwc3-imx8mp.c | 40 ++++++++++++++++++++++++++++++++++------
 drivers/usb/host/xhci-plat.c   |  6 ++++++
 2 files changed, 40 insertions(+), 6 deletions(-)
---
base-commit: 9c0c11bb87b09a8b7cdc21ca1090e7b36abe9d09
change-id: 20240711-dwc-mp-d1564eec57b1

Best regards,
---
Frank Li <Frank.Li@nxp.com>



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

* [PATCH v4 1/3] usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk
  2024-09-05 20:06 [PATCH v4 0/3] usb: imx8mp: collect some improvement Frank Li
@ 2024-09-05 20:06 ` Frank Li
  2024-09-05 20:06 ` [PATCH v4 2/3] usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode Frank Li
  2024-09-05 20:06 ` [PATCH v4 3/3] usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep Frank Li
  2 siblings, 0 replies; 6+ messages in thread
From: Frank Li @ 2024-09-05 20:06 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Thinh Nguyen, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
  Cc: linux-usb, linux-kernel, imx, linux-arm-kernel, jun.li, Frank Li

Parse software managed property 'xhci-skip-phy-init-quirk' and
'xhci-skip-phy-init-quirk' to apply related quirk. It allows usb glue layer
driver apply these quirk.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/usb/host/xhci-plat.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 31bdfa52eeb25..ecaa75718e592 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -259,6 +259,12 @@ int xhci_plat_probe(struct platform_device *pdev, struct device *sysdev, const s
 		if (device_property_read_bool(tmpdev, "write-64-hi-lo-quirk"))
 			xhci->quirks |= XHCI_WRITE_64_HI_LO;
 
+		if (device_property_read_bool(tmpdev, "xhci-missing-cas-quirk"))
+			xhci->quirks |= XHCI_MISSING_CAS;
+
+		if (device_property_read_bool(tmpdev, "xhci-skip-phy-init-quirk"))
+			xhci->quirks |= XHCI_SKIP_PHY_INIT;
+
 		device_property_read_u32(tmpdev, "imod-interval-ns",
 					 &xhci->imod_interval);
 	}

-- 
2.34.1



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

* [PATCH v4 2/3] usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode
  2024-09-05 20:06 [PATCH v4 0/3] usb: imx8mp: collect some improvement Frank Li
  2024-09-05 20:06 ` [PATCH v4 1/3] usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk Frank Li
@ 2024-09-05 20:06 ` Frank Li
  2024-09-05 20:58   ` Thinh Nguyen
  2024-09-05 20:06 ` [PATCH v4 3/3] usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep Frank Li
  2 siblings, 1 reply; 6+ messages in thread
From: Frank Li @ 2024-09-05 20:06 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Thinh Nguyen, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
  Cc: linux-usb, linux-kernel, imx, linux-arm-kernel, jun.li, Frank Li

Add 2 software manage quirk properties (xhci-missing-cas-quirk and
xhci-skip-phy-init-quirk) for xhci host.

dwc3 driver have PHY management to cover both device and host mode, so add
xhci-skip-phy-init-quirk to skip PHY management from HCD core.

Cold Attach Status (CAS) bit can't be set at i.MX8MP after resume from
suspend state. So set xhci-missing-cas-quirk.

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Change from v2 to v3
- rework commit message to descript why need set quirk.

Change from v1 to v2
- use {0}
---
 drivers/usb/dwc3/dwc3-imx8mp.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
index 8b88649b569fe..f62f6f960e501 100644
--- a/drivers/usb/dwc3/dwc3-imx8mp.c
+++ b/drivers/usb/dwc3/dwc3-imx8mp.c
@@ -145,6 +145,17 @@ static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx)
 	return IRQ_HANDLED;
 }
 
+static int dwc3_imx8mp_set_software_node(struct device *dev)
+{
+	struct property_entry props[3] = { 0 };
+	int prop_idx = 0;
+
+	props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-missing-cas-quirk");
+	props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-skip-phy-init-quirk");
+
+	return device_create_managed_software_node(dev, props, NULL);
+}
+
 static int dwc3_imx8mp_probe(struct platform_device *pdev)
 {
 	struct device		*dev = &pdev->dev;
@@ -207,6 +218,20 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
 	if (err < 0)
 		goto disable_rpm;
 
+	dwc3_np = of_get_compatible_child(node, "snps,dwc3");
+	if (!dwc3_np) {
+		err = -ENODEV;
+		dev_err(dev, "failed to find dwc3 core child\n");
+		goto disable_rpm;
+	}
+
+	err = dwc3_imx8mp_set_software_node(dev);
+	if (err) {
+		err = -ENODEV;
+		dev_err(dev, "failed to create software node\n");
+		goto disable_rpm;
+	}
+
 	err = of_platform_populate(node, NULL, NULL, dev);
 	if (err) {
 		dev_err(&pdev->dev, "failed to create dwc3 core\n");

-- 
2.34.1



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

* [PATCH v4 3/3] usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep
  2024-09-05 20:06 [PATCH v4 0/3] usb: imx8mp: collect some improvement Frank Li
  2024-09-05 20:06 ` [PATCH v4 1/3] usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk Frank Li
  2024-09-05 20:06 ` [PATCH v4 2/3] usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode Frank Li
@ 2024-09-05 20:06 ` Frank Li
  2 siblings, 0 replies; 6+ messages in thread
From: Frank Li @ 2024-09-05 20:06 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Thinh Nguyen, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
  Cc: linux-usb, linux-kernel, imx, linux-arm-kernel, jun.li, Frank Li,
	Xu Yang

From: Li Jun <jun.li@nxp.com>

SS_CON and U3 wakeup need 'ref_clk' on. iMX8MP turn off it while system
sleep, So disable these wakeup source and only enable DP/DM wakeup source
for host mode.

Reviewed-by: Xu Yang <xu.yang_2@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/usb/dwc3/dwc3-imx8mp.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
index f62f6f960e501..4c0aef5792ce2 100644
--- a/drivers/usb/dwc3/dwc3-imx8mp.c
+++ b/drivers/usb/dwc3/dwc3-imx8mp.c
@@ -97,7 +97,8 @@ static void imx8mp_configure_glue(struct dwc3_imx8mp *dwc3_imx)
 	writel(value, dwc3_imx->glue_base + USB_CTRL1);
 }
 
-static void dwc3_imx8mp_wakeup_enable(struct dwc3_imx8mp *dwc3_imx)
+static void dwc3_imx8mp_wakeup_enable(struct dwc3_imx8mp *dwc3_imx,
+				      pm_message_t msg)
 {
 	struct dwc3	*dwc3 = platform_get_drvdata(dwc3_imx->dwc3);
 	u32		val;
@@ -107,12 +108,14 @@ static void dwc3_imx8mp_wakeup_enable(struct dwc3_imx8mp *dwc3_imx)
 
 	val = readl(dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL);
 
-	if ((dwc3->current_dr_role == DWC3_GCTL_PRTCAP_HOST) && dwc3->xhci)
-		val |= USB_WAKEUP_EN | USB_WAKEUP_SS_CONN |
-		       USB_WAKEUP_U3_EN | USB_WAKEUP_DPDM_EN;
-	else if (dwc3->current_dr_role == DWC3_GCTL_PRTCAP_DEVICE)
+	if ((dwc3->current_dr_role == DWC3_GCTL_PRTCAP_HOST) && dwc3->xhci) {
+		val |= USB_WAKEUP_EN | USB_WAKEUP_DPDM_EN;
+		if (PMSG_IS_AUTO(msg))
+			val |= USB_WAKEUP_SS_CONN | USB_WAKEUP_U3_EN;
+	} else {
 		val |= USB_WAKEUP_EN | USB_WAKEUP_VBUS_EN |
 		       USB_WAKEUP_VBUS_SRC_SESS_VAL;
+	}
 
 	writel(val, dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL);
 }
@@ -284,7 +287,7 @@ static int dwc3_imx8mp_suspend(struct dwc3_imx8mp *dwc3_imx, pm_message_t msg)
 
 	/* Wakeup enable */
 	if (PMSG_IS_AUTO(msg) || device_may_wakeup(dwc3_imx->dev))
-		dwc3_imx8mp_wakeup_enable(dwc3_imx);
+		dwc3_imx8mp_wakeup_enable(dwc3_imx, msg);
 
 	dwc3_imx->pm_suspended = true;
 

-- 
2.34.1



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

* Re: [PATCH v4 2/3] usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode
  2024-09-05 20:06 ` [PATCH v4 2/3] usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode Frank Li
@ 2024-09-05 20:58   ` Thinh Nguyen
  2024-09-05 21:07     ` Frank Li
  0 siblings, 1 reply; 6+ messages in thread
From: Thinh Nguyen @ 2024-09-05 20:58 UTC (permalink / raw)
  To: Frank Li
  Cc: Mathias Nyman, Greg Kroah-Hartman, Thinh Nguyen, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	jun.li@nxp.com

On Thu, Sep 05, 2024, Frank Li wrote:
> Add 2 software manage quirk properties (xhci-missing-cas-quirk and
> xhci-skip-phy-init-quirk) for xhci host.
> 
> dwc3 driver have PHY management to cover both device and host mode, so add
> xhci-skip-phy-init-quirk to skip PHY management from HCD core.
> 
> Cold Attach Status (CAS) bit can't be set at i.MX8MP after resume from
> suspend state. So set xhci-missing-cas-quirk.
> 
> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---

You're missing changes from v3 to v4

> Change from v2 to v3
> - rework commit message to descript why need set quirk.
> 
> Change from v1 to v2
> - use {0}
> ---
>  drivers/usb/dwc3/dwc3-imx8mp.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
> index 8b88649b569fe..f62f6f960e501 100644
> --- a/drivers/usb/dwc3/dwc3-imx8mp.c
> +++ b/drivers/usb/dwc3/dwc3-imx8mp.c
> @@ -145,6 +145,17 @@ static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx)
>  	return IRQ_HANDLED;
>  }
>  
> +static int dwc3_imx8mp_set_software_node(struct device *dev)
> +{
> +	struct property_entry props[3] = { 0 };
> +	int prop_idx = 0;
> +
> +	props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-missing-cas-quirk");
> +	props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-skip-phy-init-quirk");
> +
> +	return device_create_managed_software_node(dev, props, NULL);
> +}
> +
>  static int dwc3_imx8mp_probe(struct platform_device *pdev)
>  {
>  	struct device		*dev = &pdev->dev;
> @@ -207,6 +218,20 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
>  	if (err < 0)
>  		goto disable_rpm;
>  
> +	dwc3_np = of_get_compatible_child(node, "snps,dwc3");
> +	if (!dwc3_np) {
> +		err = -ENODEV;
> +		dev_err(dev, "failed to find dwc3 core child\n");
> +		goto disable_rpm;
> +	}

This looks very different than the previous version. Did you review the
change before rebase? We should already do of_get_compatible_child() a
few lines above.

> +
> +	err = dwc3_imx8mp_set_software_node(dev);
> +	if (err) {
> +		err = -ENODEV;
> +		dev_err(dev, "failed to create software node\n");
> +		goto disable_rpm;
> +	}
> +
>  	err = of_platform_populate(node, NULL, NULL, dev);
>  	if (err) {
>  		dev_err(&pdev->dev, "failed to create dwc3 core\n");
> 
> -- 
> 2.34.1
> 

Please remove the Acked-by for now.

Thanks,
Thinh

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

* Re: [PATCH v4 2/3] usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode
  2024-09-05 20:58   ` Thinh Nguyen
@ 2024-09-05 21:07     ` Frank Li
  0 siblings, 0 replies; 6+ messages in thread
From: Frank Li @ 2024-09-05 21:07 UTC (permalink / raw)
  To: Thinh Nguyen
  Cc: Mathias Nyman, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org, jun.li@nxp.com

On Thu, Sep 05, 2024 at 08:58:55PM +0000, Thinh Nguyen wrote:
> On Thu, Sep 05, 2024, Frank Li wrote:
> > Add 2 software manage quirk properties (xhci-missing-cas-quirk and
> > xhci-skip-phy-init-quirk) for xhci host.
> >
> > dwc3 driver have PHY management to cover both device and host mode, so add
> > xhci-skip-phy-init-quirk to skip PHY management from HCD core.
> >
> > Cold Attach Status (CAS) bit can't be set at i.MX8MP after resume from
> > suspend state. So set xhci-missing-cas-quirk.
> >
> > Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > ---
>
> You're missing changes from v3 to v4
>
> > Change from v2 to v3
> > - rework commit message to descript why need set quirk.
> >
> > Change from v1 to v2
> > - use {0}
> > ---
> >  drivers/usb/dwc3/dwc3-imx8mp.c | 25 +++++++++++++++++++++++++
> >  1 file changed, 25 insertions(+)
> >
> > diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
> > index 8b88649b569fe..f62f6f960e501 100644
> > --- a/drivers/usb/dwc3/dwc3-imx8mp.c
> > +++ b/drivers/usb/dwc3/dwc3-imx8mp.c
> > @@ -145,6 +145,17 @@ static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx)
> >  	return IRQ_HANDLED;
> >  }
> >
> > +static int dwc3_imx8mp_set_software_node(struct device *dev)
> > +{
> > +	struct property_entry props[3] = { 0 };
> > +	int prop_idx = 0;
> > +
> > +	props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-missing-cas-quirk");
> > +	props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-skip-phy-init-quirk");
> > +
> > +	return device_create_managed_software_node(dev, props, NULL);
> > +}
> > +
> >  static int dwc3_imx8mp_probe(struct platform_device *pdev)
> >  {
> >  	struct device		*dev = &pdev->dev;
> > @@ -207,6 +218,20 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
> >  	if (err < 0)
> >  		goto disable_rpm;
> >
> > +	dwc3_np = of_get_compatible_child(node, "snps,dwc3");
> > +	if (!dwc3_np) {
> > +		err = -ENODEV;
> > +		dev_err(dev, "failed to find dwc3 core child\n");
> > +		goto disable_rpm;
> > +	}
>
> This looks very different than the previous version. Did you review the
> change before rebase? We should already do of_get_compatible_child() a
> few lines above.

Sorry, mass up at rebase

Frank

>
> > +
> > +	err = dwc3_imx8mp_set_software_node(dev);
> > +	if (err) {
> > +		err = -ENODEV;
> > +		dev_err(dev, "failed to create software node\n");
> > +		goto disable_rpm;
> > +	}
> > +
> >  	err = of_platform_populate(node, NULL, NULL, dev);
> >  	if (err) {
> >  		dev_err(&pdev->dev, "failed to create dwc3 core\n");
> >
> > --
> > 2.34.1
> >
>
> Please remove the Acked-by for now.
>
> Thanks,
> Thinh


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

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

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-05 20:06 [PATCH v4 0/3] usb: imx8mp: collect some improvement Frank Li
2024-09-05 20:06 ` [PATCH v4 1/3] usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk Frank Li
2024-09-05 20:06 ` [PATCH v4 2/3] usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode Frank Li
2024-09-05 20:58   ` Thinh Nguyen
2024-09-05 21:07     ` Frank Li
2024-09-05 20:06 ` [PATCH v4 3/3] usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep Frank Li

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