From patchwork Mon Aug 27 15:11:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10577359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 58414920 for ; Mon, 27 Aug 2018 15:18:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4559B29CE0 for ; Mon, 27 Aug 2018 15:18:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38E5029CE6; Mon, 27 Aug 2018 15:18:25 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BF82B29CE0 for ; Mon, 27 Aug 2018 15:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=DGKu1THLFJL0jje8qDu+A7ioKbtadqI6ANffeMiH4PQ=; b=sZMPXL2fEX5h0i4RSSdJkXl83Q o/RufoFiKpDWjkiNTjE8KoUZrfp0X2I/WHJFCL+QS8+J8LtiVdz1CvT5kxiLi1Jdoq4la54y72OZX oHwU5rJP1rR/tI6HkyQUvTAIGX5L267RfoztNNDQaEqb08t31Jev91yUZDoSck6gaKfvBAL+SbRqT iDhxczHw2qxJ1Wc5PYbNRyXI8XA1Xn6vJzidyB8TvfFlcbxj+ltDGAvndUh4Z+A6CM+HxBBlgZDcV uSxGqNTZPdFFwXWcjxBuvZdh2vsfF779c9FKYIug0dASyrk8hf9qCtetIZqmygXLvWV44d7Fo4DsJ uqRv4RgQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuJHN-0001j1-VK; Mon, 27 Aug 2018 15:18:10 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuJBN-00069T-MR for linux-arm-kernel@bombadil.infradead.org; Mon, 27 Aug 2018 15:11:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EAORhX7vSDaSseeTMB+rlGUM6H/tgGzKQdZMLPAwQuM=; b=W8APdL/LF/kLjP9vrAPxlEBWj hRCWuL+EBbWqKM8mZe6XS0Kfxk1ZNhzlHPYXKGWcXSW065SWM2g6Zw/ndEsgzRACX/lIhJbIupCnm 73tuoYMB+eZlBEkCJ+iO58cVYGyIUJkW7xFViOINMSN6OnFJDsWiXmfHY8SFEYVvjHo+fTNkSR5ab IqkcHRTVOvJQK9glAg6GLDbk7i6TSUNJs/Tx9H/nyzSXftvRWAfp2JzoBTC2YCTld4VMIfXdnp1/y VDeSwp/KyaMcQRKexApCIySVp2Tv5OnLZY36/m3I6E3s+uYREKW12u6DK8fw/BKt4lQAbLqtdEO0T gthDJIXRQ==; Received: from smtp.codeaurora.org ([198.145.29.96]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuJBK-00056m-9Z for linux-arm-kernel@lists.infradead.org; Mon, 27 Aug 2018 15:11:56 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A6C196053D; Mon, 27 Aug 2018 15:11:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1535382700; bh=SX4rjLARuXOsUxZj/nPKA7Q+bTBKMsuBWGZwaKbrmpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Quh3MgzeE3egxX/48wWvhCtXX8VESbvPETSUv5e3meEjd5pnmUm/W14zptDe+GU+P mlTkVnhudzNrBH4OAsTNxTUeU70GOZw4Kwi8jdtz9bLP/t2dbDJOuz667qWEtCxexF /ALIJviD6GKZVpO8WAtY+paTpSzhP8llyJTowKy4= Received: from jcrouse-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A602660BE6; Mon, 27 Aug 2018 15:11:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1535382686; bh=SX4rjLARuXOsUxZj/nPKA7Q+bTBKMsuBWGZwaKbrmpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JJaZGe12TPpuzW5h+sXaH0mszmJt/DDNcV32WEVAwqeHBcZxiQpz4BLs8O1YvNouS 5z3TyCiN9yPq39jAcB9fn8kcunvhctDn6d28v1oRr0rGAiOkbUM7bI7S/+c9rB4CNU WAYtGM4dkhNXCfaU4vzkSdM0E1u7b8AtevCRx3yA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A602660BE6 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org From: Jordan Crouse To: freedreno@lists.freedesktop.org, georgi.djakov@linaro.org Subject: [PATCH 7/9] OPP: Add dev_pm_opp_get_interconnect_bw() Date: Mon, 27 Aug 2018 09:11:10 -0600 Message-Id: <20180827151112.25211-8-jcrouse@codeaurora.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180827151112.25211-1-jcrouse@codeaurora.org> References: <20180827151112.25211-1-jcrouse@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180827_161154_621992_63E9FB17 X-CRM114-Status: GOOD ( 11.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nm@ti.com, devicetree@vger.kernel.org, linux-pm@vger.kernel.org, sboyd@kernel.org, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, bjorn.andersson@linaro.org, vireshk@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add dev_pm_opp_get_interconnect_bw() to read the interconnect bandwidth values for a given OPP. Signed-off-by: Jordan Crouse --- drivers/opp/of.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 7 +++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 7af0ddec936b..6a5eecaaf8c1 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -777,3 +777,39 @@ struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) return of_node_get(opp->np); } EXPORT_SYMBOL_GPL(dev_pm_opp_get_of_node); + +/** + * dev_pm_opp_get_interconnect_bw() - Get the interconnect bandwidth for the opp + * @opp: opp containing the bandwidth values + * @pathname: name of the interconnect path for the bandwidth values + * @avgbw: Pointer for the value to hold the average BW defined for the OPP + * @peakbw: Pointer for the value to hold the peak BW defined for the OPP + * + * Return: Negative value on error or 0 on success + */ +int dev_pm_opp_get_interconnect_bw(struct dev_pm_opp *opp, + const char *pathname, u64 *avgbw, u64 *peakbw) +{ + char name[NAME_MAX]; + struct property *prop; + int count; + + if (IS_ERR_OR_NULL(opp)) + return -ENOENT; + + snprintf(name, NAME_MAX, "opp-interconnect-bw-%s", pathname); + prop = of_find_property(opp->np, name, NULL); + + if (!prop) + return -ENOENT; + + count = of_property_count_u64_elems(opp->np, name); + if (count != 2) + return -EINVAL; + + of_property_read_u64_index(opp->np, name, 0, avgbw); + of_property_read_u64_index(opp->np, name, 0, peakbw); + + return 0; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_interconnect_bw); diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 099b31960dec..70e49e259d0e 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -301,6 +301,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpuma struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev, struct device_node *np); struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); +int dev_pm_opp_get_interconnect_bw(struct dev_pm_opp *opp, const char *pathname, u64 *avgbw, u64 *peakbw); #else static inline int dev_pm_opp_of_add_table(struct device *dev) { @@ -343,6 +344,12 @@ static inline struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) { return NULL; } + +static inline int dev_pm_opp_get_interconnect_bw(struct dev_pm_opp *opp, const char *pathname, + u64 *avgbw, u64 *peakbw) +{ + return -ENOTSUPP; +} #endif #endif /* __LINUX_OPP_H__ */