321-v6.2-mmc-mtk-sd-add-Inline-Crypto-Engine-clock-control.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. From 7b438d0377fbd520b475a68bdd9de1692393f22d Mon Sep 17 00:00:00 2001
  2. From: Mengqi Zhang <[email protected]>
  3. Date: Sun, 6 Nov 2022 11:39:24 +0800
  4. Subject: [PATCH 2/6] mmc: mtk-sd: add Inline Crypto Engine clock control
  5. Add crypto clock control and ungate it before CQHCI init.
  6. Signed-off-by: Mengqi Zhang <[email protected]>
  7. Reviewed-by: AngeloGioacchino Del Regno <[email protected]>
  8. Link: https://lore.kernel.org/r/[email protected]
  9. Signed-off-by: Ulf Hansson <[email protected]>
  10. ---
  11. drivers/mmc/host/mtk-sd.c | 12 ++++++++++++
  12. 1 file changed, 12 insertions(+)
  13. --- a/drivers/mmc/host/mtk-sd.c
  14. +++ b/drivers/mmc/host/mtk-sd.c
  15. @@ -452,6 +452,7 @@ struct msdc_host {
  16. struct clk *bus_clk; /* bus clock which used to access register */
  17. struct clk *src_clk_cg; /* msdc source clock control gate */
  18. struct clk *sys_clk_cg; /* msdc subsys clock control gate */
  19. + struct clk *crypto_clk; /* msdc crypto clock control gate */
  20. struct clk_bulk_data bulk_clks[MSDC_NR_CLOCKS];
  21. u32 mclk; /* mmc subsystem clock frequency */
  22. u32 src_clk_freq; /* source clock frequency */
  23. @@ -840,6 +841,7 @@ static void msdc_set_busy_timeout(struct
  24. static void msdc_gate_clock(struct msdc_host *host)
  25. {
  26. clk_bulk_disable_unprepare(MSDC_NR_CLOCKS, host->bulk_clks);
  27. + clk_disable_unprepare(host->crypto_clk);
  28. clk_disable_unprepare(host->src_clk_cg);
  29. clk_disable_unprepare(host->src_clk);
  30. clk_disable_unprepare(host->bus_clk);
  31. @@ -855,6 +857,7 @@ static int msdc_ungate_clock(struct msdc
  32. clk_prepare_enable(host->bus_clk);
  33. clk_prepare_enable(host->src_clk);
  34. clk_prepare_enable(host->src_clk_cg);
  35. + clk_prepare_enable(host->crypto_clk);
  36. ret = clk_bulk_prepare_enable(MSDC_NR_CLOCKS, host->bulk_clks);
  37. if (ret) {
  38. dev_err(host->dev, "Cannot enable pclk/axi/ahb clock gates\n");
  39. @@ -2670,6 +2673,15 @@ static int msdc_drv_probe(struct platfor
  40. goto host_free;
  41. }
  42. + /* only eMMC has crypto property */
  43. + if (!(mmc->caps2 & MMC_CAP2_NO_MMC)) {
  44. + host->crypto_clk = devm_clk_get_optional(&pdev->dev, "crypto");
  45. + if (IS_ERR(host->crypto_clk))
  46. + host->crypto_clk = NULL;
  47. + else
  48. + mmc->caps2 |= MMC_CAP2_CRYPTO;
  49. + }
  50. +
  51. host->irq = platform_get_irq(pdev, 0);
  52. if (host->irq < 0) {
  53. ret = host->irq;