From patchwork Fri Aug 23 15:50:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 19488 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0B85A248E6 for ; Fri, 23 Aug 2013 15:54:33 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id e13sf601785vbg.4 for ; Fri, 23 Aug 2013 08:54:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=bHOvF/wmifLoAfO/cUoriZ2DFmyoue6+bTc3vmbd0EU=; b=NctV4uktxiyrEAxgtK2tWjUCBF564Z67VZd4hh7nQCZnVcazsX3C7XsgCnsMRRwpBt xyoX/pgyCgurxSwaqUg3O+JPNfU/SQ44slyuTRmBYVkX64mmfiR7KfZJqeOuZYmHIyf1 BxawGf9Am5i7DefQAjVwWDCZjEo9uVNx3lTF68FiHP8sqw0SkJ02ORkGRFSJk/9vyWiL LQYNwj0XvppRuzVbrYnLQCof9WiXqfm1fp+ZTR+N1a+Opp36u/Wsncbwd0Wb01FPRRCD 3HNpjEkyvTyq+UR/Lr5c43JoDBiy/B/JnC9D5RI486PZCt62NGCdeN25ndcpYLVU3sfu qBiQ== X-Received: by 10.224.74.72 with SMTP id t8mr17240129qaj.4.1377273272816; Fri, 23 Aug 2013 08:54:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.29.129 with SMTP id k1ls1749175qeh.75.gmail; Fri, 23 Aug 2013 08:54:32 -0700 (PDT) X-Received: by 10.58.249.136 with SMTP id yu8mr138707vec.37.1377273272732; Fri, 23 Aug 2013 08:54:32 -0700 (PDT) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id h13si142112vco.11.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 08:54:32 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id oz10so566235veb.17 for ; Fri, 23 Aug 2013 08:54:32 -0700 (PDT) X-Gm-Message-State: ALoCoQkceR76OBtZ/WyvtiGDHeJXpxTPVhj+zWArFxtYdS1HGHD1LAWTpwZH8JZI8Zj2hXEaXw84 X-Received: by 10.220.76.201 with SMTP id d9mr131229vck.49.1377273272624; Fri, 23 Aug 2013 08:54:32 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp100759vcz; Fri, 23 Aug 2013 08:54:32 -0700 (PDT) X-Received: by 10.68.52.200 with SMTP id v8mr478608pbo.48.1377273271497; Fri, 23 Aug 2013 08:54:31 -0700 (PDT) Received: from mail-pd0-f172.google.com (mail-pd0-f172.google.com [209.85.192.172]) by mx.google.com with ESMTPS id dw1si222278pbc.246.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 08:54:31 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.172 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.172; Received: by mail-pd0-f172.google.com with SMTP id z10so831714pdj.31 for ; Fri, 23 Aug 2013 08:54:31 -0700 (PDT) X-Received: by 10.68.98.36 with SMTP id ef4mr508661pbb.27.1377273270975; Fri, 23 Aug 2013 08:54:30 -0700 (PDT) Received: from localhost ([122.172.193.46]) by mx.google.com with ESMTPSA id pu5sm1831588pac.21.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 23 Aug 2013 08:54:29 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar , Kukjin Kim Subject: [PATCH 12/16] cpufreq: s3c: use cpufreq_generic_get() routine Date: Fri, 23 Aug 2013 21:20:47 +0530 Message-Id: <651e5cf5ca16072cd111c15d7853e14ec79c645f.1377272740.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , We have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver. We don't need a global variable to hold clock anymore. Cc: Kukjin Kim Signed-off-by: Viresh Kumar --- drivers/cpufreq/s3c24xx-cpufreq.c | 10 +++------- drivers/cpufreq/s3c64xx-cpufreq.c | 33 ++++++++++++--------------------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c index 4850882..7be6c2d 100644 --- a/drivers/cpufreq/s3c24xx-cpufreq.c +++ b/drivers/cpufreq/s3c24xx-cpufreq.c @@ -355,11 +355,6 @@ static int s3c_cpufreq_target(struct cpufreq_policy *policy, return -EINVAL; } -static unsigned int s3c_cpufreq_get(unsigned int cpu) -{ - return clk_get_rate(clk_arm) / 1000; -} - struct clk *s3c_cpufreq_clk_get(struct device *dev, const char *name) { struct clk *clk; @@ -373,6 +368,7 @@ struct clk *s3c_cpufreq_clk_get(struct device *dev, const char *name) static int s3c_cpufreq_init(struct cpufreq_policy *policy) { + policy->clk = clk_arm; return cpufreq_generic_init(policy, ftab, cpu_cur.info->latency); } @@ -408,7 +404,7 @@ static int s3c_cpufreq_suspend(struct cpufreq_policy *policy) { suspend_pll.frequency = clk_get_rate(_clk_mpll); suspend_pll.driver_data = __raw_readl(S3C2410_MPLLCON); - suspend_freq = s3c_cpufreq_get(0) * 1000; + suspend_freq = clk_get_rate(clk_arm); return 0; } @@ -450,7 +446,7 @@ static int s3c_cpufreq_resume(struct cpufreq_policy *policy) static struct cpufreq_driver s3c24xx_driver = { .flags = CPUFREQ_STICKY, .target = s3c_cpufreq_target, - .get = s3c_cpufreq_get, + .get = cpufreq_generic_get, .init = s3c_cpufreq_init, .suspend = s3c_cpufreq_suspend, .resume = s3c_cpufreq_resume, diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c index 8b49a06..5b0089a 100644 --- a/drivers/cpufreq/s3c64xx-cpufreq.c +++ b/drivers/cpufreq/s3c64xx-cpufreq.c @@ -19,7 +19,6 @@ #include #include -static struct clk *armclk; static struct regulator *vddarm; static unsigned long regulator_latency; @@ -54,14 +53,6 @@ static struct cpufreq_frequency_table s3c64xx_freq_table[] = { }; #endif -static unsigned int s3c64xx_cpufreq_get_speed(unsigned int cpu) -{ - if (cpu != 0) - return 0; - - return clk_get_rate(armclk) / 1000; -} - static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index) { @@ -69,7 +60,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int old_freq, new_freq; int ret; - old_freq = clk_get_rate(armclk) / 1000; + old_freq = clk_get_rate(policy->clk) / 1000; new_freq = s3c64xx_freq_table[index].frequency; dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[index].driver_data]; @@ -86,7 +77,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy, } #endif - ret = clk_set_rate(armclk, new_freq * 1000); + ret = clk_set_rate(policy->clk, new_freq * 1000); if (ret < 0) { pr_err("Failed to set rate %dkHz: %d\n", new_freq, ret); @@ -101,7 +92,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy, if (ret != 0) { pr_err("Failed to set VDDARM for %dkHz: %d\n", new_freq, ret); - if (clk_set_rate(armclk, old_freq * 1000) < 0) + if (clk_set_rate(policy->clk, old_freq * 1000) < 0) pr_err("Failed to restore original clock rate\n"); return ret; @@ -110,7 +101,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy, #endif pr_debug("Set actual frequency %lukHz\n", - clk_get_rate(armclk) / 1000); + clk_get_rate(policy->clk) / 1000); return 0; } @@ -169,11 +160,11 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy) return -ENODEV; } - armclk = clk_get(NULL, "armclk"); - if (IS_ERR(armclk)) { + policy->clk = clk_get(NULL, "armclk"); + if (IS_ERR(policy->clk)) { pr_err("Unable to obtain ARMCLK: %ld\n", - PTR_ERR(armclk)); - return PTR_ERR(armclk); + PTR_ERR(policy->clk)); + return PTR_ERR(policy->clk); } #ifdef CONFIG_REGULATOR @@ -193,7 +184,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy) unsigned long r; /* Check for frequencies we can generate */ - r = clk_round_rate(armclk, freq->frequency * 1000); + r = clk_round_rate(policy->clk, freq->frequency * 1000); r /= 1000; if (r != freq->frequency) { pr_debug("%dkHz unsupported by clock\n", @@ -203,7 +194,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy) /* If we have no regulator then assume startup * frequency is the maximum we can support. */ - if (!vddarm && freq->frequency > s3c64xx_cpufreq_get_speed(0)) + if (!vddarm && freq->frequency > clk_get_rate(policy->clk) / 1000) freq->frequency = CPUFREQ_ENTRY_INVALID; freq++; @@ -219,7 +210,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy) pr_err("Failed to configure frequency table: %d\n", ret); regulator_put(vddarm); - clk_put(armclk); + clk_put(policy->clk); } return ret; @@ -229,7 +220,7 @@ static struct cpufreq_driver s3c64xx_cpufreq_driver = { .flags = 0, .verify = cpufreq_generic_frequency_table_verify, .target_index = s3c64xx_cpufreq_set_target, - .get = s3c64xx_cpufreq_get_speed, + .get = cpufreq_generic_get, .init = s3c64xx_cpufreq_driver_init, .name = "s3c", };