Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6026513ybh; Wed, 7 Aug 2019 15:53:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJoUlO7zA/PlZEhGIRLhoAcT6qHh3HteoCxkNAoCZxHX5GVRXkT13vOHqj2iKo55fIWVyz X-Received: by 2002:a63:f941:: with SMTP id q1mr9814837pgk.350.1565218382983; Wed, 07 Aug 2019 15:53:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565218382; cv=none; d=google.com; s=arc-20160816; b=YAyRwHxcHF4FrjNk9D3gIx9rZPWsBIDII5iaUYym1/+kNggpm9n0frkv+ovsUInQbi L/5hzdY213huk0MyonmNfj0gEqGi4WOfpVMlDEKUgs21tluy4TVduMaATPiavxlCGazF iCgz6VDAAMgFARQf8V+p7ifKIH6k9rBnSeAfN7YUHlCa3nNyFG3xOVMVYRMadjaeFR4K QS8wOnQw7GtV6VQtmfTM4Ir2oaTPIOJDGXmJ8rRKyhPuZOVS9X1dVvi1blbo+bkatZ6C 7p2HIV3Fu4zfLdJtTVRXPlpjWb/DFi4+GGxCnl+0sJ2W1sM64sgLd8I4vizZNSDvEun5 BLlw== 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=f/5iyKYNpppjBF3zdaFLWaB9mtwpqzd2AKaKjPJxAWs=; b=drFdBaeFbWaZRTs8w7LMyRFHhzAejWsnkSG3XbpzR2t0n9MOjdkhT88WyCelUEL6Dk kVBRKZzv53SHx//IoqJ/bLU9asHTeWwUK/NtVA+U4c+KRWPpJD6EdT9Fr1E+1vHAp4Ly Z3sSqBIJ4u7BMO3yC2x19Go+98ogbPq0A1db6DqRlNbpAJ8q4I62Cad98QFFGiLvP7d3 fJCAguXIrzCbvr3knKIp8r9dhQ70reYndCb+sL/77laEHaxNizC7Aj8JxvTSeiGadGoB Tdz7QJE4Vyl/uTx9cpHFWg8DCJeUfhuYUevHmLoB9Ax34tQn5Pj1EMH3g3N1R7gz4FFx FE9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="oG/h5CSE"; 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 z5si45815937plo.434.2019.08.07.15.52.45; Wed, 07 Aug 2019 15:53:02 -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="oG/h5CSE"; 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 S2389521AbfHGWbX (ORCPT + 99 others); Wed, 7 Aug 2019 18:31:23 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:38444 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389454AbfHGWbW (ORCPT ); Wed, 7 Aug 2019 18:31:22 -0400 Received: by mail-qk1-f202.google.com with SMTP id n190so80643153qkd.5 for ; Wed, 07 Aug 2019 15:31:21 -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=f/5iyKYNpppjBF3zdaFLWaB9mtwpqzd2AKaKjPJxAWs=; b=oG/h5CSE4Vl8m9nJpZKL2XmKPaShpcaKcKIvjDfvwRS9zUFnoyEJ3iouLQdGeCZq+E hf9dKIkpZb9iIuxITVcANYzlRy6K7U+DS0F6TsUJOUjUBN39vlI6rEFj7nwKYnjH1jnX 6aSKpaBVNOrDAU8lFkxwVB4padlrh79dFWccl81oByzfLMik8LcjrwAAATm0E9k+bbVs eKzqRFY+EYl5uV2uMKPbKLCMo93gdvytxJvjedgKr3PGKLN/s5CP10TvgN1jHHWZ58dc VFrHN/eoabKXS5bZ03G+2CTZZeJfUJacXEtg2vO+jIsZWRl1Enxs5vUieQ0d0zVf+S+g sIAA== 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=f/5iyKYNpppjBF3zdaFLWaB9mtwpqzd2AKaKjPJxAWs=; b=Khw01Lx80diFEU/4dmgbHFLCCBvqSsrvpddjAMofcTIJXiUMAdXdQV6E8F0sfYPvL1 VTnIgphYXPszH3KVuswv4sWk5yiP54IlKf1bbTHI54xiAtq1z2/vGGLIlmyVacme2jno YBnbWoY6JhqxUrEjYx0piqDXTWwaw87ztrgA4MYWECaWBhZorTDd3fF01vveEWvz2Fan MY37Xjy/SmZjUVpKy3PIkTMCkMrJGfpsUFh3jgDEjzuhGa4JFLjxarvqEtERehAFpiIr JDruGeA7XTv/JaSkMInuOxfk9blDDCd+PmadgOGhiJtF1fM7X8rk2LTdXt99CWFxoTRM 2iPg== X-Gm-Message-State: APjAAAW3FOnzmSdbspvihstafRqt+KATa8U8du0N+ZTgcygO6lJ0rDQM jMRnBoUk6WX5eTt69B4diEjrAby2IjNnLCQ= X-Received: by 2002:a0c:df12:: with SMTP id g18mr10126912qvl.34.1565217081340; Wed, 07 Aug 2019 15:31:21 -0700 (PDT) Date: Wed, 7 Aug 2019 15:31:10 -0700 In-Reply-To: <20190807223111.230846-1-saravanak@google.com> Message-Id: <20190807223111.230846-3-saravanak@google.com> Mime-Version: 1.0 References: <20190807223111.230846-1-saravanak@google.com> X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog Subject: [PATCH v5 2/3] OPP: Add support for bandwidth OPP tables From: Saravana Kannan To: Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , Georgi Djakov , vincent.guittot@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, adharmap@codeaurora.org, Rajendra Nayak , sibis@codeaurora.org, bjorn.andersson@linaro.org, evgreen@chromium.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 | 41 ++++++++++++++++++++++++++++++++--------- drivers/opp/opp.h | 4 +++- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 1813f5ad5fa2..e1750033fef9 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -523,6 +523,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 @@ -560,22 +589,16 @@ 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-kBps not found\n", + __func__); goto free_opp; } rate_not_available = true; - } else { - /* - * 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; } of_property_read_u32(np, "opp-level", &new_opp->level); diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 01a500e2c40a..6bb238af9cac 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -56,7 +56,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 @@ -78,6 +79,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.23.0.rc1.153.gdeed80330f-goog