From patchwork Wed Jan 27 09:05:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 371488 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp72896jam; Wed, 27 Jan 2021 01:09:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQo/JgE7eKum5VSzIIQ40x8cXSQ0o9pcpJY3oLB8SqA547D8NTbRtkSPTyktYasUlEetuc X-Received: by 2002:a17:906:bfcc:: with SMTP id us12mr6027657ejb.163.1611738543077; Wed, 27 Jan 2021 01:09:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611738543; cv=none; d=google.com; s=arc-20160816; b=Vh4NN9BpFQNaES0YlJ8eviBdgYi4N6L5NrJYDZQVMv4DpKpS2WIMpiRcTD1FvbGrlE 9U7kJZ67bPaNDrCtbTN/w/oioHl79YQQK9+jyzOGlHBzvlhlWgV6KAsHR7CFaWHajO+u b1TgS2Z8zbfuSwuUmDB6Gg8VW0Kg1rq7EgYnEdg40bcJGGkUE7SvIb0aehDbKO7YK7A8 QirA6/UN2BXy4+MtQomG7URX72FwLD8KaUb3k3HYhiJg2dwByerES2y95l8scSULjGIs +CCVHavi46jttkkssx62D7DTyrLHnTKJ2KDq2xW8k8pIK+JGxtnYdHL10CaG9tgdZPMi vG/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=kHVpzPPwZR4A49rdw4CEuR8WNyenxazX6G1grb14wCE=; b=sUpfS3z8IAMB7/A31dD+iZYNv6NkL+M9EONg386MOTAQ9mrhlwQjx0MMyjKN7CoA3+ 9Eh/2LtdLdZehR/xp3kEYERnPSNot38pU70vgmTxFKAo8KJ5w0kcrmC3ib7w/8q6Q41w skXyVWHizUUVQG7jxzRndLFSrQaJLz578IXZWA4+Yr8P0DQQ07d5BcHzZqfn+pEVhKze +5SifbGE8s2dU6tFWqkHw1QZUCLnjtU7m5DvBoHmy2+irvpdx7s+ElxNXuPBH4vKCBld SVkVh8+nO1gt6/Hi6K3egQZWCDScwtuq4bqfn1s3fXZQ3RK4v7WPbpz80LXlHHuTw11g BR8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=acywSujm; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x23si594273ejv.558.2021.01.27.01.09.02; Wed, 27 Jan 2021 01:09:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=acywSujm; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235020AbhA0JI1 (ORCPT + 7 others); Wed, 27 Jan 2021 04:08:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234875AbhA0JGW (ORCPT ); Wed, 27 Jan 2021 04:06:22 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4BB7C061788 for ; Wed, 27 Jan 2021 01:05:41 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id lw17so2695991pjb.0 for ; Wed, 27 Jan 2021 01:05:41 -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:mime-version :content-transfer-encoding; bh=kHVpzPPwZR4A49rdw4CEuR8WNyenxazX6G1grb14wCE=; b=acywSujm9nQpsrNHfFh94SHb8cLDWeUZ7iPxSX88YEJMHegEonrRF/fENUeISIT852 gS6Ll1nGjeAH4tGloIfue2DVm7+00yQ6OdYulQ8V/lTyFE+EIh8Xbb7gW1s87fdzgAjm 7kbihIeuaYrI+CmOarHzcLt167rA2EhIXicaG2ed4e6SonAAckJqscwKxv5JruJRZfUv oddDrdLWx5HWAl33YgDB+q9hzX+kMNrl0nXAtAsEJeT4v22T6AZeMptjY0wLA3ZSzTdA Tzw8MzTKWzi2wOHn90d3PGwKVbO6pE/hr2etjoYHdT9jmiRf5DmzbRxeG5DHyu/q7wbb +ynA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kHVpzPPwZR4A49rdw4CEuR8WNyenxazX6G1grb14wCE=; b=IL2bMsqBBbulRAQ+VensF5ooD/31PAxgrYFJbS9Ah7oW+VqFOziBy+9RJYgydiB/T2 WcVduAzdx3sfgiIM8/6AoLi7CEeX4uvx/gxwOWeE8iDtgXzqWZKycEqPb7+gkkSK/GXA TK3O7Dry4S8O/3JUiFLnsN5xW/FyOjYiGGn3jXFD9MbuPZ9WUBmDZ9xjo7fNWEy79hU8 O+q8EE4gTjskJeRd9Whq51Am80TweQG/B5/tHhnNjPVVu1TH66Hx6DvERvozAC13Kc2e hvAbSnpamAhjNZYjNaAmz/JQGOm0SAyGPXda/9CQq678mSsetfeTHK7kfYFwRiAjRfH/ Xm0A== X-Gm-Message-State: AOAM533/jjo/KimPVn7vhADkFMeXEfkS8YTi8wm/IfgUxyVLXdS7/ern xN1mB5zf3qJwkELBLXePnSjDNw== X-Received: by 2002:a17:902:7102:b029:de:aa85:e04e with SMTP id a2-20020a1709027102b02900deaa85e04emr10259942pll.23.1611738341240; Wed, 27 Jan 2021 01:05:41 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id hs21sm1352257pjb.6.2021.01.27.01.05.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jan 2021 01:05:40 -0800 (PST) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] opp: Create _of_add_table_indexed() to reduce code duplication Date: Wed, 27 Jan 2021 14:35:26 +0530 Message-Id: <6c2160ff30a8f421563793020264cf9f533f293c.1611738228.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The implementation of dev_pm_opp_of_add_table() and dev_pm_opp_of_add_table_indexed() are almost identical. Create _of_add_table_indexed() to reduce code redundancy. Also remove the duplication of the doc style comments by referring to dev_pm_opp_of_add_table() from dev_pm_opp_of_add_table_indexed(). Signed-off-by: Viresh Kumar --- drivers/opp/of.c | 81 ++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 48 deletions(-) -- 2.25.0.rc1.19.g042ed3e048af diff --git a/drivers/opp/of.c b/drivers/opp/of.c index d0c0336be39b..c6856dcf4c34 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -956,29 +956,23 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) return ret; } -/** - * dev_pm_opp_of_add_table() - Initialize opp table from device tree - * @dev: device pointer used to lookup OPP table. - * - * Register the initial OPP table with the OPP library for given device. - * - * Return: - * 0 On success OR - * Duplicate OPPs (both freq and volt are same) and opp->available - * -EEXIST Freq are same and volt are different OR - * Duplicate OPPs (both freq and volt are same) and !opp->available - * -ENOMEM Memory allocation failure - * -ENODEV when 'operating-points' property is not found or is invalid data - * in device node. - * -ENODATA when empty 'operating-points' property is found - * -EINVAL when invalid entries are found in opp-v2 table - */ -int dev_pm_opp_of_add_table(struct device *dev) +static int _of_add_table_indexed(struct device *dev, int index) { struct opp_table *opp_table; - int ret; + int ret, count; - opp_table = _add_opp_table_indexed(dev, 0); + if (index) { + /* + * If only one phandle is present, then the same OPP table + * applies for all index requests. + */ + count = of_count_phandle_with_args(dev->of_node, + "operating-points-v2", NULL); + if (count == 1) + index = 0; + } + + opp_table = _add_opp_table_indexed(dev, index); if (IS_ERR(opp_table)) return PTR_ERR(opp_table); @@ -996,15 +990,12 @@ int dev_pm_opp_of_add_table(struct device *dev) return ret; } -EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table); /** - * dev_pm_opp_of_add_table_indexed() - Initialize indexed opp table from device tree + * dev_pm_opp_of_add_table() - Initialize opp table from device tree * @dev: device pointer used to lookup OPP table. - * @index: Index number. * - * Register the initial OPP table with the OPP library for given device only - * using the "operating-points-v2" property. + * Register the initial OPP table with the OPP library for given device. * * Return: * 0 On success OR @@ -1017,31 +1008,25 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table); * -ENODATA when empty 'operating-points' property is found * -EINVAL when invalid entries are found in opp-v2 table */ -int dev_pm_opp_of_add_table_indexed(struct device *dev, int index) +int dev_pm_opp_of_add_table(struct device *dev) { - struct opp_table *opp_table; - int ret, count; - - if (index) { - /* - * If only one phandle is present, then the same OPP table - * applies for all index requests. - */ - count = of_count_phandle_with_args(dev->of_node, - "operating-points-v2", NULL); - if (count == 1) - index = 0; - } - - opp_table = _add_opp_table_indexed(dev, index); - if (IS_ERR(opp_table)) - return PTR_ERR(opp_table); - - ret = _of_add_opp_table_v2(dev, opp_table); - if (ret) - dev_pm_opp_put_opp_table(opp_table); + return _of_add_table_indexed(dev, 0); +} +EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table); - return ret; +/** + * dev_pm_opp_of_add_table_indexed() - Initialize indexed opp table from device tree + * @dev: device pointer used to lookup OPP table. + * @index: Index number. + * + * Register the initial OPP table with the OPP library for given device only + * using the "operating-points-v2" property. + * + * Return: Refer to dev_pm_opp_of_add_table() for return values. + */ +int dev_pm_opp_of_add_table_indexed(struct device *dev, int index) +{ + return _of_add_table_indexed(dev, index); } EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table_indexed); From patchwork Wed Jan 27 09:05:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 371489 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp72913jam; Wed, 27 Jan 2021 01:09:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyawJPAG/KjSy7jcLI3StlW/h9k8gqQDzb+cvbEOvsznJdpA2152EgvZxfl1tSThphiUhwC X-Received: by 2002:a17:907:961d:: with SMTP id gb29mr6186345ejc.460.1611738544037; Wed, 27 Jan 2021 01:09:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611738544; cv=none; d=google.com; s=arc-20160816; b=LjaILjQ4RqfXM2MyifVPVQvJ3/x+In0LWh/UJ9EosCOxz0/X3295BfJ0dWtAm07q3M UMNyMfiacsQKZD/+BMqz5uht7tZlgjTUJcgS5h2mJhMBjFxXaQPSYhoCWdfEAGGZqHPg Ws0G2ZH3w2J6Z/3dyyv7qwbS3qmPyv7yT5D4F3mCqqnEbz+fkoevwY50IFtTk8iJb43n Q72mA5M26w8oeSUZVy6B5/9M2aM/bQRTALJBhXATetskYIYwExOQHhX5o2oninGc0E/l Ws9faw67vaZZmjsFnknYv8f13XSgXo/uke2xnkqyh5zok9Km7qRAjUbbsa17dmUSCoWU hdQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OjpOd/Y/FK/H2NSbndAgqWfjTMnUxw5T0tdE3/+WPu0=; b=TFefF3p0BlX6r95OOyxLMEnsP+Kz6tkURxY1atbpE8WxSaY/ddp0L0D7M49rZZ7WBn Ugj5ddHgRCeCDpvmi0fJ18fWUdJoJI7TvDje5o3FdHQEs04ny4lu0gZJ++DByA7BsoUe r3s6K+TWLbwsS6QSPNvP2gFkV8lY9pG+u1m2GJ3dGJtMV7qWeMo9Y9Ooi1Sqeg3+DtcT qXXQplIjOMBsPbUmDm5OLD9SxXuAi8ivaYE+XZwL/XMy/UaDneWE/XdBwG5P1oT9nFky TL+KhHNnVdmFAQ+UoDuFRJG10qWtha/+4JPJKZeeGO3wFIiaeQhY1KSz+SAgJLcIk40K GDxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pYQE0Igw; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x23si594273ejv.558.2021.01.27.01.09.03; Wed, 27 Jan 2021 01:09:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pYQE0Igw; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234875AbhA0JI3 (ORCPT + 7 others); Wed, 27 Jan 2021 04:08:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234928AbhA0JG0 (ORCPT ); Wed, 27 Jan 2021 04:06:26 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A90BC06178C for ; Wed, 27 Jan 2021 01:05:45 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id b21so1132422pgk.7 for ; Wed, 27 Jan 2021 01:05:45 -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 :mime-version:content-transfer-encoding; bh=OjpOd/Y/FK/H2NSbndAgqWfjTMnUxw5T0tdE3/+WPu0=; b=pYQE0IgwXy1Zs6ba72Xjz1to1eQPd8M7H8sIYE/kP/kcbVple/AFEQAxw4t0DjPerZ MkICrsPw8/tZZFc1dHkWLISMPvl7ev/U0M+KiIj1dzPAJjxF3O2V22CVkPxkgWc/ZZCO AnlWWwVBcYgiVepHvz3zeTgRYaq9jlk/eeijnV8/pK1LDYbh9GCfUSVIECqkYYobxdk9 OYh8I16fo3dnvDxmd0qZh3QKvkVEIJiaPWQ+O+Menf/UNJ2I6RmwTkdywamI9HoaIhxh 3DUl9zkBvePZRgCNEbjLX/y/26oYhyQatEo7vNo9yL4jiS5RiKeD24LBmuKoUSkX8P68 o87Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OjpOd/Y/FK/H2NSbndAgqWfjTMnUxw5T0tdE3/+WPu0=; b=HtXC72HF+55O4/QM6vgafl/LTho0pZSE6kc7GNo2hIqKGNbbpoAJJ4/AbFYkfxIzxM HdkpM2PnQyPYpeDSf8rD2nX0emuNoUqOWoVJgaUBh267USXFioyLZVgRmjyDCPQlSJfj NF4F9+vdrRq69pJWRjB41rwMxrAB79OwccY4VA8YMdRN5KnHNkd9+4EsO9EHtVy5H09N Pn31ogEzU2ahi19fUJynIhnpGoCGWGp9qXXdQujkKSxgT2FV1E+Ih5dzFnTZNplK/2OO 4H9d2m+oKvEvbCBGgVVegteubY5XX8VRtuSup+nljf32yoEYMJpC6nBk/TT0LV1rwbIf 8Jdg== X-Gm-Message-State: AOAM531NPJnzGj/elxbZcMXdfZVvVtq0OB4wAcslEKzLBpYwD/NoufNi ZKCgkn3240hslc0OgE8BrJcLqwOQnYdAbA== X-Received: by 2002:a63:c70c:: with SMTP id n12mr10338049pgg.347.1611738344665; Wed, 27 Jan 2021 01:05:44 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id i7sm1732164pfc.50.2021.01.27.01.05.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jan 2021 01:05:44 -0800 (PST) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] opp: Add dev_pm_opp_of_add_table_noclk() Date: Wed, 27 Jan 2021 14:35:27 +0530 Message-Id: <26de96f200805b43634bcc2b4d9824b2e38b0f6b.1611738228.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: <6c2160ff30a8f421563793020264cf9f533f293c.1611738228.git.viresh.kumar@linaro.org> References: <6c2160ff30a8f421563793020264cf9f533f293c.1611738228.git.viresh.kumar@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org A few drivers have device's clk but they don't want the OPP core to handle that. Add a new helper for them, dev_pm_opp_of_add_table_noclk(). Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 28 +++++++++++++++++----------- drivers/opp/of.c | 26 ++++++++++++++++++++++---- drivers/opp/opp.h | 2 +- include/linux/pm_opp.h | 6 ++++++ 4 files changed, 46 insertions(+), 16 deletions(-) -- 2.25.0.rc1.19.g042ed3e048af diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 9f6cf93cef3e..31abf460cd69 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1129,7 +1129,8 @@ struct opp_device *_add_opp_dev(const struct device *dev, return opp_dev; } -static struct opp_table *_allocate_opp_table(struct device *dev, int index) +static struct opp_table *_allocate_opp_table(struct device *dev, int index, + bool getclk) { struct opp_table *opp_table; struct opp_device *opp_dev; @@ -1158,14 +1159,18 @@ static struct opp_table *_allocate_opp_table(struct device *dev, int index) _of_init_opp_table(opp_table, dev, index); - /* Find clk for the device */ - opp_table->clk = clk_get(dev, NULL); - if (IS_ERR(opp_table->clk)) { - ret = PTR_ERR(opp_table->clk); - if (ret == -EPROBE_DEFER) - goto remove_opp_dev; + if (getclk) { + /* Find clk for the device */ + opp_table->clk = clk_get(dev, NULL); + if (IS_ERR(opp_table->clk)) { + ret = PTR_ERR(opp_table->clk); + if (ret == -EPROBE_DEFER) + goto remove_opp_dev; - dev_dbg(dev, "%s: Couldn't find clock: %d\n", __func__, ret); + dev_dbg(dev, "%s: Couldn't find clock: %d\n", __func__, ret); + } + } else { + opp_table->clk = ERR_PTR(-ENODEV); } /* Find interconnect path(s) for the device */ @@ -1214,7 +1219,8 @@ void _get_opp_table_kref(struct opp_table *opp_table) * uses the opp_tables_busy flag to indicate if another creator is in the middle * of adding an OPP table and others should wait for it to finish. */ -struct opp_table *_add_opp_table_indexed(struct device *dev, int index) +struct opp_table *_add_opp_table_indexed(struct device *dev, int index, + bool getclk) { struct opp_table *opp_table; @@ -1249,7 +1255,7 @@ struct opp_table *_add_opp_table_indexed(struct device *dev, int index) mutex_lock(&opp_table_lock); } else { - opp_table = _allocate_opp_table(dev, index); + opp_table = _allocate_opp_table(dev, index, getclk); mutex_lock(&opp_table_lock); if (!IS_ERR(opp_table)) @@ -1266,7 +1272,7 @@ struct opp_table *_add_opp_table_indexed(struct device *dev, int index) struct opp_table *_add_opp_table(struct device *dev) { - return _add_opp_table_indexed(dev, 0); + return _add_opp_table_indexed(dev, 0, true); } struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index c6856dcf4c34..a905497c75f8 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -956,7 +956,7 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) return ret; } -static int _of_add_table_indexed(struct device *dev, int index) +static int _of_add_table_indexed(struct device *dev, int index, bool getclk) { struct opp_table *opp_table; int ret, count; @@ -972,7 +972,7 @@ static int _of_add_table_indexed(struct device *dev, int index) index = 0; } - opp_table = _add_opp_table_indexed(dev, index); + opp_table = _add_opp_table_indexed(dev, index, getclk); if (IS_ERR(opp_table)) return PTR_ERR(opp_table); @@ -1010,7 +1010,7 @@ static int _of_add_table_indexed(struct device *dev, int index) */ int dev_pm_opp_of_add_table(struct device *dev) { - return _of_add_table_indexed(dev, 0); + return _of_add_table_indexed(dev, 0, true); } EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table); @@ -1026,10 +1026,28 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table); */ int dev_pm_opp_of_add_table_indexed(struct device *dev, int index) { - return _of_add_table_indexed(dev, index); + return _of_add_table_indexed(dev, index, true); } EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table_indexed); +/** + * dev_pm_opp_of_add_table_noclk() - Initialize indexed opp table from device + * tree without getting clk for device. + * @dev: device pointer used to lookup OPP table. + * @index: Index number. + * + * Register the initial OPP table with the OPP library for given device only + * using the "operating-points-v2" property. Do not try to get the clk for the + * device. + * + * Return: Refer to dev_pm_opp_of_add_table() for return values. + */ +int dev_pm_opp_of_add_table_noclk(struct device *dev, int index) +{ + return _of_add_table_indexed(dev, index, false); +} +EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table_noclk); + /* CPU device specific helpers */ /** diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 4ced7ffa8158..edbf05df8b82 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -224,7 +224,7 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_table *o int _opp_add_v1(struct opp_table *opp_table, struct device *dev, unsigned long freq, long u_volt, bool dynamic); void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, int last_cpu); struct opp_table *_add_opp_table(struct device *dev); -struct opp_table *_add_opp_table_indexed(struct device *dev, int index); +struct opp_table *_add_opp_table_indexed(struct device *dev, int index, bool getclk); void _put_opp_list_kref(struct opp_table *opp_table); #ifdef CONFIG_OF diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 979b208bc4a8..158158620dde 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -395,6 +395,7 @@ static inline int dev_pm_opp_sync_regulators(struct device *dev) #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) int dev_pm_opp_of_add_table(struct device *dev); int dev_pm_opp_of_add_table_indexed(struct device *dev, int index); +int dev_pm_opp_of_add_table_noclk(struct device *dev, int index); void dev_pm_opp_of_remove_table(struct device *dev); int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask); void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); @@ -419,6 +420,11 @@ static inline int dev_pm_opp_of_add_table_indexed(struct device *dev, int index) return -ENOTSUPP; } +static inline int dev_pm_opp_of_add_table_noclk(struct device *dev, int index) +{ + return -ENOTSUPP; +} + static inline void dev_pm_opp_of_remove_table(struct device *dev) { }