From patchwork Thu Mar 20 12:10:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautham R Shenoy X-Patchwork-Id: 332099 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 6BBD02C0852 for ; Thu, 20 Mar 2014 23:13:52 +1100 (EST) Received: by ozlabs.org (Postfix) id 113372C010C; Thu, 20 Mar 2014 23:11:14 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from e23smtp05.au.ibm.com (e23smtp05.au.ibm.com [202.81.31.147]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 08D7D2C010B for ; Thu, 20 Mar 2014 23:11:14 +1100 (EST) Received: from /spool/local by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 20 Mar 2014 22:11:13 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp05.au.ibm.com (202.81.31.211) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 20 Mar 2014 22:11:12 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id C61B62BB003F for ; Thu, 20 Mar 2014 23:11:11 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s2KBoxMo7078196 for ; Thu, 20 Mar 2014 22:50:59 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s2KCBA2X004137 for ; Thu, 20 Mar 2014 23:11:11 +1100 Received: from sofia.in.ibm.com (sofia.in.ibm.com [9.124.35.168]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s2KCB2Ms003964; Thu, 20 Mar 2014 23:11:09 +1100 From: "Gautham R. Shenoy" To: linuxppc-dev@ozlabs.org, linux-pm@vger.kernel.org Subject: [PATCH v3 4/5] powernv:cpufreq: Export nominal frequency via sysfs. Date: Thu, 20 Mar 2014 17:40:59 +0530 Message-Id: <1395317460-14811-5-git-send-email-ego@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1395317460-14811-1-git-send-email-ego@linux.vnet.ibm.com> References: <1395317460-14811-1-git-send-email-ego@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14032012-1396-0000-0000-0000047F4AE0 Cc: "Gautham R. Shenoy" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: "Gautham R. Shenoy" Create a driver attribute named cpuinfo_nominal_freq which creates a sysfs read-only file named cpuinfo_nominal_freq. Export the frequency corresponding to the nominal_pstate through this interface. Nominal frequency is the highest non-turbo frequency for the platform. This is generally used for setting governor policies from user space for optimal energy efficiency. Signed-off-by: Gautham R. Shenoy --- drivers/cpufreq/powernv-cpufreq.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c index e7b0292..46bee8a 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -142,8 +142,30 @@ static unsigned int pstate_id_to_freq(int pstate_id) return powernv_freqs[i].frequency; } +/** + * show_cpuinfo_nominal_freq - Show the nominal CPU frequency as indicated by + * the firmware + */ +static ssize_t show_cpuinfo_nominal_freq(struct cpufreq_policy *policy, + char *buf) +{ + int nominal_freq; + nominal_freq = pstate_id_to_freq(powernv_pstate_info.pstate_nominal_id); + return sprintf(buf, "%u\n", nominal_freq); +} + + +struct freq_attr cpufreq_freq_attr_cpuinfo_nominal_freq = { + .attr = { .name = "cpuinfo_nominal_freq", + .mode = 0444, + }, + .show = show_cpuinfo_nominal_freq, +}; + + static struct freq_attr *powernv_cpu_freq_attr[] = { &cpufreq_freq_attr_scaling_available_freqs, + &cpufreq_freq_attr_cpuinfo_nominal_freq, NULL, };