From patchwork Sat Jul 19 00:15:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 4588371 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B50B8C0514 for ; Sat, 19 Jul 2014 00:18:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD59020176 for ; Sat, 19 Jul 2014 00:18:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CCE3F20166 for ; Sat, 19 Jul 2014 00:18:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X8IKD-0002sz-0c; Sat, 19 Jul 2014 00:16:29 +0000 Received: from smtp.codeaurora.org ([198.145.11.231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X8IK9-0002kM-Mi for linux-arm-kernel@lists.infradead.org; Sat, 19 Jul 2014 00:16:26 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 04E1A13F67B; Sat, 19 Jul 2014 00:16:05 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id E7A3D13F67D; Sat, 19 Jul 2014 00:16:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from skannan1-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: skannan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 1006413F67C; Sat, 19 Jul 2014 00:16:04 +0000 (UTC) From: Saravana Kannan To: MyungJoo Ham , Kyungmin Park Subject: [PATCH v4] PM / devfreq: Add possible_frequencies device attribute Date: Fri, 18 Jul 2014 17:15:58 -0700 Message-Id: <1405728958-619-1-git-send-email-skannan@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <725805840.101171405558256488.JavaMail.weblogic@epmlwas01c> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140718_171625_824507_32788897 X-CRM114-Status: GOOD ( 17.08 ) X-Spam-Score: -0.0 (/) Cc: linux-arm-msm@vger.kernel.org, Saravana Kannan , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some devices use freq_table instead of OPP. For those devices, the available_frequencies sysfs file shows up empty. So, add a possible_frequencies attribute/syfs file that list all the possible frequencies. For devices that use OPP, the output of this file will match available_frequencies. It may change in the future to show all OPP frequencies -- even the disabled ones. Signed-off-by: Saravana Kannan --- Documentation/ABI/testing/sysfs-class-devfreq | 15 +++++++++++++++ drivers/devfreq/devfreq.c | 26 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-devfreq b/Documentation/ABI/testing/sysfs-class-devfreq index ee39aca..a461e67 100644 --- a/Documentation/ABI/testing/sysfs-class-devfreq +++ b/Documentation/ABI/testing/sysfs-class-devfreq @@ -72,6 +72,21 @@ Description: This is a snapshot of available frequencies and not limited by the min/max frequency restrictions. +What: /sys/class/devfreq/.../possible_frequencies +Date: July 2014 +Contact: Saravana Kannan +Description: + The /sys/class/devfreq/.../possible_frequencies shows + the possible frequencies of the corresponding devfreq object. + This is a snapshot of possible frequencies and not limited by + the min/max frequency restrictions. Unlike + available_frequencies, this is also does not require the + devfreq device to use OPP for listing its possible + frequencies. When OPP is used, this behaves the same way as + available_frequencies. It maybe improved in the future to + list all possible OPP frequencies even if some of them are + disabled at run-time. + What: /sys/class/devfreq/.../available_governors Date: October 2012 Contact: Nishanth Menon diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 9f90369..65eed38 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -994,6 +994,31 @@ static ssize_t available_frequencies_show(struct device *d, } static DEVICE_ATTR_RO(available_frequencies); +static ssize_t possible_frequencies_show(struct device *d, + struct device_attribute *attr, + char *buf) +{ + struct devfreq *df = to_devfreq(d); + unsigned int i = 0; + ssize_t count = 0; + + if (!df->profile->freq_table) + return available_frequencies_show(d, attr, buf); + + for (i = 0; i < df->profile->max_state; i++) + count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), + "%u ", df->profile->freq_table[i]); + + /* Truncate the trailing space */ + if (count) + count--; + + count += sprintf(&buf[count], "\n"); + + return count; +} +static DEVICE_ATTR_RO(possible_frequencies); + static ssize_t trans_stat_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -1041,6 +1066,7 @@ static struct attribute *devfreq_attrs[] = { &dev_attr_available_governors.attr, &dev_attr_cur_freq.attr, &dev_attr_available_frequencies.attr, + &dev_attr_possible_frequencies.attr, &dev_attr_target_freq.attr, &dev_attr_polling_interval.attr, &dev_attr_min_freq.attr,