From patchwork Tue Oct 21 11:23:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5116501 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 52DACC11AD for ; Tue, 21 Oct 2014 11:27:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6341B200D9 for ; Tue, 21 Oct 2014 11:27:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AB40820138 for ; Tue, 21 Oct 2014 11:27:01 +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 1XgXYO-0006Vj-3K; Tue, 21 Oct 2014 11:24:40 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XgXY7-0006GX-On for linux-arm-kernel@lists.infradead.org; Tue, 21 Oct 2014 11:24:24 +0000 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NDS004U7L4TI300@mailout1.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 21 Oct 2014 12:26:53 +0100 (BST) X-AuditID: cbfec7f5-b7f956d000005ed7-96-5446424ee86e Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 14.44.24279.E4246445; Tue, 21 Oct 2014 12:23:58 +0100 (BST) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NDS00LAIKZQCF50@eusync2.samsung.com>; Tue, 21 Oct 2014 12:23:58 +0100 (BST) From: Krzysztof Kozlowski To: Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org, Ben Dooks , Kukjin Kim , Russell King , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 2/4] regulator: max77686: Implement suspend disable for some LDOs Date: Tue, 21 Oct 2014 13:23:15 +0200 Message-id: <1413890597-31037-3-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1413890597-31037-1-git-send-email-k.kozlowski@samsung.com> References: <1413890597-31037-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJLMWRmVeSWpSXmKPExsVy+t/xK7p+Tm4hBs+2WVlsnLGe1WLSugNM FlMfPmGzuP7lOavF/CPnWC2O/i6weP3C0KJ3wVU2i7NNb9gtvl3pYLLY9Pgaq8XlXXPYLGac 38dkcfsyr8XaI3fZHfg9Wpp72Dz+Pr/O4vF31Qtmj52z7rJ7bFrVyeaxeUm9R9+WVYwenzfJ BXBEcdmkpOZklqUW6dslcGVsebuKuWCbbMXa73/ZGxj/S3QxcnJICJhI/Pr1jRXCFpO4cG89 G4gtJLCUUeLuNOYuRi4gu49J4sXy42AJNgFjic3Ll4DZIgL7mSQeTzABKWIWWM0k8fPKKWaQ hLBAmETTlJtgNouAqkTX1atMIDavgLvEz/XrWSC2yUmcPDYZbDOngIfEnesd7BCb3SVWH5zD OoGRdwEjwypG0dTS5ILipPRcI73ixNzi0rx0veT83E2MkOD9uoNx6TGrQ4wCHIxKPLwRS1xD hFgTy4orcw8xSnAwK4nw5gq7hQjxpiRWVqUW5ccXleakFh9iZOLglGpgVP+dGbPSftGCiF3T TjDo6dc2hpot2/BmxtTQrq22HJZRE37OOaymH/TdXvP4i069CKuG36WsoZr1VqXHFJui9v5Z cuKZWlCZfLvDnQfr3TaGFBdJ7z7QNG+fXY3Wu9S3Z11rVpy2eXrCZYuk1Oq9ggfcfG5ofWM5 KvPhubTP+5XLvq3rfK39R4mlOCPRUIu5qDgRAIGLB988AgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141021_042423_940894_B665C780 X-CRM114-Status: GOOD ( 13.53 ) X-Spam-Score: -6.5 (------) Cc: Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Chanwoo Choi , Kyungmin Park , Javier Martinez Canillas , Marek Szyprowski X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 LDOs of Maxim 77686 PMIC support disabling during system suspend (LDO{2,6,7,8,10,11,12,14,15,16}). This was already implemented as part of set_suspend_mode function. In that case the mode was one of: - disable, - normal mode, - low power mode. However there are no bindings for setting the mode during suspend. Add suspend disable for LDO regulators supporting this to the existing max77686_buck_set_suspend_disable() function. This helps reducing energy consumption during system sleep. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Javier Martinez Canillas --- drivers/regulator/max77686.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index cffe0c69d57d..05df72d584bf 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c @@ -79,17 +79,33 @@ struct max77686_data { }; /* Some BUCKS supports Normal[ON/OFF] mode during suspend */ -static int max77686_buck_set_suspend_disable(struct regulator_dev *rdev) +static int max77686_set_suspend_disable(struct regulator_dev *rdev) { unsigned int val; struct max77686_data *max77686 = rdev_get_drvdata(rdev); int ret, id = rdev_get_id(rdev); - if (id == MAX77686_BUCK1) + switch (id) { + case MAX77686_BUCK1: val = MAX77686_OPMODE_OFF_PWRREQ; - else + break; + case MAX77686_BUCK2: + case MAX77686_BUCK3: + case MAX77686_BUCK4: val = MAX77686_OPMODE_OFF_PWRREQ << MAX77686_OPMODE_BUCK234_SHIFT; + break; + case MAX77686_LDO2: + case MAX77686_LDO6 ... MAX77686_LDO8: + case MAX77686_LDO10 ... MAX77686_LDO12: + case MAX77686_LDO14 ... MAX77686_LDO16: + val = MAX77686_OPMODE_OFF_PWRREQ << MAX77686_OPMODE_SHIFT; + break; + default: + pr_warn("%s: regulator_suspend_disable not supported\n", + rdev->desc->name); + return -EINVAL; + } ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, rdev->desc->enable_mask, val); @@ -171,6 +187,9 @@ static int max77686_enable(struct regulator_dev *rdev) { struct max77686_data *max77686 = rdev_get_drvdata(rdev); + if (max77686->opmode[rdev_get_id(rdev)] == MAX77686_OPMODE_OFF_PWRREQ) + max77686->opmode[rdev_get_id(rdev)] = MAX77686_OPMODE_NORMAL; + return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, rdev->desc->enable_mask, max77686->opmode[rdev_get_id(rdev)]); @@ -223,6 +242,8 @@ static struct regulator_ops max77686_ldo_ops = { .set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, .set_suspend_mode = max77686_ldo_set_suspend_mode, + .set_suspend_disable = max77686_set_suspend_disable, + .set_suspend_enable = max77686_enable, }; static struct regulator_ops max77686_buck1_ops = { @@ -234,7 +255,8 @@ static struct regulator_ops max77686_buck1_ops = { .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, - .set_suspend_disable = max77686_buck_set_suspend_disable, + .set_suspend_disable = max77686_set_suspend_disable, + .set_suspend_enable = max77686_enable, }; static struct regulator_ops max77686_buck_dvs_ops = { @@ -247,7 +269,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { .set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, .set_ramp_delay = max77686_set_ramp_delay, - .set_suspend_disable = max77686_buck_set_suspend_disable, + .set_suspend_disable = max77686_set_suspend_disable, + .set_suspend_enable = max77686_enable, }; #define regulator_desc_ldo(num) { \