From patchwork Tue Feb 9 05:00:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61501 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1831995lbl; Mon, 8 Feb 2016 21:04:34 -0800 (PST) X-Received: by 10.98.14.68 with SMTP id w65mr48362222pfi.146.1454994274179; Mon, 08 Feb 2016 21:04:34 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x9si51326937pas.214.2016.02.08.21.04.33; Mon, 08 Feb 2016 21:04:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754161AbcBIFCR (ORCPT + 30 others); Tue, 9 Feb 2016 00:02:17 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:34185 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752763AbcBIFBn (ORCPT ); Tue, 9 Feb 2016 00:01:43 -0500 Received: by mail-pa0-f45.google.com with SMTP id kp3so1845589pab.1 for ; Mon, 08 Feb 2016 21:01:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=JEafRdvCjvhMi9hwnuTcfreASQYJ129yy3AuWK5y1E8=; b=XnyTyyLYkfvQ11vGQemI3XyAVj1hX25EV9WU+oWndtXLeK6kcZBZQbt92tg9hZ7ZGO BctWiDqJiuV9D7TFS33HuNwRWFjm4xxcBAgkU3fXbU+K13h1UNCvQ9b+536skwiHXZK8 6fEfm2Yyr9hrLUd+k2w+4qLtGU/qi7Kan0ZcU= 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:in-reply-to:references; bh=JEafRdvCjvhMi9hwnuTcfreASQYJ129yy3AuWK5y1E8=; b=k4zSkCS4Ye+KJH6TwBHMUci8wJuhaxdpIw6e83zq9zLmfkPPQNX2IPSXMq+4D5RVJ8 2yOOT9mmEUl3uPT8F+CF+jZ1Ud48tq5rsEXBlEDGegMGXR8k3GTTHTpw2xIr6be+eUJ4 fC6gxOi2tpTiu0rA/1XyVwojBAJo8Jhfpj1HAy2Z2/cszZsFgi6IDSwmFDEfvNbEYksC llDn8R8ouRbJ15NAfH0BesMoI1fGg3EVUj3W933LsEgztakKIYm7rWzql7AaaMj51cep RTZL479r+Pm2Qn5PulMYZHBW3zxV/Xddxy22oXlq67yeXX9QYEg7lMU/yfcp2HQl2kIc Dmxg== X-Gm-Message-State: AG10YORlxdPY/L2uGekB8KG9BqKvYEEwDQTbd9+YTLgacASfyi0u/LJwwmE9NLHFxuVAdjYY X-Received: by 10.66.122.97 with SMTP id lr1mr46886049pab.68.1454994102950; Mon, 08 Feb 2016 21:01:42 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id x10sm46862105pas.37.2016.02.08.21.01.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 21:01:42 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Stephen Boyd , nm@ti.com, Viresh Kumar , Greg Kroah-Hartman , Len Brown , linux-kernel@vger.kernel.org (open list), Pavel Machek , Viresh Kumar Subject: [PATCH V3 06/16] PM / OPP: Manage device clk Date: Tue, 9 Feb 2016 10:30:38 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.370.gb2aa7f8 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org OPP core has got almost everything now to manage device's OPP transitions, the only thing left is device's clk. Get that as well. Signed-off-by: Viresh Kumar Reviewed-by: Stephen Boyd --- drivers/base/power/opp/core.c | 15 +++++++++++++++ drivers/base/power/opp/opp.h | 3 +++ 2 files changed, 18 insertions(+) -- 2.7.1.370.gb2aa7f8 diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 4fafa733a1c7..7d7749ce1ce4 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -13,6 +13,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -583,6 +584,7 @@ static struct device_opp *_add_device_opp(struct device *dev) struct device_opp *dev_opp; struct device_list_opp *list_dev; struct device_node *np; + int ret; /* Check for existing list for 'dev' first */ dev_opp = _find_device_opp(dev); @@ -620,6 +622,15 @@ static struct device_opp *_add_device_opp(struct device *dev) of_node_put(np); } + /* Find clk for the device */ + dev_opp->clk = clk_get(dev, NULL); + if (IS_ERR(dev_opp->clk)) { + ret = PTR_ERR(dev_opp->clk); + if (ret != -EPROBE_DEFER) + dev_dbg(dev, "%s: Couldn't find clock: %d\n", __func__, + ret); + } + srcu_init_notifier_head(&dev_opp->srcu_head); INIT_LIST_HEAD(&dev_opp->opp_list); @@ -661,6 +672,10 @@ static void _remove_device_opp(struct device_opp *dev_opp) if (!IS_ERR_OR_NULL(dev_opp->regulator)) return; + /* Release clk */ + if (!IS_ERR(dev_opp->clk)) + clk_put(dev_opp->clk); + list_dev = list_first_entry(&dev_opp->dev_list, struct device_list_opp, node); diff --git a/drivers/base/power/opp/opp.h b/drivers/base/power/opp/opp.h index fe44beb404ba..4f1bdfc7da03 100644 --- a/drivers/base/power/opp/opp.h +++ b/drivers/base/power/opp/opp.h @@ -22,6 +22,7 @@ #include #include +struct clk; struct regulator; /* Lock to allow exclusive modification to the device and opp lists */ @@ -134,6 +135,7 @@ struct device_list_opp { * @supported_hw: Array of version number to support. * @supported_hw_count: Number of elements in supported_hw array. * @prop_name: A name to postfix to many DT properties, while parsing them. + * @clk: Device's clock handle * @regulator: Supply regulator * @dentry: debugfs dentry pointer of the real device directory (not links). * @dentry_name: Name of the real dentry. @@ -168,6 +170,7 @@ struct device_opp { unsigned int *supported_hw; unsigned int supported_hw_count; const char *prop_name; + struct clk *clk; struct regulator *regulator; #ifdef CONFIG_DEBUG_FS