From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Frank Li <Frank.li@nxp.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Shawn Guo <shawnguo@kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"bjorn.andersson@oss.qualcomm.com"
<bjorn.andersson@oss.qualcomm.com>, Ze Huang <huang.ze@linux.dev>
Subject: Re: [PATCH v2 2/3] usb: dwc3: dwc3-generic-plat: add layerscape dwc3 support
Date: Thu, 25 Sep 2025 23:42:59 +0000 [thread overview]
Message-ID: <20250925234225.6uaxndkhm5nq654s@synopsys.com> (raw)
In-Reply-To: <aNTAjk1zsWF5lm3p@lizhi-Precision-Tower-5810>
On Thu, Sep 25, 2025, Frank Li wrote:
> On Wed, Sep 24, 2025 at 10:13:36PM +0000, Thinh Nguyen wrote:
> > >
> > > +static const struct dwc3_generic_drvdata spacemit_k1_dwc3 = {
> > > + .gsbuscfg0 = DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED,
> >
> > Why do we need to do this?
>
> because is 0 valildate setting for cfg0_regqinfo.
>
> Avoid add new flags like REGINFO_VALDATE in drvdata. dwc3 will use default
> value if reginfo is DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED.
>
> of cousre, if you like add bool b_usebuscfg0 in drvdata, I am also fine.
>
Let's avoid the parent-child model to pass the properties as if they
were from device-tree. That was a workaround we had before the new
flattened model.
I'm thinking of something like below. Let me know if this works for you.
Note that this isn't tested:
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index ae140c356295..bf7323a1658e 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1666,7 +1666,8 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE, true);
}
-static void dwc3_get_software_properties(struct dwc3 *dwc)
+static void dwc3_get_software_properties(struct dwc3 *dwc,
+ const struct dwc3_properties *properties)
{
struct device *tmpdev;
u16 gsbuscfg0_reqinfo;
@@ -1674,16 +1675,20 @@ static void dwc3_get_software_properties(struct dwc3 *dwc)
dwc->gsbuscfg0_reqinfo = DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED;
- /*
- * Iterate over all parent nodes for finding swnode properties
- * and non-DT (non-ABI) properties.
- */
- for (tmpdev = dwc->dev; tmpdev; tmpdev = tmpdev->parent) {
- ret = device_property_read_u16(tmpdev,
- "snps,gsbuscfg0-reqinfo",
- &gsbuscfg0_reqinfo);
- if (!ret)
- dwc->gsbuscfg0_reqinfo = gsbuscfg0_reqinfo;
+ if (properties->gsbuscfg0_reqinfo != DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED) {
+ dwc->gsbuscfg0_reqinfo = properties->gsbuscfg0_reqinfo;
+ } else {
+ /*
+ * Iterate over all parent nodes for finding swnode properties
+ * and non-DT (non-ABI) properties.
+ */
+ for (tmpdev = dwc->dev; tmpdev; tmpdev = tmpdev->parent) {
+ ret = device_property_read_u16(tmpdev,
+ "snps,gsbuscfg0-reqinfo",
+ &gsbuscfg0_reqinfo);
+ if (!ret)
+ dwc->gsbuscfg0_reqinfo = gsbuscfg0_reqinfo;
+ }
}
}
@@ -2206,7 +2211,7 @@ int dwc3_core_probe(const struct dwc3_probe_data *data)
dwc3_get_properties(dwc);
- dwc3_get_software_properties(dwc);
+ dwc3_get_software_properties(dwc, &data->properties);
dwc->usb_psy = dwc3_get_usb_power_supply(dwc);
if (IS_ERR(dwc->usb_psy))
@@ -2356,6 +2361,7 @@ static int dwc3_probe(struct platform_device *pdev)
probe_data.dwc = dwc;
probe_data.res = res;
+ probe_data.properties.gsbuscfg0_reqinfo = DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED;
return dwc3_core_probe(&probe_data);
}
diff --git a/drivers/usb/dwc3/dwc3-generic-plat.c b/drivers/usb/dwc3/dwc3-generic-plat.c
index d96b20570002..b9bf27ed8c05 100644
--- a/drivers/usb/dwc3/dwc3-generic-plat.c
+++ b/drivers/usb/dwc3/dwc3-generic-plat.c
@@ -30,6 +30,7 @@ static void dwc3_generic_reset_control_assert(void *data)
static int dwc3_generic_probe(struct platform_device *pdev)
{
struct dwc3_probe_data probe_data = {};
+ const struct dwc3_properties *properties;
struct device *dev = &pdev->dev;
struct dwc3_generic *dwc3g;
struct resource *res;
@@ -75,6 +76,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;
+
+ properties = of_device_get_match_data(dev);
+ if (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");
@@ -145,8 +153,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);
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index ded2ca86670c..9ac75547820d 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -704,6 +704,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
probe_data.dwc = &qcom->dwc;
probe_data.res = &res;
probe_data.ignore_clocks_and_resets = true;
+ probe_data.properties = DWC3_DEFAULT_PROPERTIES;
ret = dwc3_core_probe(&probe_data);
if (ret) {
ret = dev_err_probe(dev, ret, "failed to register DWC3 Core\n");
diff --git a/drivers/usb/dwc3/glue.h b/drivers/usb/dwc3/glue.h
index 2efd00e763be..7083ab193417 100644
--- a/drivers/usb/dwc3/glue.h
+++ b/drivers/usb/dwc3/glue.h
@@ -9,17 +9,31 @@
#include <linux/types.h>
#include "core.h"
+/**
+ * dwc3_properties: DWC3 core properties
+ * @gsbuscfg0_reqinfo: Value to be programmed in the GSBUSCFG0.REQINFO field
+ */
+struct dwc3_properties {
+ u32 gsbuscfg0_reqinfo;
+};
+
+#define DWC3_DEFAULT_PROPERTIES ((struct dwc3_properties){ \
+ .gsbuscfg0_reqinfo = DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED, \
+ })
+
/**
* dwc3_probe_data: Initialization parameters passed to dwc3_core_probe()
* @dwc: Reference to dwc3 context structure
* @res: resource for the DWC3 core mmio region
* @ignore_clocks_and_resets: clocks and resets defined for the device should
* be ignored by the DWC3 core, as they are managed by the glue
+ * @properties: <description>
*/
struct dwc3_probe_data {
struct dwc3 *dwc;
struct resource *res;
bool ignore_clocks_and_resets;
+ struct dwc3_properties properties;
};
int dwc3_core_probe(const struct dwc3_probe_data *data);
---
BR,
Thinh
next prev parent reply other threads:[~2025-09-25 23:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 20:22 [PATCH v2 0/3] usb: dwc3: add layerscape platform driver use flatten dwc3 core Frank Li
2025-09-23 20:22 ` [PATCH v2 1/3] dt-bindings: usb: add missed compatible string for arm64 layerscape Frank Li
2025-09-23 20:22 ` [PATCH v2 2/3] usb: dwc3: dwc3-generic-plat: add layerscape dwc3 support Frank Li
2025-09-24 22:13 ` Thinh Nguyen
2025-09-25 4:09 ` Frank Li
2025-09-25 23:42 ` Thinh Nguyen [this message]
2025-09-25 23:47 ` Thinh Nguyen
2025-09-23 20:22 ` [PATCH v2 3/3] arm64: dts: layerscape: add dma-coherent for usb node Frank Li
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=20250925234225.6uaxndkhm5nq654s@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=Frank.li@nxp.com \
--cc=bjorn.andersson@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=huang.ze@linux.dev \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=robh@kernel.org \
--cc=shawnguo@kernel.org \
/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