Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp496489ybi; Thu, 13 Jun 2019 21:18:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUrQkoO+aVFJfZ6ZDcf8v3mGiNjnSUGkFF56cvKNwi9GvAgiVmMlEnddBsk1SOapiw+Ail X-Received: by 2002:aa7:8817:: with SMTP id c23mr29408547pfo.146.1560485912742; Thu, 13 Jun 2019 21:18:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560485912; cv=none; d=google.com; s=arc-20160816; b=fsUwZw979LHf5p1CUeILuieXEPsd+3r7Ei0OCrI6sMYaz5uWiHO16wOp0pD5b6EsLk 4Cr/HMKSnbdqn5EYGU5g1SyB+AhXczIBPjUjQTIRBLAhr+UG+I8Z635Xpiv14mWQWKU/ iQFmvEJuui4tBDOIysrjZpFGftomJBJrRTw0FDSWUzjXQNssdrAz2Byh1dSEVAttP6nW eB/tnUt7J5tvwyYg2T+8BvJrXL+iiT7YSiasXLTV6VlMmOQZ+WPjr7gW+aYp7Ei9jOos qERKsYLlRaTE6/2obHmZBOYdNjehTbAJN15HWWqHKMc9Wvt0QeiEIjqcoKaNNxwcixzL sP4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=S7+vYKQUq5lZMW6Ri78n8SISGeuUnAv5G2fMh5MCCB0=; b=jX7ftI7gcr45wfELjsDcmGJqt4ybChPSJ/7DTY/LAZNSh7tQM2ChljcyrH/Noq9+WG /4Cd1Gnho1CbwTz+eSIX0OqNhTrLKdKTBBnqTFMw2pZXxpZTnn0L16HoZo9iWvkAkWR4 BAUbkmPYutZsTwm2Fn9bfTSWOAYqHjhNT/yal0PgNF8eRpxnYXTnZSCClLSpbiXYZI83 EwLxLEkxnjooS9IOKrBji2zT610JFGYmT21s8m2ncSzNIioSIdc+1TtKqQxzaXebn6eL AnPsHiyjeEyVmwEzFzdUmfLPxS6bzG2V+X2gpZdrjipTK5QKu2xwlCodHo8XDfzB9Qs7 Ospw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dm8bZhPE; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si1201369plk.342.2019.06.13.21.18.17; Thu, 13 Jun 2019 21:18:32 -0700 (PDT) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=dm8bZhPE; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726213AbfFNERz (ORCPT + 99 others); Fri, 14 Jun 2019 00:17:55 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:49463 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbfFNERy (ORCPT ); Fri, 14 Jun 2019 00:17:54 -0400 Received: by mail-qt1-f201.google.com with SMTP id 97so1047271qtb.16 for ; Thu, 13 Jun 2019 21:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=S7+vYKQUq5lZMW6Ri78n8SISGeuUnAv5G2fMh5MCCB0=; b=dm8bZhPEuM2wGtMvKc4gKqPZQ3mLqzd91ZsffM4nT/XjREXW8Zp4bMnDnbqJzhfGLA 38L5mApWLtGNnvt4U1sFjTigD+r4o8ZCWHbEzdrLoreO/Ra0fsuIhDLFfz01ha7AbinR RCScftofhtV1n6geuxrFD37xuQv6fN5f9yrnWiT64NUxZsHJS3/MmdzQh3FnTreCYKAq ymoehLzNzvJmSiIGmQrCerHzbhQqPJcplC1wBWgMpDk57VSNBAsybLBLHmVPTak18L3H uBBT8fjTIGFdD4gW08nssJhMgmUI9+Ws5ZsVpC9M9XM2YOLQA/YAm0+A2uLxXMq3a7rk K5BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=S7+vYKQUq5lZMW6Ri78n8SISGeuUnAv5G2fMh5MCCB0=; b=WE8oq8+ZcFS3ppaCZSqA1fCwmwYkukVJ/cstzAoV8uJOQ1AHJEB2H1l+ca0kF3tjGD BOXq1Wjb7wAEdpd0TpmAz5Hn53fR8Gc1tmw2Ka4fMpRWtOQCZsibzFUe0yp0wpJwIoxY wrhhI1yj98Lz3URms08hDU7Qtf4jC0iC8UhlMvZ79HKAkWYemjtAnyqhL5D42puYxwp9 Fkek0q1pFxVfTkE0G8BNiKI0T0Eym1qDc2o5NU82rRMfvzwsFxdlfzXRniYYDDefX03V kae9QiijzzwEbqDsgGgB3n1kRIIm34HRcE2MDoBtjvC2mXMm8FE9PcwK7AhQ+qJ9pwW7 cb9A== X-Gm-Message-State: APjAAAVgiUBBACu2BvWVJLI5VEO/ibhqE+mDyPR1ZlrePPqbcb8AUsY6 z12xThVy+xoc7fvK3bdpP32uhzRMlRMTs5g= X-Received: by 2002:a0c:9253:: with SMTP id 19mr6478264qvz.180.1560485873506; Thu, 13 Jun 2019 21:17:53 -0700 (PDT) Date: Thu, 13 Jun 2019 21:17:27 -0700 In-Reply-To: <20190614041733.120807-1-saravanak@google.com> Message-Id: <20190614041733.120807-6-saravanak@google.com> Mime-Version: 1.0 References: <20190614041733.120807-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v2 05/11] OPP: Add support for bandwidth OPP tables From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Not all devices quantify their performance points in terms of frequency. Devices like interconnects quantify their performance points in terms of bandwidth. We need a way to represent these bandwidth levels in OPP. So, add support for parsing bandwidth OPPs from DT. Signed-off-by: Saravana Kannan --- drivers/opp/of.c | 34 ++++++++++++++++++++++++++++++++-- drivers/opp/opp.h | 4 +++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 7c8336e94aff..d5815289518a 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -538,6 +538,35 @@ void dev_pm_opp_of_remove_table(struct device *dev) } EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); +static int _read_opp_key(struct dev_pm_opp *new_opp, struct device_node *np) +{ + int ret; + u64 rate; + u32 bw; + + ret = of_property_read_u64(np, "opp-hz", &rate); + if (!ret) { + /* + * Rate is defined as an unsigned long in clk API, and so + * casting explicitly to its type. Must be fixed once rate is 64 + * bit guaranteed in clk API. + */ + new_opp->rate = (unsigned long)rate; + return 0; + } + + ret = of_property_read_u32(np, "opp-peak-KBps", &bw); + if (ret) + return ret; + new_opp->rate = (unsigned long) &bw; + + ret = of_property_read_u32(np, "opp-avg-KBps", &bw); + if (!ret) + new_opp->avg_bw = (unsigned long) &bw; + + return 0; +} + /** * _opp_add_static_v2() - Allocate static OPPs (As per 'v2' DT bindings) * @opp_table: OPP table @@ -575,11 +604,12 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, if (!new_opp) return ERR_PTR(-ENOMEM); - ret = of_property_read_u64(np, "opp-hz", &rate); + ret = _read_opp_key(new_opp, np); if (ret < 0) { /* "opp-hz" is optional for devices like power domains. */ if (!opp_table->is_genpd) { - dev_err(dev, "%s: opp-hz not found\n", __func__); + dev_err(dev, "%s: opp-hz or opp-peak-bw not found\n", + __func__); goto free_opp; } diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 569b3525aa67..ead2cdafe957 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -59,7 +59,8 @@ extern struct list_head opp_tables; * @turbo: true if turbo (boost) OPP * @suspend: true if suspend OPP * @pstate: Device's power domain's performance state. - * @rate: Frequency in hertz + * @rate: Frequency in hertz OR Peak bandwidth in kilobytes per second + * @avg_bw: Average bandwidth in kilobytes per second * @level: Performance level * @supplies: Power supplies voltage/current values * @clock_latency_ns: Latency (in nanoseconds) of switching to this OPP's @@ -81,6 +82,7 @@ struct dev_pm_opp { bool suspend; unsigned int pstate; unsigned long rate; + unsigned long avg_bw; unsigned int level; struct dev_pm_opp_supply *supplies; -- 2.22.0.rc2.383.gf4fbbf30c2-goog