122-04-clk-qcom-krait-cc-rework-mux-reset-logic-and-reset-h.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. From 6a77cf3f5f95ec0058e1b4d1ada018748cb0b83b Mon Sep 17 00:00:00 2001
  2. From: Christian Marangi <[email protected]>
  3. Date: Thu, 15 Sep 2022 03:33:13 +0200
  4. Subject: [PATCH 9/9] clk: qcom: krait-cc: rework mux reset logic and reset
  5. hfpll
  6. Rework and clean mux reset logic.
  7. Compact it to a for loop to handle both CPU and L2 in one place.
  8. Move hardcoded aux_rate to define and add a new hfpll_rate value to
  9. reset hfpll settings.
  10. Change logic to now reset the hfpll to the lowest value of 600 Mhz and
  11. then restoring the previous frequency. This permits to reset the hfpll if
  12. the primary mux was set to source out of the secondary mux.
  13. Signed-off-by: Christian Marangi <[email protected]>
  14. ---
  15. drivers/clk/qcom/krait-cc.c | 50 +++++++++++++++++--------------------
  16. 1 file changed, 23 insertions(+), 27 deletions(-)
  17. --- a/drivers/clk/qcom/krait-cc.c
  18. +++ b/drivers/clk/qcom/krait-cc.c
  19. @@ -25,7 +25,9 @@ enum {
  20. clks_max,
  21. };
  22. -#define QSB_RATE 2250000000
  23. +#define QSB_RATE 225000000
  24. +#define AUX_RATE 384000000
  25. +#define HFPLL_RATE 600000000
  26. static unsigned int sec_mux_map[] = {
  27. 2,
  28. @@ -350,7 +352,7 @@ static int krait_cc_probe(struct platfor
  29. {
  30. struct device *dev = &pdev->dev;
  31. const struct of_device_id *id;
  32. - unsigned long cur_rate, aux_rate, qsb_rate;
  33. + unsigned long cur_rate, qsb_rate;
  34. int cpu;
  35. struct clk_hw *mux, *l2_pri_mux;
  36. struct clk *clk, **clks;
  37. @@ -420,28 +422,29 @@ static int krait_cc_probe(struct platfor
  38. * two different rates to force a HFPLL reinit under all
  39. * circumstances.
  40. */
  41. - cur_rate = clk_get_rate(clks[l2_mux]);
  42. - aux_rate = 384000000;
  43. - if (cur_rate < aux_rate) {
  44. - dev_info(dev, "L2 @ Undefined rate. Forcing new rate.\n");
  45. - cur_rate = aux_rate;
  46. - }
  47. - clk_set_rate(clks[l2_mux], aux_rate);
  48. - clk_set_rate(clks[l2_mux], 2);
  49. - clk_set_rate(clks[l2_mux], cur_rate);
  50. - dev_info(dev, "L2 @ %lu KHz\n", clk_get_rate(clks[l2_mux]) / 1000);
  51. - for_each_possible_cpu(cpu) {
  52. + for (cpu = 0; cpu < 5; cpu++) {
  53. + const char *l2_s = "L2";
  54. + char cpu_s[5];
  55. +
  56. clk = clks[cpu];
  57. + if (!clk)
  58. + continue;
  59. +
  60. + if (cpu < 4)
  61. + snprintf(cpu_s, 5, "CPU%d", cpu);
  62. +
  63. cur_rate = clk_get_rate(clk);
  64. - if (cur_rate < aux_rate) {
  65. - dev_info(dev, "CPU%d @ Undefined rate. Forcing new rate.\n", cpu);
  66. - cur_rate = aux_rate;
  67. + if (cur_rate < AUX_RATE) {
  68. + dev_info(dev, "%s @ Undefined rate. Forcing new rate.\n",
  69. + cpu < 4 ? cpu_s : l2_s);
  70. + cur_rate = AUX_RATE;
  71. }
  72. - clk_set_rate(clk, aux_rate);
  73. - clk_set_rate(clk, 2);
  74. + clk_set_rate(clk, AUX_RATE);
  75. + clk_set_rate(clk, HFPLL_RATE);
  76. clk_set_rate(clk, cur_rate);
  77. - dev_info(dev, "CPU%d @ %lu KHz\n", cpu, clk_get_rate(clk) / 1000);
  78. + dev_info(dev, "%s @ %lu KHz\n", cpu < 4 ? cpu_s : l2_s,
  79. + clk_get_rate(clk) / 1000);
  80. }
  81. of_clk_add_provider(dev->of_node, krait_of_get, clks);