From patchwork Tue Oct 21 11:23:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5116581 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 35279C11AD for ; Tue, 21 Oct 2014 11:27:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B3632010F for ; Tue, 21 Oct 2014 11:27:26 +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 72A9D2013A for ; Tue, 21 Oct 2014 11:27:25 +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 1XgXYG-0006Un-GM; Tue, 21 Oct 2014 11:24:32 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XgXY7-0006GZ-6z for linux-arm-kernel@lists.infradead.org; Tue, 21 Oct 2014 11:24:23 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NDS006VKL4NIA00@mailout2.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 21 Oct 2014 12:26:47 +0100 (BST) X-AuditID: cbfec7f4-b7f6c6d00000120b-1a-5446424eea74 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id C3.B7.04619.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 1/4] regulator: max77686: Replace hard-coded opmode values with defines Date: Tue, 21 Oct 2014 13:23:14 +0200 Message-id: <1413890597-31037-2-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+Tm4hBhf6WCw2zljPajFp3QEm i6kPn7BZXP/ynNVi/pFzrBZHfxdYvH5haNG74CqbxdmmN+wW3650MFlsenyN1eLyrjlsFjPO 72OyuH2Z12LtkbvsDvweLc09bB5/n19n8fi76gWzx85Zd9k9Nq3qZPPYvKTeo2/LKkaPz5vk AjiiuGxSUnMyy1KL9O0SuDL2909hLHgiWrFg9iHWBsYfgl2MnBwSAiYSD1svsEPYYhIX7q1n 62Lk4hASWMoo8enaQVYIp49J4sXy42wgVWwCxhKbly8Bs0UE9jNJPJ5gAlLELLCaSeLnlVPM XYwcHMICMRJfruSB1LAIqEo0dPQwg9i8Au4Skz5NZYbYJidx8thkVhCbU8BD4s71DrArhIBq Vh+cwzqBkXcBI8MqRtHU0uSC4qT0XEO94sTc4tK8dL3k/NxNjJDg/bKDcfExq0OMAhyMSjy8 G5a5hgixJpYVV+YeYpTgYFYS4c0VdgsR4k1JrKxKLcqPLyrNSS0+xMjEwSnVwKjrbVR0bpf4 gWtfhUKLJ1y5/bCVU2VTnPAzy5Q3Lko+ms/9Xu5bVimf6BO+92+AbNRBt4B3/9s2Lj2yW/XC FaXzV98dlDI057A4Pe270dfzCbLLFdluViYk+W3b4VT9I9ouXb+Pya7ynmjVd+ar5UVyxtZz ZzwxfvdtyQd+92z2P1yKh7gq9yqxFGckGmoxFxUnAgB5bdLtPAIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141021_042423_391241_EDF537F0 X-CRM114-Status: GOOD ( 11.28 ) 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 Add defines for regulator operating modes which should be more readable, especially if one does not have Maxim 77686 datasheet. The patch does not introduce any functional change. Signed-off-by: Krzysztof Kozlowski Suggested-by: Javier Martinez Canillas --- drivers/regulator/max77686.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index ef1af2debbd2..cffe0c69d57d 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c @@ -45,6 +45,16 @@ #define MAX77686_DVS_MINUV 600000 #define MAX77686_DVS_UVSTEP 12500 +/* On/off controlled by PWRREQ */ +#define MAX77686_OPMODE_OFF_PWRREQ 0x1 +/* + * For some regulators this means: + * - forcing low power mode. + * - low power mode controlled by PWRREQ. + */ +#define MAX77686_OPMODE_LOWPOWER 0x2 +#define MAX77686_OPMODE_NORMAL 0x3 + #define MAX77686_OPMODE_SHIFT 6 #define MAX77686_OPMODE_BUCK234_SHIFT 4 #define MAX77686_OPMODE_MASK 0x3 @@ -76,9 +86,10 @@ static int max77686_buck_set_suspend_disable(struct regulator_dev *rdev) int ret, id = rdev_get_id(rdev); if (id == MAX77686_BUCK1) - val = 0x1; + val = MAX77686_OPMODE_OFF_PWRREQ; else - val = 0x1 << MAX77686_OPMODE_BUCK234_SHIFT; + val = MAX77686_OPMODE_OFF_PWRREQ + << MAX77686_OPMODE_BUCK234_SHIFT; ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, rdev->desc->enable_mask, val); @@ -103,10 +114,10 @@ static int max77686_set_suspend_mode(struct regulator_dev *rdev, switch (mode) { case REGULATOR_MODE_IDLE: /* ON in LP Mode */ - val = 0x2 << MAX77686_OPMODE_SHIFT; + val = MAX77686_OPMODE_LOWPOWER << MAX77686_OPMODE_SHIFT; break; case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */ - val = 0x3 << MAX77686_OPMODE_SHIFT; + val = MAX77686_OPMODE_NORMAL << MAX77686_OPMODE_SHIFT; break; default: pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n", @@ -133,13 +144,13 @@ static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev, switch (mode) { case REGULATOR_MODE_STANDBY: /* switch off */ - val = 0x1 << MAX77686_OPMODE_SHIFT; + val = MAX77686_OPMODE_OFF_PWRREQ << MAX77686_OPMODE_SHIFT; break; case REGULATOR_MODE_IDLE: /* ON in LP Mode */ - val = 0x2 << MAX77686_OPMODE_SHIFT; + val = MAX77686_OPMODE_LOWPOWER << MAX77686_OPMODE_SHIFT; break; case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */ - val = 0x3 << MAX77686_OPMODE_SHIFT; + val = MAX77686_OPMODE_NORMAL << MAX77686_OPMODE_SHIFT; break; default: pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n",