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: 3865501 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2B98F9F382 for ; Thu, 20 Mar 2014 12:11:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C45320237 for ; Thu, 20 Mar 2014 12:11:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D90620222 for ; Thu, 20 Mar 2014 12:11:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756610AbaCTMLR (ORCPT ); Thu, 20 Mar 2014 08:11:17 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:37236 "EHLO e23smtp09.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751290AbaCTMLQ (ORCPT ); Thu, 20 Mar 2014 08:11:16 -0400 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 20 Mar 2014 22:11:14 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 20 Mar 2014 22:11:12 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 6474C2BB0052 for ; Thu, 20 Mar 2014 23:11:12 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s2KCAvch11403664 for ; Thu, 20 Mar 2014 23:10:58 +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 s2KCBA2Z004137 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 Cc: benh@kernel.crashing.org, svaidy@linux.vnet.ibm.com, "Gautham R. Shenoy" 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-3568-0000-0000-000005210701 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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, };