From: wni@nvidia.com
To: sameo@linux.intel.com, mike@compulab.co.il, gking@nvidia.com,
nkumbhar@nvidia.com
Cc: linux-kernel@vger.kernel.org, Wei Ni <wni@nvidia.com>
Subject: [PATCH] mfd: tps6586x: add api to power off tps6586x
Date: Thu, 28 Jul 2011 14:30:36 +0800 [thread overview]
Message-ID: <1311834636-15940-1-git-send-email-wni@nvidia.com> (raw)
From: Wei Ni <wni@nvidia.com>
Add an api to put tps6586x in sleep mode by resetting EXITSLREQ and
setting SLEEP_MODE in SUPPLYENE register. It will power off ldos.
Signed-off-by: Wei Ni <wni@nvidia.com>
Signed-off-by: Nitin Kumbhar <nkumbhar@nvidia.com>
---
drivers/mfd/tps6586x.c | 29 +++++++++++++++++++++++++++++
include/linux/mfd/tps6586x.h | 1 +
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index bba26d9..d0eaa0a 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -27,6 +27,10 @@
#include <linux/mfd/core.h>
#include <linux/mfd/tps6586x.h>
+#define TPS6586X_SUPPLYENE 0x14
+#define EXITSLREQ_BIT BIT(1) /* Exit sleep mode request */
+#define SLEEP_MODE_BIT BIT(3) /* Sleep mode */
+
/* GPIO control registers */
#define TPS6586X_GPIOSET1 0x5d
#define TPS6586X_GPIOSET2 0x5e
@@ -251,6 +255,29 @@ out:
}
EXPORT_SYMBOL_GPL(tps6586x_update);
+static struct i2c_client *tps6586x_i2c_client;
+int tps6586x_power_off(void)
+{
+ struct device *dev = NULL;
+ int ret = -EINVAL;
+
+ if (!tps6586x_i2c_client)
+ return ret;
+
+ dev = &tps6586x_i2c_client->dev;
+
+ ret = tps6586x_clr_bits(dev, TPS6586X_SUPPLYENE, EXITSLREQ_BIT);
+ if (ret)
+ return ret;
+
+ ret = tps6586x_set_bits(dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(tps6586x_power_off);
+
static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset)
{
struct tps6586x *tps6586x = container_of(gc, struct tps6586x, gpio);
@@ -525,6 +552,8 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
goto err_add_devs;
}
+ tps6586x_i2c_client = client;
+
return 0;
err_add_devs:
diff --git a/include/linux/mfd/tps6586x.h b/include/linux/mfd/tps6586x.h
index b6bab1b..cfbf387 100644
--- a/include/linux/mfd/tps6586x.h
+++ b/include/linux/mfd/tps6586x.h
@@ -74,5 +74,6 @@ extern int tps6586x_set_bits(struct device *dev, int reg, uint8_t bit_mask);
extern int tps6586x_clr_bits(struct device *dev, int reg, uint8_t bit_mask);
extern int tps6586x_update(struct device *dev, int reg, uint8_t val,
uint8_t mask);
+extern int tps6586x_power_off(void);
#endif /*__LINUX_MFD_TPS6586X_H */
--
1.7.0
next reply other threads:[~2011-07-28 6:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-28 6:30 wni [this message]
2011-07-29 7:53 ` [PATCH] mfd: tps6586x: add api to power off tps6586x Wei Ni
2011-08-03 4:04 ` Wei Ni
2011-08-21 23:05 ` Samuel Ortiz
2011-08-22 3:47 ` Wei Ni
2011-08-22 5:06 ` Haojian Zhuang
2011-08-23 15:40 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1311834636-15940-1-git-send-email-wni@nvidia.com \
--to=wni@nvidia.com \
--cc=gking@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mike@compulab.co.il \
--cc=nkumbhar@nvidia.com \
--cc=sameo@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox