Skip to content

Commit 075d3db

Browse files
Rajendra NayakAndy Gross
authored andcommitted
soc: qcom: rpmpd: Add support for get/set performance state
Add support for the .set_performace_state() and .opp_to_performance_state() callbacks in the rpmpd driver. Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Andy Gross <andy.gross@linaro.org>
1 parent bbe3a66 commit 075d3db

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎drivers/soc/qcom/rpmpd.c‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/of.h>
1111
#include <linux/of_device.h>
1212
#include <linux/platform_device.h>
13+
#include <linux/pm_opp.h>
1314
#include <linux/soc/qcom/smd-rpm.h>
1415

1516
#include <dt-bindings/mfd/qcom-rpm.h>
@@ -26,6 +27,8 @@
2627
#define KEY_ENABLE 0x6e657773 /* swen */
2728
#define KEY_FLOOR_CORNER 0x636676 /* vfc */
2829

30+
#define MAX_RPMPD_STATE 6
31+
2932
#define DEFINE_RPMPD_CORNER_SMPA(_platform, _name, _active, r_id) \
3033
static struct rpmpd _platform##_##_active; \
3134
static struct rpmpd _platform##_##_name = { \
@@ -218,6 +221,36 @@ static int rpmpd_power_off(struct generic_pm_domain *domain)
218221
return ret;
219222
}
220223

224+
static int rpmpd_set_performance(struct generic_pm_domain *domain,
225+
unsigned int state)
226+
{
227+
int ret = 0;
228+
struct rpmpd *pd = domain_to_rpmpd(domain);
229+
230+
if (state > MAX_RPMPD_STATE)
231+
goto out;
232+
233+
mutex_lock(&rpmpd_lock);
234+
235+
pd->corner = state;
236+
237+
if (!pd->enabled && pd->key != KEY_FLOOR_CORNER)
238+
goto out;
239+
240+
ret = rpmpd_aggregate_corner(pd);
241+
242+
out:
243+
mutex_unlock(&rpmpd_lock);
244+
245+
return ret;
246+
}
247+
248+
static unsigned int rpmpd_get_performance(struct generic_pm_domain *genpd,
249+
struct dev_pm_opp *opp)
250+
{
251+
return dev_pm_opp_get_level(opp);
252+
}
253+
221254
static int rpmpd_probe(struct platform_device *pdev)
222255
{
223256
int i;
@@ -258,6 +291,8 @@ static int rpmpd_probe(struct platform_device *pdev)
258291
rpmpds[i]->rpm = rpm;
259292
rpmpds[i]->pd.power_off = rpmpd_power_off;
260293
rpmpds[i]->pd.power_on = rpmpd_power_on;
294+
rpmpds[i]->pd.set_performance_state = rpmpd_set_performance;
295+
rpmpds[i]->pd.opp_to_performance_state = rpmpd_get_performance;
261296
pm_genpd_init(&rpmpds[i]->pd, NULL, true);
262297

263298
data->domains[i] = &rpmpds[i]->pd;

0 commit comments

Comments
 (0)