From patchwork Tue May 20 14:27:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 4210891 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5E493BEEAB for ; Tue, 20 May 2014 14:27:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 781D3202DD for ; Tue, 20 May 2014 14:27:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 06DF220328 for ; Tue, 20 May 2014 14:27:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751461AbaETO1r (ORCPT ); Tue, 20 May 2014 10:27:47 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:34043 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753292AbaETO1q (ORCPT ); Tue, 20 May 2014 10:27:46 -0400 Received: from dude.hi.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Wml10-0006AV-OU; Tue, 20 May 2014 16:27:38 +0200 From: Lucas Stach To: linux-pm@vger.kernel.org Cc: Greg Kroah-Hartman , Len Brown , Pavel Machek , "Rafael J. Wysocki" , Nishanth Menon Subject: [RFC 2/2] PM / OPP: extend DT parsing to allow voltage ranges Date: Tue, 20 May 2014 16:27:40 +0200 Message-Id: <1400596060-5330-3-git-send-email-l.stach@pengutronix.de> X-Mailer: git-send-email 2.0.0.rc0 In-Reply-To: <1400596060-5330-1-git-send-email-l.stach@pengutronix.de> References: <1400596060-5330-1-git-send-email-l.stach@pengutronix.de> X-SA-Exim-Connect-IP: 10.1.0.7 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pm@vger.kernel.org Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Following the introduction of voltage ranges into OPP we need a way to encode them in the device tree in a similar fashion to the non-ranged versions. To keep compatibility with old DTs the parsing function is changed to understand both versions. Signed-off-by: Lucas Stach Reviewed-by: Pavel Machek --- Documentation/devicetree/bindings/power/opp.txt | 23 ++++++++++++++++++ drivers/base/power/opp.c | 31 ++++++++++++++++++------- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/power/opp.txt b/Documentation/devicetree/bindings/power/opp.txt index 74499e5033fc..5b520ff321f5 100644 --- a/Documentation/devicetree/bindings/power/opp.txt +++ b/Documentation/devicetree/bindings/power/opp.txt @@ -10,6 +10,16 @@ Properties: freq: clock frequency in kHz vol: voltage in microvolt +or + +- operating-points-range: An array of 4-tuple items, each item consisting + of a frequency and a related voltage range in the following form: + + freq: clock frequency in kHz + min-vol-uV: absolute minimum required voltage for this frequency + nom-vol-uV: nominal voltage for this frequency + max-vol-uV: absolute maximum allowed voltage for this frequency + Examples: cpu@0 { @@ -23,3 +33,16 @@ cpu@0 { 198000 850000 >; }; + +cpu@0 { + compatible = "arm,cortex-a8"; + reg = <0x0>; + operating-points-range = < + /* kHz min(uV) nom(uV) max(uV) */ + 166666 850000 900000 1400000 + 400000 900000 950000 1400000 + 800000 1050000 1100000 1400000 + 1000000 1200000 1250000 1400000 + 1200000 1300000 1350000 1400000 + >; +}; diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index e738a37df915..6af9c465c46b 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -727,11 +727,16 @@ int of_init_opp_table(struct device *dev) { const struct property *prop; const __be32 *val; - int nr; + int nr, prop_size; - prop = of_find_property(dev->of_node, "operating-points", NULL); - if (!prop) + if ((prop = of_find_property(dev->of_node, "operating-points", NULL))) + prop_size = 2; + else if ((prop = of_find_property(dev->of_node, + "operating-points-range", NULL))) + prop_size = 4; + else return -ENODEV; + if (!prop->value) return -ENODATA; @@ -740,22 +745,32 @@ int of_init_opp_table(struct device *dev) * voltage like . */ nr = prop->length / sizeof(u32); - if (nr % 2) { + if (nr % prop_size) { dev_err(dev, "%s: Invalid OPP list\n", __func__); return -EINVAL; } val = prop->value; while (nr) { - unsigned long freq = be32_to_cpup(val++) * 1000; - unsigned long volt = be32_to_cpup(val++); + unsigned long freq, volt_min, volt_nominal, volt_max; + + freq = be32_to_cpup(val++) * 1000; + if (prop_size == 4) { + volt_min = be32_to_cpup(val++); + volt_nominal = be32_to_cpup(val++); + volt_max = be32_to_cpup(val++); + } else { + volt_nominal = be32_to_cpup(val++); + volt_min = volt_max = volt_nominal; + } - if (dev_pm_opp_add(dev, freq, volt, volt, volt)) { + if (dev_pm_opp_add(dev, freq, volt_min, volt_nominal, + volt_max)) { dev_warn(dev, "%s: Failed to add OPP %ld\n", __func__, freq); continue; } - nr -= 2; + nr -= prop_size; } return 0;