From patchwork Fri Sep 11 12:02:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 7160281 X-Patchwork-Delegate: rjw@sisk.pl 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9F8C8BEEC1 for ; Fri, 11 Sep 2015 12:05:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B2EE52055C for ; Fri, 11 Sep 2015 12:05:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A9D0A20501 for ; Fri, 11 Sep 2015 12:05:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752904AbbIKMEF (ORCPT ); Fri, 11 Sep 2015 08:04:05 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:34466 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752702AbbIKMED (ORCPT ); Fri, 11 Sep 2015 08:04:03 -0400 Received: by padhy16 with SMTP id hy16so73648419pad.1 for ; Fri, 11 Sep 2015 05:04:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=H0U0FY61QV3XfUf8XbOvlqDKvBOshpoVQxX5khqvuy4=; b=DQIQiPkl0zz5vJn3duz2mIesUmnTeTglyoYHfRsXcw1tg/QCPQpBCQa3G0ejawSZBP lknZ4xnUooJIGk6+Y9GvEE2HhbZme8A8SABfS61yB2OyQl5JbB/mUvOnrI8Rp8QM8Tdu vRaXnZmDQfOldZu7pBagImQcgSoZP0w30TvcbOSP+3gkk09nFzUF14AonLbs3skwubGy 3v4tntotZdpUviJ45tZuwSIQgv5Ztg1rnykvzuUf9DnBbjj4kqMBm0HRu2eqhLanvI9c NUkGH+I59HfzKBIeyH7vG2bwVB4uADkwWSr3PmhoxBoQaTutY3BY9AjRriNmJdBf6kaI afuA== X-Gm-Message-State: ALoCoQmYQ5qCnSJvflgMX2WtH2MOYnT7oEt8OS0hX/lOL1HxEHOd1ifpkONIrSeGnXpRjT82qag8 X-Received: by 10.66.163.161 with SMTP id yj1mr85798822pab.34.1441973041923; Fri, 11 Sep 2015 05:04:01 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id pi9sm7970pbb.96.2015.09.11.05.04.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 11 Sep 2015 05:04:01 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , nm@ti.com, sboyd@codeaurora.org Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, rob.herring@linaro.org, lee.jones@linaro.org, Viresh Kumar , Bartlomiej Zolnierkiewicz , Dmitry Torokhov , Greg Kroah-Hartman , Len Brown , linux-kernel@vger.kernel.org (open list), Pavel Machek Subject: [PATCH 12/16] PM / OPP: Parse clock and voltage tolerance for v1 bindings Date: Fri, 11 Sep 2015 17:32:08 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 V2 bindings have better support for that and doesn't need special care. To use callbacks, like dev_pm_opp_get_max_{transition|volt}_latency(), irrespective of the bindings, the core needs to know clock/voltage tolerance for the earlier bindings. Signed-off-by: Viresh Kumar --- drivers/base/power/opp/core.c | 29 ++++++++++++++++++++++++++--- drivers/base/power/opp/opp.h | 5 +++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index d0678e804a75..9633f2fc3481 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -568,16 +568,19 @@ struct device_list_opp *_add_list_dev(const struct device *dev, * _add_device_opp() - Find device OPP table or allocate a new one * @dev: device for which we do this operation * @supply_count: Number of supplies available for each OPP. + * @opp_v2: true if parsing v2 bindings, else false. * * It tries to find an existing table first, if it couldn't find one, it * allocates a new OPP table and returns that. * * Return: valid device_opp pointer if success, else NULL. */ -static struct device_opp *_add_device_opp(struct device *dev, int supply_count) +static struct device_opp *_add_device_opp(struct device *dev, int supply_count, + bool opp_v2) { struct device_opp *dev_opp; struct device_list_opp *list_dev; + struct device_node *np; size_t size; /* Check for existing list for 'dev' first */ @@ -598,6 +601,22 @@ static struct device_opp *_add_device_opp(struct device *dev, int supply_count) if (!dev_opp) return NULL; + if (!opp_v2) { + /* + * Only required for backward compatibility with v1 bindings. + */ + np = of_node_get(dev->of_node); + if (np) { + u32 val; + + if (!of_property_read_u32(np, "clock-latency", &val)) + dev_opp->clock_latency_ns_max = val; + of_property_read_u32(np, "voltage-tolerance", + &dev_opp->voltage_tolerance_v1); + of_node_put(np); + } + } + dev_opp->supply_count = supply_count; dev_opp->regulators = (struct regulator **)(dev_opp + 1); dev_opp->supply_names = (const char **)(dev_opp->regulators + supply_count); @@ -767,7 +786,7 @@ _allocate_opp(struct device *dev, struct device_opp **dev_opp, int supply_count) INIT_LIST_HEAD(&opp->node); - *dev_opp = _add_device_opp(dev, supply_count); + *dev_opp = _add_device_opp(dev, supply_count, false); if (!*dev_opp) { kfree(opp); return NULL; @@ -873,6 +892,7 @@ static int _opp_add_v1(struct device *dev, unsigned long freq, long u_volt, { struct device_opp *dev_opp; struct dev_pm_opp *new_opp; + unsigned long tol; int ret; /* Hold our list modification lock here */ @@ -886,7 +906,10 @@ static int _opp_add_v1(struct device *dev, unsigned long freq, long u_volt, /* populate the opp table */ new_opp->rate = freq; + tol = u_volt * dev_opp->voltage_tolerance_v1 / 100; new_opp->supplies[0].u_volt = u_volt; + new_opp->supplies[0].u_volt_min = u_volt - tol; + new_opp->supplies[0].u_volt_max = u_volt + tol; new_opp->available = true; new_opp->dynamic = dynamic; @@ -1436,7 +1459,7 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np) * We need to add dev_opp before adding any OPPs, so that supply_names * are valid while the OPPs are getting added. */ - dev_opp = _add_device_opp(dev, supply_count); + dev_opp = _add_device_opp(dev, supply_count, true); if (!dev_opp) return -ENOMEM; diff --git a/drivers/base/power/opp/opp.h b/drivers/base/power/opp/opp.h index 830c4b654a51..55205cbe59dc 100644 --- a/drivers/base/power/opp/opp.h +++ b/drivers/base/power/opp/opp.h @@ -142,6 +142,8 @@ struct device_list_opp { * @dentry: debugfs dentry pointer of the real device directory (not links). * @dentry_name: Name of the real dentry. * + * @voltage_tolerance_v1: In percentage, for v1 bindings only. + * * This is an internal data structure maintaining the link to opps attached to * a device. This structure is not meant to be shared to users as it is * meant for book keeping and private to OPP library. @@ -173,6 +175,9 @@ struct device_opp { struct dentry *dentry; char dentry_name[NAME_MAX]; #endif + + /* For backward compatibility with v1 bindings */ + unsigned int voltage_tolerance_v1; }; /* Routines internal to opp core */