802-OPP-Provide-old-opp-to-config_clks-on-_set_opp.patch 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. From fd59b838dd90452f61a17dc9e5ff175205003068 Mon Sep 17 00:00:00 2001
  2. From: Christian Marangi <[email protected]>
  3. Date: Thu, 15 Sep 2022 18:49:43 +0200
  4. Subject: [PATCH] OPP: Provide old opp to config_clks on _set_opp
  5. With the target opp, also pass the old opp to config_clks function.
  6. This can be useful when a driver needs to take decision on what fequency
  7. to set based on what is the current frequency without using a
  8. clk_get_freq call.
  9. Update the only user of custom config_clks (tegra30 devfreq driver) to
  10. this new implementation.
  11. Signed-off-by: Christian Marangi <[email protected]>
  12. ---
  13. drivers/devfreq/tegra30-devfreq.c | 5 +++--
  14. drivers/opp/core.c | 11 ++++++-----
  15. include/linux/pm_opp.h | 11 ++++++-----
  16. 3 files changed, 15 insertions(+), 12 deletions(-)
  17. --- a/drivers/devfreq/tegra30-devfreq.c
  18. +++ b/drivers/devfreq/tegra30-devfreq.c
  19. @@ -823,8 +823,9 @@ static int devm_tegra_devfreq_init_hw(st
  20. static int tegra_devfreq_config_clks_nop(struct device *dev,
  21. struct opp_table *opp_table,
  22. - struct dev_pm_opp *opp, void *data,
  23. - bool scaling_down)
  24. + struct dev_pm_opp *old_opp,
  25. + struct dev_pm_opp *opp,
  26. + void *data, bool scaling_down)
  27. {
  28. /* We want to skip clk configuration via dev_pm_opp_set_opp() */
  29. return 0;
  30. --- a/drivers/opp/core.c
  31. +++ b/drivers/opp/core.c
  32. @@ -902,7 +902,8 @@ static int _set_opp_voltage(struct devic
  33. static int
  34. _opp_config_clk_single(struct device *dev, struct opp_table *opp_table,
  35. - struct dev_pm_opp *opp, void *data, bool scaling_down)
  36. + struct dev_pm_opp *old_opp, struct dev_pm_opp *opp,
  37. + void *data, bool scaling_down)
  38. {
  39. unsigned long *target = data;
  40. unsigned long freq;
  41. @@ -934,8 +935,8 @@ _opp_config_clk_single(struct device *de
  42. * the order in which they are present in the array while scaling up.
  43. */
  44. int dev_pm_opp_config_clks_simple(struct device *dev,
  45. - struct opp_table *opp_table, struct dev_pm_opp *opp, void *data,
  46. - bool scaling_down)
  47. + struct opp_table *opp_table, struct dev_pm_opp *old_opp,
  48. + struct dev_pm_opp *opp, void *data, bool scaling_down)
  49. {
  50. int ret, i;
  51. @@ -1217,7 +1218,7 @@ static int _set_opp(struct device *dev,
  52. }
  53. if (opp_table->config_clks) {
  54. - ret = opp_table->config_clks(dev, opp_table, opp, clk_data, scaling_down);
  55. + ret = opp_table->config_clks(dev, opp_table, old_opp, opp, clk_data, scaling_down);
  56. if (ret)
  57. return ret;
  58. }
  59. @@ -1292,7 +1293,7 @@ int dev_pm_opp_set_rate(struct device *d
  60. * equivalent to a clk_set_rate()
  61. */
  62. if (!_get_opp_count(opp_table)) {
  63. - ret = opp_table->config_clks(dev, opp_table, NULL,
  64. + ret = opp_table->config_clks(dev, opp_table, NULL, NULL,
  65. &target_freq, false);
  66. goto put_opp_table;
  67. }
  68. --- a/include/linux/pm_opp.h
  69. +++ b/include/linux/pm_opp.h
  70. @@ -61,7 +61,8 @@ typedef int (*config_regulators_t)(struc
  71. struct dev_pm_opp *old_opp, struct dev_pm_opp *new_opp,
  72. struct regulator **regulators, unsigned int count);
  73. -typedef int (*config_clks_t)(struct device *dev, struct opp_table *opp_table,
  74. +typedef int (*config_clks_t)(struct device *dev,
  75. + struct opp_table *opp_table, struct dev_pm_opp *old_opp,
  76. struct dev_pm_opp *opp, void *data, bool scaling_down);
  77. /**
  78. @@ -172,8 +173,8 @@ int dev_pm_opp_set_config(struct device
  79. int devm_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config);
  80. void dev_pm_opp_clear_config(int token);
  81. int dev_pm_opp_config_clks_simple(struct device *dev,
  82. - struct opp_table *opp_table, struct dev_pm_opp *opp, void *data,
  83. - bool scaling_down);
  84. + struct opp_table *opp_table, struct dev_pm_opp *old_opp,
  85. + struct dev_pm_opp *opp, void *data, bool scaling_down);
  86. struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, struct opp_table *dst_table, struct dev_pm_opp *src_opp);
  87. int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate);
  88. @@ -377,8 +378,8 @@ static inline int devm_pm_opp_set_config
  89. static inline void dev_pm_opp_clear_config(int token) {}
  90. static inline int dev_pm_opp_config_clks_simple(struct device *dev,
  91. - struct opp_table *opp_table, struct dev_pm_opp *opp, void *data,
  92. - bool scaling_down)
  93. + struct opp_table *opp_table, struct dev_pm_opp *old_opp,
  94. + struct dev_pm_opp *opp, void *data, bool scaling_down)
  95. {
  96. return -EOPNOTSUPP;
  97. }