ufs: Add bRefClkFreq attribute setting
authorJared McArthur <j-mcarthur@ti.com>
Fri, 10 Oct 2025 19:55:56 +0000 (14:55 -0500)
committerNeil Armstrong <neil.armstrong@linaro.org>
Tue, 28 Oct 2025 16:12:10 +0000 (17:12 +0100)
commitc7327ac29590952089bf3d8994d0951e58cc2322
tree54b144ed25c9f8f6952ff5a6cd95c6baebf5447c
parentae0872e9c38394be8fcdb38ef391e635d4cf7a22
ufs: Add bRefClkFreq attribute setting

A UFS device needs its bRefClkFreq attribute set to the correct value
before switching to high speed. If bRefClkFreq is set to the wrong
value, all transactions after the power mode change will fail.

The bRefClkFreq depends on the host controller and the device.
Query the device's current bRefClkFreq and compare with the ref_clk
specified in the device-tree. If the two differ, set the bRefClkFreq
to the device-tree's ref_clk frequency.

Taken from Linux kernel v6.17 (drivers/ufs/core/ufshcd.c and
include/ufs/ufs.h) and ported to U-Boot.

Signed-off-by: Jared McArthur <j-mcarthur@ti.com>
Reviewed-by: Bryan Brattlof <bb@ti.com>
Reviewed-by: Udit Kumar <u-kumar1@ti.com>
Reviewed-by: Neha Malcom Francis <n-francis@ti.com>
Link: https://patch.msgid.link/20251010195556.1772611-3-j-mcarthur@ti.com
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
drivers/ufs/ufs.c
drivers/ufs/ufs.h