From patchwork Fri Sep 11 12:02:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 7160311 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 333D09F314 for ; Fri, 11 Sep 2015 12:06:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5BAAC207E7 for ; Fri, 11 Sep 2015 12:06:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 746DA207BD for ; Fri, 11 Sep 2015 12:06:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753155AbbIKMDl (ORCPT ); Fri, 11 Sep 2015 08:03:41 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:35027 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753154AbbIKMDj (ORCPT ); Fri, 11 Sep 2015 08:03:39 -0400 Received: by pacfv12 with SMTP id fv12so75009819pac.2 for ; Fri, 11 Sep 2015 05:03:39 -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=wX6Kcq8jmDuDf2bnF/66xTvBE6Nb++itSWw342wiOJI=; b=DLfTM3YLt16tdmsosnWzXgKEAw3cM6gZt/VQ/30gcu+QEueSx1bvyBTtFXpeeW04P2 u++r0WYQY/HGDwRQ3tuYphMMIMqJ+jvqxzKOS+eK0hrja/u39BnNBP1RkeTBUN25gxYq PIyeDwQMstZTiFDLwXEo6H0t5Uxfa1yirN6vS7xUyDOCJ48FSRbrqg11omgINaUzcLIu X+Tn9e8SNgg51kuDMOlZ7tXlFEvPLGfV9QHbNQhtW/rEiop5ZN3NTVEkeTsBC1za15Mc KZ8Vtf+v2wGe8p7CJLKSgYZHAE8jr00JVS7oqw0LSBcd8vW4K1sDVGVh9lALEFmN2tS3 B4aQ== X-Gm-Message-State: ALoCoQlzEKnKiYZdOJLZmA95PmRwFpV0zejVtmE10gGODaxc0NZM4aJOvBPKpqQZsjCcdoCbgy2d X-Received: by 10.68.173.165 with SMTP id bl5mr95181213pbc.157.1441973019327; Fri, 11 Sep 2015 05:03:39 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id td5sm91344pab.1.2015.09.11.05.03.38 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 11 Sep 2015 05:03:38 -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 09/16] PM / OPP: Disable OPPs that aren't supported by the regulators Date: Fri, 11 Sep 2015 17:32:05 +0530 Message-Id: <2cd568e33356b2f409d6af81aaad4e2ee418b905.1441972771.git.viresh.kumar@linaro.org> 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 Disable any OPPs where the connected regulators aren't able to provide the specified voltage. Signed-off-by: Viresh Kumar --- drivers/base/power/opp/core.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 42ea5a332ddc..04fe181b8132 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -834,6 +834,34 @@ static int _opp_add_v1(struct device *dev, unsigned long freq, long u_volt, return ret; } +static bool opp_supported_by_regulators(struct dev_pm_opp *opp, + struct device_opp *dev_opp) +{ + struct opp_supply *supply; + struct regulator *reg; + int count; + + for (count = 0; count < dev_opp->supply_count; count++) { + supply = opp->supplies + count; + reg = dev_opp->regulators[count]; + + /* Regulator may not be available for device */ + if (IS_ERR(reg)) + continue; + + if (!regulator_is_supported_voltage(reg, supply->u_volt_min, + supply->u_volt_max)) { + pr_warn("%s: OPP minuV: %lu maxuV: %lu, not supported by regulator: %s\n", + __func__, supply->u_volt_min, + supply->u_volt_max, + dev_opp->supply_names[count]); + return false; + } + } + + return true; +} + /* returns the number of entries used from microvolt */ static void opp_parse_single_supply(struct opp_supply *supply, bool triplet, u32 *microvolt, u32 *microamp) @@ -1016,6 +1044,12 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np, if (new_opp->clock_latency_ns > dev_opp->clock_latency_ns_max) dev_opp->clock_latency_ns_max = new_opp->clock_latency_ns; + if (!opp_supported_by_regulators(new_opp, dev_opp)) { + new_opp->available = false; + dev_warn(dev, "%s: OPP not supported by regulators (%lu)\n", + __func__, new_opp->rate); + } + mutex_unlock(&dev_opp_list_lock); supply = &new_opp->supplies[0];