From patchwork Fri Apr 1 04:52:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 680481 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 p314rQ5E021491 for ; Fri, 1 Apr 2011 04:53:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752266Ab1DAExe (ORCPT ); Fri, 1 Apr 2011 00:53:34 -0400 Received: from na3sys009aog101.obsmtp.com ([74.125.149.67]:33320 "EHLO na3sys009aog101.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751590Ab1DAExd (ORCPT ); Fri, 1 Apr 2011 00:53:33 -0400 Received: from source ([209.85.218.41]) (using TLSv1) by na3sys009aob101.postini.com ([74.125.148.12]) with SMTP ID DSNKTZVaTF5Rucnj+KKJAWPUYnETa74sftk/@postini.com; Thu, 31 Mar 2011 21:53:33 PDT Received: by yib18 with SMTP id 18so1534796yib.0 for ; Thu, 31 Mar 2011 21:53:32 -0700 (PDT) Received: by 10.236.161.71 with SMTP id v47mr383757yhk.19.1301633612072; Thu, 31 Mar 2011 21:53:32 -0700 (PDT) Received: from localhost (dragon.ti.com [192.94.94.33]) by mx.google.com with ESMTPS id p66sm953796yhm.55.2011.03.31.21.53.27 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Mar 2011 21:53:30 -0700 (PDT) From: Nishanth Menon To: linux-omap Cc: Liam Girdwood , Mark Brown , Samuel Ortiz , Saquib , Nishanth Menon Subject: [PATCH v2 4/5] regulator: twl: add twl6030 get_status Date: Fri, 1 Apr 2011 10:22:45 +0530 Message-Id: <1301633566-5212-5-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:35 +0000 (UTC) diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 11d2e08..d2f7e71 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c @@ -79,6 +79,8 @@ struct twlreg_info { /* TWL6030 LDO register values for CFG_STATE */ #define TWL6030_CFG_STATE_OFF 0x00 #define TWL6030_CFG_STATE_ON 0x01 +#define TWL6030_CFG_STATE_OFF2 0x02 +#define TWL6030_CFG_STATE_SLEEP 0x03 #define TWL6030_CFG_STATE_GRP_SHIFT 5 #define TWL6030_CFG_STATE_APP_SHIFT 2 #define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT) @@ -217,13 +219,10 @@ static int twlreg_disable(struct regulator_dev *rdev) return ret; } -static int twlreg_get_status(struct regulator_dev *rdev) +static int twl4030reg_get_status(struct regulator_dev *rdev) { int state = twlreg_grp(rdev); - if (twl_class_is_6030()) - return 0; /* FIXME return for 6030 regulator */ - if (state < 0) return state; state &= 0x0f; @@ -236,6 +235,33 @@ static int twlreg_get_status(struct regulator_dev *rdev) : REGULATOR_STATUS_STANDBY; } +static int twl6030reg_get_status(struct regulator_dev *rdev) +{ + struct twlreg_info *info = rdev_get_drvdata(rdev); + int val; + + val = twlreg_grp(rdev); + if (val < 0) + return val; + + val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE); + + switch (TWL6030_CFG_STATE_APP(val)) { + case TWL6030_CFG_STATE_ON: + return REGULATOR_STATUS_NORMAL; + + case TWL6030_CFG_STATE_SLEEP: + return REGULATOR_STATUS_STANDBY; + + case TWL6030_CFG_STATE_OFF: + case TWL6030_CFG_STATE_OFF2: + default: + break; + } + + return REGULATOR_STATUS_OFF; +} + static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode) { struct twlreg_info *info = rdev_get_drvdata(rdev); @@ -427,7 +453,7 @@ static struct regulator_ops twl4030ldo_ops = { .set_mode = twlreg_set_mode, - .get_status = twlreg_get_status, + .get_status = twl4030reg_get_status, }; static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) @@ -485,7 +511,7 @@ static struct regulator_ops twl6030ldo_ops = { .set_mode = twlreg_set_mode, - .get_status = twlreg_get_status, + .get_status = twl6030reg_get_status, }; /*----------------------------------------------------------------------*/ @@ -518,7 +544,7 @@ static struct regulator_ops twl4030fixed_ops = { .set_mode = twlreg_set_mode, - .get_status = twlreg_get_status, + .get_status = twl4030reg_get_status, }; static struct regulator_ops twl6030fixed_ops = { @@ -532,14 +558,14 @@ static struct regulator_ops twl6030fixed_ops = { .set_mode = twlreg_set_mode, - .get_status = twlreg_get_status, + .get_status = twl6030reg_get_status, }; static struct regulator_ops twl6030_fixed_resource = { .enable = twlreg_enable, .disable = twlreg_disable, .is_enabled = twl6030reg_is_enabled, - .get_status = twlreg_get_status, + .get_status = twl6030reg_get_status, }; /*----------------------------------------------------------------------*/