diff options
| author | Zixun LI <[email protected]> | 2026-06-27 14:38:35 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-06-27 14:38:35 +0200 |
| commit | ca8a74fa93a597e81ebd869c351f8a3529e01aba (patch) | |
| tree | 53f84d1f05ac8d8ee06bb724e03bbe3f2d478d0a | |
| parent | c1e529fc02eb6e771957077870450abce14c7f0b (diff) | |
| parent | 0ec10636b386b27308c68610916e131c7f6ef570 (diff) | |
Merge pull request #3731 from zjzhang-cn/fix/dwc2-hcd-ls-hfir
fix(dwc2_hcd): correct HFIR for Low-Speed devices via internal FS PHY
| -rw-r--r-- | src/portable/synopsys/dwc2/hcd_dwc2.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/portable/synopsys/dwc2/hcd_dwc2.c b/src/portable/synopsys/dwc2/hcd_dwc2.c index 84a0c6afd..a536b1e36 100644 --- a/src/portable/synopsys/dwc2/hcd_dwc2.c +++ b/src/portable/synopsys/dwc2/hcd_dwc2.c @@ -1410,15 +1410,15 @@ static bool handle_sof_irq(uint8_t rhport, bool in_isr) { // Config HCFG FS/LS clock and HFIR for SOF interval according to link speed (value is in PHY clock unit) // Databook Table 2-2: System Clock Speeds -// +-----------+------------------+----------+-----------+-------------------+ -// | PHY | PHY Clock (MHz) | Width | HCFG.Sel | HFIR (clk cycles) | -// +-----------+------------------+----------+-----------+-------------------+ -// | HS UTMI+ | 30 | 16-bit | 30_60 | HS:3749 FS:29999 | -// | HS UTMI+ | 60 | 8-bit | 30_60 | HS:7499 FS:59999 | -// | HS ULPI | 60 | 8-bit | 30_60 | HS:7499 FS:59999 | +// +------------+------------------+----------+-----------+-------------------+ +// | PHY | PHY Clock (MHz) | Width | HCFG.Sel | HFIR (clk cycles) | +// +------------+------------------+----------+-----------+-------------------+ +// | HS UTMI+ | 30 | 16-bit | 30_60 | HS:3749 FS:29999 | +// | HS UTMI+ | 60 | 8-bit | 30_60 | HS:7499 FS:59999 | +// | HS ULPI | 60 | 8-bit | 30_60 | HS:7499 FS:59999 | // | FS (dead.) | 48 | internal | 48 | FS:47999 | -// | LS via FS | 48 (6 effective) | internal | 6 | LS:47999 | -// +-----------+------------------+----------+-----------+-------------------+ +// | LS via FS | 6 | internal | 6 | LS:5999 | +// +------------+------------------+----------+-----------+-------------------+ // HFIR = (interval_us * phy_clock) - 1, where interval is 125us (HS) or 1000us (FS/LS) static void port0_enable(dwc2_regs_t* dwc2, tusb_speed_t speed) { uint32_t hcfg = dwc2->hcfg & ~HCFG_FSLS_PHYCLK_SEL; @@ -1427,10 +1427,11 @@ static void port0_enable(dwc2_regs_t* dwc2, tusb_speed_t speed) { uint32_t phy_clock; if (gusbcfg.phy_sel == GUSBCFG_PHYSEL_FULLSPEED) { - phy_clock = 48; // dedicated FS is 48Mhz if (speed == TUSB_SPEED_LOW) { + phy_clock = 6; // LS via FS PHY is 6MHz (utmifs_clk48/8) hcfg |= HCFG_FSLS_PHYCLK_SEL_6MHZ; } else { + phy_clock = 48; // FS is 48Mhz (utmifs_clk48) hcfg |= HCFG_FSLS_PHYCLK_SEL_48MHZ; } } else { |
