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