From patchwork Tue Nov 1 08:47:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: huang lin X-Patchwork-Id: 9407065 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BBA9760721 for ; Tue, 1 Nov 2016 08:48:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2FEE29566 for ; Tue, 1 Nov 2016 08:48:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A768829575; Tue, 1 Nov 2016 08:48:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8FE072958D for ; Tue, 1 Nov 2016 08:48:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c1UjQ-0007HF-Tc; Tue, 01 Nov 2016 08:47:44 +0000 Received: from mail-pf0-f194.google.com ([209.85.192.194]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c1UjL-0007FF-BD for linux-rockchip@lists.infradead.org; Tue, 01 Nov 2016 08:47:43 +0000 Received: by mail-pf0-f194.google.com with SMTP id y68so5255273pfb.1 for ; Tue, 01 Nov 2016 01:47:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=REBAjHNt0KgBENdxy/x8/gHG1j2oKO39+CYjhCaRjpo=; b=Wbnz5QyTNyc56Utk9Tq8HbtJ0u3YzJgOR+nSo5j2FZZrkJNBLth1ja8Of+WRyS+oTt ZSTxdXVoq6RNp6Kxn8FW2/y0BHJgILLFawLGxxZlqXiuhcfswLLMkgaFBx+NHSjauNzE VLKObzty6XT5RtBVHKS9vthz2gVkZFyt+N7iDdST/y7dIpvxPbbEu7Y8NQxcjk3gdBf/ O4JtHXfVg3swaHSa37X8fN3COkO8g8192XF7OAtz31GE6Y7lUdGf0LRYIii5K+DsAWX9 g0brRCf35o1oGp9cpJdt3Te5jiQjn2S7E2oV5l0fTEU7Ug0ez4B5ssLhPtjeSO3xBhow WpzA== X-Gm-Message-State: ABUngvfhvStd1gS4orsWPwZXGa+zH+8+jHFjiDoejbA/xQoxNXKReaamwElbY4mtu/MwSQ== X-Received: by 10.98.36.195 with SMTP id k64mr24038987pfk.126.1477990038604; Tue, 01 Nov 2016 01:47:18 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id o85sm40609352pfj.15.2016.11.01.01.47.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Nov 2016 01:47:18 -0700 (PDT) From: Lin Huang To: myungjoo.ham@samsung.com Subject: [PATCH v1 1/2] PM/devfreq: add suspend frequency support Date: Tue, 1 Nov 2016 16:47:08 +0800 Message-Id: <1477990029-11062-2-git-send-email-hl@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1477990029-11062-1-git-send-email-hl@rock-chips.com> References: <1477990029-11062-1-git-send-email-hl@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161101_014739_454183_F26FE06A X-CRM114-Status: GOOD ( 12.83 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lin Huang , linux-pm@vger.kernel.org, dbasehore@chromium.org, dianders@chromium.org, cw00.choi@samsung.com, linux-rockchip@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add suspend frequency support and if needed set it to the frequency obtained from the suspend opp (can be defined using opp-v2 bindings and is optional). Change-Id: Iaa0d3848d63d9ce03f65ea76f263e4685a4c295e Signed-off-by: Lin Huang --- drivers/devfreq/devfreq.c | 17 ++++++++++++++++- include/linux/devfreq.h | 9 +++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index bf3ea76..d1152eb 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -364,7 +364,10 @@ void devfreq_monitor_suspend(struct devfreq *devfreq) return; } - devfreq_update_status(devfreq, devfreq->previous_freq); + if (devfreq->suspend_freq) + devfreq_update_status(devfreq, devfreq->suspend_freq); + else + devfreq_update_status(devfreq, devfreq->previous_freq); devfreq->stop_polling = true; mutex_unlock(&devfreq->lock); cancel_delayed_work_sync(&devfreq->work); @@ -1251,6 +1254,18 @@ struct dev_pm_opp *devfreq_recommended_opp(struct device *dev, } EXPORT_SYMBOL(devfreq_recommended_opp); +void devfreq_opp_get_suspend_opp(struct device *dev, struct devfreq *devfreq) +{ + struct dev_pm_opp *suspend_opp; + + rcu_read_lock(); + suspend_opp = dev_pm_opp_get_suspend_opp(dev); + if (suspend_opp) + devfreq->suspend_freq = dev_pm_opp_get_freq(suspend_opp); + rcu_read_unlock(); +} +EXPORT_SYMBOL(devfreq_opp_get_suspend_opp); + /** * devfreq_register_opp_notifier() - Helper function to get devfreq notified * for any changes in the OPP availability diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 2de4e2e..c785ad9 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -88,6 +88,7 @@ struct devfreq_dev_status { */ struct devfreq_dev_profile { unsigned long initial_freq; + unsigned long suspend_freq; unsigned int polling_ms; int (*target)(struct device *dev, unsigned long *freq, u32 flags); @@ -172,6 +173,7 @@ struct devfreq { struct delayed_work work; unsigned long previous_freq; + unsigned long suspend_freq; struct devfreq_dev_status last_status; void *data; /* private data for governors */ @@ -214,6 +216,8 @@ extern int devfreq_resume_device(struct devfreq *devfreq); /* Helper functions for devfreq user device driver with OPP. */ extern struct dev_pm_opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq, u32 flags); +extern void devfreq_opp_get_suspend_opp(struct device *dev, + struct devfreq *devfreq); extern int devfreq_register_opp_notifier(struct device *dev, struct devfreq *devfreq); extern int devfreq_unregister_opp_notifier(struct device *dev, @@ -348,6 +352,11 @@ static inline struct dev_pm_opp *devfreq_recommended_opp(struct device *dev, return ERR_PTR(-EINVAL); } +static inline void devfreq_opp_get_suspend_opp(struct device *dev, + struct devfreq *devfreq) +{ +} + static inline int devfreq_register_opp_notifier(struct device *dev, struct devfreq *devfreq) {