From patchwork Fri Sep 21 15:11:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rajagopal.venkat@linaro.org X-Patchwork-Id: 11625 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id F19ED23EFD for ; Fri, 21 Sep 2012 15:14:20 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 763C4A192FD for ; Fri, 21 Sep 2012 15:14:20 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so5115339iej.11 for ; Fri, 21 Sep 2012 08:14:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=ct2G0M6xKLfvBCsf/qHX2l36mJWP87j4uEW5XAMfSb0=; b=hxJoATJbQG8h7emzs3lIb1btEYK4UTUozyg+RoZbh5GnrxXK0R0Hu0CqqhvWxDYNMV gouYZWiaF/1cRHZUMZ0CyumX9PRwR3+VGkI+BLBIfBusbrhrOFgcbT1uMp8x2gH9AnQT p+YexpGSQ75tdPgaBhweywg+huSGEFFW561ytTV0eVQXTlGJRrCVDocxBnDbhXhYKujd 2uqV8OWBtxASta/R/zLvsCkPyrlwUW3PaRtDdZTSkHuzUkpDPpf/TrrgoH9+9fP2n6en HXNAqLxAj4ZCUnrDp/oSUiq1RC7PZhaCROFODq7ouPXgNH9eF9xsLRtoWguMP3WMLTQy FQRg== Received: by 10.42.110.130 with SMTP id q2mr4141936icp.53.1348240460116; Fri, 21 Sep 2012 08:14:20 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp133749igc; Fri, 21 Sep 2012 08:14:19 -0700 (PDT) Received: by 10.68.189.99 with SMTP id gh3mr16475165pbc.31.1348240458583; Fri, 21 Sep 2012 08:14:18 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id gh6si11849540pbc.267.2012.09.21.08.14.18 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Sep 2012 08:14:18 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) smtp.mail=rajagopal.venkat@linaro.org Received: by mail-pb0-f50.google.com with SMTP id md12so8331106pbc.37 for ; Fri, 21 Sep 2012 08:14:18 -0700 (PDT) Received: by 10.68.138.163 with SMTP id qr3mr16245726pbb.161.1348240458199; Fri, 21 Sep 2012 08:14:18 -0700 (PDT) Received: from localhost.localdomain ([101.62.22.184]) by mx.google.com with ESMTPS id wn4sm5257991pbc.55.2012.09.21.08.14.12 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Sep 2012 08:14:17 -0700 (PDT) From: Rajagopal Venkat To: mturquette@linaro.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, rjw@sisk.pl Cc: patches@linaro.org, linaro-dev@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Rajagopal Venkat Subject: [PATCH v3 3/3] devfreq: Add current freq callback in device profile Date: Fri, 21 Sep 2012 20:41:58 +0530 Message-Id: <1348240318-2967-4-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1348240318-2967-1-git-send-email-rajagopal.venkat@linaro.org> References: <1348240318-2967-1-git-send-email-rajagopal.venkat@linaro.org> X-Gm-Message-State: ALoCoQl7Hk9Kc2rnzZct94vqabKU1RhPkZlNUHa3xd8BZC0alrwptPEXkJCFs9QYKtyOlPQdOcQ7 Devfreq returns governor predicted frequency as current frequency via sysfs interface. But device may not support all frequencies that governor predicts. So add a callback in device profile to get current freq from driver. Also add a new sysfs node to expose governor predicted next target frequency. Signed-off-by: Rajagopal Venkat Signed-off-by: MyungJoo Ham --- Documentation/ABI/testing/sysfs-class-devfreq | 11 ++++++++++- drivers/devfreq/devfreq.c | 14 ++++++++++++++ include/linux/devfreq.h | 3 +++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-class-devfreq b/Documentation/ABI/testing/sysfs-class-devfreq index 89283b1..e6cf08e 100644 --- a/Documentation/ABI/testing/sysfs-class-devfreq +++ b/Documentation/ABI/testing/sysfs-class-devfreq @@ -19,7 +19,16 @@ Date: September 2011 Contact: MyungJoo Ham Description: The /sys/class/devfreq/.../cur_freq shows the current - frequency of the corresponding devfreq object. + frequency of the corresponding devfreq object. Same as + target_freq when get_cur_freq() is not implemented by + devfreq driver. + +What: /sys/class/devfreq/.../target_freq +Date: September 2012 +Contact: Rajagopal Venkat +Description: + The /sys/class/devfreq/.../target_freq shows the next governor + predicted target frequency of the corresponding devfreq object. What: /sys/class/devfreq/.../polling_interval Date: September 2011 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index edddb9e..33b0a33 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -453,6 +453,19 @@ static ssize_t show_governor(struct device *dev, static ssize_t show_freq(struct device *dev, struct device_attribute *attr, char *buf) { + unsigned long freq; + struct devfreq *devfreq = to_devfreq(dev); + + if (devfreq->profile->get_cur_freq && + !devfreq->profile->get_cur_freq(devfreq->dev.parent, &freq)) + return sprintf(buf, "%lu\n", freq); + + return sprintf(buf, "%lu\n", devfreq->previous_freq); +} + +static ssize_t show_target_freq(struct device *dev, + struct device_attribute *attr, char *buf) +{ return sprintf(buf, "%lu\n", to_devfreq(dev)->previous_freq); } @@ -552,6 +565,7 @@ static ssize_t show_max_freq(struct device *dev, struct device_attribute *attr, static struct device_attribute devfreq_attrs[] = { __ATTR(governor, S_IRUGO, show_governor, NULL), __ATTR(cur_freq, S_IRUGO, show_freq, NULL), + __ATTR(target_freq, S_IRUGO, show_target_freq, NULL), __ATTR(polling_interval, S_IRUGO | S_IWUSR, show_polling_interval, store_polling_interval), __ATTR(min_freq, S_IRUGO | S_IWUSR, show_min_freq, store_min_freq), diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 18bd3b7..f49c5d3 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -66,6 +66,8 @@ struct devfreq_dev_status { * explained above with "DEVFREQ_FLAG_*" macros. * @get_dev_status The device should provide the current performance * status to devfreq, which is used by governors. + * @get_cur_freq The device should provide the current frequency + * at which it is operating. * @exit An optional callback that is called when devfreq * is removing the devfreq object due to error or * from devfreq_remove_device() call. If the user @@ -79,6 +81,7 @@ struct devfreq_dev_profile { int (*target)(struct device *dev, unsigned long *freq, u32 flags); int (*get_dev_status)(struct device *dev, struct devfreq_dev_status *stat); + int (*get_cur_freq)(struct device *dev, unsigned long *freq); void (*exit)(struct device *dev); };