From patchwork Fri Aug 17 18:20:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajagopal Venkat X-Patchwork-Id: 1339271 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 0EC173FC81 for ; Fri, 17 Aug 2012 18:23:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758772Ab2HQSX3 (ORCPT ); Fri, 17 Aug 2012 14:23:29 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:64593 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758764Ab2HQSX2 (ORCPT ); Fri, 17 Aug 2012 14:23:28 -0400 Received: by dady13 with SMTP id y13so939341dad.19 for ; Fri, 17 Aug 2012 11:23:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=Tx4esaY5HcioselVZrGXJBkEmAFE1RoPjMVQNLFGloI=; b=FHn+391LC5ttTHzNP5yR8pSdN7ImUls4S5ZngeLxkR2/Tv4FitDX/WZgtcOpWi5ieA XfYXj0fdjnaAAngilyqjMwT+J4iAn1jVdraEpA8TpIvG5PuFh73O16ZGkFOpfLJscS5l n2ixFsph4F0jObCg/QMotsG6boRBd0kWUaFm3YP35XFNRycvhRYxHN3cO5OB8P7TNs8X WLtapcTOx+Ru1ZZD67T7f2LSXBWjj1eNRBWeEImGgThER/gGSTgSTEuJRJtdqRoOxI2O EHm9qta4XzHK0tq404O/Zwyz9geJFJM/2UsVY8cQjw4GbwD/idlWvuBu4iJQt+nk8+8W GGbw== Received: by 10.68.235.41 with SMTP id uj9mr13760601pbc.41.1345227808036; Fri, 17 Aug 2012 11:23:28 -0700 (PDT) Received: from localhost.localdomain ([115.241.125.74]) by mx.google.com with ESMTPS id uy3sm4739046pbc.29.2012.08.17.11.23.23 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 17 Aug 2012 11:23:27 -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, Rajagopal Venkat Subject: [PATCH 2/3][RFC] devfreq: Add suspend and resume apis Date: Fri, 17 Aug 2012 23:50:44 +0530 Message-Id: <1345227645-20703-3-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1345227645-20703-1-git-send-email-rajagopal.venkat@linaro.org> References: <1345227645-20703-1-git-send-email-rajagopal.venkat@linaro.org> X-Gm-Message-State: ALoCoQnvnf4mVa+S1AF0x0wr1gpWuiSvRLOL7YJrkBgbWQ7pyg9JMZZ7gtvh0i6mfhC86ypHsA54 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This patch adds suspend and resume apis needed for devices which can idle. Suspend/resume apis are called from driver to suspend/resume devfreq load monitoring of that device. Signed-off-by: Rajagopal Venkat --- drivers/devfreq/devfreq.c | 30 ++++++++++++++++++++++++++++++ drivers/devfreq/governor_simpleondemand.c | 15 +++++++++++++++ include/linux/devfreq.h | 16 ++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 5aa23a8..375b5aa1 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -233,6 +233,36 @@ int devfreq_remove_device(struct devfreq *devfreq) } EXPORT_SYMBOL(devfreq_remove_device); +/** + * devfreq_suspend_device() - Suspend devfreq of a device. + * @devfreq the devfreq instance to be suspended + */ +int devfreq_suspend_device(struct devfreq *devfreq) +{ + if (!devfreq) + return -EINVAL; + + devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_SUSPEND); + + return 0; +} +EXPORT_SYMBOL(devfreq_suspend_device); + +/** + * devfreq_resume_device() - Resume devfreq of a device. + * @devfreq the devfreq instance to be resumed + */ +int devfreq_resume_device(struct devfreq *devfreq) +{ + if (!devfreq) + return -EINVAL; + + devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_RESUME); + + return 0; +} +EXPORT_SYMBOL(devfreq_resume_device); + static ssize_t show_governor(struct device *dev, struct device_attribute *attr, char *buf) { diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c index 7c70c30..95e4db9 100644 --- a/drivers/devfreq/governor_simpleondemand.c +++ b/drivers/devfreq/governor_simpleondemand.c @@ -221,6 +221,21 @@ static int devfreq_simple_ondemand_func(struct devfreq *df, ondemand_exit(df); break; + case DEVFREQ_GOV_SUSPEND: + if (delayed_work_pending(&data->work)) { + data->stop_queuing = true; + cancel_delayed_work_sync(&data->work); + } + break; + + case DEVFREQ_GOV_RESUME: + if (!delayed_work_pending(&data->work)) { + data->stop_queuing = false; + queue_delayed_work(devfreq_wq, &data->work, + msecs_to_jiffies(df->profile->polling_ms)); + } + break; + case DEVFREQ_GOV_LIMITS: if (delayed_work_pending(&data->work)) { mutex_lock(&df->lock); diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 600cc2e..7c6517f 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -56,6 +56,8 @@ struct devfreq_dev_status { #define DEVFREQ_GOV_START 0x1 #define DEVFREQ_GOV_STOP 0x2 #define DEVFREQ_GOV_LIMITS 0x3 +#define DEVFREQ_GOV_SUSPEND 0x4 +#define DEVFREQ_GOV_RESUME 0x5 /** * struct devfreq_dev_profile - Devfreq's user device profile @@ -155,6 +157,10 @@ extern struct devfreq *devfreq_add_device(struct device *dev, void *data); extern int devfreq_remove_device(struct devfreq *devfreq); +extern int devfreq_suspend_device(struct devfreq *devfreq); + +extern int devfreq_resume_device(struct devfreq *devfreq); + /* Helper functions for devfreq user device driver with OPP. */ extern struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq, u32 flags); @@ -207,6 +213,16 @@ static int devfreq_remove_device(struct devfreq *devfreq) return 0; } +static int devfreq_suspend_device(struct devfreq *devfreq) +{ + return 0; +} + +extern int devfreq_resume_device(struct devfreq *devfreq) +{ + return 0; +} + static struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq, u32 flags) {