All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Li <Frank.Li@nxp.com>
To: thinh.nguyen@synopsys.com, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org
Cc: Frank.Li@nxp.com, balbi@kernel.org, devicetree@vger.kernel.org,
	gregkh@linuxfoundation.org, imx@lists.linux.dev,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	mark.rutland@arm.com, mathias.nyman@intel.com, pku.leo@gmail.com,
	sergei.shtylyov@cogentembedded.com
Subject: [PATCH 2/2] usb: dwc3: core: allow overwrite reqinfo in GSBUSCFG0 by dts
Date: Tue, 23 Jan 2024 12:02:06 -0500	[thread overview]
Message-ID: <20240123170206.3702413-2-Frank.Li@nxp.com> (raw)
In-Reply-To: <20240123170206.3702413-1-Frank.Li@nxp.com>

Add function dwc3_set_bus_req_info() to allow dts overwrite bus request
info in GSBUSCFG0. Some platform (such as Layerscape) require correct
setting for dma-coherent. But default value is wrong in chips.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/usb/dwc3/core.c | 33 +++++++++++++++++++++++++++++++++
 drivers/usb/dwc3/core.h |  4 ++++
 2 files changed, 37 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 3b68e8e45b8b9..c72929b122014 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -948,6 +948,37 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc)
 static int dwc3_core_get_phy(struct dwc3 *dwc);
 static int dwc3_core_ulpi_init(struct dwc3 *dwc);
 
+static void dwc3_set_bus_req_info(struct dwc3 *dwc)
+{
+	struct device *dev = dwc->dev;
+	u32 cfg;
+	u8 val;
+
+	cfg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0);
+
+	if (!device_property_read_u8(dev, "snps,des-wr-reqinfo", &val)) {
+		cfg &= ~DWC3_GSBUSCFG0_DESWRREQINFO_MASK;
+		cfg |= FIELD_PREP(DWC3_GSBUSCFG0_DESWRREQINFO_MASK, val);
+	}
+
+	if (!device_property_read_u8(dev, "snps,des-rd-reqinfo", &val)) {
+		cfg &= ~DWC3_GSBUSCFG0_DESRDREQINFO_MASK;
+		cfg |= FIELD_PREP(DWC3_GSBUSCFG0_DESRDREQINFO_MASK, val);
+	}
+
+	if (!device_property_read_u8(dev, "snps,dat-wr-reqinfo", &val)) {
+		cfg &= ~DWC3_GSBUSCFG0_DATWRREQINFO_MASK;
+		cfg |= FIELD_PREP(DWC3_GSBUSCFG0_DATWRREQINFO_MASK, val);
+	}
+
+	if (!device_property_read_u8(dev, "snps,dat-rd-reqinfo", &val)) {
+		cfg &= ~DWC3_GSBUSCFG0_DATRDREQINFO_MASK;
+		cfg |= FIELD_PREP(DWC3_GSBUSCFG0_DATRDREQINFO_MASK, val);
+	}
+
+	dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, cfg);
+}
+
 /* set global incr burst type configuration registers */
 static void dwc3_set_incr_burst_type(struct dwc3 *dwc)
 {
@@ -1256,6 +1287,8 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
 	dwc3_set_incr_burst_type(dwc);
 
+	dwc3_set_bus_req_info(dwc);
+
 	ret = dwc3_phy_power_on(dwc);
 	if (ret)
 		goto err_exit_phy;
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index df544ec730d22..cf64cfc0f208a 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -186,6 +186,10 @@
 #define DWC3_GSBUSCFG0_INCR4BRSTENA	(1 << 1) /* INCR4 burst */
 #define DWC3_GSBUSCFG0_INCRBRSTENA	(1 << 0) /* undefined length enable */
 #define DWC3_GSBUSCFG0_INCRBRST_MASK	0xff
+#define DWC3_GSBUSCFG0_DESWRREQINFO_MASK	GENMASK(19, 16)
+#define DWC3_GSBUSCFG0_DATWRREQINFO_MASK	GENMASK(23, 20)
+#define DWC3_GSBUSCFG0_DESRDREQINFO_MASK	GENMASK(27, 24)
+#define DWC3_GSBUSCFG0_DATRDREQINFO_MASK	GENMASK(31, 28)
 
 /* Global Debug LSP MUX Select */
 #define DWC3_GDBGLSPMUX_ENDBC		BIT(15)	/* Host only */
-- 
2.34.1


  reply	other threads:[~2024-01-23 17:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23 17:02 [PATCH 1/2] dt-bindings: usb: dwc3: Add system bus request info Frank Li
2024-01-23 17:02 ` Frank Li [this message]
2024-01-23 17:27 ` Conor Dooley
2024-01-23 17:49   ` Frank Li
2024-01-23 17:51     ` Conor Dooley
2024-01-23 18:02       ` Frank Li
2024-01-23 18:42         ` Conor Dooley
2024-01-23 19:22           ` Frank Li
2024-01-23 21:46             ` Krzysztof Kozlowski
2024-01-23 22:23               ` Frank Li
2024-01-29 15:19                 ` Frank Li
2024-01-29 16:49                   ` Conor Dooley
2024-01-29 17:41                     ` Frank Li
2024-01-30  7:40                       ` Krzysztof Kozlowski
2024-01-30 15:20                         ` Frank Li
2024-01-30 16:10                           ` Krzysztof Kozlowski
2024-02-08 21:20                             ` Frank Li
2024-02-09  7:31                               ` Krzysztof Kozlowski
2024-01-23 18:37 ` Rob Herring

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=20240123170206.3702413-2-Frank.Li@nxp.com \
    --to=frank.li@nxp.com \
    --cc=balbi@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=imx@lists.linux.dev \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathias.nyman@intel.com \
    --cc=pku.leo@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=thinh.nguyen@synopsys.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.