All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anders Roxell <anders.roxell@linaro.org>
To: u-boot@lists.u-boot-project.org
Cc: marek.vasut@mailbox.org, trini@konsulko.com,
	ilias.apalodimas@linaro.org, michal.simek@amd.com, lukma@denx.de,
	alchark@flipper.net, jerome.forissier@arm.com,
	Jens Wiklander <jens.wiklander@linaro.org>,
	Anders Roxell <anders.roxell@linaro.org>,
	Mattijs Korpershoek <mkorpershoek@kernel.org>
Subject: [PATCH v7 50/63] usb: dwc3: import from kernel v6.5
Date: Mon, 24 Aug 2026 17:27:21 +0200	[thread overview]
Message-ID: <20260824152734.159794-51-anders.roxell@linaro.org> (raw)
In-Reply-To: <20260824152734.159794-1-anders.roxell@linaro.org>

From: Jens Wiklander <jens.wiklander@linaro.org>

Sync Linux kernel dwc3 changes from v6.4 to v6.5.

The following files are preserved across the import:
Makefile Kconfig dwc3-meson-g12a.c dwc3-meson-gxl.c dwc3-omap.c
dwc3-uniphier.c dwc3-generic.h dwc3-generic.c dwc3-generic-sti.c
dwc3-layerscape.c ti_usb_phy.c

Skipping unused files:
debugfs.c drd.c dwc3-exynos.c dwc3-haps.c dwc3-imx8mp.c dwc3-keystone.c
dwc3-octeon.c dwc3-of-simple.c dwc3-pci.c dwc3-qcom.c dwc3-qcom-legacy.c
dwc3-rtk.c dwc3-st.c dwc3-xilinx.c host.c trace.c trace.h ulpi.c

Note that this is a raw import and doesn't build.
A fixup commit at the end of the series fixes that.

List of commits: git log --oneline v6.4..v6.5
Commits imported:
3ddaa6a27457 usb: dwc3: Properly handle processing of pending events
734ae15ab95a Revert "usb: dwc3: core: Enable AutoRetry feature in the controller"
e835c0a4e23c usb: dwc3: don't reset device side if dwc3 was configured as host-only
c0aabed9cabe usb: dwc3: gadget: Propagate core init errors to UDC during pullup
b4a4be847184 USB: fix up merge of 6.4-rc4 into usb-next
890258e22117 usb: dwc3-am62: Convert to platform remove callback returning void
0176568702a5 usb: core: Convert to platform remove callback returning void
813f44d57e19 usb: dwc3: gadget: Bail out in pullup if soft reset timeout happens
2f28c3c9c347 usb: dwc3: Add error logs for unknown endpoint events
ec5eb43813a4 usb: dwc3: core: add support for realtek SoCs custom's global register start address

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
---
 drivers/usb/dwc3/core.c      | 37 +++++++++++++++---------------------
 drivers/usb/dwc3/core.h      |  5 ++---
 drivers/usb/dwc3/dwc3-am62.c |  5 ++---
 drivers/usb/dwc3/ep0.c       |  3 +++
 drivers/usb/dwc3/gadget.c    | 22 ++++++++++++++++++---
 5 files changed, 41 insertions(+), 31 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index d68958e151a7..9c6bf054f15d 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -277,9 +277,9 @@ int dwc3_core_soft_reset(struct dwc3 *dwc)
 	/*
 	 * We're resetting only the device side because, if we're in host mode,
 	 * XHCI driver will reset the host block. If dwc3 was configured for
-	 * host-only mode, then we can return early.
+	 * host-only mode or current role is host, then we can return early.
 	 */
-	if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST)
+	if (dwc->dr_mode == USB_DR_MODE_HOST || dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST)
 		return 0;
 
 	reg = dwc3_readl(dwc->regs, DWC3_DCTL);
@@ -1209,22 +1209,6 @@ static int dwc3_core_init(struct dwc3 *dwc)
 		dwc3_writel(dwc->regs, DWC3_GUCTL1, reg);
 	}
 
-	if (dwc->dr_mode == USB_DR_MODE_HOST ||
-	    dwc->dr_mode == USB_DR_MODE_OTG) {
-		reg = dwc3_readl(dwc->regs, DWC3_GUCTL);
-
-		/*
-		 * Enable Auto retry Feature to make the controller operating in
-		 * Host mode on seeing transaction errors(CRC errors or internal
-		 * overrun scenerios) on IN transfers to reply to the device
-		 * with a non-terminating retry ACK (i.e, an ACK transcation
-		 * packet with Retry=1 & Nump != 0)
-		 */
-		reg |= DWC3_GUCTL_HSTINAUTORETRY;
-
-		dwc3_writel(dwc->regs, DWC3_GUCTL, reg);
-	}
-
 	/*
 	 * Must config both number of packets and max burst settings to enable
 	 * RX and/or TX threshold.
@@ -1800,6 +1784,17 @@ static int dwc3_probe(struct platform_device *pdev)
 	dwc_res = *res;
 	dwc_res.start += DWC3_GLOBALS_REGS_START;
 
+	if (dev->of_node) {
+		struct device_node *parent = of_get_parent(dev->of_node);
+
+		if (of_device_is_compatible(parent, "realtek,rtd-dwc3")) {
+			dwc_res.start -= DWC3_GLOBALS_REGS_START;
+			dwc_res.start += DWC3_RTK_RTD_GLOBALS_REGS_START;
+		}
+
+		of_node_put(parent);
+	}
+
 	regs = devm_ioremap_resource(dev, &dwc_res);
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
@@ -1913,7 +1908,7 @@ err_put_psy:
 	return ret;
 }
 
-static int dwc3_remove(struct platform_device *pdev)
+static void dwc3_remove(struct platform_device *pdev)
 {
 	struct dwc3	*dwc = platform_get_drvdata(pdev);
 
@@ -1940,8 +1935,6 @@ static int dwc3_remove(struct platform_device *pdev)
 
 	if (dwc->usb_psy)
 		power_supply_put(dwc->usb_psy);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM
@@ -2252,7 +2245,7 @@ MODULE_DEVICE_TABLE(acpi, dwc3_acpi_match);
 
 static struct platform_driver dwc3_driver = {
 	.probe		= dwc3_probe,
-	.remove		= dwc3_remove,
+	.remove_new	= dwc3_remove,
 	.driver		= {
 		.name	= "dwc3",
 		.of_match_table	= of_match_ptr(of_dwc3_match),
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 1f043c31a096..a69ac67d89fe 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -84,6 +84,8 @@
 #define DWC3_OTG_REGS_START		0xcc00
 #define DWC3_OTG_REGS_END		0xccff
 
+#define DWC3_RTK_RTD_GLOBALS_REGS_START	0x8100
+
 /* Global Registers */
 #define DWC3_GSBUSCFG0		0xc100
 #define DWC3_GSBUSCFG1		0xc104
@@ -254,9 +256,6 @@
 #define DWC3_GCTL_GBLHIBERNATIONEN	BIT(1)
 #define DWC3_GCTL_DSBLCLKGTNG		BIT(0)
 
-/* Global User Control Register */
-#define DWC3_GUCTL_HSTINAUTORETRY	BIT(14)
-
 /* Global User Control 1 Register */
 #define DWC3_GUCTL1_DEV_DECOUPLE_L1L2_EVT	BIT(31)
 #define DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS	BIT(28)
diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c
index cda9458c809b..1755f2f848c5 100644
--- a/drivers/usb/dwc3/dwc3-am62.c
+++ b/drivers/usb/dwc3/dwc3-am62.c
@@ -275,7 +275,7 @@ static int dwc3_ti_remove_core(struct device *dev, void *c)
 	return 0;
 }
 
-static int dwc3_ti_remove(struct platform_device *pdev)
+static void dwc3_ti_remove(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct dwc3_data *data = platform_get_drvdata(pdev);
@@ -294,7 +294,6 @@ static int dwc3_ti_remove(struct platform_device *pdev)
 	pm_runtime_set_suspended(dev);
 
 	platform_set_drvdata(pdev, NULL);
-	return 0;
 }
 
 #ifdef CONFIG_PM
@@ -362,7 +361,7 @@ MODULE_DEVICE_TABLE(of, dwc3_ti_of_match);
 
 static struct platform_driver dwc3_ti_driver = {
 	.probe		= dwc3_ti_probe,
-	.remove		= dwc3_ti_remove,
+	.remove_new	= dwc3_ti_remove,
 	.driver		= {
 		.name	= "dwc3-am62",
 		.pm	= DEV_PM_OPS,
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 953b752a5052..b94243237293 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -1207,5 +1207,8 @@ void dwc3_ep0_interrupt(struct dwc3 *dwc,
 			dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
 		}
 		break;
+	default:
+		dev_err(dwc->dev, "unknown endpoint event %d\n", event->endpoint_event);
+		break;
 	}
 }
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index b78599dd705c..858fe4c299b7 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2703,13 +2703,17 @@ static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc)
 
 static int dwc3_gadget_soft_connect(struct dwc3 *dwc)
 {
+	int ret;
+
 	/*
 	 * In the Synopsys DWC_usb31 1.90a programming guide section
 	 * 4.1.9, it specifies that for a reconnect after a
 	 * device-initiated disconnect requires a core soft reset
 	 * (DCTL.CSftRst) before enabling the run/stop bit.
 	 */
-	dwc3_core_soft_reset(dwc);
+	ret = dwc3_core_soft_reset(dwc);
+	if (ret)
+		return ret;
 
 	dwc3_event_buffers_setup(dwc);
 	__dwc3_gadget_start(dwc);
@@ -2744,7 +2748,9 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
 	ret = pm_runtime_get_sync(dwc->dev);
 	if (!ret || ret < 0) {
 		pm_runtime_put(dwc->dev);
-		return 0;
+		if (ret < 0)
+			pm_runtime_set_suspended(dwc->dev);
+		return ret;
 	}
 
 	if (dwc->pullups_connected == is_on) {
@@ -3809,6 +3815,9 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
 		break;
 	case DWC3_DEPEVT_RXTXFIFOEVT:
 		break;
+	default:
+		dev_err(dwc->dev, "unknown endpoint event %d\n", event->endpoint_event);
+		break;
 	}
 }
 
@@ -4446,9 +4455,14 @@ static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
 	u32 count;
 
 	if (pm_runtime_suspended(dwc->dev)) {
+		dwc->pending_events = true;
+		/*
+		 * Trigger runtime resume. The get() function will be balanced
+		 * after processing the pending events in dwc3_process_pending
+		 * events().
+		 */
 		pm_runtime_get(dwc->dev);
 		disable_irq_nosync(dwc->irq_gadget);
-		dwc->pending_events = true;
 		return IRQ_HANDLED;
 	}
 
@@ -4709,6 +4723,8 @@ void dwc3_gadget_process_pending_events(struct dwc3 *dwc)
 {
 	if (dwc->pending_events) {
 		dwc3_interrupt(dwc->irq_gadget, dwc->ev_buf);
+		dwc3_thread_interrupt(dwc->irq_gadget, dwc->ev_buf);
+		pm_runtime_put(dwc->dev);
 		dwc->pending_events = false;
 		enable_irq(dwc->irq_gadget);
 	}
-- 
2.53.0


  parent reply	other threads:[~2026-08-24 16:45 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 15:26 [PATCH v7 00/63] usb: dwc3: part 1, reset and import from Linux v6.16 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 01/63] usb: host: re-import xhci-ext-caps.h from kernel v6.16 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 02/63] usb: dwc3: restore to original v3.19-rc1 kernel import Anders Roxell
2026-08-24 15:26 ` [PATCH v7 03/63] usb: dwc3: import from kernel v3.19 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 04/63] usb: dwc3: import from kernel v4.0 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 05/63] usb: dwc3: import from kernel v4.1 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 06/63] usb: dwc3: import from kernel v4.2 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 07/63] usb: dwc3: import from kernel v4.3 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 08/63] usb: dwc3: import from kernel v4.4 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 09/63] usb: dwc3: import from kernel v4.5 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 10/63] usb: dwc3: import from kernel v4.6 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 11/63] usb: dwc3: import from kernel v4.7 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 12/63] usb: dwc3: import from kernel v4.8 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 13/63] usb: dwc3: import from kernel v4.9 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 14/63] usb: dwc3: import from kernel v4.10 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 15/63] usb: dwc3: import from kernel v4.11 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 16/63] usb: dwc3: import from kernel v4.12 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 17/63] usb: dwc3: import from kernel v4.13 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 18/63] usb: dwc3: import from kernel v4.14 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 19/63] usb: dwc3: import from kernel v4.15 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 20/63] usb: dwc3: import from kernel v4.16 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 21/63] usb: dwc3: import from kernel v4.17 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 22/63] usb: dwc3: import from kernel v4.18 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 23/63] usb: dwc3: import from kernel v4.19 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 24/63] usb: dwc3: import from kernel v4.20 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 25/63] usb: dwc3: import from kernel v5.0 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 26/63] usb: dwc3: import from kernel v5.1 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 27/63] usb: dwc3: import from kernel v5.2 Anders Roxell
2026-08-24 15:26 ` [PATCH v7 28/63] usb: dwc3: import from kernel v5.3 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 29/63] usb: dwc3: import from kernel v5.4 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 30/63] usb: dwc3: import from kernel v5.5 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 31/63] usb: dwc3: import from kernel v5.6 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 32/63] usb: dwc3: import from kernel v5.7 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 33/63] usb: dwc3: import from kernel v5.8 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 34/63] usb: dwc3: import from kernel v5.9 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 35/63] usb: dwc3: import from kernel v5.10 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 36/63] usb: dwc3: import from kernel v5.11 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 37/63] usb: dwc3: import from kernel v5.12 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 38/63] usb: dwc3: import from kernel v5.13 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 39/63] usb: dwc3: import from kernel v5.14 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 40/63] usb: dwc3: import from kernel v5.15 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 41/63] usb: dwc3: import from kernel v5.16 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 42/63] usb: dwc3: import from kernel v5.17 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 43/63] usb: dwc3: import from kernel v5.18 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 44/63] usb: dwc3: import from kernel v5.19 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 45/63] usb: dwc3: import from kernel v6.0 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 46/63] usb: dwc3: import from kernel v6.1 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 47/63] usb: dwc3: import from kernel v6.2 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 48/63] usb: dwc3: import from kernel v6.3 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 49/63] usb: dwc3: import from kernel v6.4 Anders Roxell
2026-08-24 15:27 ` Anders Roxell [this message]
2026-08-24 15:27 ` [PATCH v7 51/63] usb: dwc3: import from kernel v6.6 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 52/63] usb: dwc3: import from kernel v6.7 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 53/63] usb: dwc3: import from kernel v6.8 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 54/63] usb: dwc3: import from kernel v6.9 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 55/63] usb: dwc3: import from kernel v6.10 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 56/63] usb: dwc3: import from kernel v6.11 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 57/63] usb: dwc3: import from kernel v6.12 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 58/63] usb: dwc3: import from kernel v6.13 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 59/63] usb: dwc3: import from kernel v6.14 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 60/63] usb: dwc3: import from kernel v6.15 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 61/63] usb: dwc3: import from kernel v6.16 Anders Roxell
2026-08-24 15:27 ` [PATCH v7 62/63] usb: gadget: re-import epautoconf.c " Anders Roxell
2026-08-24 15:27 ` [PATCH v7 63/63] usb: udc: re-import udc-core.c " Anders Roxell
2026-09-11 10:39 ` [PATCH v7 00/63] usb: dwc3: part 1, reset and import from Linux v6.16 Love Kumar

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=20260824152734.159794-51-anders.roxell@linaro.org \
    --to=anders.roxell@linaro.org \
    --cc=alchark@flipper.net \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jens.wiklander@linaro.org \
    --cc=jerome.forissier@arm.com \
    --cc=lukma@denx.de \
    --cc=marek.vasut@mailbox.org \
    --cc=michal.simek@amd.com \
    --cc=mkorpershoek@kernel.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.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 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.