aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Murthy <arun.murthy@stericsson.com>2011-05-26 16:57:32 +0530
committersaid m bagheri <ebgheri@steludxu2848.(none)>2011-06-29 10:30:33 +0200
commit12d28112ce6b2a66e5b6afdd017cf2148a36b92b (patch)
treeab9a381f83a65d12db228820dafe35dacc6b0bbf
parentf9cf9587beb5a5f2d57462d8bbbe1f726945e305 (diff)
downloadlinux-2.6.38-lt-ux500-12d28112ce6b2a66e5b6afdd017cf2148a36b92b.tar.gz
mfd: ab5500-gpadc: Discard adc converted value if < 5
ADC Convertion made on BDATA, using resistance mode, sometimes provides a null value or a value < 5. Discard susch values and provide the previous converted value ST-Ericsson Linux next: Not Tested ST-Ericsson ID: WP332221 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: Ib0eaaed520789b91ea77b2a90c640d33a6c913f6 Signed-off-by: Arun Murthy <arun.murthy@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/23607 Reviewed-by: Johan PALSSON <johan.palsson@stericsson.com> Reviewed-by: QATEST Reviewed-by: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
-rw-r--r--drivers/mfd/ab5500-gpadc.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/mfd/ab5500-gpadc.c b/drivers/mfd/ab5500-gpadc.c
index e90bd9a3aaa..dbfc9c30e38 100644
--- a/drivers/mfd/ab5500-gpadc.c
+++ b/drivers/mfd/ab5500-gpadc.c
@@ -47,7 +47,7 @@
#define AB5500_GPADC_AUTO_TRIG_ADOUT0_CTRL 0x34
#define AB5500_GPADC_AUTO_TRIG_ADOUT1_CTRL 0x35
#define AB5500_GPADC_AUTO_TRIG0_MUX_CTRL 0x37
-#define AB5500_GPADC_AUTO_XALTEMP_CTRL 0x57
+#define AB5500_GPADC_AUTO_XTALTEMP_CTRL 0x57
#define AB5500_GPADC_KELVIN_CTRL 0xFE
/* gpadc constants */
@@ -194,6 +194,7 @@ struct ab5500_gpadc {
struct mutex ab5500_gpadc_lock;
struct regulator *regu;
int irq;
+ int prev_bdata;
spinlock_t gpadc_auto_lock;
struct adc_auto_trigger adc_trig[N_AUTO_TRIGGER];
struct workqueue_struct *gpadc_wq;
@@ -358,7 +359,7 @@ int ab5500_gpadc_convert(struct ab5500_gpadc *gpadc, u8 input)
break;
case XTAL_TEMP:
ret = abx500_mask_and_set_register_interruptible(gpadc->dev,
- AB5500_BANK_ADC, AB5500_GPADC_AUTO_XALTEMP_CTRL,
+ AB5500_BANK_ADC, AB5500_GPADC_AUTO_XTALTEMP_CTRL,
ADC_XTAL_FORCE_MASK, ADC_XTAL_FORCE_EN);
if (ret < 0) {
dev_err(gpadc->dev, "gpadc: fail to set xtaltemp\n");
@@ -454,7 +455,7 @@ int ab5500_gpadc_convert(struct ab5500_gpadc *gpadc, u8 input)
*/
if (input == XTAL_TEMP) {
ret = abx500_mask_and_set_register_interruptible(gpadc->dev,
- AB5500_BANK_ADC, AB5500_GPADC_AUTO_XALTEMP_CTRL,
+ AB5500_BANK_ADC, AB5500_GPADC_AUTO_XTALTEMP_CTRL,
ADC_XTAL_FORCE_MASK, ADC_XTAL_FORCE_DI);
if (ret < 0) {
dev_err(gpadc->dev,
@@ -478,6 +479,17 @@ int ab5500_gpadc_convert(struct ab5500_gpadc *gpadc, u8 input)
}
data = (high_data << 2) | (low_data >> 6);
+ if (input == BAT_CTRL || input == BTEMP_BALL) {
+ /*
+ * TODO: Re-check with h/w team
+ * discard null or value < 5, as there is some error
+ * in conversion
+ */
+ if (data < 5)
+ data = gpadc->prev_bdata;
+ else
+ gpadc->prev_bdata = data;
+ }
result = ab5500_gpadc_ad_to_voltage(gpadc, input, data);
mutex_unlock(&gpadc->ab5500_gpadc_lock);