Devicetree
 help / color / mirror / Atom feed
From: Frank Li <Frank.Li@nxp.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	 Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	Shawn Guo <shawnguo@kernel.org>
Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	 bjorn.andersson@oss.qualcomm.com, imx@lists.linux.dev,
	 Frank Li <Frank.Li@nxp.com>, Ze Huang <huang.ze@linux.dev>
Subject: [PATCH v3 2/3] usb: dwc3: dwc3-generic-plat: add layerscape dwc3 support
Date: Fri, 26 Sep 2025 11:05:49 -0400	[thread overview]
Message-ID: <20250926-ls_dma_coherence-v3-2-602b1c0ce6b4@nxp.com> (raw)
In-Reply-To: <20250926-ls_dma_coherence-v3-0-602b1c0ce6b4@nxp.com>

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

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
change in v3
- rename gsbuscfg0 to gsbuscfg0_reqinfo
- add default_dwc3 driver data.
- use_reqinfo to indicate gsbuscfg0_reqinfo is validate because 0 is
validate value for reqinfo.
---
 drivers/usb/dwc3/dwc3-generic-plat.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/dwc3-generic-plat.c b/drivers/usb/dwc3/dwc3-generic-plat.c
index d96b20570002dc619ea813f4d6a8013636a0f346..ad7358f6e68ae4f434bf78bb958a73589c9a224e 100644
--- a/drivers/usb/dwc3/dwc3-generic-plat.c
+++ b/drivers/usb/dwc3/dwc3-generic-plat.c
@@ -8,10 +8,17 @@
  */
 
 #include <linux/clk.h>
+#include <linux/of_address.h>
 #include <linux/platform_device.h>
 #include <linux/reset.h>
 #include "glue.h"
 
+struct dwc3_generic_drvdata {
+	u16	gsbuscfg0_reqinfo;
+	/* true: use gsbuscfg0_reqinfo, false: use default value */
+	bool	use_reqinfo : 1;
+};
+
 struct dwc3_generic {
 	struct device		*dev;
 	struct dwc3		dwc;
@@ -29,6 +36,7 @@ static void dwc3_generic_reset_control_assert(void *data)
 
 static int dwc3_generic_probe(struct platform_device *pdev)
 {
+	const struct dwc3_generic_drvdata *drvdata;
 	struct dwc3_probe_data probe_data = {};
 	struct device *dev = &pdev->dev;
 	struct dwc3_generic *dwc3g;
@@ -41,6 +49,8 @@ static int dwc3_generic_probe(struct platform_device *pdev)
 
 	dwc3g->dev = dev;
 
+	drvdata = of_device_get_match_data(dev);
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
 		dev_err(&pdev->dev, "missing memory resource\n");
@@ -70,6 +80,18 @@ static int dwc3_generic_probe(struct platform_device *pdev)
 	if (ret < 0)
 		return dev_err_probe(dev, ret, "failed to get clocks\n");
 
+	if (of_dma_is_coherent(pdev->dev.of_node) && drvdata->use_reqinfo) {
+		struct property_entry props[2] = {};
+
+		props[0] = PROPERTY_ENTRY_U16("snps,gsbuscfg0-reqinfo",
+					      drvdata->gsbuscfg0_reqinfo);
+
+		ret = device_create_managed_software_node(dev, props, NULL);
+		if (ret)
+			return dev_err_probe(dev, ret,
+					     "fail create software managed property node\n");
+	}
+
 	dwc3g->num_clocks = ret;
 	dwc3g->dwc.dev = dev;
 	probe_data.dwc = &dwc3g->dwc;
@@ -145,8 +167,17 @@ static const struct dev_pm_ops dwc3_generic_dev_pm_ops = {
 		       dwc3_generic_runtime_idle)
 };
 
+static const struct dwc3_generic_drvdata default_dwc3 = {
+};
+
+static const struct dwc3_generic_drvdata fsl_ls1028_dwc3 = {
+	.gsbuscfg0_reqinfo = 0x2222,
+	.use_reqinfo = true,
+};
+
 static const struct of_device_id dwc3_generic_of_match[] = {
-	{ .compatible = "spacemit,k1-dwc3", },
+	{ .compatible = "spacemit,k1-dwc3", &default_dwc3},
+	{ .compatible = "fsl,ls1028a-dwc3", &fsl_ls1028_dwc3},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, dwc3_generic_of_match);

-- 
2.34.1


  parent reply	other threads:[~2025-09-26 15:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-26 15:05 [PATCH v3 0/3] usb: dwc3: add layerscape platform driver use flatten dwc3 core Frank Li
2025-09-26 15:05 ` [PATCH v3 1/3] dt-bindings: usb: add missed compatible string for arm64 layerscape Frank Li
2025-09-26 15:05 ` Frank Li [this message]
2025-09-26 15:05 ` [PATCH v3 3/3] arm64: dts: layerscape: add dma-coherent for usb node Frank Li
2025-09-26 15:08 ` [PATCH v3 0/3] usb: dwc3: add layerscape platform driver use flatten dwc3 core 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=20250926-ls_dma_coherence-v3-2-602b1c0ce6b4@nxp.com \
    --to=frank.li@nxp.com \
    --cc=Thinh.Nguyen@synopsys.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=imx@lists.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