From patchwork Thu Aug 28 05:52:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 4792811 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 656AFC0338 for ; Thu, 28 Aug 2014 05:53:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7A2A420145 for ; Thu, 28 Aug 2014 05:53:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E42592016C for ; Thu, 28 Aug 2014 05:53:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934247AbaH1Fx0 (ORCPT ); Thu, 28 Aug 2014 01:53:26 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:64348 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934124AbaH1FxZ (ORCPT ); Thu, 28 Aug 2014 01:53:25 -0400 Received: by mail-pa0-f41.google.com with SMTP id lj1so1140094pab.0 for ; Wed, 27 Aug 2014 22:53:25 -0700 (PDT) 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=ujeyFNplFeu5TKllWD0IpLmbTTUIElnZaxELpTb+7dg=; b=efkqhJOAo1veXh7PbmLq+frPjrOQzQP3z5YBh2SXCDhrikhy3Nntdm/5hD25QTqPkz XfseGMN0lqXPKP0DmgWGGeBDRIC9ISwZayFqEmLRP+GQa9a/biekVDqr2OCaWQ3ikoNy N9CZ027uB4A2uJ4UWMnDatYI8/qqXse+msburx5k9BU2jaEy3RmHKX+mYJ6Lvsv6MlQC U/mgire9BSUudmpj3OWfOVSIGmq6dVnOg8UWAeO2jCUdS2sZqXUV0gnTmoTKtVh9UL68 eC2Ty8WaQjDg5kTYsoB22J4nBedt8zw7RnpE74Ot9W3w/QCTQSQK5jvx9zerdxt4Qz4l hsNA== X-Gm-Message-State: ALoCoQmuefHFYk/qWk6uG/NnJDoXLFVswms6g4Um0EhuFDWfHWJWo9mjSzq6lpUZkCw1/2mDGhte X-Received: by 10.68.131.38 with SMTP id oj6mr2317220pbb.168.1409205205167; Wed, 27 Aug 2014 22:53:25 -0700 (PDT) Received: from localhost ([122.167.123.172]) by mx.google.com with ESMTPSA id d15sm3740846pdj.11.2014.08.27.22.53.23 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 27 Aug 2014 22:53:24 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, shawn.guo@linaro.org, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, spk.linux@gmail.com, thomas.ab@samsung.com, t.figa@samsung.com, santosh.shilimkar@ti.com, thomas.petazzoni@free-electrons.com, pramod.gurav@smartplayin.com, Viresh Kumar Subject: [PATCH V3 08/10] cpufreq: cpu0: Make allocate_resources() work for any CPU Date: Thu, 28 Aug 2014 11:22:30 +0530 Message-Id: <2f01b7a9b7abbdd4539fa27dff84656523bddf19.1409201048.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.0.3.693.g996b0fd In-Reply-To: References: In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently allocate_resources() supports only CPU0 and it would need to allocate resources for any CPU going forward. Add another argument to it, i.e. cpu, and update code accordingly. Tested-by: Stephen Boyd Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq-cpu0.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c index de38952..a5f8c5f 100644 --- a/drivers/cpufreq/cpufreq-cpu0.c +++ b/drivers/cpufreq/cpufreq-cpu0.c @@ -106,7 +106,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, unsigned int index) return ret; } -static int allocate_resources(struct device **cdev, +static int allocate_resources(int cpu, struct device **cdev, struct regulator **creg, struct clk **cclk) { struct device *cpu_dev; @@ -115,24 +115,28 @@ static int allocate_resources(struct device **cdev, int ret = 0; char *reg_cpu0 = "cpu0", *reg_cpu = "cpu", *reg; - cpu_dev = get_cpu_device(0); + cpu_dev = get_cpu_device(cpu); if (!cpu_dev) { - pr_err("failed to get cpu0 device\n"); + pr_err("failed to get cpu%d device\n", cpu); return -ENODEV; } /* Try "cpu0" for older DTs */ - reg = reg_cpu0; + if (!cpu) + reg = reg_cpu0; + else + reg = reg_cpu; try_again: cpu_reg = regulator_get_optional(cpu_dev, reg); if (IS_ERR(cpu_reg)) { /* - * If cpu0 regulator supply node is present, but regulator is + * If cpu's regulator supply node is present, but regulator is * not yet registered, we should try defering probe. */ if (PTR_ERR(cpu_reg) == -EPROBE_DEFER) { - dev_dbg(cpu_dev, "cpu0 regulator not ready, retry\n"); + dev_dbg(cpu_dev, "cpu%d regulator not ready, retry\n", + cpu); return -EPROBE_DEFER; } @@ -142,8 +146,8 @@ static int allocate_resources(struct device **cdev, goto try_again; } - dev_warn(cpu_dev, "failed to get cpu0 regulator: %ld\n", - PTR_ERR(cpu_reg)); + dev_warn(cpu_dev, "failed to get cpu%d regulator: %ld\n", + cpu, PTR_ERR(cpu_reg)); } cpu_clk = clk_get(cpu_dev, NULL); @@ -159,9 +163,10 @@ static int allocate_resources(struct device **cdev, * registered, we should try defering probe. */ if (ret == -EPROBE_DEFER) - dev_dbg(cpu_dev, "cpu0 clock not ready, retry\n"); + dev_dbg(cpu_dev, "cpu%d clock not ready, retry\n", cpu); else - dev_err(cpu_dev, "failed to get cpu0 clock: %d\n", ret); + dev_err(cpu_dev, "failed to get cpu%d clock: %d\n", ret, + cpu); } else { *cdev = cpu_dev; *creg = cpu_reg; @@ -183,8 +188,7 @@ static int cpu0_cpufreq_init(struct cpufreq_policy *policy) unsigned int transition_latency; int ret; - /* We only support cpu0 currently */ - ret = allocate_resources(&cpu_dev, &cpu_reg, &cpu_clk); + ret = allocate_resources(policy->cpu, &cpu_dev, &cpu_reg, &cpu_clk); if (ret) { pr_err("%s: Failed to allocate resources\n: %d", __func__, ret); return ret; @@ -322,7 +326,7 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) * * FIXME: Is checking this only for CPU0 sufficient ? */ - ret = allocate_resources(&cpu_dev, &cpu_reg, &cpu_clk); + ret = allocate_resources(0, &cpu_dev, &cpu_reg, &cpu_clk); if (ret) return ret;