002-v6.4-mmc-sdhci-of-dwcmshc-properly-determine-max-clock-on.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From 49502408007b77ff290ce62e6218cefaeedcb31a Mon Sep 17 00:00:00 2001
  2. From: Vasily Khoruzhick <[email protected]>
  3. Date: Thu, 9 Mar 2023 17:03:49 -0800
  4. Subject: [PATCH] mmc: sdhci-of-dwcmshc: properly determine max clock on
  5. Rockchip
  6. Currently .get_max_clock returns the current clock rate for cclk_emmc
  7. on rk35xx, thus max clock gets set to whatever bootloader set it to.
  8. In case of u-boot, it is intentionally reset to 50 MHz if it boots
  9. from eMMC, see mmc_deinit() in u-boot sources. As a result, HS200 and
  10. HS400 modes are never selected by Linux, because dwcmshc_rk35xx_postinit
  11. clears appropriate caps if host->mmc->f_max is < 52MHz
  12. cclk_emmc is not a fixed clock on rk35xx, so using
  13. sdhci_pltfm_clk_get_max_clock is not appropriate here.
  14. Implement rk35xx_get_max_clock that returns actual max clock for cclk_emmc.
  15. Signed-off-by: Vasily Khoruzhick <[email protected]>
  16. Acked-by: Adrian Hunter <[email protected]>
  17. Link: https://lore.kernel.org/r/[email protected]
  18. Signed-off-by: Ulf Hansson <[email protected]>
  19. ---
  20. drivers/mmc/host/sdhci-of-dwcmshc.c | 9 ++++++++-
  21. 1 file changed, 8 insertions(+), 1 deletion(-)
  22. --- a/drivers/mmc/host/sdhci-of-dwcmshc.c
  23. +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c
  24. @@ -126,6 +126,13 @@ static unsigned int dwcmshc_get_max_cloc
  25. return pltfm_host->clock;
  26. }
  27. +static unsigned int rk35xx_get_max_clock(struct sdhci_host *host)
  28. +{
  29. + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  30. +
  31. + return clk_round_rate(pltfm_host->clk, ULONG_MAX);
  32. +}
  33. +
  34. static void dwcmshc_check_auto_cmd23(struct mmc_host *mmc,
  35. struct mmc_request *mrq)
  36. {
  37. @@ -343,7 +350,7 @@ static const struct sdhci_ops sdhci_dwcm
  38. .set_clock = dwcmshc_rk3568_set_clock,
  39. .set_bus_width = sdhci_set_bus_width,
  40. .set_uhs_signaling = dwcmshc_set_uhs_signaling,
  41. - .get_max_clock = sdhci_pltfm_clk_get_max_clock,
  42. + .get_max_clock = rk35xx_get_max_clock,
  43. .reset = rk35xx_sdhci_reset,
  44. .adma_write_desc = dwcmshc_adma_write_desc,
  45. };