From patchwork Wed Mar 5 09:22:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 3771741 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 200439F1EE for ; Wed, 5 Mar 2014 09:23:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 44BA720225 for ; Wed, 5 Mar 2014 09:23:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 517C820220 for ; Wed, 5 Mar 2014 09:23:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751952AbaCEJXL (ORCPT ); Wed, 5 Mar 2014 04:23:11 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:42628 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752250AbaCEJXE (ORCPT ); Wed, 5 Mar 2014 04:23:04 -0500 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) 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 <0N1Y003QWI284E20@mailout2.w1.samsung.com>; Wed, 05 Mar 2014 09:22:56 +0000 (GMT) X-AuditID: cbfec7f5-b7fc96d000004885-be-5316ecf53d80 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 2D.A7.18565.5FCE6135; Wed, 05 Mar 2014 09:23:01 +0000 (GMT) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N1Y007PNI28KU90@eusync4.samsung.com>; Wed, 05 Mar 2014 09:23:01 +0000 (GMT) From: Krzysztof Kozlowski To: Sangbeom Kim , Liam Girdwood , Mark Brown , Samuel Ortiz , Lee Jones , linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Kyungmin Park , Marek Szyprowski , Bartlomiej Zolnierkiewicz , Tomasz Figa , Yadwinder Singh Brar , Sachin Kamat , Krzysztof Kozlowski Subject: [PATCH 2/3] regulator: s2mps11: Add set_suspend_disable for S2MPS14 Date: Wed, 05 Mar 2014 10:22:52 +0100 Message-id: <1394011373-4057-3-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1394011373-4057-1-git-send-email-k.kozlowski@samsung.com> References: <1394011373-4057-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBLMWRmVeSWpSXmKPExsVy+t/xa7pf34gFGzxepWqxccZ6VoupD5+w Wbx+YWhxtukNu8X9r0cZLb5d6WCyuLxrDpvFjPP7mCzWHrnLbnHyTy+jxeluVouLK74wWayf 8ZrFYs70d0wOfB47Z91l99i0qpPN4861PWwe804GevRtWcXo8XmTXABbFJdNSmpOZllqkb5d AlfG72umBT+EKxoe2jUwvhXoYuTkkBAwkZh0+CMThC0mceHeejYQW0hgKaNE/4uALkYuILuP SWLJpgWsIAk2AWOJzcuXsIEkRAR+M0r0nLvLDuIwCxxmkrj39i9Yu7CAj8T9N5tZuhg5OFgE VCX+PdEHCfMKuElsvPmYFSQsIaAgMWeSDUiYU8BdounHEqjFbhJL17ezTGDkXcDIsIpRNLU0 uaA4KT3XSK84Mbe4NC9dLzk/dxMjJDS/7mBceszqEKMAB6MSD+8LDrFgIdbEsuLK3EOMEhzM SiK8KS+AQrwpiZVVqUX58UWlOanFhxiZODilGhgndKV4qYh1MIpnrrGWyVE4zBfjrs5Ydkn2 RkJj48VrnWXzv52/2lY813aXo2bfHkettY+1LqjeehHh8qMruU786RQfTZ/ndiyzYli7zrcf zqhuSJvoyxS5SNcqVSNF6+n6WelLja3rWY9MTth7axsn+82bfxmKn0z3Ddu9f1ZAWWfjoo0X JZRYijMSDbWYi4oTAbBNclIrAgAA 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=-3.9 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, 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 S2MPS14 regulators support suspend mode where their status is controlled by PWREN coming from SoC. This patch implements the set_suspend_disable for S2MPS14 regulators. Signed-off-by: Krzysztof Kozlowski --- drivers/regulator/s2mps11.c | 26 ++++++++++++++++++++++++++ include/linux/mfd/samsung/s2mps14.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 1a732e54cd70..d3209acefd79 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -399,6 +399,31 @@ static const struct regulator_desc s2mps11_regulators[] = { regulator_desc_s2mps11_buck10, }; +static int s2mps14_set_suspend_disable(struct regulator_dev *rdev) +{ + int ret; + unsigned int data; + + /* LDO3 should be always on and does not support suspend mode */ + if (rdev_get_id(rdev) == S2MPS14_LDO3) + return 0; + + ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &data); + if (ret < 0) + return ret; + + /* + * Don't enable suspend mode if regulator is already disabled because + * this would effectively for a short time turn on the regulator after + * resuming. + */ + if (!(data & rdev->desc->enable_mask)) + return 0; + + return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, + rdev->desc->enable_mask, S2MPS14_ENABLE_SUSPEND); +} + static struct regulator_ops s2mps14_reg_ops = { .list_voltage = regulator_list_voltage_linear, .map_voltage = regulator_map_voltage_linear, @@ -408,6 +433,7 @@ static struct regulator_ops s2mps14_reg_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 = s2mps14_set_suspend_disable, }; #define regulator_desc_s2mps14_ldo1(num) { \ diff --git a/include/linux/mfd/samsung/s2mps14.h b/include/linux/mfd/samsung/s2mps14.h index ec1e0857ddde..4b449b8ac548 100644 --- a/include/linux/mfd/samsung/s2mps14.h +++ b/include/linux/mfd/samsung/s2mps14.h @@ -146,6 +146,8 @@ enum s2mps14_regulators { #define S2MPS14_BUCK_VSEL_MASK 0xFF #define S2MPS14_ENABLE_MASK (0x03 << S2MPS14_ENABLE_SHIFT) #define S2MPS14_ENABLE_SHIFT 6 +/* On/Off controlled by PWREN */ +#define S2MPS14_ENABLE_SUSPEND (0x01 << S2MPS14_ENABLE_SHIFT) #define S2MPS14_LDO_N_VOLTAGES (S2MPS14_LDO_VSEL_MASK + 1) #define S2MPS14_BUCK_N_VOLTAGES (S2MPS14_BUCK_VSEL_MASK + 1)