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: 36156 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f71.google.com (mail-oi0-f71.google.com [209.85.218.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 048BD2054F for ; Thu, 28 Aug 2014 05:53:28 +0000 (UTC) Received: by mail-oi0-f71.google.com with SMTP id v63sf5308217oia.2 for ; Wed, 27 Aug 2014 22:53:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=t1lbzQGtgEzKdOr7NWuYD+NB/CpsOQ+Kyt1mrWlLm5c=; b=W1oRfMUTf4fiU4YgERNs7yomShi7xAnyG8P8NIODfezA1Y6z3y83ijUGAiBzE9WVLZ 2/O0OHU6AVQHmAKTr17NmPwJNqvreqq6Oa9bmkYZekTwhTJBEP8cF5H9PSHUn4cUe/hH oxBimAwo7r1Pkk0fLwhUbHf4zHXfIYlu/SUFQpgm/Di42IKw1RXqT7AFxGqZ0wPgpaIb 1qgxDWYoG8baZpy5y9WqjhrqETITBik/LwzzdexfL3GFyBXd41+p8gcQpfDW8DXgUtBz EplCHvVWUIZlfyPCVZl9lDvtdJskzWGS74OW0rhWwHNIvGi1572wleQD/hOorHX+AiyZ +ICQ== X-Gm-Message-State: ALoCoQmDCIydbXTju/tpGwg749USDPadUHFaU9ICBMJLmQKn58Dwllb8/vDuhn4j0iwgnCo2Hanl X-Received: by 10.50.28.68 with SMTP id z4mr1764825igg.2.1409205208586; Wed, 27 Aug 2014 22:53:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.34.99 with SMTP id k90ls442742qgk.78.gmail; Wed, 27 Aug 2014 22:53:28 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr1489282vcn.16.1409205208468; Wed, 27 Aug 2014 22:53:28 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id sl18si2808877vdb.42.2014.08.27.22.53.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 27 Aug 2014 22:53:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so309329vcb.9 for ; Wed, 27 Aug 2014 22:53:28 -0700 (PDT) X-Received: by 10.220.2.136 with SMTP id 8mr1370693vcj.17.1409205208376; Wed, 27 Aug 2014 22:53:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp184470vcb; Wed, 27 Aug 2014 22:53:27 -0700 (PDT) X-Received: by 10.70.94.103 with SMTP id db7mr2403188pdb.122.1409205207510; Wed, 27 Aug 2014 22:53:27 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oz2si4047100pbc.237.2014.08.27.22.53.26 for ; Wed, 27 Aug 2014 22:53:27 -0700 (PDT) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934216AbaH1Fx0 (ORCPT + 15 others); Thu, 28 Aug 2014 01:53:26 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:60703 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933927AbaH1FxZ (ORCPT ); Thu, 28 Aug 2014 01:53:25 -0400 Received: by mail-pa0-f48.google.com with SMTP id ey11so1121794pad.21 for ; Wed, 27 Aug 2014 22:53:25 -0700 (PDT) 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-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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;