aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Marklund <robert.marklund@stericsson.com>2011-10-28 17:54:26 +0200
committerPhilippe LANGLAIS <philippe.langlais@stericsson.com>2011-11-08 16:00:03 +0100
commit41a41cc9492eeba59cf9ca66f311788771833131 (patch)
treef8387296e3690796f74e9be7698cd96000233ba1
parent28448158f4495671be9e4ce047a485ec76017393 (diff)
downloadlinux-3.0-ux500-41a41cc9492eeba59cf9ca66f311788771833131.tar.gz
input/misc: Add regulator support to lps001wpHEADmaster
Change-Id: I39f57da20017ff7e963d0001a99dd426e12c77d0 Signed-off-by: Robert Marklund <robert.marklund@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/35833 Reviewed-by: Philippe LANGLAIS <philippe.langlais@stericsson.com>
-rw-r--r--drivers/input/misc/lps001wp_prs.c36
-rw-r--r--include/linux/input/lps001wp.h2
2 files changed, 27 insertions, 11 deletions
diff --git a/drivers/input/misc/lps001wp_prs.c b/drivers/input/misc/lps001wp_prs.c
index 9ec96ba3863..cb60762ac61 100644
--- a/drivers/input/misc/lps001wp_prs.c
+++ b/drivers/input/misc/lps001wp_prs.c
@@ -46,6 +46,7 @@
#include <linux/input.h>
#include <linux/workqueue.h>
#include <linux/device.h>
+#include <linux/regulator/consumer.h>
#include <linux/input/lps001wp.h>
@@ -164,6 +165,8 @@ struct lps001wp_prs_data {
u8 resume_state[RESUME_ENTRIES];
+ struct regulator *regulator;
+
#ifdef DEBUG
u8 reg_addr;
#endif
@@ -380,10 +383,13 @@ static void lps001wp_prs_device_power_off(struct lps001wp_prs_data *prs)
if (err < 0)
dev_err(&prs->client->dev, "soft power off failed: %d\n", err);
- if (prs->pdata->power_off) {
- prs->pdata->power_off();
- prs->hw_initialized = 0;
+ /* disable regulator */
+ if (prs->regulator) {
+ err = regulator_disable(prs->regulator);
+ if (err < 0)
+ dev_err(&prs->client->dev, "failed to disable regulator\n");
}
+
if (prs->hw_initialized) {
prs->hw_initialized = 0;
}
@@ -394,15 +400,23 @@ static int lps001wp_prs_device_power_on(struct lps001wp_prs_data *prs)
{
int err = -1;
- if (prs->pdata->power_on) {
- err = prs->pdata->power_on();
- if (err < 0) {
- dev_err(&prs->client->dev,
- "power_on failed: %d\n", err);
- return err;
+ /* get the regulator the first time */
+ if (!prs->regulator) {
+ prs->regulator = regulator_get(&prs->client->dev, "vdd");
+ if (IS_ERR(prs->regulator)) {
+ dev_err(&prs->client->dev, "failed to get regulator\n");
+ prs->regulator = NULL;
+ return PTR_ERR(prs->regulator);
}
}
+ /* enable it also */
+ err = regulator_enable(prs->regulator);
+ if (err < 0) {
+ dev_err(&prs->client->dev, "failed to enable regulator\n");
+ return err;
+ }
+
if (!prs->hw_initialized) {
err = lps001wp_prs_hw_init(prs);
if (prs->hw_working == 1 && err < 0) {
@@ -1210,6 +1224,10 @@ static int __devexit lps001wp_prs_remove(struct i2c_client *client)
if (prs->pdata->exit)
prs->pdata->exit();
+
+ if (prs->regulator)
+ regulator_put(prs->regulator);
+
kfree(prs->pdata);
kfree(prs);
diff --git a/include/linux/input/lps001wp.h b/include/linux/input/lps001wp.h
index aa5eac9af8f..779a415ea68 100644
--- a/include/linux/input/lps001wp.h
+++ b/include/linux/input/lps001wp.h
@@ -70,8 +70,6 @@ struct lps001wp_prs_platform_data {
int (*init)(void);
void (*exit)(void);
- int (*power_on)(void);
- int (*power_off)(void);
};