[PATCH v4 3/4] usb: dwc3: dwc3-generic-plat: Add layerscape dwc3 support

Frank Li via B4 Relay posted 4 patches 5 days, 4 hours ago
There is a newer version of this series
[PATCH v4 3/4] usb: dwc3: dwc3-generic-plat: Add layerscape dwc3 support
Posted by Frank Li via B4 Relay 5 days, 4 hours ago
From: Frank Li <Frank.Li@nxp.com>

Add layerscape dwc3 support by using flatten dwc3 core library. Layerscape
dwc3 need set gsbuscfg0-reqinfo as 0x2222 when dma-coherence set.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
chagne in v4
- rename gsbuscfg0 to gsbuscfg0_reqinfo
- use flatten core's properties.

change in v3 (skipped)
---
 drivers/usb/dwc3/dwc3-generic-plat.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/dwc3-generic-plat.c b/drivers/usb/dwc3/dwc3-generic-plat.c
index af95a527dcc27a7a14d38dcc887f74a888ed91e6..cfcefeffd7ad6c0a21ccc9aaa4483b9acb9dc4e0 100644
--- a/drivers/usb/dwc3/dwc3-generic-plat.c
+++ b/drivers/usb/dwc3/dwc3-generic-plat.c
@@ -8,6 +8,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/of_address.h>
 #include <linux/platform_device.h>
 #include <linux/reset.h>
 #include "glue.h"
@@ -29,6 +30,7 @@ static void dwc3_generic_reset_control_assert(void *data)
 
 static int dwc3_generic_probe(struct platform_device *pdev)
 {
+	const struct dwc3_properties *properties;
 	struct dwc3_probe_data probe_data = {};
 	struct device *dev = &pdev->dev;
 	struct dwc3_generic *dwc3g;
@@ -75,7 +77,13 @@ static int dwc3_generic_probe(struct platform_device *pdev)
 	probe_data.dwc = &dwc3g->dwc;
 	probe_data.res = res;
 	probe_data.ignore_clocks_and_resets = true;
-	probe_data.properties = DWC3_DEFAULT_PROPERTIES;
+
+	properties = of_device_get_match_data(dev);
+	if (of_dma_is_coherent(pdev->dev.of_node) && properties)
+		probe_data.properties = *properties;
+	else
+		probe_data.properties = DWC3_DEFAULT_PROPERTIES;
+
 	ret = dwc3_core_probe(&probe_data);
 	if (ret)
 		return dev_err_probe(dev, ret, "failed to register DWC3 Core\n");
@@ -146,8 +154,13 @@ static const struct dev_pm_ops dwc3_generic_dev_pm_ops = {
 		       dwc3_generic_runtime_idle)
 };
 
+static const struct dwc3_properties fsl_ls1028_dwc3 = {
+	.gsbuscfg0_reqinfo = 0x2222,
+};
+
 static const struct of_device_id dwc3_generic_of_match[] = {
 	{ .compatible = "spacemit,k1-dwc3", },
+	{ .compatible = "fsl,ls1028a-dwc3", &fsl_ls1028_dwc3},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, dwc3_generic_of_match);

-- 
2.34.1
Re: [PATCH v4 3/4] usb: dwc3: dwc3-generic-plat: Add layerscape dwc3 support
Posted by Thinh Nguyen 4 days, 23 hours ago
On Fri, Sep 26, 2025, Frank Li via B4 Relay wrote:
> From: Frank Li <Frank.Li@nxp.com>
> 
> Add layerscape dwc3 support by using flatten dwc3 core library. Layerscape
> dwc3 need set gsbuscfg0-reqinfo as 0x2222 when dma-coherence set.
> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> chagne in v4
> - rename gsbuscfg0 to gsbuscfg0_reqinfo
> - use flatten core's properties.
> 
> change in v3 (skipped)
> ---
>  drivers/usb/dwc3/dwc3-generic-plat.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-generic-plat.c b/drivers/usb/dwc3/dwc3-generic-plat.c
> index af95a527dcc27a7a14d38dcc887f74a888ed91e6..cfcefeffd7ad6c0a21ccc9aaa4483b9acb9dc4e0 100644
> --- a/drivers/usb/dwc3/dwc3-generic-plat.c
> +++ b/drivers/usb/dwc3/dwc3-generic-plat.c
> @@ -8,6 +8,7 @@
>   */
>  
>  #include <linux/clk.h>
> +#include <linux/of_address.h>
>  #include <linux/platform_device.h>
>  #include <linux/reset.h>
>  #include "glue.h"
> @@ -29,6 +30,7 @@ static void dwc3_generic_reset_control_assert(void *data)
>  
>  static int dwc3_generic_probe(struct platform_device *pdev)
>  {
> +	const struct dwc3_properties *properties;
>  	struct dwc3_probe_data probe_data = {};
>  	struct device *dev = &pdev->dev;
>  	struct dwc3_generic *dwc3g;
> @@ -75,7 +77,13 @@ static int dwc3_generic_probe(struct platform_device *pdev)
>  	probe_data.dwc = &dwc3g->dwc;
>  	probe_data.res = res;
>  	probe_data.ignore_clocks_and_resets = true;
> -	probe_data.properties = DWC3_DEFAULT_PROPERTIES;
> +
> +	properties = of_device_get_match_data(dev);
> +	if (of_dma_is_coherent(pdev->dev.of_node) && properties)

Why do we need the check of_dma_is_coherent() here? Is this specific to
your platform to determine whether set gsbuscfg0_reqinfo only?

> +		probe_data.properties = *properties;
> +	else
> +		probe_data.properties = DWC3_DEFAULT_PROPERTIES;
> +
>  	ret = dwc3_core_probe(&probe_data);
>  	if (ret)
>  		return dev_err_probe(dev, ret, "failed to register DWC3 Core\n");
> @@ -146,8 +154,13 @@ static const struct dev_pm_ops dwc3_generic_dev_pm_ops = {
>  		       dwc3_generic_runtime_idle)
>  };
>  
> +static const struct dwc3_properties fsl_ls1028_dwc3 = {
> +	.gsbuscfg0_reqinfo = 0x2222,
> +};
> +
>  static const struct of_device_id dwc3_generic_of_match[] = {
>  	{ .compatible = "spacemit,k1-dwc3", },
> +	{ .compatible = "fsl,ls1028a-dwc3", &fsl_ls1028_dwc3},
>  	{ /* sentinel */ }
>  };
>  MODULE_DEVICE_TABLE(of, dwc3_generic_of_match);
> 
> -- 
> 2.34.1
> 
> 

BR,
Thinh
Re: [PATCH v4 3/4] usb: dwc3: dwc3-generic-plat: Add layerscape dwc3 support
Posted by Frank Li 4 days, 23 hours ago
On Fri, Sep 26, 2025 at 10:43:03PM +0000, Thinh Nguyen wrote:
> On Fri, Sep 26, 2025, Frank Li via B4 Relay wrote:
> > From: Frank Li <Frank.Li@nxp.com>
> >
> > Add layerscape dwc3 support by using flatten dwc3 core library. Layerscape
> > dwc3 need set gsbuscfg0-reqinfo as 0x2222 when dma-coherence set.
> >
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > ---
> > chagne in v4
> > - rename gsbuscfg0 to gsbuscfg0_reqinfo
> > - use flatten core's properties.
> >
> > change in v3 (skipped)
> > ---
> >  drivers/usb/dwc3/dwc3-generic-plat.c | 15 ++++++++++++++-
> >  1 file changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/dwc3/dwc3-generic-plat.c b/drivers/usb/dwc3/dwc3-generic-plat.c
> > index af95a527dcc27a7a14d38dcc887f74a888ed91e6..cfcefeffd7ad6c0a21ccc9aaa4483b9acb9dc4e0 100644
> > --- a/drivers/usb/dwc3/dwc3-generic-plat.c
> > +++ b/drivers/usb/dwc3/dwc3-generic-plat.c
> > @@ -8,6 +8,7 @@
> >   */
> >
> >  #include <linux/clk.h>
> > +#include <linux/of_address.h>
> >  #include <linux/platform_device.h>
> >  #include <linux/reset.h>
> >  #include "glue.h"
> > @@ -29,6 +30,7 @@ static void dwc3_generic_reset_control_assert(void *data)
> >
> >  static int dwc3_generic_probe(struct platform_device *pdev)
> >  {
> > +	const struct dwc3_properties *properties;
> >  	struct dwc3_probe_data probe_data = {};
> >  	struct device *dev = &pdev->dev;
> >  	struct dwc3_generic *dwc3g;
> > @@ -75,7 +77,13 @@ static int dwc3_generic_probe(struct platform_device *pdev)
> >  	probe_data.dwc = &dwc3g->dwc;
> >  	probe_data.res = res;
> >  	probe_data.ignore_clocks_and_resets = true;
> > -	probe_data.properties = DWC3_DEFAULT_PROPERTIES;
> > +
> > +	properties = of_device_get_match_data(dev);
> > +	if (of_dma_is_coherent(pdev->dev.of_node) && properties)
>
> Why do we need the check of_dma_is_coherent() here? Is this specific to
> your platform to determine whether set gsbuscfg0_reqinfo only?

I remember someone's review feedback. Anyway, 0x2222 works for both.

Frank

>
> > +		probe_data.properties = *properties;
> > +	else
> > +		probe_data.properties = DWC3_DEFAULT_PROPERTIES;
> > +
> >  	ret = dwc3_core_probe(&probe_data);
> >  	if (ret)
> >  		return dev_err_probe(dev, ret, "failed to register DWC3 Core\n");
> > @@ -146,8 +154,13 @@ static const struct dev_pm_ops dwc3_generic_dev_pm_ops = {
> >  		       dwc3_generic_runtime_idle)
> >  };
> >
> > +static const struct dwc3_properties fsl_ls1028_dwc3 = {
> > +	.gsbuscfg0_reqinfo = 0x2222,
> > +};
> > +
> >  static const struct of_device_id dwc3_generic_of_match[] = {
> >  	{ .compatible = "spacemit,k1-dwc3", },
> > +	{ .compatible = "fsl,ls1028a-dwc3", &fsl_ls1028_dwc3},
> >  	{ /* sentinel */ }
> >  };
> >  MODULE_DEVICE_TABLE(of, dwc3_generic_of_match);
> >
> > --
> > 2.34.1
> >
> >
>
> BR,
> Thinh
Re: [PATCH v4 3/4] usb: dwc3: dwc3-generic-plat: Add layerscape dwc3 support
Posted by Thinh Nguyen 4 days, 22 hours ago
On Fri, Sep 26, 2025, Frank Li wrote:
> On Fri, Sep 26, 2025 at 10:43:03PM +0000, Thinh Nguyen wrote:
> > On Fri, Sep 26, 2025, Frank Li via B4 Relay wrote:
> > > From: Frank Li <Frank.Li@nxp.com>
> > >
> > > Add layerscape dwc3 support by using flatten dwc3 core library. Layerscape
> > > dwc3 need set gsbuscfg0-reqinfo as 0x2222 when dma-coherence set.
> > >
> > > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > > ---
> > > chagne in v4
> > > - rename gsbuscfg0 to gsbuscfg0_reqinfo
> > > - use flatten core's properties.
> > >
> > > change in v3 (skipped)
> > > ---
> > >  drivers/usb/dwc3/dwc3-generic-plat.c | 15 ++++++++++++++-
> > >  1 file changed, 14 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/usb/dwc3/dwc3-generic-plat.c b/drivers/usb/dwc3/dwc3-generic-plat.c
> > > index af95a527dcc27a7a14d38dcc887f74a888ed91e6..cfcefeffd7ad6c0a21ccc9aaa4483b9acb9dc4e0 100644
> > > --- a/drivers/usb/dwc3/dwc3-generic-plat.c
> > > +++ b/drivers/usb/dwc3/dwc3-generic-plat.c
> > > @@ -8,6 +8,7 @@
> > >   */
> > >
> > >  #include <linux/clk.h>
> > > +#include <linux/of_address.h>
> > >  #include <linux/platform_device.h>
> > >  #include <linux/reset.h>
> > >  #include "glue.h"
> > > @@ -29,6 +30,7 @@ static void dwc3_generic_reset_control_assert(void *data)
> > >
> > >  static int dwc3_generic_probe(struct platform_device *pdev)
> > >  {
> > > +	const struct dwc3_properties *properties;
> > >  	struct dwc3_probe_data probe_data = {};
> > >  	struct device *dev = &pdev->dev;
> > >  	struct dwc3_generic *dwc3g;
> > > @@ -75,7 +77,13 @@ static int dwc3_generic_probe(struct platform_device *pdev)
> > >  	probe_data.dwc = &dwc3g->dwc;
> > >  	probe_data.res = res;
> > >  	probe_data.ignore_clocks_and_resets = true;
> > > -	probe_data.properties = DWC3_DEFAULT_PROPERTIES;
> > > +
> > > +	properties = of_device_get_match_data(dev);
> > > +	if (of_dma_is_coherent(pdev->dev.of_node) && properties)
> >
> > Why do we need the check of_dma_is_coherent() here? Is this specific to
> > your platform to determine whether set gsbuscfg0_reqinfo only?
> 
> I remember someone's review feedback. Anyway, 0x2222 works for both.
> 

Yes. I believe gave a review feedback on that here:
https://lore.kernel.org/linux-usb/20240610202148.yamu4acezsijvpk7@synopsys.com/

This check should be platform specific and not a general check as being
done here. There will be other properties here where that check won't
be applicable.

Will there be a case where the dma coherent is set differently for the
same compatible string?

Regardless, I think we should not have that check here.

Thanks,
Thinh