From patchwork Fri Apr 1 04:52:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 680451 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 p314r90x021342 for ; Fri, 1 Apr 2011 04:53:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751442Ab1DAExI (ORCPT ); Fri, 1 Apr 2011 00:53:08 -0400 Received: from na3sys009aog108.obsmtp.com ([74.125.149.199]:32849 "EHLO na3sys009aog108.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751407Ab1DAExH (ORCPT ); Fri, 1 Apr 2011 00:53:07 -0400 Received: from source ([209.85.160.174]) (using TLSv1) by na3sys009aob108.postini.com ([74.125.148.12]) with SMTP ID DSNKTZVaMR5+iQ073rlpkFF2qfYPj71PaUeC@postini.com; Thu, 31 Mar 2011 21:53:06 PDT Received: by mail-gy0-f174.google.com with SMTP id 10so1268381gyd.19 for ; Thu, 31 Mar 2011 21:53:05 -0700 (PDT) Received: by 10.151.3.2 with SMTP id f2mr3541622ybi.47.1301633585516; Thu, 31 Mar 2011 21:53:05 -0700 (PDT) Received: from localhost (dragon.ti.com [192.94.94.33]) by mx.google.com with ESMTPS id b1sm672572ybn.1.2011.03.31.21.53.01 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Mar 2011 21:53:04 -0700 (PDT) From: Nishanth Menon To: linux-omap Cc: Liam Girdwood , Mark Brown , Samuel Ortiz , Saquib , Nishanth Menon Subject: [PATCH 1/5] regulator: twl: fix twl6030 enable/disable Date: Fri, 1 Apr 2011 10:22:42 +0530 Message-Id: <1301633566-5212-2-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:09 +0000 (UTC) diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 6a29285..3e9060c 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c @@ -76,6 +76,11 @@ struct twlreg_info { #define VREG_BC_PROC 3 #define VREG_BC_CLK_RST 4 +/* TWL6030 LDO register values for CFG_STATE */ +#define TWL6030_CFG_STATE_OFF 0x00 +#define TWL6030_CFG_STATE_ON 0x01 +#define TWL6030_CFG_STATE_GRP_SHIFT 5 + static inline int twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset) { @@ -149,6 +154,11 @@ static int twlreg_enable(struct regulator_dev *rdev) ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp); + if (!ret && twl_class_is_6030()) + ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, + grp << TWL6030_CFG_STATE_GRP_SHIFT | + TWL6030_CFG_STATE_ON); + udelay(info->delay); return ret; @@ -158,17 +168,36 @@ static int twlreg_disable(struct regulator_dev *rdev) { struct twlreg_info *info = rdev_get_drvdata(rdev); int grp; + int ret; grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP); if (grp < 0) return grp; + /* For 6030, set the off state for all grps enabled */ + if (twl_class_is_6030()) { + ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, + (grp & (P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030)) << + TWL6030_CFG_STATE_GRP_SHIFT | + TWL6030_CFG_STATE_OFF); + if (ret) + return ret; + } + if (twl_class_is_4030()) grp &= ~(P1_GRP_4030 | P2_GRP_4030 | P3_GRP_4030); else grp &= ~(P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030); - return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp); + ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp); + + /* Next, associate cleared grp in state register */ + if (!ret && twl_class_is_6030()) + ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, + grp << TWL6030_CFG_STATE_GRP_SHIFT | + TWL6030_CFG_STATE_OFF); + + return ret; } static int twlreg_get_status(struct regulator_dev *rdev)