summaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
authorSri Krishna chowdary <schowdary@nvidia.com>2014-05-29 14:28:26 +0530
committerRiham Haidar <rhaidar@nvidia.com>2014-05-30 16:16:03 -0700
commit2529e3e1108913eef8215eccd4147da922547db4 (patch)
treec0de47ab8eb1735fa7b8bc39425b01d85ef67d2c /drivers/staging
parente2540e21568abff316b3264ca6e714bcd63e8d36 (diff)
staging: iio: light: ltr659: tune prox settings
Change default settings for proximity channel as below Gain: x16, LED Current: 100mA, Duty Cycle: 100%, PMF: 30KHz N_Pluse: 5, Measurement Repeat Rate: 100ms This change also - Enables saturation detection. - replaces mdelay with msleep since all delays are >= 10 ms. Bug 1496949 Bug 200003335 Bug 1510031 Change-Id: Id4bce839b10ab356141d5cbf28a31fa414fca768 Signed-off-by: wahsu <wahsu@nvidia.com> Signed-off-by: Sri Krishna chowdary <schowdary@nvidia.com> Reviewed-on: http://git-master/r/411380 (cherry picked from commit ebbd4163499e7cea62e967ec352cac07fcd53231) Reviewed-on: http://git-master/r/416937 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/iio/light/ltr558als.c28
-rw-r--r--drivers/staging/iio/light/ltr558als.h50
2 files changed, 71 insertions, 7 deletions
diff --git a/drivers/staging/iio/light/ltr558als.c b/drivers/staging/iio/light/ltr558als.c
index e4983dbd46b6..e1c79a7b9a55 100644
--- a/drivers/staging/iio/light/ltr558als.c
+++ b/drivers/staging/iio/light/ltr558als.c
@@ -104,8 +104,24 @@ static int ltr558_ps_enable(struct i2c_client *client, int gainrange)
break;
}
- error = ltr558_i2c_write_reg(client, LTR558_PS_CONTR, setgain);
- mdelay(WAKEUP_DELAY);
+ /*
+ * Per HW Suggestion, LED Current: 100mA, Duty Cycle: 100%, PMF: 30KHz
+ * LED Pulse Count: 5, Measurement Repeat Rate: 200ms
+ */
+ error = ltr558_i2c_write_reg(client, LTR558_PS_LED,
+ PS_LED_PMF_30KHZ | PS_LED_CUR_DUTY_100 |
+ PS_LED_CUR_LEVEL_100);
+ if (!error)
+ error = ltr558_i2c_write_reg(client, LTR558_PS_N_PULSES,
+ PS_N_PULSES_5);
+ if (!error)
+ error = ltr558_i2c_write_reg(client, LTR558_PS_MEAS_RATE,
+ PS_MEAS_RATE_200MS);
+ if (!error) {
+ error = ltr558_i2c_write_reg(client,
+ LTR558_PS_CONTR, BIT(5) | setgain);
+ mdelay(WAKEUP_DELAY);
+ }
return error;
}
@@ -129,6 +145,10 @@ static int ltr558_ps_read(struct i2c_client *client)
goto out;
}
+ /* PS should never saturate */
+ /* FIX ME: enable WARN_ON once sensor is calibrated */
+ /* WARN_ON(psval_hi & BIT(7)); */
+
psdata = ((psval_hi & 0x07) * 256) + psval_lo;
out:
return psdata;
@@ -145,7 +165,7 @@ static int ltr558_als_enable(struct i2c_client *client, int gainrange)
error = ltr558_i2c_write_reg(client, LTR558_ALS_CONTR,
MODE_ALS_ON_Range2);
- mdelay(WAKEUP_DELAY);
+ msleep(WAKEUP_DELAY);
return error;
}
@@ -695,7 +715,7 @@ static int ltr558_chip_init(struct i2c_client *client)
struct ltr558_chip *chip = iio_priv(indio_dev);
int error = 0;
- mdelay(PON_DELAY);
+ msleep(PON_DELAY);
chip->is_prox_enable = 0;
chip->prox_low_thres = 0;
diff --git a/drivers/staging/iio/light/ltr558als.h b/drivers/staging/iio/light/ltr558als.h
index eb948dc163ac..8ffabb013df6 100644
--- a/drivers/staging/iio/light/ltr558als.h
+++ b/drivers/staging/iio/light/ltr558als.h
@@ -65,13 +65,57 @@
#define MODE_PS_ON_Gain16 0x0F
#define MODE_PS_StdBy 0x00
-#define PS_RANGE1 1
+#define PS_LED_CUR_LEVEL_5 0x00
+#define PS_LED_CUR_LEVEL_10 0x01
+#define PS_LED_CUR_LEVEL_20 0x02
+#define PS_LED_CUR_LEVEL_50 0x03
+#define PS_LED_CUR_LEVEL_100 0x07
+
+#define PS_LED_CUR_DUTY_25 0x00
+#define PS_LED_CUR_DUTY_50 0x08
+#define PS_LED_CUR_DUTY_75 0x10
+#define PS_LED_CUR_DUTY_100 0x18
+
+#define PS_LED_PMF_30KHZ 0x0
+#define PS_LED_PMF_40KHZ 0x20
+#define PS_LED_PMF_50KHZ 0x40
+#define PS_LED_PMF_60KHZ 0x60
+#define PS_LED_PMF_70KHZ 0x80
+#define PS_LED_PMF_80KHZ 0xA0
+#define PS_LED_PMF_90KHZ 0xC0
+#define PS_LED_PMF_100KHZ 0xE0
+
+#define PS_N_PULSES_1 0x01
+#define PS_N_PULSES_2 0x02
+#define PS_N_PULSES_3 0x03
+#define PS_N_PULSES_4 0x04
+#define PS_N_PULSES_5 0x05
+#define PS_N_PULSES_6 0x06
+#define PS_N_PULSES_7 0x07
+#define PS_N_PULSES_8 0x08
+#define PS_N_PULSES_9 0x09
+#define PS_N_PULSES_10 0x0A
+#define PS_N_PULSES_11 0x0B
+#define PS_N_PULSES_12 0x0C
+#define PS_N_PULSES_13 0x0D
+#define PS_N_PULSES_14 0x0E
+#define PS_N_PULSES_15 0x0F
+
+#define PS_MEAS_RATE_50MS 0x00
+#define PS_MEAS_RATE_70MS 0x01
+#define PS_MEAS_RATE_100MS 0x02
+#define PS_MEAS_RATE_200MS 0x03
+#define PS_MEAS_RATE_500MS 0x04
+#define PS_MEAS_RATE_1000MS 0x05
+#define PS_MEAS_RATE_2000MS 0x07
+
+#define PS_RANGE1 1
#define PS_RANGE4 2
-#define PS_RANGE8 4
+#define PS_RANGE8 4
#define PS_RANGE16 8
#define ALS_RANGE1_320 1
-#define ALS_RANGE2_64K 2
+#define ALS_RANGE2_64K 2
#define LTR_MANUFACTURER_ID 0x05