From patchwork Tue Oct 21 13:19:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5124971 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D02869F30B for ; Tue, 21 Oct 2014 13:21:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD52E20138 for ; Tue, 21 Oct 2014 13:21:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9CB38200D5 for ; Tue, 21 Oct 2014 13:21:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932700AbaJUNVK (ORCPT ); Tue, 21 Oct 2014 09:21:10 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:56684 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932527AbaJUNUK (ORCPT ); Tue, 21 Oct 2014 09:20:10 -0400 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 <0NDS004VXQIE8U30@mailout1.w1.samsung.com>; Tue, 21 Oct 2014 14:23:02 +0100 (BST) X-AuditID: cbfec7f5-b7f956d000005ed7-98-54465d87b716 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 9C.9B.24279.78D56445; Tue, 21 Oct 2014 14:20:07 +0100 (BST) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync1.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NDS00G9ZQDE1310@eusync1.samsung.com>; Tue, 21 Oct 2014 14:20:07 +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, Samuel Ortiz , Lee Jones Cc: Kyungmin Park , Marek Szyprowski , Bartlomiej Zolnierkiewicz , Javier Martinez Canillas , Chanwoo Choi , Krzysztof Kozlowski Subject: [PATCH v3 2/4] regulator: max77686: Implement suspend disable for some LDOs Date: Tue, 21 Oct 2014 15:19:53 +0200 Message-id: <1413897595-28752-3-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1413897595-28752-1-git-send-email-k.kozlowski@samsung.com> References: <1413897595-28752-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBLMWRmVeSWpSXmKPExsVy+t/xy7rtsW4hBl9P6FhsnLGe1WLSugNM FlMfPmGzuP7lOavF/CPnWC2O/i6weP3C0KJ3wVU2i7NNb9gt7n89ymjx7UoHk8Wmx9dYLS7v msNmMeP8PiaL25d5LdYeuctucbqb1UHQo6W5h83j7/PrLB5/V71g9tg56y67x6ZVnWwed67t YfOYdzLQY/OSeo++LasYPT5vkgvgiuKySUnNySxLLdK3S+DK2L11DVPBQsWKyas2MzYwLpPp YuTkkBAwkbjXeIsVwhaTuHBvPRuILSSwlFHi7UQOCLuPSeJAN1icTcBYYvPyJWC2iEAns8SX 7wFdjFwczAKrmSR+XjnF3MXIwSEsECbxY442SA2LgKrE2RXrGUFsXgF3ibvLmtkgdslJnDw2 GWwvp4CHxO/dexlBWoWAaq59Tp3AyLuAkWEVo2hqaXJBcVJ6rpFecWJucWleul5yfu4mRkho f93BuPSY1SFGAQ5GJR7eiCWuIUKsiWXFlbmHGCU4mJVEeHOF3UKEeFMSK6tSi/Lji0pzUosP MTJxcEo1MB64zHh17Vu7DLlrL/NnG7zY+X6ajWtq1+eso18TFxxND7T2yFm/ojL01lQTbtNT yzjZWlTeuRavW/vAW89Sz0HRUrTmbUqDabLueecJO6ssHTusmfZ+n81z/NfPx9wawaK8XNdj vhiu3/04+NemjBbHVpuMf6svVs2bYi11cOHTWzlFyYeYs5RYijMSDbWYi4oTAZHOr3BLAgAA Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index 3d0922051488..81f4b69adc82 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c @@ -87,18 +87,31 @@ struct max77686_data { unsigned int opmode[MAX77686_REGULATORS]; }; -/* Some BUCKS supports Normal[ON/OFF] mode during suspend */ -static int max77686_buck_set_suspend_disable(struct regulator_dev *rdev) +/* Some BUCKs and LDOs supports Normal[ON/OFF] mode during suspend */ +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_BUCK_OFF_PWRREQ; - else - val = MAX77686_BUCK_OFF_PWRREQ - << MAX77686_OPMODE_BUCK234_SHIFT; + break; + case MAX77686_BUCK2 ... MAX77686_BUCK4: + val = MAX77686_BUCK_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_LDO_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); @@ -180,6 +193,16 @@ static int max77686_enable(struct regulator_dev *rdev) { struct max77686_data *max77686 = rdev_get_drvdata(rdev); + /* + * One enable function is used for LDO and bucks. Assuming + * the same values are used for enable registers. + */ + BUILD_BUG_ON(MAX77686_LDO_OFF_PWRREQ != MAX77686_BUCK_OFF_PWRREQ); + BUILD_BUG_ON(MAX77686_LDO_NORMAL != MAX77686_BUCK_NORMAL); + + if (max77686->opmode[rdev_get_id(rdev)] == MAX77686_LDO_OFF_PWRREQ) + max77686->opmode[rdev_get_id(rdev)] = MAX77686_LDO_NORMAL; + return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, rdev->desc->enable_mask, max77686->opmode[rdev_get_id(rdev)]); @@ -232,6 +255,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 = { @@ -243,7 +268,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 = { @@ -256,7 +282,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) { \