]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
usb: dwc2: Fix HBstLen setting for external DMA mode
authorKongyang Liu <seashell11234455@gmail.com>
Fri, 10 Jan 2025 13:55:22 +0000 (21:55 +0800)
committerMattijs Korpershoek <mkorpershoek@kernel.org>
Mon, 2 Jun 2025 07:57:25 +0000 (09:57 +0200)
The loop used to calculate HBstLen for extern DMA mode does not produce
the correct result according to the datasheet [1]. Replacing that loop
with a direct calculation using LOG2 to correctly assign the burst length
in the GAHBCFG register for external DMA mode.

[1] https://rockchip.fr/RK312X%20TRM/chapter-26-usb-otg-2-0.pdf#page=24

Signed-off-by: Kongyang Liu <seashell11234455@gmail.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech>
Link: https://lore.kernel.org/r/20250110-dwc2-dev-v4-3-987f4fd6f8b2@pigmoral.tech
Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
drivers/usb/host/dwc2.c

index 609de18faa3abc5f4ecb0c23cf3590966bad7992..954650d856a4f2e95d74e1b5716c0ebe83fa9ba8 100644 (file)
@@ -448,11 +448,8 @@ static void dwc_otg_core_init(struct udevice *dev)
        case DWC2_HWCFG2_ARCHITECTURE_SLAVE_ONLY:
                break;
        case DWC2_HWCFG2_ARCHITECTURE_EXT_DMA:
-               while (brst_sz > 1) {
-                       ahbcfg |= ahbcfg + (1 << DWC2_GAHBCFG_HBURSTLEN_OFFSET);
-                       ahbcfg &= DWC2_GAHBCFG_HBURSTLEN_MASK;
-                       brst_sz >>= 1;
-               }
+               ahbcfg |= (LOG2(brst_sz >> 1) << DWC2_GAHBCFG_HBURSTLEN_OFFSET) &
+                         DWC2_GAHBCFG_HBURSTLEN_MASK;
 
 #ifdef DWC2_DMA_ENABLE
                ahbcfg |= DWC2_GAHBCFG_DMAENABLE;