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: 53460 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by patches.linaro.org (Postfix) with ESMTPS id 23FC9215BF for ; Fri, 11 Sep 2015 12:04:25 +0000 (UTC) Received: by lbcjc2 with SMTP id jc2sf23547739lbc.0 for ; Fri, 11 Sep 2015 05:04:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=6OsdJ91Vy4Xrr49MJKZaNMKFjqJKNlErNlgnclQ8f08=; b=TGej7lo4oMGW0YchQrwWgG1TVVns66aXt36TMDHkOjUBbCPKeMgKMX5H2GCBtniPvt TgPH6tyGJFo/cyqbNf/e9J/ZC5LaGEbpyFNmupiRZHe1ePVk2v6jiRsvMbFmu9ArpEEI gxfgyefugbeiil67pYow3nlrToXM1ySqqv9fFE29FEcStdkvychksOrndGpsvVP+VGBT pq/+S6ct1CIa4CAvU8UqJ31SRBJEzTPaYDvUQZ5Z0aFN3oJQ1MhbRCPhkd+q8RFBEVmE Viu3QWVp3+nbOGar373NT0E3TAEs2T8sfYuUC7RTa9jd8wPRmUb05+mTbVaJ4/ydlWxK 5lXQ== X-Gm-Message-State: ALoCoQn2q0W7USYZ25wAQZ0jTZejMDYhAIUQEqCV4E+dyh5DOjpJhXWTlsHn6nmCmE8nAOFbg8L4 X-Received: by 10.112.170.67 with SMTP id ak3mr11158317lbc.6.1441973064216; Fri, 11 Sep 2015 05:04:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.103 with SMTP id l7ls291102laf.78.gmail; Fri, 11 Sep 2015 05:04:24 -0700 (PDT) X-Received: by 10.112.171.227 with SMTP id ax3mr40328047lbc.118.1441973064030; Fri, 11 Sep 2015 05:04:24 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id s8si22876laa.81.2015.09.11.05.04.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 05:04:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by lagj9 with SMTP id j9so47173126lag.2 for ; Fri, 11 Sep 2015 05:04:24 -0700 (PDT) X-Received: by 10.152.170.230 with SMTP id ap6mr41516874lac.73.1441973063860; Fri, 11 Sep 2015 05:04:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1545965lbq; Fri, 11 Sep 2015 05:04:22 -0700 (PDT) X-Received: by 10.107.164.201 with SMTP id d70mr3152623ioj.127.1441973052953; Fri, 11 Sep 2015 05:04:12 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m5si129889iom.184.2015.09.11.05.04.11; Fri, 11 Sep 2015 05:04:12 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753271AbbIKMEG (ORCPT + 28 others); Fri, 11 Sep 2015 08:04:06 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:36199 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752168AbbIKMED (ORCPT ); Fri, 11 Sep 2015 08:04:03 -0400 Received: by padhk3 with SMTP id hk3so73569278pad.3 for ; Fri, 11 Sep 2015 05:04:02 -0700 (PDT) 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-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 */