From: Daniel Palmer <daniel@thingy.jp>
To: peter.chen@kernel.org, gregkh@linuxfoundation.org,
stern@rowland.harvard.edu
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Daniel Palmer <daniel@0x0f.com>
Subject: [RFC PATCH 1/2] usb: ehci: Add option to override ehci_readl()/ehci_writel()
Date: Mon, 13 Jul 2026 21:22:04 +0900 [thread overview]
Message-ID: <20260713122205.1350933-2-daniel@thingy.jp> (raw)
In-Reply-To: <20260713122205.1350933-1-daniel@thingy.jp>
From: Daniel Palmer <daniel@0x0f.com>
There are EHCI-like hosts, like fotg210, out there that should
be able to use the shared ehci code but can't because they need
to override some parts of the ehci code to work properly.
Let ehci_readl() and ehci_writel() be overridden first.
This allows the ehci code to be used with hosts that need
to do special dances when accessing their registers.
The change is hidden behind a boolean kconfig option
so that the extra function pointer NULL check and call
only happens when a broken controller is enabled.
Signed-off-by: Daniel Palmer <daniel@0x0f.com>
---
drivers/usb/host/Kconfig | 3 +++
drivers/usb/host/ehci.h | 16 ++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index b3b1ec696bf5..8c88354e91e5 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -362,6 +362,9 @@ config USB_OCTEON_EHCI
USB 2.0 device support. All CN6XXX based chips with USB are
supported.
+config HAVE_BROKEN_EHCI_HCD
+ bool
+
endif # USB_EHCI_HCD
config USB_OXU210HP_HCD
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index d7a3c8d13f6b..f592cc26e494 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -258,6 +258,14 @@ struct ehci_hcd { /* one per controller */
/* us budgeted per uframe */
struct list_head tt_list;
+#ifdef CONFIG_HAVE_BROKEN_EHCI_HCD
+ /* Overrides to fix up broken implementations */
+ /* Broken IO */
+ void (*ehci_writel)(const struct ehci_hcd *ehci,
+ const unsigned int val, __u32 __iomem *regs);
+ unsigned int (*ehci_readl)(const struct ehci_hcd *ehci, __u32 __iomem *regs);
+#endif
+
/* platform-specific data -- must come last */
unsigned long priv[] __aligned(sizeof(s64));
};
@@ -762,6 +770,10 @@ static inline unsigned int ehci_readl(const struct ehci_hcd *ehci,
readl_be(regs) :
readl(regs);
#else
+#ifdef CONFIG_HAVE_BROKEN_EHCI_HCD
+ if (ehci->ehci_readl)
+ return ehci->ehci_readl(ehci, regs);
+#endif
return readl(regs);
#endif
}
@@ -788,6 +800,10 @@ static inline void ehci_writel(const struct ehci_hcd *ehci,
#else
if (ehci->imx28_write_fix)
imx28_ehci_writel(val, regs);
+#ifdef CONFIG_HAVE_BROKEN_EHCI_HCD
+ else if (ehci->ehci_writel)
+ ehci->ehci_writel(ehci, val, regs);
+#endif
else
writel(val, regs);
#endif
--
2.53.0
next prev parent reply other threads:[~2026-07-13 12:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 12:22 [RFC PATCH 0/2] usb: ehci: Allow ehci accessors to be overridden Daniel Palmer
2026-07-13 12:22 ` Daniel Palmer [this message]
2026-07-13 14:21 ` [RFC PATCH 1/2] usb: ehci: Add option to override ehci_readl()/ehci_writel() Alan Stern
2026-07-13 14:37 ` Daniel Palmer
2026-07-13 14:45 ` Alan Stern
2026-07-13 15:07 ` Daniel Palmer
2026-07-13 16:18 ` Alan Stern
2026-07-13 12:22 ` [RFC PATCH 2/2] usb: chipidea: use the generic ehci_writel override for i.MX28 Daniel Palmer
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=20260713122205.1350933-2-daniel@thingy.jp \
--to=daniel@thingy.jp \
--cc=daniel@0x0f.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter.chen@kernel.org \
--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