summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorKongyang Liu <[email protected]>2025-01-10 21:55:22 +0800
committerMattijs Korpershoek <[email protected]>2025-06-02 09:57:25 +0200
commitbd6ef5097dd6c6219f12c0f2866ee4d578f190e9 (patch)
treeb31d81880ae35bc6617857b02bcab749f7377f02 /drivers
parent94a1f8fe47e26250dd5704b2c2187622522eca6b (diff)
usb: dwc2: Fix HBstLen setting for external DMA mode
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 <[email protected]> Reviewed-by: Marek Vasut <[email protected]> Tested-by: Peter Robinson <[email protected]> Reviewed-by: Mattijs Korpershoek <[email protected]> Signed-off-by: Junhui Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mattijs Korpershoek <[email protected]>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/host/dwc2.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index 609de18faa3..954650d856a 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -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;