Add CONFIG_QCOM_USB_FIXUP option to allow platforms to disable
the USB speed limitation fixup when they have proper super-speed
USB support in U-Boot.

Currently, U-Boot limits USB to high-speed mode on all Qualcomm
platforms by fixing up the device tree at runtime. This was
necessary because most platforms lacked super-speed PHY drivers.

However, newer platforms now have proper QMP PHY drivers that support
super-speed USB. For these platforms, the fixup is counterproductive
as it prevents the hardware from operating at its full capability.

This change:
- Adds CONFIG_QCOM_USB_FIXUP (default y) to maintain backward
  compatibility with existing platforms
- Wraps the fixup code with #ifdef to allow selective disabling
- Allows platforms with super-speed support to disable the fixup
  via their defconfig

Platforms without super-speed PHY drivers will continue to work
as before with the fixup enabled by default.

Signed-off-by: Balaji Selvanathan <[email protected]>
---
 arch/arm/mach-snapdragon/Kconfig    | 10 ++++++++++
 arch/arm/mach-snapdragon/of_fixup.c |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/arch/arm/mach-snapdragon/Kconfig b/arch/arm/mach-snapdragon/Kconfig
index 976c0e35fce..6c53aeef597 100644
--- a/arch/arm/mach-snapdragon/Kconfig
+++ b/arch/arm/mach-snapdragon/Kconfig
@@ -29,6 +29,16 @@ config SYS_MALLOC_LEN
 config LNX_KRNL_IMG_TEXT_OFFSET_BASE
        default 0x80000000
 
+config QCOM_USB_FIXUP
+       bool "Enable USB speed fixup for Qualcomm platforms"
+       default y
+       help
+         Enable runtime fixup of USB device tree nodes to limit USB to
+         high-speed mode. This is needed on some Qualcomm platforms where
+         U-Boot doesn't support super-speed USB.
+         Disable this for platforms that have proper super-speed USB support
+         in U-Boot.
+
 config SYS_BOARD
        string "Snapdragon SoCs based board"
        help
diff --git a/arch/arm/mach-snapdragon/of_fixup.c 
b/arch/arm/mach-snapdragon/of_fixup.c
index eec2c0c757e..6a64168f67e 100644
--- a/arch/arm/mach-snapdragon/of_fixup.c
+++ b/arch/arm/mach-snapdragon/of_fixup.c
@@ -27,6 +27,7 @@
 #include <stdlib.h>
 #include <time.h>
 
+#ifdef CONFIG_QCOM_USB_FIXUP
 /* U-Boot only supports USB high-speed mode on Qualcomm platforms with DWC3
  * USB controllers. Rather than requiring source level DT changes, we fix up
  * DT here. This improves compatibility with upstream DT and simplifies the
@@ -115,6 +116,7 @@ static void fixup_usb_nodes(struct device_node *root)
                        log_warning("Failed to fixup node %s: %d\n", 
glue_np->name, ret);
        }
 }
+#endif
 
 /* Remove all references to the rpmhpd device */
 static void fixup_power_domains(struct device_node *root)
@@ -157,7 +159,9 @@ static int qcom_of_fixup_nodes(void * __maybe_unused ctx, 
struct event *event)
 {
        struct device_node *root = event->data.of_live_built.root;
 
+#ifdef CONFIG_QCOM_USB_FIXUP
        time_call(fixup_usb_nodes, root);
+#endif
        time_call(fixup_power_domains, root);
 
        return 0;
-- 
2.34.1

Reply via email to