From patchwork Fri Sep 13 13:02:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20269 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f71.google.com (mail-vb0-f71.google.com [209.85.212.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1430A20358 for ; Fri, 13 Sep 2013 13:28:39 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id g17sf1211234vbg.2 for ; Fri, 13 Sep 2013 06:28:38 -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 :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=FUv1eu9tgX+qyJoFOlVcSAEjNTOi+LYb49Ad1he5JdE=; b=JX+1fze96WBhRIH3wn38SGQDUHP0a8Q6bjOs+F3bjSBwvKC8T3FRcp1A2QiqVnjrnV vjeJGyHR0hNF7Az/1G9T+oVFcGSjJIOpg0hvXayE88X8HJ3sIJFoBXIsf6n+fNjguJ5w S28UudtJWTp6cTnSiTl+x9UvAm1Ev7oTHQTYt/hGnIxR1BesFxawr45e7huwlV6B/Hqi ruubZuWBToDEvu6kMhi+3l1fvn45t4AjF67GN1z2sGKc5rRZpQjazShSAoLxh05HPIoe AKXvKG5S9iDzfmnai6o+e/4HHzmPo/BCnZHQd1FBoYESSqBBlPsiVJBP4zEmKMZiZT6k 62dQ== X-Gm-Message-State: ALoCoQnSjGzcFbe9j4N2yxD1VoPG2qvEg8g5fvfZ+62lzU6coKpZauubgXX87UentGIx59/Xk3jv X-Received: by 10.236.176.1 with SMTP id a1mr4879759yhm.10.1379078918816; Fri, 13 Sep 2013 06:28:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.3.169 with SMTP id d9ls1208265qed.61.gmail; Fri, 13 Sep 2013 06:28:38 -0700 (PDT) X-Received: by 10.220.10.194 with SMTP id q2mr11883001vcq.2.1379078918607; Fri, 13 Sep 2013 06:28:38 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id t9si3126917vcz.72.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:28:38 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hf12so903779vcb.41 for ; Fri, 13 Sep 2013 06:28:38 -0700 (PDT) X-Received: by 10.58.190.34 with SMTP id gn2mr107021vec.34.1379078918519; Fri, 13 Sep 2013 06:28:38 -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 u4csp80775vcz; Fri, 13 Sep 2013 06:28:37 -0700 (PDT) X-Received: by 10.68.223.161 with SMTP id qv1mr13562201pbc.79.1379078917369; Fri, 13 Sep 2013 06:28:37 -0700 (PDT) Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by mx.google.com with ESMTPS id z1si11221426pab.218.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:28:37 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.48 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.48; Received: by mail-pa0-f48.google.com with SMTP id kp13so2523657pab.21 for ; Fri, 13 Sep 2013 06:28:36 -0700 (PDT) X-Received: by 10.68.234.73 with SMTP id uc9mr13332646pbc.142.1379078916895; Fri, 13 Sep 2013 06:28:36 -0700 (PDT) Received: from localhost ([122.167.78.148]) by mx.google.com with ESMTPSA id go4sm11788255pbb.15.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:28:36 -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, linux-arm-kernel@lists.infradead.org, Viresh Kumar Subject: [PATCH 215/228] cpufreq: at32ap: use cpufreq_generic_get() routine Date: Fri, 13 Sep 2013 18:32:41 +0530 Message-Id: <7ea11571a11f19985f6d2db6dbec12450f0b5341.1379063063.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.220.182 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. Acked-by: Hans-Christian Egtvedt Signed-off-by: Viresh Kumar --- drivers/cpufreq/at32ap-cpufreq.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c index 856ad80..869c0b5 100644 --- a/drivers/cpufreq/at32ap-cpufreq.c +++ b/drivers/cpufreq/at32ap-cpufreq.c @@ -21,17 +21,8 @@ #include #include -static struct clk *cpuclk; static struct cpufreq_frequency_table *freq_table; -static unsigned int at32_get_speed(unsigned int cpu) -{ - /* No SMP support */ - if (cpu) - return 0; - return (unsigned int)((clk_get_rate(cpuclk) + 500) / 1000); -} - static unsigned int ref_freq; static unsigned long loops_per_jiffy_ref; @@ -39,7 +30,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index) { unsigned int old_freq, new_freq; - old_freq = at32_get_speed(0); + old_freq = policy->cur; new_freq = freq_table[index].frequency; if (!ref_freq) { @@ -50,7 +41,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index) if (old_freq < new_freq) boot_cpu_data.loops_per_jiffy = cpufreq_scale( loops_per_jiffy_ref, ref_freq, new_freq); - clk_set_rate(cpuclk, new_freq * 1000); + clk_set_rate(policy->clk, new_freq * 1000); if (new_freq < old_freq) boot_cpu_data.loops_per_jiffy = cpufreq_scale( loops_per_jiffy_ref, ref_freq, new_freq); @@ -61,6 +52,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index) static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy) { unsigned int frequency, rate, min_freq; + static struct clk *cpuclk; int retval, steps, i; if (policy->cpu != 0) @@ -103,6 +95,7 @@ static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy) frequency /= 2; } + policy->clk = cpuclk; freq_table[steps - 1].frequency = CPUFREQ_TABLE_END; retval = cpufreq_table_validate_and_show(policy, freq_table); @@ -123,7 +116,7 @@ static struct cpufreq_driver at32_driver = { .init = at32_cpufreq_driver_init, .verify = cpufreq_generic_frequency_table_verify, .target_index = at32_set_target, - .get = at32_get_speed, + .get = cpufreq_generic_get, .flags = CPUFREQ_STICKY, };