[RFC PATCH 6/9] usb: xhci: Allow accessing 64-bit registers with DWORD accesses only

Sylwester Nawrocki s.nawrocki at samsung.com
Tue Apr 21 18:50:56 CEST 2020


This patch adds a Kconfig option which allows accessing 64-bit xHCI
IO registers only with 2 double word accesses rather than using
a single quad word access. There might be HW configurations where
single quad word access doesn't work, even though the CPU is 64-bit.
That seems to be the case on rpi4 board with Broadcom BCM2711 SoC,
where the VL805 USB xHCI hub is connected to the PCIe controller
behind the SCB bridge.

Signed-off-by: Sylwester Nawrocki <s.nawrocki at samsung.com>
---
So far I couldn't come up with anything better to make the xHCI host
controller working on the rpi4 board. For some reason dereferencing
a 64-bit pointer to access 64-bit registers doesn't work there,
might be a limitation of the PCIe bridge behind the SCB. In Linux
always 2 double word accesses are used.
---
 drivers/usb/host/Kconfig | 7 +++++++
 include/usb/xhci.h       | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 0987ff2..3990b8a 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -15,6 +15,13 @@ config USB_XHCI_HCD
 
 if USB_XHCI_HCD
 
+config XHCI_64BIT_DWORD_ACCESS_ONLY
+	bool "Access xHCI 64-bit registers with double word accesses only"
+	help
+	  Choose this option if your hardware does not support quad word accesses
+	  for registers with 64-bit address pointers.
+	  If unsure, say Y.
+
 config USB_XHCI_DWC3
 	bool "DesignWare USB3 DRD Core Support"
 	help
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 6017504..459e76b 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -1111,7 +1111,7 @@ static inline void xhci_writel(uint32_t volatile *regs, const unsigned int val)
  */
 static inline u64 xhci_readq(__le64 volatile *regs)
 {
-#if BITS_PER_LONG == 64
+#if BITS_PER_LONG == 64 && !defined(CONFIG_XHCI_64BIT_DWORD_ACCESS_ONLY)
 	return readq(regs);
 #else
 	__u32 *ptr = (__u32 *)regs;
@@ -1123,7 +1123,7 @@ static inline u64 xhci_readq(__le64 volatile *regs)
 
 static inline void xhci_writeq(__le64 volatile *regs, const u64 val)
 {
-#if BITS_PER_LONG == 64
+#if BITS_PER_LONG == 64 && !defined(CONFIG_XHCI_64BIT_DWORD_ACCESS_ONLY)
 	writeq(val, regs);
 #else
 	__u32 *ptr = (__u32 *)regs;
-- 
2.7.4



More information about the U-Boot mailing list