From patchwork Fri Apr 1 04:52:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 680491 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p314rha6021633 for ; Fri, 1 Apr 2011 04:53:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752269Ab1DAExm (ORCPT ); Fri, 1 Apr 2011 00:53:42 -0400 Received: from na3sys009aog114.obsmtp.com ([74.125.149.211]:43211 "EHLO na3sys009aog114.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751942Ab1DAExl (ORCPT ); Fri, 1 Apr 2011 00:53:41 -0400 Received: from source ([209.85.218.42]) (using TLSv1) by na3sys009aob114.postini.com ([74.125.148.12]) with SMTP ID DSNKTZVaVAbHsJPwf14mzTL46+pUwc9EQXmd@postini.com; Thu, 31 Mar 2011 21:53:41 PDT Received: by mail-yi0-f42.google.com with SMTP id 12so1666960yib.15 for ; Thu, 31 Mar 2011 21:53:40 -0700 (PDT) Received: by 10.150.100.6 with SMTP id x6mr435621ybb.21.1301633620682; Thu, 31 Mar 2011 21:53:40 -0700 (PDT) Received: from localhost (dragon.ti.com [192.94.94.33]) by mx.google.com with ESMTPS id t5sm849568ybe.14.2011.03.31.21.53.36 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Mar 2011 21:53:39 -0700 (PDT) From: Nishanth Menon To: linux-omap Cc: Liam Girdwood , Mark Brown , Samuel Ortiz , Saquib , Nishanth Menon Subject: [PATCH 5/5] regulator: twl: add twl6030 set_mode Date: Fri, 1 Apr 2011 10:22:46 +0530 Message-Id: <1301633566-5212-6-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1301633566-5212-1-git-send-email-nm@ti.com> References: <1301633566-5212-1-git-send-email-nm@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 01 Apr 2011 04:53:43 +0000 (UTC) diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index d2f7e71..bf7c402 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c @@ -262,15 +262,12 @@ static int twl6030reg_get_status(struct regulator_dev *rdev) return REGULATOR_STATUS_OFF; } -static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode) +static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode) { struct twlreg_info *info = rdev_get_drvdata(rdev); unsigned message; int status; - if (twl_class_is_6030()) - return 0; /* FIXME return for 6030 regulator */ - /* We can only set the mode through state machine commands... */ switch (mode) { case REGULATOR_MODE_NORMAL: @@ -299,6 +296,35 @@ static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode) message & 0xff, TWL4030_PM_MASTER_PB_WORD_LSB); } +static int twl6030reg_set_mode(struct regulator_dev *rdev, unsigned mode) +{ + struct twlreg_info *info = rdev_get_drvdata(rdev); + int grp; + int val; + + grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP); + + if (grp < 0) + return grp; + + /* Compose the state register settings */ + val = grp << TWL6030_CFG_STATE_GRP_SHIFT; + /* We can only set the mode through state machine commands... */ + switch (mode) { + case REGULATOR_MODE_NORMAL: + val |= TWL6030_CFG_STATE_ON; + break; + case REGULATOR_MODE_STANDBY: + val |= TWL6030_CFG_STATE_SLEEP; + break; + + default: + return -EINVAL; + } + + return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, val); +} + /*----------------------------------------------------------------------*/ /* @@ -451,7 +477,7 @@ static struct regulator_ops twl4030ldo_ops = { .disable = twlreg_disable, .is_enabled = twl4030reg_is_enabled, - .set_mode = twlreg_set_mode, + .set_mode = twl4030reg_set_mode, .get_status = twl4030reg_get_status, }; @@ -509,7 +535,7 @@ static struct regulator_ops twl6030ldo_ops = { .disable = twlreg_disable, .is_enabled = twl6030reg_is_enabled, - .set_mode = twlreg_set_mode, + .set_mode = twl6030reg_set_mode, .get_status = twl6030reg_get_status, }; @@ -542,7 +568,7 @@ static struct regulator_ops twl4030fixed_ops = { .disable = twlreg_disable, .is_enabled = twl4030reg_is_enabled, - .set_mode = twlreg_set_mode, + .set_mode = twl4030reg_set_mode, .get_status = twl4030reg_get_status, }; @@ -556,7 +582,7 @@ static struct regulator_ops twl6030fixed_ops = { .disable = twlreg_disable, .is_enabled = twl6030reg_is_enabled, - .set_mode = twlreg_set_mode, + .set_mode = twl6030reg_set_mode, .get_status = twl6030reg_get_status, };