aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergii Postulga <x0153364@ti.com>2012-01-18 19:49:49 +0200
committerZiyann <jaraidaniel@gmail.com>2014-10-03 01:17:59 +0200
commitac693a20a7f5ab5122c2cce82d4b158b1ebe1994 (patch)
tree34753b284619b744194326898dffcfd2ba201831
parent8b185e6910a6a60eda2a3e9bb00c84a849740315 (diff)
downloadkernel_samsung_tuna-ac693a20a7f5ab5122c2cce82d4b158b1ebe1994.zip
kernel_samsung_tuna-ac693a20a7f5ab5122c2cce82d4b158b1ebe1994.tar.gz
kernel_samsung_tuna-ac693a20a7f5ab5122c2cce82d4b158b1ebe1994.tar.bz2
tsl2771 prox/als: Change suspend/resume and enable/disable logic
Logic in suspend/resume path is not correct. Even if proximity sensor is disabled - resume logic will enable it. This patch fixed this. Also, patch resolve issue with disabling ALS sensor. TSL2771's datasheet says that AEN bit should be enable, even if only proximity sensor is used. This patch keep AEN-bit if sensors are enabled and clear it during disabling last of them. Change-Id: Ib134429d36af2c640ff0b52235d91f7f0cf754ef Signed-off-by: Sergii Postulga <x0153364@ti.com>
-rw-r--r--drivers/input/misc/tsl2771.c55
1 files changed, 29 insertions, 26 deletions
diff --git a/drivers/input/misc/tsl2771.c b/drivers/input/misc/tsl2771.c
index 09332d6..9837d64 100644
--- a/drivers/input/misc/tsl2771.c
+++ b/drivers/input/misc/tsl2771.c
@@ -383,13 +383,12 @@ static int tsl2771_als_enable(struct tsl2771_data *data, int val)
TSL2771_PWR_ON | enable_buf[0]);
data->power_state |= TSL2771_ALS_EN_FLAG;
} else {
- write_buf = (~TSL2771_ALS_INT_EN & ~TSL2771_ADC_EN &
- enable_buf[0]);
-
- if (!(data->power_state & ~TSL2771_PROX_EN_FLAG))
- write_buf &= ~TSL2771_PWR_ON;
+ write_buf = (~TSL2771_ALS_INT_EN & enable_buf[0]);
data->power_state &= ~TSL2771_ALS_EN_FLAG;
+
+ if (!data->power_state)
+ write_buf &= ~(TSL2771_PWR_ON | TSL2771_ADC_EN);
}
return tsl2771_write_reg(data, TSL2771_ENABLE, write_buf, 1);
@@ -403,17 +402,18 @@ static int tsl2771_prox_enable(struct tsl2771_data *data, int val)
tsl2771_read_reg(data, TSL2771_ENABLE, enable_buf, 1);
if (val) {
- write_buf = (TSL2771_PROX_INT_EN | TSL2771_PROX_EN |
- TSL2771_PWR_ON | enable_buf[0]);
+ write_buf = (TSL2771_PROX_INT_EN | TSL2771_ADC_EN |
+ TSL2771_PROX_EN | TSL2771_PWR_ON |
+ enable_buf[0]);
data->power_state |= TSL2771_PROX_EN_FLAG;
} else {
write_buf = (~TSL2771_PROX_INT_EN & ~TSL2771_PROX_EN &
enable_buf[0]);
- if (!(data->power_state & ~TSL2771_ALS_EN_FLAG))
- write_buf &= ~TSL2771_PWR_ON;
-
data->power_state &= ~TSL2771_PROX_EN_FLAG;
+
+ if (!data->power_state)
+ write_buf &= ~(TSL2771_PWR_ON | TSL2771_ADC_EN);
}
return tsl2771_write_reg(data, TSL2771_ENABLE, write_buf, 1);
@@ -857,18 +857,20 @@ static int tsl2771_driver_suspend(struct device *dev)
/* TO DO: May need to retain the interrupt thresholds but won't know
* until the thresholds are implemented */
data->power_context = data->power_state;
- if (data->power_state & 0x2) {
+
+ if (data->power_state & TSL2771_ALS_EN_FLAG) {
+ tsl2771_als_enable(data, 0);
if (als_prox_debug & 0x4)
- pr_info("%s:Prox was enabled into suspend\n", __func__);
- } else
- tsl2771_prox_enable(data, 0);
+ pr_info("%s:ALS was disabled\n", __func__);
+ }
- tsl2771_als_enable(data, 0);
+ if (data->power_state & TSL2771_PROX_EN_FLAG) {
+ if (als_prox_debug & 0x4)
+ pr_info("%s:Prox was enabled into suspend\n", __func__);
+ }
- if (!(data->power_state & 0x2)) {
- if (data->pdata->tsl2771_pwr_control)
+ if (!data->power_state && data->pdata->tsl2771_pwr_control)
data->pdata->tsl2771_pwr_control(0);
- }
return 0;
}
@@ -878,21 +880,22 @@ static int tsl2771_driver_resume(struct device *dev)
struct platform_device *pdev = to_platform_device(dev);
struct tsl2771_data *data = platform_get_drvdata(pdev);
- if (data->pdata->tsl2771_pwr_control) {
+ if (data->power_context &&
+ !(data->power_context & TSL2771_PROX_EN_FLAG) &&
+ (data->pdata->tsl2771_pwr_control)) {
data->pdata->tsl2771_pwr_control(1);
tsl2771_init_device(data);
}
- if (data->power_context & 0x2) {
+ if (data->power_context & TSL2771_ALS_EN_FLAG) {
+ tsl2771_als_enable(data, 1);
if (als_prox_debug & 0x4)
- pr_info("%s:Prox was enabled into suspend\n", __func__);
- } else
- tsl2771_prox_enable(data, 1);
+ pr_info("%s:ALS was enabled\n", __func__);
+ }
- if (data->power_context & 0x1) {
+ if (data->power_context & TSL2771_PROX_EN_FLAG) {
if (als_prox_debug & 0x4)
- pr_info("%s:ALS was enabled\n", __func__);
- tsl2771_als_enable(data, 1);
+ pr_info("%s:Prox was enabled into suspend\n", __func__);
}
return 0;