From patchwork Tue Feb 9 04:10:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61488 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1815167lbl; Mon, 8 Feb 2016 20:10:14 -0800 (PST) X-Received: by 10.66.158.169 with SMTP id wv9mr46913002pab.138.1454991014352; Mon, 08 Feb 2016 20:10:14 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t70si51020408pfa.240.2016.02.08.20.10.14; Mon, 08 Feb 2016 20:10:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756102AbcBIEKM (ORCPT + 11 others); Mon, 8 Feb 2016 23:10:12 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:33845 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754495AbcBIEKK (ORCPT ); Mon, 8 Feb 2016 23:10:10 -0500 Received: by mail-pa0-f48.google.com with SMTP id kp3so1172692pab.1 for ; Mon, 08 Feb 2016 20:10:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=jtBrqlTY4Fx+Bx7u+dvzW6F4xwrI1Zlxfh4egnuVyMs=; b=QM9djPgqnm9yIRyO6+UvNgnYfto9beyB8rzd4maUrofKdxIyDxqC4sBfCLKt90683J X6f72WqUnK4LmiarDjDdB9ty+pvKgE8geUmysvAeiMMFHdzlNKOjiKdNAZGO+uiaUF6m usMtHnY0p9QWMfU/AbjecOOipMrKs5OIsTnts= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=jtBrqlTY4Fx+Bx7u+dvzW6F4xwrI1Zlxfh4egnuVyMs=; b=if6LXQjSNRv0GkMhj6i/2cd7V9VwEnL+4x98VzBNflfcP2VtbQYI6Yte0LtLwPL9NM gpIMSmR0nCV69bxQ4kD1/TImRk+7xXaFVSVec9GHh7GmQqs2DDTXQLBaDuCrNEdmGW7m 2If2CkiF/ESy7NDMmwG6jZZ9En6n+Ods83T/+Hv2edHo/qPa7SBI+V5U5gxD3nunRdh0 jLO6DwRZ+26S6kbfNDTbtYDUpqaZAl9f+7UiP/se1fFfi+B5vvxTrqy+GlrJNj9NoCqB WLgSWlwVvwkO+h0doSF5yPiQea4JCPK23iRjS0SIvP0OdCPUrOge1VzsGZIVkV0sXV5g uTcA== X-Gm-Message-State: AG10YORb4dMjPyRbfbgYbIC9BXYZiOL4h1Dy000ureKXKAWG1Nx7py9JJZS452gCtX96iwT+ X-Received: by 10.66.219.164 with SMTP id pp4mr37965077pac.79.1454991010348; Mon, 08 Feb 2016 20:10:10 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id r145sm19244182pfr.59.2016.02.08.20.10.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 20:10:09 -0800 (PST) Date: Tue, 9 Feb 2016 09:40:07 +0530 From: Viresh Kumar To: Stephen Boyd Cc: Rafael Wysocki , linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, nm@ti.com, open list Subject: Re: [PATCH V2 11/16] cpufreq: dt: Pass regulator name to the OPP core Message-ID: <20160209041007.GE10843@vireshk> References: <20160202023418.GK4848@codeaurora.org> <20160202061013.GC31828@vireshk> <20160208225515.GF10791@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160208225515.GF10791@codeaurora.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On 08-02-16, 14:55, Stephen Boyd wrote: > On 02/02, Viresh Kumar wrote: > > static int allocate_resources(int cpu, struct device **cdev, > > struct regulator **creg, struct clk **cclk) > > { > > @@ -200,6 +225,7 @@ static int cpufreq_init(struct cpufreq_policy *policy) > > unsigned long min_uV = ~0, max_uV = 0; > > unsigned int transition_latency; > > bool opp_v1 = false; > > + const char *name = NULL; > > Is this initialization necessary? > > > int ret; > > > > ret = allocate_resources(policy->cpu, &cpu_dev, &cpu_reg, &cpu_clk); > > @@ -229,6 +255,25 @@ static int cpufreq_init(struct cpufreq_policy *policy) > > } > > > > /* > > + * OPP layer will be taking care of regulators now, but it needs to know > > + * the name of the regulator first. > > + */ > > + name = find_supply_name(cpu_dev, np); > > + if (IS_ERR(name)) { > > This looks to never happen? Stupid me :( -------------------------8<------------------------- From: Viresh Kumar Date: Tue, 8 Sep 2015 17:16:46 +0530 Subject: [PATCH] cpufreq: dt: Pass regulator name to the OPP core OPP core can handle the regulators by itself, and but it needs to know the name of the regulator to fetch. Add support for that. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq-dt.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 4c9f8a828f6f..2af75f8088bb 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -34,6 +34,7 @@ struct private_data { struct regulator *cpu_reg; struct thermal_cooling_device *cdev; unsigned int voltage_tolerance; /* in percentage */ + const char *reg_name; }; static struct freq_attr *cpufreq_dt_attr[] = { @@ -119,6 +120,30 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index) return ret; } +/* + * An earlier version of opp-v1 bindings used to name the regulator + * "cpu0-supply", we still need to handle that for backwards compatibility. + */ +static const char *find_supply_name(struct device *dev, struct device_node *np) +{ + struct property *pp; + int cpu = dev->id; + + /* Try "cpu0" for older DTs */ + if (!cpu) { + pp = of_find_property(np, "cpu0-supply", NULL); + if (pp) + return "cpu0"; + } + + pp = of_find_property(np, "cpu-supply", NULL); + if (pp) + return "cpu"; + + dev_dbg(dev, "no regulator for cpu%d\n", cpu); + return NULL; +} + static int allocate_resources(int cpu, struct device **cdev, struct regulator **creg, struct clk **cclk) { @@ -200,6 +225,7 @@ static int cpufreq_init(struct cpufreq_policy *policy) unsigned long min_uV = ~0, max_uV = 0; unsigned int transition_latency; bool opp_v1 = false; + const char *name; int ret; ret = allocate_resources(policy->cpu, &cpu_dev, &cpu_reg, &cpu_clk); @@ -229,6 +255,20 @@ static int cpufreq_init(struct cpufreq_policy *policy) } /* + * OPP layer will be taking care of regulators now, but it needs to know + * the name of the regulator first. + */ + name = find_supply_name(cpu_dev, np); + if (name) { + ret = dev_pm_opp_set_regulator(cpu_dev, name); + if (ret) { + dev_err(cpu_dev, "Failed to set regulator for cpu%d: %d\n", + policy->cpu, ret); + goto out_node_put; + } + } + + /* * Initialize OPP tables for all policy->cpus. They will be shared by * all CPUs which have marked their CPUs shared with OPP bindings. * @@ -273,6 +313,7 @@ static int cpufreq_init(struct cpufreq_policy *policy) goto out_free_opp; } + priv->reg_name = name; of_property_read_u32(np, "voltage-tolerance", &priv->voltage_tolerance); transition_latency = dev_pm_opp_get_max_clock_latency(cpu_dev); @@ -366,6 +407,8 @@ static int cpufreq_init(struct cpufreq_policy *policy) kfree(priv); out_free_opp: dev_pm_opp_of_cpumask_remove_table(policy->cpus); + if (name) + dev_pm_opp_put_regulator(cpu_dev); out_node_put: of_node_put(np); out_put_reg_clk: @@ -383,6 +426,9 @@ static int cpufreq_exit(struct cpufreq_policy *policy) cpufreq_cooling_unregister(priv->cdev); dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); dev_pm_opp_of_cpumask_remove_table(policy->related_cpus); + if (priv->reg_name) + dev_pm_opp_put_regulator(priv->cpu_dev); + clk_put(policy->clk); if (!IS_ERR(priv->cpu_reg)) regulator_put(priv->cpu_reg);