From patchwork Tue Dec 22 10:16:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 58854 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3139810lbb; Tue, 22 Dec 2015 02:17:07 -0800 (PST) X-Received: by 10.98.87.216 with SMTP id i85mr34086763pfj.90.1450779427512; Tue, 22 Dec 2015 02:17:07 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sw10si3585212pab.55.2015.12.22.02.17.07; Tue, 22 Dec 2015 02:17:07 -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 S932664AbbLVKRG (ORCPT + 11 others); Tue, 22 Dec 2015 05:17:06 -0500 Received: from mail-pf0-f176.google.com ([209.85.192.176]:34719 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932181AbbLVKRF (ORCPT ); Tue, 22 Dec 2015 05:17:05 -0500 Received: by mail-pf0-f176.google.com with SMTP id u7so57928285pfb.1 for ; Tue, 22 Dec 2015 02:17:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=FKgn88u3JhtpBsiKKstKgA9En7+ESUWJhbMaVGFH+5Y=; b=YFQTjmawFqo91mVNo6ltLSCQYKCvR/DHzRU1Kay+lxQE1jvSNTZE2je0pR1EnqOCkb QFKAGVOgB4TCkNeHt2/Gk13UPYlNypYivQMxXICNFwLrccmMYZbyHGvOowafVh3t0R31 GC4VGgRCZMULk4O5ykXhVhHTri6HuHhYYHOEE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=FKgn88u3JhtpBsiKKstKgA9En7+ESUWJhbMaVGFH+5Y=; b=ZGkJSuflxrGIpFrjjbVC3m8t1P+pN7PJ4P5AoKM7s+MffANyCnGPG9/n+SFW+r0cJu TZROgQDUelEXatZ7kRkwjrAFI/WocF0PiTKZ7ob3DwIKQxjojVIW30S4M9TY9o9GfLib Z41s5fWxYVE0RXO13ZPnomsbvPJUu6ibkYfo3MN9+ED0mD02MW1VLDZ2qKmy/GdsQIxm Zc4cAEBL8InGdWziztZXl2p9NRz72WSajH59zjne3+F0bAuFoQ5p/J+yXwGWlJiKC/Ym 2YkcDptT53y5EBbTyXOq6H2KqLqpE4fiOQ5qNUWjf8DsPe17ETYKnm71DXxgkp9lY1xc T3dw== X-Gm-Message-State: ALoCoQlWrjfvIS2RsDeq+khqV5w3uY1i4m8fxG+b+Dea1d6LGjh/tLpAjA9aC/EhtMdCtQuFh+b63WAzWGerYTq7lkH1yeOYjw== X-Received: by 10.98.18.206 with SMTP id 75mr24689457pfs.91.1450779425032; Tue, 22 Dec 2015 02:17:05 -0800 (PST) Received: from localhost ([122.171.29.67]) by smtp.gmail.com with ESMTPSA id c20sm40260672pfj.47.2015.12.22.02.17.03 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 22 Dec 2015 02:17:04 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Stephen Boyd , nm@ti.com, Viresh Kumar Subject: [PATCH 12/17] cpufreq: dt: Pass regulator name to the OPP core for V1 bindings Date: Tue, 22 Dec 2015 15:46:13 +0530 Message-Id: <981905b802879bff26d839b0aab19ad67a3aa1ff.1450777582.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.0.rc1.186.g94414c4 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org OPP core can handle the regulators by itself, and it allocates the regulator based on device's name. But for older V1 bindings, many DT files have used names like 'cpu-supply' instead of 'cpu0-supply'. The cpufreq-dt driver needs to tell the right name of the regulator in this case to the OPP core. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq-dt.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) -- 2.7.0.rc1.186.g94414c4 -- 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 a6f91da7283e..39df4f1a06d2 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[] = { @@ -118,6 +119,22 @@ 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 + * "cpu-supply", we still need to handle that for backwards compatibility. + */ +static const char *find_supply_name(struct device *dev) +{ + struct regulator *cpu_reg; + + cpu_reg = regulator_get_optional(dev, dev_name(dev)); + if (IS_ERR(cpu_reg)) + return "cpu"; + + regulator_put(cpu_reg); + return NULL; +} + static int allocate_resources(int cpu, struct device **cdev, struct regulator **creg, struct clk **cclk) { @@ -200,6 +217,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; int ret; ret = allocate_resources(policy->cpu, &cpu_dev, &cpu_reg, &cpu_clk); @@ -229,6 +247,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 for v1 bindings. + */ + if (opp_v1) { + name = find_supply_name(cpu_dev); + if (name) { + ret = dev_pm_opp_set_regulator(cpu_dev, name); + if (ret) { + /* + * Regulators aren't compulsory on few + * platforms, don't error out for them. + */ + dev_dbg(cpu_dev, "Failed to set regulator for cpu%d: %d\n", + policy->cpu, ret); + } + } + } + + /* * 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 +310,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 +404,8 @@ static int cpufreq_init(struct cpufreq_policy *policy) kfree(priv); out_free_opp: dev_pm_opp_of_cpumask_remove_table(policy->cpus); + if (opp_v1) + dev_pm_opp_put_regulator(cpu_dev); out_node_put: of_node_put(np); out_put_reg_clk: @@ -383,6 +423,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);