Commit c9c9513fd08d1e0548003e86d70a211c2e456d49
Committed by
Samuel Ortiz
1 parent
863dde5bfa
Exists in
master
and in
20 other branches
mfd: Add manual ab8500-gpadc batt temp activation for AB8500 3.0
In AB8500 3.0 the pull-up supplying the NTC must be manually activated. Add enumerators to chip version detection logic. Signed-off-by: Kalle Komierowski <karl.komierowski@stericsson.com> Reviewed-by: Johan Palsson <johan.palsson@stericsson.com> Reviewed-by: Daniel Willerud <daniel.willerud@stericsson.com> Reviewed-by: Jonas Aberg <jonas.aberg@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Showing 1 changed file with 33 additions and 1 deletions Side-by-side Diff
drivers/mfd/ab8500-gpadc.c
... | ... | @@ -57,6 +57,7 @@ |
57 | 57 | #define SW_AVG_16 0x60 |
58 | 58 | #define ADC_SW_CONV 0x04 |
59 | 59 | #define EN_ICHAR 0x80 |
60 | +#define BATTEMP_PULLUP 0x04 | |
60 | 61 | #define EN_BUF 0x40 |
61 | 62 | #define DIS_ZERO 0x00 |
62 | 63 | #define GPADC_BUSY 0x01 |
... | ... | @@ -101,6 +102,7 @@ |
101 | 102 | |
102 | 103 | /** |
103 | 104 | * struct ab8500_gpadc - AB8500 GPADC device information |
105 | + * @chip_id ABB chip id | |
104 | 106 | * @dev: pointer to the struct device |
105 | 107 | * @node: a list of AB8500 GPADCs, hence prepared for |
106 | 108 | reentrance |
... | ... | @@ -112,6 +114,7 @@ |
112 | 114 | * @cal_data array of ADC calibration data structs |
113 | 115 | */ |
114 | 116 | struct ab8500_gpadc { |
117 | + u8 chip_id; | |
115 | 118 | struct device *dev; |
116 | 119 | struct list_head node; |
117 | 120 | struct completion ab8500_gpadc_complete; |
... | ... | @@ -274,6 +277,7 @@ |
274 | 277 | dev_err(gpadc->dev, "gpadc_conversion: enable gpadc failed\n"); |
275 | 278 | goto out; |
276 | 279 | } |
280 | + | |
277 | 281 | /* Select the input source and set average samples to 16 */ |
278 | 282 | ret = abx500_set_register_interruptible(gpadc->dev, AB8500_GPADC, |
279 | 283 | AB8500_GPADC_CTRL2_REG, (input | SW_AVG_16)); |
280 | 284 | |
... | ... | @@ -282,9 +286,11 @@ |
282 | 286 | "gpadc_conversion: set avg samples failed\n"); |
283 | 287 | goto out; |
284 | 288 | } |
289 | + | |
285 | 290 | /* |
286 | 291 | * Enable ADC, buffering, select rising edge and enable ADC path |
287 | - * charging current sense if it needed | |
292 | + * charging current sense if it needed, ABB 3.0 needs some special | |
293 | + * treatment too. | |
288 | 294 | */ |
289 | 295 | switch (input) { |
290 | 296 | case MAIN_CHARGER_C: |
... | ... | @@ -294,6 +300,23 @@ |
294 | 300 | EN_BUF | EN_ICHAR, |
295 | 301 | EN_BUF | EN_ICHAR); |
296 | 302 | break; |
303 | + case BTEMP_BALL: | |
304 | + if (gpadc->chip_id >= AB8500_CUT3P0) { | |
305 | + /* Turn on btemp pull-up on ABB 3.0 */ | |
306 | + ret = abx500_mask_and_set_register_interruptible( | |
307 | + gpadc->dev, | |
308 | + AB8500_GPADC, AB8500_GPADC_CTRL1_REG, | |
309 | + EN_BUF | BATTEMP_PULLUP, | |
310 | + EN_BUF | BATTEMP_PULLUP); | |
311 | + | |
312 | + /* | |
313 | + * Delay might be needed for ABB8500 cut 3.0, if not, remove | |
314 | + * when hardware will be availible | |
315 | + */ | |
316 | + msleep(1); | |
317 | + break; | |
318 | + } | |
319 | + /* Intentional fallthrough */ | |
297 | 320 | default: |
298 | 321 | ret = abx500_mask_and_set_register_interruptible(gpadc->dev, |
299 | 322 | AB8500_GPADC, AB8500_GPADC_CTRL1_REG, EN_BUF, EN_BUF); |
... | ... | @@ -304,6 +327,7 @@ |
304 | 327 | "gpadc_conversion: select falling edge failed\n"); |
305 | 328 | goto out; |
306 | 329 | } |
330 | + | |
307 | 331 | ret = abx500_mask_and_set_register_interruptible(gpadc->dev, |
308 | 332 | AB8500_GPADC, AB8500_GPADC_CTRL1_REG, ADC_SW_CONV, ADC_SW_CONV); |
309 | 333 | if (ret < 0) { |
... | ... | @@ -551,6 +575,14 @@ |
551 | 575 | gpadc->irq); |
552 | 576 | goto fail; |
553 | 577 | } |
578 | + | |
579 | + /* Get Chip ID of the ABB ASIC */ | |
580 | + ret = abx500_get_chip_id(gpadc->dev); | |
581 | + if (ret < 0) { | |
582 | + dev_err(gpadc->dev, "failed to get chip ID\n"); | |
583 | + goto fail_irq; | |
584 | + } | |
585 | + gpadc->chip_id = (u8) ret; | |
554 | 586 | |
555 | 587 | /* VTVout LDO used to power up ab8500-GPADC */ |
556 | 588 | gpadc->regu = regulator_get(&pdev->dev, "vddadc"); |