aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/ab8500-gpadc.c
diff options
context:
space:
mode:
authorKarl Komierowski <karl.komierowski@stericsson.com>2011-05-07 18:55:31 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2011-05-26 13:45:43 -0400
commitc9c9513fd08d1e0548003e86d70a211c2e456d49 (patch)
tree98a557eb124dda2535b8e0708c5d5a92b577b4ea /drivers/mfd/ab8500-gpadc.c
parent863dde5bfa3c48f459c6302daf64f94a11c7c1e5 (diff)
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>
Diffstat (limited to 'drivers/mfd/ab8500-gpadc.c')
-rw-r--r--drivers/mfd/ab8500-gpadc.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/drivers/mfd/ab8500-gpadc.c b/drivers/mfd/ab8500-gpadc.c
index 6421ad1160de..82708c1f316d 100644
--- a/drivers/mfd/ab8500-gpadc.c
+++ b/drivers/mfd/ab8500-gpadc.c
@@ -57,6 +57,7 @@
57#define SW_AVG_16 0x60 57#define SW_AVG_16 0x60
58#define ADC_SW_CONV 0x04 58#define ADC_SW_CONV 0x04
59#define EN_ICHAR 0x80 59#define EN_ICHAR 0x80
60#define BATTEMP_PULLUP 0x04
60#define EN_BUF 0x40 61#define EN_BUF 0x40
61#define DIS_ZERO 0x00 62#define DIS_ZERO 0x00
62#define GPADC_BUSY 0x01 63#define GPADC_BUSY 0x01
@@ -101,6 +102,7 @@ struct adc_cal_data {
101 102
102/** 103/**
103 * struct ab8500_gpadc - AB8500 GPADC device information 104 * struct ab8500_gpadc - AB8500 GPADC device information
105 * @chip_id ABB chip id
104 * @dev: pointer to the struct device 106 * @dev: pointer to the struct device
105 * @node: a list of AB8500 GPADCs, hence prepared for 107 * @node: a list of AB8500 GPADCs, hence prepared for
106 reentrance 108 reentrance
@@ -112,6 +114,7 @@ struct adc_cal_data {
112 * @cal_data array of ADC calibration data structs 114 * @cal_data array of ADC calibration data structs
113 */ 115 */
114struct ab8500_gpadc { 116struct ab8500_gpadc {
117 u8 chip_id;
115 struct device *dev; 118 struct device *dev;
116 struct list_head node; 119 struct list_head node;
117 struct completion ab8500_gpadc_complete; 120 struct completion ab8500_gpadc_complete;
@@ -274,6 +277,7 @@ int ab8500_gpadc_convert(struct ab8500_gpadc *gpadc, u8 input)
274 dev_err(gpadc->dev, "gpadc_conversion: enable gpadc failed\n"); 277 dev_err(gpadc->dev, "gpadc_conversion: enable gpadc failed\n");
275 goto out; 278 goto out;
276 } 279 }
280
277 /* Select the input source and set average samples to 16 */ 281 /* Select the input source and set average samples to 16 */
278 ret = abx500_set_register_interruptible(gpadc->dev, AB8500_GPADC, 282 ret = abx500_set_register_interruptible(gpadc->dev, AB8500_GPADC,
279 AB8500_GPADC_CTRL2_REG, (input | SW_AVG_16)); 283 AB8500_GPADC_CTRL2_REG, (input | SW_AVG_16));
@@ -282,9 +286,11 @@ int ab8500_gpadc_convert(struct ab8500_gpadc *gpadc, u8 input)
282 "gpadc_conversion: set avg samples failed\n"); 286 "gpadc_conversion: set avg samples failed\n");
283 goto out; 287 goto out;
284 } 288 }
289
285 /* 290 /*
286 * Enable ADC, buffering, select rising edge and enable ADC path 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 switch (input) { 295 switch (input) {
290 case MAIN_CHARGER_C: 296 case MAIN_CHARGER_C:
@@ -294,6 +300,23 @@ int ab8500_gpadc_convert(struct ab8500_gpadc *gpadc, u8 input)
294 EN_BUF | EN_ICHAR, 300 EN_BUF | EN_ICHAR,
295 EN_BUF | EN_ICHAR); 301 EN_BUF | EN_ICHAR);
296 break; 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 default: 320 default:
298 ret = abx500_mask_and_set_register_interruptible(gpadc->dev, 321 ret = abx500_mask_and_set_register_interruptible(gpadc->dev,
299 AB8500_GPADC, AB8500_GPADC_CTRL1_REG, EN_BUF, EN_BUF); 322 AB8500_GPADC, AB8500_GPADC_CTRL1_REG, EN_BUF, EN_BUF);
@@ -304,6 +327,7 @@ int ab8500_gpadc_convert(struct ab8500_gpadc *gpadc, u8 input)
304 "gpadc_conversion: select falling edge failed\n"); 327 "gpadc_conversion: select falling edge failed\n");
305 goto out; 328 goto out;
306 } 329 }
330
307 ret = abx500_mask_and_set_register_interruptible(gpadc->dev, 331 ret = abx500_mask_and_set_register_interruptible(gpadc->dev,
308 AB8500_GPADC, AB8500_GPADC_CTRL1_REG, ADC_SW_CONV, ADC_SW_CONV); 332 AB8500_GPADC, AB8500_GPADC_CTRL1_REG, ADC_SW_CONV, ADC_SW_CONV);
309 if (ret < 0) { 333 if (ret < 0) {
@@ -552,6 +576,14 @@ static int __devinit ab8500_gpadc_probe(struct platform_device *pdev)
552 goto fail; 576 goto fail;
553 } 577 }
554 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;
586
555 /* VTVout LDO used to power up ab8500-GPADC */ 587 /* VTVout LDO used to power up ab8500-GPADC */
556 gpadc->regu = regulator_get(&pdev->dev, "vddadc"); 588 gpadc->regu = regulator_get(&pdev->dev, "vddadc");
557 if (IS_ERR(gpadc->regu)) { 589 if (IS_ERR(gpadc->regu)) {