• Axe Yang's avatar
    mmc: mtk-sd: Extend number of tuning steps · d3ddafd3
    Axe Yang authored
    Previously, during the MSDC calibration process, a full clock cycle
    actually not be covered, which in some cases didn't yield the best
    results and could cause CRC errors. This problem is particularly
    evident when MSDC is used as an SDIO host. In fact, MSDC support
    tuning up to a maximum of 64 steps, but by default, the step number
    is 32. By increase the tuning step, we are more likely to cover more
    parts of a clock cycle, and get better calibration result.
    
    To illustrate, when tuning 32 steps, if the obtained window has a hole
    near the middle, like this: 0xffc07ff (hex), then the selected delay
    will be the 6 (counting from right to left).
    
    (32 <- 1)
    1111 1111 1100 0000 0000 0111 11(1)1 1111
    
    However, if we tune 64 steps, the window obtained may look like this:
    0xfffffffffffc07ff. The final selected delay will be 44, which is
    safer as it is further away from the hole:
    
    (64 <- 1)
    1111 ... (1)111 1111 1111 1111 1111 1100 0000 0000 0111 1111 1111
    
    In this case, delay 6 selected through 32 steps tuning is obviously
    not optimal, and this delay is closer to the hole, using it would
    easily cause CRC problems.
    
    As per mesaurements taken on mediatek SoC platform, the tuning phase
    will take:
    	eMMC	- 32 steps: ~3ms
    		- 64 steps: ~6ms
    	SDIO	- 32 steps: ~4ms
    		- 64 steos: ~7ms
    Tuning more steps won't prolong boot times by any meaningful amount
    of time, so for SD/SDIO the default tuning steps will be adjust to
    64. But for eMMC, it is still preferred to use 32 steps tuning as
    otherwise there would be performance lose when accessing the RPMB
    partition(requiring retuning each time).
    
    You can configure property "mediatek,tuning-step" in MSDC dts node
    to adjust the step number.
    Signed-off-by: default avatarAxe Yang <axe.yang@mediatek.com>
    Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Link: https://lore.kernel.org/r/20231207063535.29546-3-axe.yang@mediatek.comSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
    d3ddafd3
mtk-sd.c 90.1 KB