public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@linux.dev>
To: Marek Vasut <marex@denx.de>, u-boot@lists.denx.de
Cc: Michal Simek <michal.simek@amd.com>,
	Sean Anderson <sean.anderson@linux.dev>
Subject: [PATCH] usb: dwc3: Initialize Xilinx glue registers
Date: Tue,  6 Jan 2026 17:17:28 -0500	[thread overview]
Message-ID: <20260106221728.738219-1-sean.anderson@linux.dev> (raw)

These registers may have been initialized by SPL/FSBL, but program them
in case they have not. If they are left at their default values, the
controller will never exit reset.

Signed-off-by: Sean Anderson <sean.anderson@linux.dev>

---

 drivers/usb/dwc3/dwc3-generic.c | 32 ++++++++++++++++++++++++++------
 drivers/usb/dwc3/dwc3-generic.h |  2 ++
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index c09014aec60..ce896db9532 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -501,6 +501,27 @@ struct dwc3_glue_ops rk_ops = {
 	.glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev,
 };
 
+void dwc3_xlnx_glue_configure(struct udevice *dev, int index,
+			      enum usb_dr_mode mode)
+{
+/* USB glue registers */
+#define USB3_FPD_PIPE_CLK	0x7c
+#define USB3_FPD_POWER_PRSNT	0x80
+	struct dwc3_glue_data *glue = dev_get_plat(dev);
+	void *base = map_physmem(glue->regs, 0x10000, MAP_NOCACHE);
+
+	if (generic_phy_valid(&glue->phy)) {
+		writel(0, base + USB3_FPD_PIPE_CLK);
+		writel(1, base + USB3_FPD_POWER_PRSNT);
+	} else {
+		writel(1, base + USB3_FPD_PIPE_CLK);
+	}
+}
+
+struct dwc3_glue_ops xlnx_ops = {
+	.glue_configure = dwc3_xlnx_glue_configure,
+};
+
 static int dwc3_glue_bind_common(struct udevice *parent, ofnode node)
 {
 	const char *name = ofnode_get_name(node);
@@ -621,11 +642,10 @@ int dwc3_glue_probe(struct udevice *dev)
 	struct udevice *child = NULL;
 	int index = 0;
 	int ret;
-	struct phy phy;
 
-	ret = generic_phy_get_by_name(dev, "usb3-phy", &phy);
+	ret = generic_phy_get_by_name(dev, "usb3-phy", &glue->phy);
 	if (!ret) {
-		ret = generic_phy_init(&phy);
+		ret = generic_phy_init(&glue->phy);
 		if (ret)
 			return ret;
 	} else if (ret != -ENOENT && ret != -ENODATA) {
@@ -643,8 +663,8 @@ int dwc3_glue_probe(struct udevice *dev)
 	if (ret)
 		return ret;
 
-	if (generic_phy_valid(&phy)) {
-		ret = generic_phy_power_on(&phy);
+	if (generic_phy_valid(&glue->phy)) {
+		ret = generic_phy_power_on(&glue->phy);
 		if (ret)
 			return ret;
 	}
@@ -690,7 +710,7 @@ int dwc3_glue_remove(struct udevice *dev)
 }
 
 static const struct udevice_id dwc3_glue_ids[] = {
-	{ .compatible = "xlnx,zynqmp-dwc3" },
+	{ .compatible = "xlnx,zynqmp-dwc3", .data = (ulong)&xlnx_ops },
 	{ .compatible = "xlnx,versal-dwc3" },
 	{ .compatible = "ti,keystone-dwc3"},
 	{ .compatible = "ti,dwc3", .data = (ulong)&ti_ops },
diff --git a/drivers/usb/dwc3/dwc3-generic.h b/drivers/usb/dwc3/dwc3-generic.h
index 40902c8923f..13f6391cae8 100644
--- a/drivers/usb/dwc3/dwc3-generic.h
+++ b/drivers/usb/dwc3/dwc3-generic.h
@@ -10,12 +10,14 @@
 #define __DRIVERS_USB_DWC3_GENERIC_H
 
 #include <clk.h>
+#include <generic-phy.h>
 #include <reset.h>
 #include <dwc3-uboot.h>
 
 struct dwc3_glue_data {
 	struct clk_bulk		clks;
 	struct reset_ctl_bulk	resets;
+	struct phy phy;
 	fdt_addr_t regs;
 	fdt_size_t size;
 };
-- 
2.35.1.1320.gc452695387.dirty

base-commit: beab3fe49e1e9209dd32fe2791e7ac706038460f
branch: dwc3_xlnx_glue

             reply	other threads:[~2026-01-06 22:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-06 22:17 Sean Anderson [this message]
2026-01-16  8:19 ` [PATCH] usb: dwc3: Initialize Xilinx glue registers Michal Simek
2026-01-16 14:07   ` Marek Vasut
2026-01-16 16:14     ` Sean Anderson
2026-01-22 13:25       ` Michal Simek
2026-02-17  8:48         ` Kumar, Love
2026-01-29 10:13       ` Michal Simek
2026-02-17 11:06         ` Michal Simek

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=20260106221728.738219-1-sean.anderson@linux.dev \
    --to=sean.anderson@linux.dev \
    --cc=marex@denx.de \
    --cc=michal.simek@amd.com \
    --cc=u-boot@lists.denx.de \
    /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