Message ID | 20181221085622.25573-1-rnayak@codeaurora.org |
---|---|
Headers | show |
Series | Add power domain driver for corners on msm8996/sdm845 | expand |
On Fri, 21 Dec 2018 at 09:57, Rajendra Nayak <rnayak@codeaurora.org> wrote: > > Now that we have atleast 2 genpd providers, both using a simple > routine to read a performance state value from device tree and > return it, in order to implement the .opp_to_performance_state > callback, add a simple_opp_to_performance_state() helper to do > it, so it can be resued across all such genpd providers which > just need to read the value from DT. > > Suggested-by: Stephen Boyd <sboyd@kernel.org> > Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org> > Reviewed-by: Stephen Boyd <swboyd@chromium.org> > --- > drivers/base/power/domain.c | 17 +++++++++++++++++ > include/linux/pm_domain.h | 9 +++++++++ > 2 files changed, 26 insertions(+) > > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c > index 8e554e6a82a2..193872afbe20 100644 > --- a/drivers/base/power/domain.c > +++ b/drivers/base/power/domain.c > @@ -2520,6 +2520,23 @@ int of_genpd_parse_idle_states(struct device_node *dn, > } > EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states); > > +unsigned int simple_opp_to_performance_state(struct generic_pm_domain *genpd, > + struct dev_pm_opp *opp, > + const char *name) > +{ Looks like this function should be moved into the OPP library instead. There is no use of the genpd. > + struct device_node *np; > + unsigned int perf_state = 0; > + > + np = dev_pm_opp_get_of_node(opp); > + if (of_property_read_u32(np, name, &perf_state)) > + pr_err("%s: missing %s property\n", __func__, name); > + > + of_node_put(np); > + > + return perf_state; > +} > +EXPORT_SYMBOL_GPL(simple_opp_to_performance_state); > + Kind regards Uffe
On Fri, 21 Dec 2018 at 09:57, Rajendra Nayak <rnayak@codeaurora.org> wrote: > > Get rid of the duplicate code across rpmpd and rpmhpd to read the > performance state value from Device tree and use the > simple_opp_to_performance_state() helper instead. > > Suggested-by: Stephen Boyd <sboyd@kernel.org> > Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org> > Reviewed-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Kind regards Uffe > --- > drivers/soc/qcom/rpmhpd.c | 11 +---------- > drivers/soc/qcom/rpmpd.c | 11 +---------- > 2 files changed, 2 insertions(+), 20 deletions(-) > > diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c > index e37976e87370..f7fbe57f31ae 100644 > --- a/drivers/soc/qcom/rpmhpd.c > +++ b/drivers/soc/qcom/rpmhpd.c > @@ -276,16 +276,7 @@ static int rpmhpd_set_performance_state(struct generic_pm_domain *domain, > static unsigned int rpmhpd_get_performance_state(struct generic_pm_domain *genpd, > struct dev_pm_opp *opp) > { > - struct device_node *np; > - unsigned int level = 0; > - > - np = dev_pm_opp_get_of_node(opp); > - if (of_property_read_u32(np, "qcom,level", &level)) > - pr_err("%s: missing 'qcom,level' property\n", __func__); > - > - of_node_put(np); > - > - return level; > + return simple_opp_to_performance_state(genpd, opp, "qcom,level"); > } > > static int rpmhpd_update_level_mapping(struct rpmhpd *rpmhpd) > diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c > index 59e21c88a144..29288af502b0 100644 > --- a/drivers/soc/qcom/rpmpd.c > +++ b/drivers/soc/qcom/rpmpd.c > @@ -248,16 +248,7 @@ static int rpmpd_set_performance(struct generic_pm_domain *domain, > static unsigned int rpmpd_get_performance(struct generic_pm_domain *genpd, > struct dev_pm_opp *opp) > { > - struct device_node *np; > - unsigned int corner = 0; > - > - np = dev_pm_opp_get_of_node(opp); > - if (of_property_read_u32(np, "qcom,level", &corner)) > - pr_err("%s: missing 'qcom,level' property\n", __func__); > - > - of_node_put(np); > - > - return corner; > + return simple_opp_to_performance_state(genpd, opp, "qcom,level"); > } > > static int rpmpd_probe(struct platform_device *pdev) > -- > QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member > of Code Aurora Forum, hosted by The Linux Foundation >
On Fri, 21 Dec 2018 at 09:57, Rajendra Nayak <rnayak@codeaurora.org> wrote: > > Specify the active + sleep and active-only MX power domains as > the parents of the corresponding CX power domains. This will ensure that > performance state requests on CX automatically generate equivalent requests > on MX power domains. > > This is used to enforce a requirement that exists for various > hardware blocks on SDM845 that MX performance state >= CX performance > state for a given operating frequency. > > Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org> > Acked-by: Viresh Kumar <viresh.kumar@linaro.org> > Reviewed-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Kind regards Uffe > --- > drivers/soc/qcom/rpmhpd.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c > index f7fbe57f31ae..71d693c31e3b 100644 > --- a/drivers/soc/qcom/rpmhpd.c > +++ b/drivers/soc/qcom/rpmhpd.c > @@ -97,12 +97,14 @@ static struct rpmhpd sdm845_cx_ao; > static struct rpmhpd sdm845_cx = { > .pd = { .name = "cx", }, > .peer = &sdm845_cx_ao, > + .parent = &sdm845_mx.pd, > .res_name = "cx.lvl", > }; > > static struct rpmhpd sdm845_cx_ao = { > .pd = { .name = "cx_ao", }, > .peer = &sdm845_cx, > + .parent = &sdm845_mx_ao.pd, > .res_name = "cx.lvl", > }; > > @@ -372,6 +374,15 @@ static int rpmhpd_probe(struct platform_device *pdev) > data->domains[i] = &rpmhpds[i]->pd; > } > > + /* Add subdomains */ > + for (i = 0; i < num_pds; i++) { > + if (!rpmhpds[i]) > + continue; > + if (rpmhpds[i]->parent) > + pm_genpd_add_subdomain(rpmhpds[i]->parent, > + &rpmhpds[i]->pd); > + } > + > return of_genpd_add_provider_onecell(pdev->dev.of_node, data); > } > > -- > QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member > of Code Aurora Forum, hosted by The Linux Foundation >
On 21-12-18, 14:26, Rajendra Nayak wrote: > +unsigned int simple_opp_to_performance_state(struct generic_pm_domain *genpd, > + struct dev_pm_opp *opp, Maybe name it as: dev_pm_opp_read_u32_prop().