summaryrefslogtreecommitdiff
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorChethan Krishna N <chethan.krishna@stericsson.com>2011-03-08 15:18:34 +0530
committerUlf Hansson <ulf.hansson@stericsson.com>2011-09-19 15:14:54 +0200
commit7c747beb07d35ef8d7e056fc10dcc524b614353f (patch)
treec018f0b3188ba1713e46d8c12ed7b593da300234 /drivers/hwmon
parent599e33b736effe251c0a3a2080ba10e1661946f7 (diff)
lsm303dlh: Reboot memory content after suspend/resume
It is observed that device screen orientation doesn't behave as expected sometimes after suspend/resume. Rebooting the device's internal registers to ensure good device behavior. ST Ericsson ID : ER327596 Signed-off-by: Chethan Krishna N <chethan.krishna@stericsson.com> Change-Id: I6bdecf0959a3497b00d57d907d5a7a7d67b12c32 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/17814 Reviewed-by: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/lsm303dlh_a.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/drivers/hwmon/lsm303dlh_a.c b/drivers/hwmon/lsm303dlh_a.c
index bbcf1663061..307a07cb031 100644
--- a/drivers/hwmon/lsm303dlh_a.c
+++ b/drivers/hwmon/lsm303dlh_a.c
@@ -324,6 +324,8 @@ static int lsm303dlh_a_restore(struct lsm303dlh_a_data *ddata)
goto fail;
fail:
+ /* write to the boot bit to reboot memory content */
+ lsm303dlh_a_write(ddata, CTRL_REG2, 0x80, "CTRL_REG2");
mutex_unlock(&ddata->lock);
return ret;
}
@@ -757,6 +759,7 @@ static ssize_t lsm303dlh_a_store_mode(struct device *dev,
long val;
unsigned char data;
int error;
+ bool set_boot_bit = false;
error = strict_strtol(buf, 0, &val);
if (error)
@@ -771,11 +774,15 @@ static ssize_t lsm303dlh_a_store_mode(struct device *dev,
return -EINVAL;
}
- if (ddata->device_status == DEVICE_SUSPENDED &&
- val == LSM303DLH_A_MODE_OFF) {
- ddata->mode = val;
- mutex_unlock(&ddata->lock);
- return 0;
+ if (ddata->device_status == DEVICE_SUSPENDED) {
+ if (val == LSM303DLH_A_MODE_OFF) {
+ ddata->mode = val;
+ mutex_unlock(&ddata->lock);
+ return 0;
+ } else {
+ /* device is turning on after suspend, reset memory */
+ set_boot_bit = true;
+ }
}
/* if same mode as existing, return */
@@ -814,6 +821,14 @@ static ssize_t lsm303dlh_a_store_mode(struct device *dev,
return error;
}
+ /*
+ * Power on request when device is in suspended state
+ * write to the boot bit in CTRL_REG2 to reboot memory content
+ * and ensure correct device behavior after it resumes
+ */
+ if (set_boot_bit)
+ lsm303dlh_a_write(ddata, CTRL_REG2, 0x80, "CTRL_REG2");
+
if (val == LSM303DLH_A_MODE_OFF) {
#ifdef CONFIG_SENSORS_LSM303DLH_INPUT_DEVICE
disable_irq(gpio_to_irq(ddata->pdata.irq_a1));