From patchwork Tue Feb 6 16:34:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter De Schrijver X-Patchwork-Id: 10203359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2927F60327 for ; Tue, 6 Feb 2018 16:37:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2201C28AEA for ; Tue, 6 Feb 2018 16:37:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 157FA28C9B; Tue, 6 Feb 2018 16:37:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAE4C28AEA for ; Tue, 6 Feb 2018 16:37:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752851AbeBFQhb (ORCPT ); Tue, 6 Feb 2018 11:37:31 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:18934 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752518AbeBFQek (ORCPT ); Tue, 6 Feb 2018 11:34:40 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Tue, 06 Feb 2018 08:34:44 -0800 Received: from HQMAIL108.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 06 Feb 2018 08:34:39 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 06 Feb 2018 08:34:39 -0800 Received: from UKMAIL101.nvidia.com (10.26.138.13) by HQMAIL108.nvidia.com (172.18.146.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 6 Feb 2018 16:34:39 +0000 Received: from tbergstrom-lnx.Nvidia.com (10.21.24.170) by UKMAIL101.nvidia.com (10.26.138.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 6 Feb 2018 16:34:34 +0000 Received: from tbergstrom-lnx.nvidia.com (localhost [127.0.0.1]) by tbergstrom-lnx.Nvidia.com (Postfix) with ESMTP id 4EBCCF8083F; Tue, 6 Feb 2018 18:34:33 +0200 (EET) From: Peter De Schrijver To: , , , , , , , , , CC: Laxman Dewangan Subject: [PATCH v3 01/11] regulator: core: add API to get voltage constraints Date: Tue, 6 Feb 2018 18:34:02 +0200 Message-ID: <1517934852-23255-2-git-send-email-pdeschrijver@nvidia.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1517934852-23255-1-git-send-email-pdeschrijver@nvidia.com> References: <1517934852-23255-1-git-send-email-pdeschrijver@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-Originating-IP: [10.21.24.170] X-ClientProxiedBy: UKMAIL102.nvidia.com (10.26.138.15) To UKMAIL101.nvidia.com (10.26.138.13) Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Laxman Dewangan Add API to get min/max rail voltage configured from platform for given rails. Changes to the commit message by Peter De Schrijver Signed-off-by: Laxman Dewangan --- drivers/regulator/core.c | 31 +++++++++++++++++++++++++++++++ include/linux/regulator/consumer.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index be767dd..c498774 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3246,6 +3246,37 @@ int regulator_get_voltage(struct regulator *regulator) EXPORT_SYMBOL_GPL(regulator_get_voltage); /** + * regulator_get_constraint_voltages - get platform specific constraint voltage, + * @regulator: regulator source + * @min_uV: Minimum microvolts. + * @max_uV: Maximum microvolts. + * + * This returns the current regulator voltage in uV. + * + * NOTE: If the regulator is disabled it will return the voltage value. This + * function should not be used to determine regulator state. + */ + +int regulator_get_constraint_voltages(struct regulator *regulator, + int *min_uV, int *max_uV) +{ + struct regulator_dev *rdev = regulator->rdev; + + if (rdev->desc && rdev->desc->fixed_uV && rdev->desc->n_voltages == 1) { + *min_uV = rdev->desc->fixed_uV; + *max_uV = rdev->desc->fixed_uV; + return 0; + } + if (rdev->constraints) { + *min_uV = rdev->constraints->min_uV; + *max_uV = rdev->constraints->max_uV; + return 0; + } + return -EINVAL; +} +EXPORT_SYMBOL_GPL(regulator_get_constraint_voltages); + +/** * regulator_set_current_limit - set regulator output current limit * @regulator: regulator source * @min_uA: Minimum supported current in uA diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index df176d7..d3f495a 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -250,6 +250,8 @@ int regulator_is_supported_voltage(struct regulator *regulator, int regulator_set_voltage_time(struct regulator *regulator, int old_uV, int new_uV); int regulator_get_voltage(struct regulator *regulator); +int regulator_get_constraint_voltages(struct regulator *regulator, + int *min_uV, int *max_uV); int regulator_sync_voltage(struct regulator *regulator); int regulator_set_current_limit(struct regulator *regulator, int min_uA, int max_uA);