Received: by 10.223.176.5 with SMTP id f5csp866485wra; Tue, 6 Feb 2018 08:39:20 -0800 (PST) X-Google-Smtp-Source: AH8x226gBD8FcX9qdxEXvTdikSvvzZee7XkA4S1MsFFkUf8DsojZoAITGiILUsEZcxLSPK/2LJFz X-Received: by 2002:a17:902:7887:: with SMTP id q7-v6mr2986661pll.385.1517935160486; Tue, 06 Feb 2018 08:39:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517935160; cv=none; d=google.com; s=arc-20160816; b=dqAwfFE/cC60nQ6VdkC+lPKt0BuOpaOHZjX+E95FZQ+Grz4gheSalJcZyNbnbbRQgX fUh0joiE9Z4s/3oRR0iL9umBQOr5Huhyzz6mEd3oVYZOMhKwfT9sD3iX+szGWEgUYrXr 0sFCsfxIuNwbW4bJOCC34qpa2mNmGsyhQuxM/KGsg6CdHczY2Bz9+qiIYUNRweOh6jUd pLgVQ2ag4BEOhChTlj+lp62XkfrNfKVufYOPQWqJSOwjBzGzMGcmmOwKdXoEzqFjB5hm av+cwcXUO59mvoYe5xgv7jzwuIbsuy/hEbpI34krDPUUG4hr9Wd8VzABHVEBx5S6vqZ6 vaCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=A1twOxh3uXKokybtFnK8QJRsFEHHEZpoED1dW8ThkRE=; b=vh8/K6lYqL+YvvOhRufI4jb0+k3Q9QRu/3jd7h4h+ZN/02RMEKQlxAM2K2KR5hUsTZ J5NvnEMB3mfx6QUBMiF3jl8+oNwOKUUh4Y3LNFxfMsYXm5WR+uon5OKKSUHGCt7dO9LH 5LzyCYtE6EFhzgizEb1WEyU4OeWOcnykuehpglDs4U0Zr71zpif71JnMnfVIY32E0K7F g5YfNlJle0a526C/4DytlNlDxb6qFpLW1Gswvq2USQNsDTCRs/vk+PzcVvI52YWkN5ba le+pcqB75+7M4xVCxwLy4Dp3v1MZzoEYKid25jd+SpxmyVQZ0urK9IgKULvJCgQKr44u y3uQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m25si7017105pgv.483.2018.02.06.08.39.04; Tue, 06 Feb 2018 08:39:20 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752853AbeBFQhb (ORCPT + 99 others); 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 Content-Type: text/plain 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 1.9.1