diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2013-02-15 17:56:49 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-04-08 10:36:23 -0400 |
commit | a5055d5d683605210f77d46614bbdb389c1e4a07 (patch) | |
tree | 8d0ce2d4580687da450c5e2dc351c3ec096cd869 /drivers/mfd/twl4030-madc.c | |
parent | d955cba86d32e9b4b6fe7611b4c41b7bbe286183 (diff) |
mfd: twl4030-madc: Add support for raw value in twl4030_madc_conversion
Driver twl4030-madc has hardcoded channel types (10 - battery current,
1 - battery temperature) and also conversation data in variable
twl4030_divider_ratios. These hardcoded channels are incorrect for
Nokia RX-51 board (where is channel 0 - battery temperature).
For Nokia RX-51 there is rx51_battery power_supply driver which reporting
battery information via twl4030_madc_conversion. But this driver needs
raw values (not converted via some hardcoded functions). So this patch
adding new parameter "raw" to struct twl4030_madc_request which tell
twl4030-madc driver to not convert values, but rather return raw.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Anton Vorontsov <anton@enomsg.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/twl4030-madc.c')
-rw-r--r-- | drivers/mfd/twl4030-madc.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/mfd/twl4030-madc.c b/drivers/mfd/twl4030-madc.c index 942b666a2a07..42bd3ea5df3c 100644 --- a/drivers/mfd/twl4030-madc.c +++ b/drivers/mfd/twl4030-madc.c | |||
@@ -211,12 +211,14 @@ static int twl4030battery_current(int raw_volt) | |||
211 | * @reg_base - Base address of the first channel | 211 | * @reg_base - Base address of the first channel |
212 | * @Channels - 16 bit bitmap. If the bit is set, channel value is read | 212 | * @Channels - 16 bit bitmap. If the bit is set, channel value is read |
213 | * @buf - The channel values are stored here. if read fails error | 213 | * @buf - The channel values are stored here. if read fails error |
214 | * @raw - Return raw values without conversion | ||
214 | * value is stored | 215 | * value is stored |
215 | * Returns the number of successfully read channels. | 216 | * Returns the number of successfully read channels. |
216 | */ | 217 | */ |
217 | static int twl4030_madc_read_channels(struct twl4030_madc_data *madc, | 218 | static int twl4030_madc_read_channels(struct twl4030_madc_data *madc, |
218 | u8 reg_base, unsigned | 219 | u8 reg_base, unsigned |
219 | long channels, int *buf) | 220 | long channels, int *buf, |
221 | bool raw) | ||
220 | { | 222 | { |
221 | int count = 0, count_req = 0, i; | 223 | int count = 0, count_req = 0, i; |
222 | u8 reg; | 224 | u8 reg; |
@@ -230,6 +232,10 @@ static int twl4030_madc_read_channels(struct twl4030_madc_data *madc, | |||
230 | count_req++; | 232 | count_req++; |
231 | continue; | 233 | continue; |
232 | } | 234 | } |
235 | if (raw) { | ||
236 | count++; | ||
237 | continue; | ||
238 | } | ||
233 | switch (i) { | 239 | switch (i) { |
234 | case 10: | 240 | case 10: |
235 | buf[i] = twl4030battery_current(buf[i]); | 241 | buf[i] = twl4030battery_current(buf[i]); |
@@ -371,7 +377,7 @@ static irqreturn_t twl4030_madc_threaded_irq_handler(int irq, void *_madc) | |||
371 | method = &twl4030_conversion_methods[r->method]; | 377 | method = &twl4030_conversion_methods[r->method]; |
372 | /* Read results */ | 378 | /* Read results */ |
373 | len = twl4030_madc_read_channels(madc, method->rbase, | 379 | len = twl4030_madc_read_channels(madc, method->rbase, |
374 | r->channels, r->rbuf); | 380 | r->channels, r->rbuf, r->raw); |
375 | /* Return results to caller */ | 381 | /* Return results to caller */ |
376 | if (r->func_cb != NULL) { | 382 | if (r->func_cb != NULL) { |
377 | r->func_cb(len, r->channels, r->rbuf); | 383 | r->func_cb(len, r->channels, r->rbuf); |
@@ -397,7 +403,7 @@ err_i2c: | |||
397 | method = &twl4030_conversion_methods[r->method]; | 403 | method = &twl4030_conversion_methods[r->method]; |
398 | /* Read results */ | 404 | /* Read results */ |
399 | len = twl4030_madc_read_channels(madc, method->rbase, | 405 | len = twl4030_madc_read_channels(madc, method->rbase, |
400 | r->channels, r->rbuf); | 406 | r->channels, r->rbuf, r->raw); |
401 | /* Return results to caller */ | 407 | /* Return results to caller */ |
402 | if (r->func_cb != NULL) { | 408 | if (r->func_cb != NULL) { |
403 | r->func_cb(len, r->channels, r->rbuf); | 409 | r->func_cb(len, r->channels, r->rbuf); |
@@ -585,7 +591,7 @@ int twl4030_madc_conversion(struct twl4030_madc_request *req) | |||
585 | goto out; | 591 | goto out; |
586 | } | 592 | } |
587 | ret = twl4030_madc_read_channels(twl4030_madc, method->rbase, | 593 | ret = twl4030_madc_read_channels(twl4030_madc, method->rbase, |
588 | req->channels, req->rbuf); | 594 | req->channels, req->rbuf, req->raw); |
589 | twl4030_madc->requests[req->method].active = 0; | 595 | twl4030_madc->requests[req->method].active = 0; |
590 | 596 | ||
591 | out: | 597 | out: |