From patchwork Wed May 11 09:31:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Chen X-Patchwork-Id: 9066661 Return-Path: X-Original-To: patchwork-linux-mediatek@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 BFB96BF29F for ; Wed, 11 May 2016 09:32:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DF681201B9 for ; Wed, 11 May 2016 09:32:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F134320155 for ; Wed, 11 May 2016 09:32:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b0QVN-0008Nv-DP; Wed, 11 May 2016 09:32:33 +0000 Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b0QUp-00088P-EK; Wed, 11 May 2016 09:32:01 +0000 Received: from mtkhts09.mediatek.inc [(172.21.101.70)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1816677176; Wed, 11 May 2016 17:31:36 +0800 Received: from mtkslt205.mediatek.inc (10.21.15.75) by mtkhts09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.266.1; Wed, 11 May 2016 17:31:34 +0800 From: Henry Chen To: Rob Herring , Liam Girdwood , Mark Brown , Matthias Brugger Subject: [PATCH RESEND 1/2] regulator: Add support for parsing operation mode Date: Wed, 11 May 2016 17:31:29 +0800 Message-ID: <1462959090-2877-2-git-send-email-henryc.chen@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1462959090-2877-1-git-send-email-henryc.chen@mediatek.com> References: <1462959090-2877-1-git-send-email-henryc.chen@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160511_023159_802756_917FEE3F X-CRM114-Status: GOOD ( 12.59 ) X-Spam-Score: -1.1 (-) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Pawel Moll , Ian Campbell , Stephen Boyd , linux-kernel@vger.kernel.org, Henry Chen , Laxman Dewangan , linux-mediatek@lists.infradead.org, Bjorn Andersson , Kumar Gala , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Some regulators support their operating mode to be changed by consumers for module specific purpose. This patch adds support to parse those properties and fill the regulator constraints so the regulator core can call the regualtor_set_mode to change the modes. Signed-off-by: Henry Chen --- Documentation/devicetree/bindings/regulator/regulator.txt | 10 ++++++++++ drivers/regulator/of_regulator.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt index ecfc593..88f98f0 100644 --- a/Documentation/devicetree/bindings/regulator/regulator.txt +++ b/Documentation/devicetree/bindings/regulator/regulator.txt @@ -49,6 +49,16 @@ Optional properties: 0: Disable active discharge. 1: Enable active discharge. Absence of this property will leave configuration to default. +- regulator-allow-change-mode: allow the regulator mode to be configured +- regulator-supported-modes: Regulators can run in a variety of different operating + modes depending on output load. This allows further system power savings by + selecting the best (and most efficient) regulator mode for a desired load. + The definition for each of these operation is defined at + include/linux/regulator/consumer.h + 0: FAST. + 1: NORMAL. + 2: IDLE. + 3: STANDBY. Deprecated properties: - regulator-compatible: If a regulator chip contains multiple diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 6b0aa80..12fe8c8 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -167,6 +167,20 @@ static void of_get_regulation_constraints(struct device_node *np, suspend_state = NULL; suspend_np = NULL; } + + if (of_property_read_bool(np, "regulator-allow-change-mode")) + constraints->valid_ops_mask |= REGULATOR_CHANGE_MODE; + + ret = of_property_count_elems_of_size(np, + "regulator-supported-modes", + sizeof(u32)); + for (i = 0; i < ret; i++) { + u32 mode; + + of_property_read_u32_index(np, "regulator-supported-modes", + i, &mode); + constraints->valid_modes_mask |= (1 << mode); + } } /**