Linux USB
 help / color / mirror / Atom feed
From: Linus Walleij <linusw@kernel.org>
To: Alan Stern <stern@rowland.harvard.edu>,
	 Daniel Palmer <daniel@thingy.jp>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Philipp Zabel <p.zabel@pengutronix.de>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Linus Walleij <linusw@kernel.org>
Subject: [PATCH v3 2/6] usb: ehci: add port reset hooks
Date: Thu, 03 Sep 2026 23:17:39 +0200	[thread overview]
Message-ID: <20260903-gemini-usb-fotg2-v3-2-dd92ecf5675b@kernel.org> (raw)
In-Reply-To: <20260903-gemini-usb-fotg2-v3-0-dd92ecf5675b@kernel.org>

Some EHCI implementations need controller-specific sequencing around
port reset.

Add optional hooks for reset preparation and completion. Controllers
without the hooks retain the existing behavior.

Gate the callbacks behind the hidden USB_EHCI_PORT_RESET_HOOKS option
so controllers using standard reset sequencing incur no extra state or
runtime checks.

Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Suggested-by: Daniel Palmer <daniel@thingy.jp>
Assisted-by: LLM
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
 drivers/usb/host/Kconfig    |  4 ++++
 drivers/usb/host/ehci-hub.c | 16 ++++++++++++++++
 drivers/usb/host/ehci.h     |  6 ++++++
 3 files changed, 26 insertions(+)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index af4fc14b8783..a0c66191d03c 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -215,6 +215,10 @@ config USB_EHCI_DEVIANT_PORT_STATUS_REG
 	bool
 	# Used for hosts with a deviant port status register location
 
+config USB_EHCI_PORT_RESET_HOOKS
+	bool
+	# Used for hosts with controller-specific port reset sequencing
+
 config XPS_USB_HCD_XILINX
 	bool "Use Xilinx usb host EHCI controller core"
 	depends on (PPC32 || MICROBLAZE)
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 77d0df41f45f..5aa629a92542 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -963,6 +963,13 @@ int ehci_hub_control(
 			/* see what we found out */
 			temp = check_reset_complete (ehci, wIndex, status_reg,
 					ehci_readl(ehci, status_reg));
+#ifdef CONFIG_USB_EHCI_PORT_RESET_HOOKS
+			if (ehci->post_port_reset) {
+				retval = ehci->post_port_reset(ehci, wIndex);
+				if (retval)
+					goto error_exit;
+			}
+#endif
 		}
 
 		/* transfer dedicated ports to the companion hc */
@@ -1121,7 +1128,16 @@ int ehci_hub_control(
 				 */
 				if (ehci_has_fsl_hs_errata(ehci))
 					temp |= (1 << PORTSC_FSL_PFSC);
+
+#ifdef CONFIG_USB_EHCI_PORT_RESET_HOOKS
+				if (ehci->pre_port_reset) {
+					retval = ehci->pre_port_reset(ehci, wIndex);
+					if (retval)
+						goto error_exit;
+				}
+#endif
 			}
+
 			ehci_writel(ehci, temp, status_reg);
 			break;
 
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index a65fba092e76..d7e4cd6dc0a3 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -126,6 +126,12 @@ struct ehci_hcd {			/* one per controller */
 #ifdef CONFIG_USB_EHCI_DEVIANT_PORT_STATUS_REG
 	u32 __iomem		*port_status;
 #endif
+#ifdef CONFIG_USB_EHCI_PORT_RESET_HOOKS
+	int			(*pre_port_reset)(struct ehci_hcd *ehci,
+						  unsigned int port);
+	int			(*post_port_reset)(struct ehci_hcd *ehci,
+						   unsigned int port);
+#endif
 
 	__u32			hcs_params;	/* cached register copy */
 	spinlock_t		lock;

-- 
2.55.0


  parent reply	other threads:[~2026-09-03 21:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 21:17 [PATCH v3 0/6] Modernize the Faraday FOTG210 driver Linus Walleij
2026-09-03 21:17 ` [PATCH v3 1/6] usb: ehci: support non-standard port status registers Linus Walleij
2026-09-03 21:17 ` Linus Walleij [this message]
2026-09-03 21:17 ` [PATCH v3 3/6] usb: ehci: add port speed hook Linus Walleij
2026-09-03 21:17 ` [PATCH v3 4/6] usb: ehci: support additional controller quirks Linus Walleij
2026-09-03 21:17 ` [PATCH v3 5/6] usb: fotg210: use the common EHCI core Linus Walleij
2026-09-03 21:17 ` [PATCH v3 6/6] usb: fotg210-udc: fix endpoint and resource handling Linus Walleij

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=20260903-gemini-usb-fotg2-v3-2-dd92ecf5675b@kernel.org \
    --to=linusw@kernel.org \
    --cc=daniel@thingy.jp \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=stern@rowland.harvard.edu \
    /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