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: 10577321 X-Patchwork-Delegate: agross@codeaurora.org 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 CDF5414BD for ; Mon, 27 Aug 2018 15:11:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBEBC29B54 for ; Mon, 27 Aug 2018 15:11:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B089829C77; Mon, 27 Aug 2018 15:11:55 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D6A529B54 for ; Mon, 27 Aug 2018 15:11:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727251AbeH0S6x (ORCPT ); Mon, 27 Aug 2018 14:58:53 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:36554 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727250AbeH0S6w (ORCPT ); Mon, 27 Aug 2018 14:58:52 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 0DF5F60B19; 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=1535382711; bh=SX4rjLARuXOsUxZj/nPKA7Q+bTBKMsuBWGZwaKbrmpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hk/bbeKGWVghZeks9hKD73hqxSSIYlkqke+2vtZ7PCRM0iu6jxKBwGqAfaMi7nwtF dgVmu0xUJ91dBMi5HxFtqv4bQfA4sewfiHS3BuofCcB5RQRZP4dDpVR83ZUm9SBIbP lzbd6caYrwOHxJVQDAFzPu/SJHToMhXML7+7KxWA= 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 Cc: linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, bjorn.andersson@linaro.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, vireshk@kernel.org, nm@ti.com, sboyd@kernel.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> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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__ */