From patchwork Fri Sep 13 13:01:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20181 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 A78E520358 for ; Fri, 13 Sep 2013 13:18:04 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id g17sf1197662vbg.2 for ; Fri, 13 Sep 2013 06:18:04 -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=iuRKLA0Sc17kUpgTO0qXazRAbfs2wmz5eFPd7FmA0oo=; b=CyjuhMVh8eHhoWVW1xzNt9do0mq6sRIsnKRRHdghg+Ah2yEmsKCjDbsRJX9y5QKs9j +k0aexx63tpcQgR1i6Kih99TlWC2fh80fHZ0sh1g+ODm4Z61ZJfsxnwfv5qIZyPZxSgZ QFl6ZmVWPwAPEqu25iwgv7Nyz+TZJwv09Ir4kPAMkZVMdLZRrxQ2W3YGfdPqU4d4J0DL e7zjII1GOF48mRWlMdXoTgP113vOCjBcJQ/mD8zwr1RPDXtZAaL7lC8W6HUxX89NWoT6 963Wc2zY/Kd77tA3jzDb36OKG1skUsAhjYLy9KkKPlG/D3dzs+oMuy/PI+cdROnFx6Sb j/RQ== X-Gm-Message-State: ALoCoQkj39x/6eq/jrLcq6iBnGd9t4NMa0Ylwwnw/slx/eCef8dkGytrQcQXDizhc2oPMwnX+T+x X-Received: by 10.236.26.202 with SMTP id c50mr5023558yha.14.1379078284414; Fri, 13 Sep 2013 06:18:04 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.86.161 with SMTP id q1ls1124559qez.13.gmail; Fri, 13 Sep 2013 06:18:04 -0700 (PDT) X-Received: by 10.221.47.193 with SMTP id ut1mr11979792vcb.8.1379078284156; Fri, 13 Sep 2013 06:18:04 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id o5si3114937vdw.37.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:18:04 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.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.128.182; Received: by mail-ve0-f182.google.com with SMTP id oy12so931667veb.41 for ; Fri, 13 Sep 2013 06:18:04 -0700 (PDT) X-Received: by 10.221.44.136 with SMTP id ug8mr11961131vcb.13.1379078284068; Fri, 13 Sep 2013 06:18:04 -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 u4csp80198vcz; Fri, 13 Sep 2013 06:18:03 -0700 (PDT) X-Received: by 10.68.178.2 with SMTP id cu2mr8807733pbc.161.1379078283008; Fri, 13 Sep 2013 06:18:03 -0700 (PDT) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by mx.google.com with ESMTPS id mo9si7414381pbc.306.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:18:02 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.46 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.46; Received: by mail-pa0-f46.google.com with SMTP id fa1so2517854pad.19 for ; Fri, 13 Sep 2013 06:18:02 -0700 (PDT) X-Received: by 10.68.178.132 with SMTP id cy4mr13501177pbc.85.1379078282546; Fri, 13 Sep 2013 06:18:02 -0700 (PDT) Received: from localhost ([122.167.78.148]) by mx.google.com with ESMTPSA id m4sm9224366pbg.38.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:18:01 -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 127/228] cpufreq: create cpufreq_generic_init() routine Date: Fri, 13 Sep 2013 18:31:13 +0530 Message-Id: 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.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: , Many CPUFreq drivers for SMP system (where all cores share same clock lines), do similar stuff in their ->init() part. This patch creates a generic routine in cpufreq core which can be used by these so that we can remove some redundant code. Signed-off-by: Viresh Kumar --- drivers/cpufreq/Kconfig | 1 + drivers/cpufreq/cpufreq.c | 31 +++++++++++++++++++++++++++++++ include/linux/cpufreq.h | 3 +++ 3 files changed, 35 insertions(+) diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig index 534fcb8..2d06754 100644 --- a/drivers/cpufreq/Kconfig +++ b/drivers/cpufreq/Kconfig @@ -2,6 +2,7 @@ menu "CPU Frequency scaling" config CPU_FREQ bool "CPU Frequency scaling" + select CPU_FREQ_TABLE help CPU Frequency scaling allows you to change the clock speed of CPUs on the fly. This is a nice method to save power, because diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 1e6b602..c4d89c5 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -183,6 +183,37 @@ u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy) } EXPORT_SYMBOL_GPL(get_cpu_idle_time); +/* + * This is a generic cpufreq init() routine which can be used by cpufreq + * drivers of SMP systems. It will do following: + * - validate & show freq table passed + * - set policies transition latency + * - policy->cpus with all possible CPUs + */ +int cpufreq_generic_init(struct cpufreq_policy *policy, + struct cpufreq_frequency_table *table, + unsigned int transition_latency) +{ + int ret; + + ret = cpufreq_table_validate_and_show(policy, table); + if (ret) { + pr_err("%s: invalid frequency table: %d\n", __func__, ret); + return ret; + } + + policy->cpuinfo.transition_latency = transition_latency; + + /* + * The driver only supports the SMP configuartion where all processors + * share the clock and voltage and clock. + */ + cpumask_setall(policy->cpus); + + return 0; +} +EXPORT_SYMBOL_GPL(cpufreq_generic_init); + struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) { struct cpufreq_policy *policy = NULL; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 57d2907..c2184c6 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -438,6 +438,9 @@ void cpufreq_frequency_table_put_attr(unsigned int cpu); int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table); +int cpufreq_generic_init(struct cpufreq_policy *policy, + struct cpufreq_frequency_table *table, + unsigned int transition_latency); static inline int cpufreq_generic_exit(struct cpufreq_policy *policy) { cpufreq_frequency_table_put_attr(policy->cpu);