blob: fc8da4496e84e305357953032bd735e4090d3fe2 [file] [log] [blame]
Arun Murthydae2db32011-02-22 10:11:13 +01001/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * License Terms: GNU General Public License v2
5 * Author: Arun R Murthy <arun.murthy@stericsson.com>
Daniel Willerud63219922011-03-05 11:46:13 +01006 * Author: Daniel Willerud <daniel.willerud@stericsson.com>
Johan Palsson586f3312011-03-05 11:46:37 +01007 * Author: Johan Palsson <johan.palsson@stericsson.com>
Arun Murthydae2db32011-02-22 10:11:13 +01008 */
9#include <linux/init.h>
10#include <linux/module.h>
11#include <linux/device.h>
12#include <linux/interrupt.h>
13#include <linux/spinlock.h>
14#include <linux/delay.h>
Lee Jones5f8aaef2013-02-04 08:33:13 +000015#include <linux/pm_runtime.h>
Arun Murthydae2db32011-02-22 10:11:13 +010016#include <linux/platform_device.h>
17#include <linux/completion.h>
18#include <linux/regulator/consumer.h>
19#include <linux/err.h>
20#include <linux/slab.h>
Daniel Willerud63219922011-03-05 11:46:13 +010021#include <linux/list.h>
Arun Murthydae2db32011-02-22 10:11:13 +010022#include <linux/mfd/abx500.h>
Linus Walleijee66e652011-12-02 14:16:33 +010023#include <linux/mfd/abx500/ab8500.h>
24#include <linux/mfd/abx500/ab8500-gpadc.h>
Arun Murthydae2db32011-02-22 10:11:13 +010025
26/*
27 * GPADC register offsets
28 * Bank : 0x0A
29 */
30#define AB8500_GPADC_CTRL1_REG 0x00
31#define AB8500_GPADC_CTRL2_REG 0x01
32#define AB8500_GPADC_CTRL3_REG 0x02
33#define AB8500_GPADC_AUTO_TIMER_REG 0x03
34#define AB8500_GPADC_STAT_REG 0x04
35#define AB8500_GPADC_MANDATAL_REG 0x05
36#define AB8500_GPADC_MANDATAH_REG 0x06
37#define AB8500_GPADC_AUTODATAL_REG 0x07
38#define AB8500_GPADC_AUTODATAH_REG 0x08
39#define AB8500_GPADC_MUX_CTRL_REG 0x09
40
Johan Palsson586f3312011-03-05 11:46:37 +010041/*
42 * OTP register offsets
43 * Bank : 0x15
44 */
45#define AB8500_GPADC_CAL_1 0x0F
46#define AB8500_GPADC_CAL_2 0x10
47#define AB8500_GPADC_CAL_3 0x11
48#define AB8500_GPADC_CAL_4 0x12
49#define AB8500_GPADC_CAL_5 0x13
50#define AB8500_GPADC_CAL_6 0x14
51#define AB8500_GPADC_CAL_7 0x15
52
Arun Murthydae2db32011-02-22 10:11:13 +010053/* gpadc constants */
54#define EN_VINTCORE12 0x04
55#define EN_VTVOUT 0x02
56#define EN_GPADC 0x01
57#define DIS_GPADC 0x00
Lee Jones73482342013-02-26 10:06:55 +000058#define AVG_1 0x00
59#define AVG_4 0x20
60#define AVG_8 0x40
61#define AVG_16 0x60
Arun Murthydae2db32011-02-22 10:11:13 +010062#define ADC_SW_CONV 0x04
Karl Komierowski4aad5a92011-03-05 11:46:45 +010063#define EN_ICHAR 0x80
Johan Palssoned139412011-05-08 00:55:43 +020064#define BTEMP_PULL_UP 0x08
Arun Murthydae2db32011-02-22 10:11:13 +010065#define EN_BUF 0x40
66#define DIS_ZERO 0x00
67#define GPADC_BUSY 0x01
Lee Jones73482342013-02-26 10:06:55 +000068#define EN_FALLING 0x10
69#define EN_TRIG_EDGE 0x02
Arun Murthydae2db32011-02-22 10:11:13 +010070
Johan Palsson586f3312011-03-05 11:46:37 +010071/* GPADC constants from AB8500 spec, UM0836 */
72#define ADC_RESOLUTION 1024
73#define ADC_CH_BTEMP_MIN 0
74#define ADC_CH_BTEMP_MAX 1350
75#define ADC_CH_DIETEMP_MIN 0
76#define ADC_CH_DIETEMP_MAX 1350
77#define ADC_CH_CHG_V_MIN 0
78#define ADC_CH_CHG_V_MAX 20030
79#define ADC_CH_ACCDET2_MIN 0
80#define ADC_CH_ACCDET2_MAX 2500
81#define ADC_CH_VBAT_MIN 2300
82#define ADC_CH_VBAT_MAX 4800
83#define ADC_CH_CHG_I_MIN 0
84#define ADC_CH_CHG_I_MAX 1500
85#define ADC_CH_BKBAT_MIN 0
86#define ADC_CH_BKBAT_MAX 3200
87
88/* This is used to not lose precision when dividing to get gain and offset */
89#define CALIB_SCALE 1000
90
Lee Jones5f8aaef2013-02-04 08:33:13 +000091/* Time in ms before disabling regulator */
92#define GPADC_AUDOSUSPEND_DELAY 1
93
Lee Jonesf825ebe2013-01-28 09:20:45 +000094#define CONVERSION_TIME 500 /* ms */
95
Johan Palsson586f3312011-03-05 11:46:37 +010096enum cal_channels {
97 ADC_INPUT_VMAIN = 0,
98 ADC_INPUT_BTEMP,
99 ADC_INPUT_VBAT,
100 NBR_CAL_INPUTS,
101};
102
Arun Murthydae2db32011-02-22 10:11:13 +0100103/**
Johan Palsson586f3312011-03-05 11:46:37 +0100104 * struct adc_cal_data - Table for storing gain and offset for the calibrated
105 * ADC channels
106 * @gain: Gain of the ADC channel
107 * @offset: Offset of the ADC channel
108 */
109struct adc_cal_data {
110 u64 gain;
111 u64 offset;
112};
113
114/**
115 * struct ab8500_gpadc - AB8500 GPADC device information
Arun Murthydae2db32011-02-22 10:11:13 +0100116 * @dev: pointer to the struct device
Daniel Willerud63219922011-03-05 11:46:13 +0100117 * @node: a list of AB8500 GPADCs, hence prepared for
118 reentrance
Michel JAOUEN20bf4282012-02-09 12:06:47 +0100119 * @parent: pointer to the struct ab8500
Arun Murthydae2db32011-02-22 10:11:13 +0100120 * @ab8500_gpadc_complete: pointer to the struct completion, to indicate
121 * the completion of gpadc conversion
122 * @ab8500_gpadc_lock: structure of type mutex
123 * @regu: pointer to the struct regulator
Lee Jones73482342013-02-26 10:06:55 +0000124 * @irq_sw: interrupt number that is used by gpadc for Sw
125 * conversion
126 * @irq_hw: interrupt number that is used by gpadc for Hw
127 * conversion
Johan Palsson586f3312011-03-05 11:46:37 +0100128 * @cal_data array of ADC calibration data structs
Arun Murthydae2db32011-02-22 10:11:13 +0100129 */
Daniel Willerud63219922011-03-05 11:46:13 +0100130struct ab8500_gpadc {
Arun Murthydae2db32011-02-22 10:11:13 +0100131 struct device *dev;
Daniel Willerud63219922011-03-05 11:46:13 +0100132 struct list_head node;
Michel JAOUEN20bf4282012-02-09 12:06:47 +0100133 struct ab8500 *parent;
Arun Murthydae2db32011-02-22 10:11:13 +0100134 struct completion ab8500_gpadc_complete;
135 struct mutex ab8500_gpadc_lock;
136 struct regulator *regu;
Lee Jones73482342013-02-26 10:06:55 +0000137 int irq_sw;
138 int irq_hw;
Johan Palsson586f3312011-03-05 11:46:37 +0100139 struct adc_cal_data cal_data[NBR_CAL_INPUTS];
Daniel Willerud63219922011-03-05 11:46:13 +0100140};
141
142static LIST_HEAD(ab8500_gpadc_list);
143
144/**
145 * ab8500_gpadc_get() - returns a reference to the primary AB8500 GPADC
146 * (i.e. the first GPADC in the instance list)
147 */
148struct ab8500_gpadc *ab8500_gpadc_get(char *name)
149{
150 struct ab8500_gpadc *gpadc;
151
152 list_for_each_entry(gpadc, &ab8500_gpadc_list, node) {
153 if (!strcmp(name, dev_name(gpadc->dev)))
154 return gpadc;
155 }
156
157 return ERR_PTR(-ENOENT);
158}
159EXPORT_SYMBOL(ab8500_gpadc_get);
Arun Murthydae2db32011-02-22 10:11:13 +0100160
Karl Komierowskibd4a40b2011-08-10 15:09:43 +0200161/**
162 * ab8500_gpadc_ad_to_voltage() - Convert a raw ADC value to a voltage
163 */
164int ab8500_gpadc_ad_to_voltage(struct ab8500_gpadc *gpadc, u8 channel,
Johan Palsson586f3312011-03-05 11:46:37 +0100165 int ad_value)
166{
167 int res;
168
Karl Komierowskibd4a40b2011-08-10 15:09:43 +0200169 switch (channel) {
Johan Palsson586f3312011-03-05 11:46:37 +0100170 case MAIN_CHARGER_V:
171 /* For some reason we don't have calibrated data */
172 if (!gpadc->cal_data[ADC_INPUT_VMAIN].gain) {
173 res = ADC_CH_CHG_V_MIN + (ADC_CH_CHG_V_MAX -
174 ADC_CH_CHG_V_MIN) * ad_value /
175 ADC_RESOLUTION;
176 break;
177 }
178 /* Here we can use the calibrated data */
179 res = (int) (ad_value * gpadc->cal_data[ADC_INPUT_VMAIN].gain +
180 gpadc->cal_data[ADC_INPUT_VMAIN].offset) / CALIB_SCALE;
181 break;
182
183 case BAT_CTRL:
184 case BTEMP_BALL:
185 case ACC_DETECT1:
186 case ADC_AUX1:
187 case ADC_AUX2:
188 /* For some reason we don't have calibrated data */
189 if (!gpadc->cal_data[ADC_INPUT_BTEMP].gain) {
190 res = ADC_CH_BTEMP_MIN + (ADC_CH_BTEMP_MAX -
191 ADC_CH_BTEMP_MIN) * ad_value /
192 ADC_RESOLUTION;
193 break;
194 }
195 /* Here we can use the calibrated data */
196 res = (int) (ad_value * gpadc->cal_data[ADC_INPUT_BTEMP].gain +
197 gpadc->cal_data[ADC_INPUT_BTEMP].offset) / CALIB_SCALE;
198 break;
199
200 case MAIN_BAT_V:
201 /* For some reason we don't have calibrated data */
202 if (!gpadc->cal_data[ADC_INPUT_VBAT].gain) {
203 res = ADC_CH_VBAT_MIN + (ADC_CH_VBAT_MAX -
204 ADC_CH_VBAT_MIN) * ad_value /
205 ADC_RESOLUTION;
206 break;
207 }
208 /* Here we can use the calibrated data */
209 res = (int) (ad_value * gpadc->cal_data[ADC_INPUT_VBAT].gain +
210 gpadc->cal_data[ADC_INPUT_VBAT].offset) / CALIB_SCALE;
211 break;
212
213 case DIE_TEMP:
214 res = ADC_CH_DIETEMP_MIN +
215 (ADC_CH_DIETEMP_MAX - ADC_CH_DIETEMP_MIN) * ad_value /
216 ADC_RESOLUTION;
217 break;
218
219 case ACC_DETECT2:
220 res = ADC_CH_ACCDET2_MIN +
221 (ADC_CH_ACCDET2_MAX - ADC_CH_ACCDET2_MIN) * ad_value /
222 ADC_RESOLUTION;
223 break;
224
225 case VBUS_V:
226 res = ADC_CH_CHG_V_MIN +
227 (ADC_CH_CHG_V_MAX - ADC_CH_CHG_V_MIN) * ad_value /
228 ADC_RESOLUTION;
229 break;
230
231 case MAIN_CHARGER_C:
232 case USB_CHARGER_C:
233 res = ADC_CH_CHG_I_MIN +
234 (ADC_CH_CHG_I_MAX - ADC_CH_CHG_I_MIN) * ad_value /
235 ADC_RESOLUTION;
236 break;
237
238 case BK_BAT_V:
239 res = ADC_CH_BKBAT_MIN +
240 (ADC_CH_BKBAT_MAX - ADC_CH_BKBAT_MIN) * ad_value /
241 ADC_RESOLUTION;
242 break;
243
244 default:
245 dev_err(gpadc->dev,
246 "unknown channel, not possible to convert\n");
247 res = -EINVAL;
248 break;
249
250 }
251 return res;
252}
Karl Komierowskibd4a40b2011-08-10 15:09:43 +0200253EXPORT_SYMBOL(ab8500_gpadc_ad_to_voltage);
Johan Palsson586f3312011-03-05 11:46:37 +0100254
Arun Murthydae2db32011-02-22 10:11:13 +0100255/**
Lee Jones73482342013-02-26 10:06:55 +0000256 * ab8500_gpadc_sw_hw_convert() - gpadc conversion
Karl Komierowskibd4a40b2011-08-10 15:09:43 +0200257 * @channel: analog channel to be converted to digital data
Lee Jones73482342013-02-26 10:06:55 +0000258 * @avg_sample: number of ADC sample to average
259 * @trig_egde: selected ADC trig edge
260 * @trig_timer: selected ADC trigger delay timer
261 * @conv_type: selected conversion type (HW or SW conversion)
Arun Murthydae2db32011-02-22 10:11:13 +0100262 *
263 * This function converts the selected analog i/p to digital
Johan Palsson586f3312011-03-05 11:46:37 +0100264 * data.
Arun Murthydae2db32011-02-22 10:11:13 +0100265 */
Lee Jones73482342013-02-26 10:06:55 +0000266int ab8500_gpadc_sw_hw_convert(struct ab8500_gpadc *gpadc, u8 channel,
267 u8 avg_sample, u8 trig_edge, u8 trig_timer, u8 conv_type)
Karl Komierowskibd4a40b2011-08-10 15:09:43 +0200268{
269 int ad_value;
270 int voltage;
271
Lee Jones73482342013-02-26 10:06:55 +0000272 ad_value = ab8500_gpadc_read_raw(gpadc, channel, avg_sample,
273 trig_edge, trig_timer, conv_type);
274/* On failure retry a second time */
Jonas Aabergd89cc5a2012-04-17 16:10:46 +0200275 if (ad_value < 0)
Lee Jones73482342013-02-26 10:06:55 +0000276 ad_value = ab8500_gpadc_read_raw(gpadc, channel, avg_sample,
277 trig_edge, trig_timer, conv_type);
278if (ad_value < 0) {
279 dev_err(gpadc->dev, "GPADC raw value failed ch: %d\n",
280 channel);
Karl Komierowskibd4a40b2011-08-10 15:09:43 +0200281 return ad_value;
282 }
283
284 voltage = ab8500_gpadc_ad_to_voltage(gpadc, channel, ad_value);
Karl Komierowskibd4a40b2011-08-10 15:09:43 +0200285 if (voltage < 0)
286 dev_err(gpadc->dev, "GPADC to voltage conversion failed ch:"
287 " %d AD: 0x%x\n", channel, ad_value);
288
289 return voltage;
290}
291EXPORT_SYMBOL(ab8500_gpadc_convert);
292
293/**
294 * ab8500_gpadc_read_raw() - gpadc read
295 * @channel: analog channel to be read
Lee Jones73482342013-02-26 10:06:55 +0000296 * @avg_sample: number of ADC sample to average
297 * @trig_edge: selected trig edge
298 * @trig_timer: selected ADC trigger delay timer
299 * @conv_type: selected conversion type (HW or SW conversion)
Karl Komierowskibd4a40b2011-08-10 15:09:43 +0200300 *
Lee Jones73482342013-02-26 10:06:55 +0000301 * This function obtains the raw ADC value for an hardware conversion,
302 * this then needs to be converted by calling ab8500_gpadc_ad_to_voltage()
Karl Komierowskibd4a40b2011-08-10 15:09:43 +0200303 */
Lee Jones73482342013-02-26 10:06:55 +0000304int ab8500_gpadc_read_raw(struct ab8500_gpadc *gpadc, u8 channel,
305 u8 avg_sample, u8 trig_edge, u8 trig_timer, u8 conv_type)
Arun Murthydae2db32011-02-22 10:11:13 +0100306{
307 int ret;
Arun Murthydae2db32011-02-22 10:11:13 +0100308 int looplimit = 0;
309 u8 val, low_data, high_data;
310
Daniel Willerud63219922011-03-05 11:46:13 +0100311 if (!gpadc)
Arun Murthydae2db32011-02-22 10:11:13 +0100312 return -ENODEV;
313
Lee Jonesc0eda9a2013-02-12 15:04:09 +0000314 /* check if convertion is supported */
315 if ((gpadc->irq_sw < 0) && (conv_type == ADC_SW))
316 return -ENOTSUPP;
317 if ((gpadc->irq_hw < 0) && (conv_type == ADC_HW))
318 return -ENOTSUPP;
319
Daniel Willerud63219922011-03-05 11:46:13 +0100320 mutex_lock(&gpadc->ab8500_gpadc_lock);
Arun Murthydae2db32011-02-22 10:11:13 +0100321 /* Enable VTVout LDO this is required for GPADC */
Lee Jones5f8aaef2013-02-04 08:33:13 +0000322 pm_runtime_get_sync(gpadc->dev);
Arun Murthydae2db32011-02-22 10:11:13 +0100323
324 /* Check if ADC is not busy, lock and proceed */
325 do {
Daniel Willerud63219922011-03-05 11:46:13 +0100326 ret = abx500_get_register_interruptible(gpadc->dev,
327 AB8500_GPADC, AB8500_GPADC_STAT_REG, &val);
Arun Murthydae2db32011-02-22 10:11:13 +0100328 if (ret < 0)
329 goto out;
330 if (!(val & GPADC_BUSY))
331 break;
332 msleep(10);
333 } while (++looplimit < 10);
334 if (looplimit >= 10 && (val & GPADC_BUSY)) {
Daniel Willerud63219922011-03-05 11:46:13 +0100335 dev_err(gpadc->dev, "gpadc_conversion: GPADC busy");
Arun Murthydae2db32011-02-22 10:11:13 +0100336 ret = -EINVAL;
337 goto out;
338 }
339
340 /* Enable GPADC */
Daniel Willerud63219922011-03-05 11:46:13 +0100341 ret = abx500_mask_and_set_register_interruptible(gpadc->dev,
342 AB8500_GPADC, AB8500_GPADC_CTRL1_REG, EN_GPADC, EN_GPADC);
Arun Murthydae2db32011-02-22 10:11:13 +0100343 if (ret < 0) {
Daniel Willerud63219922011-03-05 11:46:13 +0100344 dev_err(gpadc->dev, "gpadc_conversion: enable gpadc failed\n");
Arun Murthydae2db32011-02-22 10:11:13 +0100345 goto out;
346 }
Karl Komierowskic9c95132011-05-08 00:55:31 +0200347
Lee Jones73482342013-02-26 10:06:55 +0000348 /* Select the channel source and set average samples */
349 switch (avg_sample) {
350 case SAMPLE_1:
351 val = channel | AVG_1;
352 break;
353 case SAMPLE_4:
354 val = channel | AVG_4;
355 break;
356 case SAMPLE_8:
357 val = channel | AVG_8;
358 break;
359 default:
360 val = channel | AVG_16;
361 break;
362
363 }
364
365 if (conv_type == ADC_HW)
366 ret = abx500_set_register_interruptible(gpadc->dev,
367 AB8500_GPADC, AB8500_GPADC_CTRL3_REG, val);
368 else
369 ret = abx500_set_register_interruptible(gpadc->dev,
370 AB8500_GPADC, AB8500_GPADC_CTRL2_REG, val);
Arun Murthydae2db32011-02-22 10:11:13 +0100371 if (ret < 0) {
Daniel Willerud63219922011-03-05 11:46:13 +0100372 dev_err(gpadc->dev,
Arun Murthydae2db32011-02-22 10:11:13 +0100373 "gpadc_conversion: set avg samples failed\n");
374 goto out;
375 }
Karl Komierowskic9c95132011-05-08 00:55:31 +0200376
Karl Komierowski4aad5a92011-03-05 11:46:45 +0100377 /*
378 * Enable ADC, buffering, select rising edge and enable ADC path
Karl Komierowskic9c95132011-05-08 00:55:31 +0200379 * charging current sense if it needed, ABB 3.0 needs some special
380 * treatment too.
Karl Komierowski4aad5a92011-03-05 11:46:45 +0100381 */
Lee Jones73482342013-02-26 10:06:55 +0000382 if ((conv_type == ADC_HW) && (trig_edge)) {
383 ret = abx500_mask_and_set_register_interruptible(gpadc->dev,
384 AB8500_GPADC, AB8500_GPADC_CTRL1_REG,
385 EN_FALLING, EN_FALLING);
386
387 }
Karl Komierowskibd4a40b2011-08-10 15:09:43 +0200388 switch (channel) {
Karl Komierowski4aad5a92011-03-05 11:46:45 +0100389 case MAIN_CHARGER_C:
390 case USB_CHARGER_C:
Lee Jones73482342013-02-26 10:06:55 +0000391 if (conv_type == ADC_HW)
Karl Komierowskic9c95132011-05-08 00:55:31 +0200392 ret = abx500_mask_and_set_register_interruptible(
393 gpadc->dev,
394 AB8500_GPADC, AB8500_GPADC_CTRL1_REG,
Lee Jones73482342013-02-26 10:06:55 +0000395 EN_BUF | EN_ICHAR | EN_TRIG_EDGE,
396 EN_BUF | EN_ICHAR | EN_TRIG_EDGE);
397 else
398 ret = abx500_mask_and_set_register_interruptible(
399 gpadc->dev,
400 AB8500_GPADC, AB8500_GPADC_CTRL1_REG,
401 EN_BUF | EN_ICHAR,
402 EN_BUF | EN_ICHAR);
403 break;
404 case BTEMP_BALL:
405 if (!is_ab8500_2p0_or_earlier(gpadc->parent)) {
406 if (conv_type == ADC_HW)
407 /* Turn on btemp pull-up on ABB 3.0 */
408 ret = abx500_mask_and_set_register_interruptible
409 (gpadc->dev,
410 AB8500_GPADC, AB8500_GPADC_CTRL1_REG,
411 EN_BUF | BTEMP_PULL_UP | EN_TRIG_EDGE,
412 EN_BUF | BTEMP_PULL_UP | EN_TRIG_EDGE);
413 else
414 ret = abx500_mask_and_set_register_interruptible
415 (gpadc->dev,
416 AB8500_GPADC, AB8500_GPADC_CTRL1_REG,
417 EN_BUF | BTEMP_PULL_UP,
418 EN_BUF | BTEMP_PULL_UP);
Karl Komierowskic9c95132011-05-08 00:55:31 +0200419
420 /*
421 * Delay might be needed for ABB8500 cut 3.0, if not, remove
Masanari Iida5a4432b2012-08-13 21:00:25 +0900422 * when hardware will be available
Karl Komierowskic9c95132011-05-08 00:55:31 +0200423 */
Lee Jonesd0b32fa2011-08-29 08:32:36 +0200424 usleep_range(1000, 1000);
Karl Komierowskic9c95132011-05-08 00:55:31 +0200425 break;
426 }
427 /* Intentional fallthrough */
Karl Komierowski4aad5a92011-03-05 11:46:45 +0100428 default:
Lee Jones73482342013-02-26 10:06:55 +0000429 if (conv_type == ADC_HW)
430 ret = abx500_mask_and_set_register_interruptible(
431 gpadc->dev,
432 AB8500_GPADC, AB8500_GPADC_CTRL1_REG,
433 EN_BUF | EN_TRIG_EDGE,
434 EN_BUF | EN_TRIG_EDGE);
435 else
436 ret = abx500_mask_and_set_register_interruptible(
437 gpadc->dev,
438 AB8500_GPADC,
439 AB8500_GPADC_CTRL1_REG, EN_BUF, EN_BUF);
Karl Komierowski4aad5a92011-03-05 11:46:45 +0100440 break;
441 }
Arun Murthydae2db32011-02-22 10:11:13 +0100442 if (ret < 0) {
Daniel Willerud63219922011-03-05 11:46:13 +0100443 dev_err(gpadc->dev,
Arun Murthydae2db32011-02-22 10:11:13 +0100444 "gpadc_conversion: select falling edge failed\n");
445 goto out;
446 }
Karl Komierowskic9c95132011-05-08 00:55:31 +0200447
Lee Jones73482342013-02-26 10:06:55 +0000448 /* Set trigger delay timer */
449 if (conv_type == ADC_HW) {
450 ret = abx500_set_register_interruptible(gpadc->dev,
451 AB8500_GPADC, AB8500_GPADC_AUTO_TIMER_REG, trig_timer);
452 if (ret < 0) {
453 dev_err(gpadc->dev,
454 "gpadc_conversion: trig timer failed\n");
455 goto out;
456 }
Arun Murthydae2db32011-02-22 10:11:13 +0100457 }
Lee Jones73482342013-02-26 10:06:55 +0000458
459 /* Start SW conversion */
460 if (conv_type == ADC_SW) {
461 ret = abx500_mask_and_set_register_interruptible(gpadc->dev,
462 AB8500_GPADC, AB8500_GPADC_CTRL1_REG,
463 ADC_SW_CONV, ADC_SW_CONV);
464 if (ret < 0) {
465 dev_err(gpadc->dev,
466 "gpadc_conversion: start s/w conv failed\n");
467 goto out;
468 }
469 }
470
Arun Murthydae2db32011-02-22 10:11:13 +0100471 /* wait for completion of conversion */
Lee Jones73482342013-02-26 10:06:55 +0000472 if (conv_type == ADC_HW) {
473 if (!wait_for_completion_timeout(&gpadc->ab8500_gpadc_complete,
474 2*HZ)) {
475 dev_err(gpadc->dev,
476 "timeout didn't receive"
477 " hw GPADC conv interrupt\n");
478 ret = -EINVAL;
479 goto out;
480 }
481 } else {
482 if (!wait_for_completion_timeout(&gpadc->ab8500_gpadc_complete,
483 msecs_to_jiffies(CONVERSION_TIME))) {
484 dev_err(gpadc->dev,
485 "timeout didn't receive"
486 " sw GPADC conv interrupt\n");
487 ret = -EINVAL;
488 goto out;
489 }
Arun Murthydae2db32011-02-22 10:11:13 +0100490 }
491
492 /* Read the converted RAW data */
Lee Jones73482342013-02-26 10:06:55 +0000493 if (conv_type == ADC_HW) {
494 ret = abx500_get_register_interruptible(gpadc->dev,
495 AB8500_GPADC, AB8500_GPADC_AUTODATAL_REG, &low_data);
496 if (ret < 0) {
497 dev_err(gpadc->dev,
498 "gpadc_conversion: read hw low data failed\n");
499 goto out;
500 }
Arun Murthydae2db32011-02-22 10:11:13 +0100501
Lee Jones73482342013-02-26 10:06:55 +0000502 ret = abx500_get_register_interruptible(gpadc->dev,
503 AB8500_GPADC, AB8500_GPADC_AUTODATAH_REG, &high_data);
504 if (ret < 0) {
505 dev_err(gpadc->dev,
506 "gpadc_conversion: read hw high data failed\n");
507 goto out;
508 }
509 } else {
510 ret = abx500_get_register_interruptible(gpadc->dev,
511 AB8500_GPADC, AB8500_GPADC_MANDATAL_REG, &low_data);
512 if (ret < 0) {
513 dev_err(gpadc->dev,
514 "gpadc_conversion: read sw low data failed\n");
515 goto out;
516 }
517
518 ret = abx500_get_register_interruptible(gpadc->dev,
519 AB8500_GPADC, AB8500_GPADC_MANDATAH_REG, &high_data);
520 if (ret < 0) {
521 dev_err(gpadc->dev,
522 "gpadc_conversion: read sw high data failed\n");
523 goto out;
524 }
Arun Murthydae2db32011-02-22 10:11:13 +0100525 }
526
Arun Murthydae2db32011-02-22 10:11:13 +0100527 /* Disable GPADC */
Daniel Willerud63219922011-03-05 11:46:13 +0100528 ret = abx500_set_register_interruptible(gpadc->dev, AB8500_GPADC,
Arun Murthydae2db32011-02-22 10:11:13 +0100529 AB8500_GPADC_CTRL1_REG, DIS_GPADC);
530 if (ret < 0) {
Daniel Willerud63219922011-03-05 11:46:13 +0100531 dev_err(gpadc->dev, "gpadc_conversion: disable gpadc failed\n");
Arun Murthydae2db32011-02-22 10:11:13 +0100532 goto out;
533 }
Lee Jones5f8aaef2013-02-04 08:33:13 +0000534
Lee Jones73482342013-02-26 10:06:55 +0000535 /* Disable VTVout LDO this is required for GPADC */
Lee Jones5f8aaef2013-02-04 08:33:13 +0000536 pm_runtime_mark_last_busy(gpadc->dev);
537 pm_runtime_put_autosuspend(gpadc->dev);
538
Daniel Willerud63219922011-03-05 11:46:13 +0100539 mutex_unlock(&gpadc->ab8500_gpadc_lock);
Karl Komierowskibd4a40b2011-08-10 15:09:43 +0200540
541 return (high_data << 8) | low_data;
Arun Murthydae2db32011-02-22 10:11:13 +0100542
543out:
544 /*
545 * It has shown to be needed to turn off the GPADC if an error occurs,
546 * otherwise we might have problem when waiting for the busy bit in the
547 * GPADC status register to go low. In V1.1 there wait_for_completion
548 * seems to timeout when waiting for an interrupt.. Not seen in V2.0
549 */
Daniel Willerud63219922011-03-05 11:46:13 +0100550 (void) abx500_set_register_interruptible(gpadc->dev, AB8500_GPADC,
Arun Murthydae2db32011-02-22 10:11:13 +0100551 AB8500_GPADC_CTRL1_REG, DIS_GPADC);
Lee Jones5f8aaef2013-02-04 08:33:13 +0000552 pm_runtime_put(gpadc->dev);
Daniel Willerud63219922011-03-05 11:46:13 +0100553 mutex_unlock(&gpadc->ab8500_gpadc_lock);
554 dev_err(gpadc->dev,
Karl Komierowskibd4a40b2011-08-10 15:09:43 +0200555 "gpadc_conversion: Failed to AD convert channel %d\n", channel);
Arun Murthydae2db32011-02-22 10:11:13 +0100556 return ret;
557}
Karl Komierowskibd4a40b2011-08-10 15:09:43 +0200558EXPORT_SYMBOL(ab8500_gpadc_read_raw);
Arun Murthydae2db32011-02-22 10:11:13 +0100559
560/**
Lee Jones73482342013-02-26 10:06:55 +0000561 * ab8500_bm_gpadcconvend_handler() - isr for gpadc conversion completion
Arun Murthydae2db32011-02-22 10:11:13 +0100562 * @irq: irq number
563 * @data: pointer to the data passed during request irq
564 *
Lee Jones73482342013-02-26 10:06:55 +0000565 * This is a interrupt service routine for gpadc conversion completion.
Arun Murthydae2db32011-02-22 10:11:13 +0100566 * Notifies the gpadc completion is completed and the converted raw value
567 * can be read from the registers.
568 * Returns IRQ status(IRQ_HANDLED)
569 */
Lee Jones73482342013-02-26 10:06:55 +0000570static irqreturn_t ab8500_bm_gpadcconvend_handler(int irq, void *_gpadc)
Arun Murthydae2db32011-02-22 10:11:13 +0100571{
Daniel Willerud63219922011-03-05 11:46:13 +0100572 struct ab8500_gpadc *gpadc = _gpadc;
Arun Murthydae2db32011-02-22 10:11:13 +0100573
574 complete(&gpadc->ab8500_gpadc_complete);
575
576 return IRQ_HANDLED;
577}
578
Johan Palsson586f3312011-03-05 11:46:37 +0100579static int otp_cal_regs[] = {
580 AB8500_GPADC_CAL_1,
581 AB8500_GPADC_CAL_2,
582 AB8500_GPADC_CAL_3,
583 AB8500_GPADC_CAL_4,
584 AB8500_GPADC_CAL_5,
585 AB8500_GPADC_CAL_6,
586 AB8500_GPADC_CAL_7,
587};
588
589static void ab8500_gpadc_read_calibration_data(struct ab8500_gpadc *gpadc)
590{
591 int i;
592 int ret[ARRAY_SIZE(otp_cal_regs)];
593 u8 gpadc_cal[ARRAY_SIZE(otp_cal_regs)];
594
595 int vmain_high, vmain_low;
596 int btemp_high, btemp_low;
597 int vbat_high, vbat_low;
598
599 /* First we read all OTP registers and store the error code */
600 for (i = 0; i < ARRAY_SIZE(otp_cal_regs); i++) {
601 ret[i] = abx500_get_register_interruptible(gpadc->dev,
602 AB8500_OTP_EMUL, otp_cal_regs[i], &gpadc_cal[i]);
603 if (ret[i] < 0)
604 dev_err(gpadc->dev, "%s: read otp reg 0x%02x failed\n",
605 __func__, otp_cal_regs[i]);
606 }
607
608 /*
609 * The ADC calibration data is stored in OTP registers.
610 * The layout of the calibration data is outlined below and a more
611 * detailed description can be found in UM0836
612 *
613 * vm_h/l = vmain_high/low
614 * bt_h/l = btemp_high/low
615 * vb_h/l = vbat_high/low
616 *
617 * Data bits:
618 * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
619 * |.......|.......|.......|.......|.......|.......|.......|.......
620 * | | vm_h9 | vm_h8
621 * |.......|.......|.......|.......|.......|.......|.......|.......
622 * | | vm_h7 | vm_h6 | vm_h5 | vm_h4 | vm_h3 | vm_h2
623 * |.......|.......|.......|.......|.......|.......|.......|.......
624 * | vm_h1 | vm_h0 | vm_l4 | vm_l3 | vm_l2 | vm_l1 | vm_l0 | bt_h9
625 * |.......|.......|.......|.......|.......|.......|.......|.......
626 * | bt_h8 | bt_h7 | bt_h6 | bt_h5 | bt_h4 | bt_h3 | bt_h2 | bt_h1
627 * |.......|.......|.......|.......|.......|.......|.......|.......
628 * | bt_h0 | bt_l4 | bt_l3 | bt_l2 | bt_l1 | bt_l0 | vb_h9 | vb_h8
629 * |.......|.......|.......|.......|.......|.......|.......|.......
630 * | vb_h7 | vb_h6 | vb_h5 | vb_h4 | vb_h3 | vb_h2 | vb_h1 | vb_h0
631 * |.......|.......|.......|.......|.......|.......|.......|.......
632 * | vb_l5 | vb_l4 | vb_l3 | vb_l2 | vb_l1 | vb_l0 |
633 * |.......|.......|.......|.......|.......|.......|.......|.......
634 *
635 *
636 * Ideal output ADC codes corresponding to injected input voltages
637 * during manufacturing is:
638 *
639 * vmain_high: Vin = 19500mV / ADC ideal code = 997
640 * vmain_low: Vin = 315mV / ADC ideal code = 16
641 * btemp_high: Vin = 1300mV / ADC ideal code = 985
642 * btemp_low: Vin = 21mV / ADC ideal code = 16
643 * vbat_high: Vin = 4700mV / ADC ideal code = 982
644 * vbat_low: Vin = 2380mV / ADC ideal code = 33
645 */
646
647 /* Calculate gain and offset for VMAIN if all reads succeeded */
648 if (!(ret[0] < 0 || ret[1] < 0 || ret[2] < 0)) {
649 vmain_high = (((gpadc_cal[0] & 0x03) << 8) |
650 ((gpadc_cal[1] & 0x3F) << 2) |
651 ((gpadc_cal[2] & 0xC0) >> 6));
652
653 vmain_low = ((gpadc_cal[2] & 0x3E) >> 1);
654
655 gpadc->cal_data[ADC_INPUT_VMAIN].gain = CALIB_SCALE *
656 (19500 - 315) / (vmain_high - vmain_low);
657
658 gpadc->cal_data[ADC_INPUT_VMAIN].offset = CALIB_SCALE * 19500 -
659 (CALIB_SCALE * (19500 - 315) /
660 (vmain_high - vmain_low)) * vmain_high;
661 } else {
662 gpadc->cal_data[ADC_INPUT_VMAIN].gain = 0;
663 }
664
665 /* Calculate gain and offset for BTEMP if all reads succeeded */
666 if (!(ret[2] < 0 || ret[3] < 0 || ret[4] < 0)) {
667 btemp_high = (((gpadc_cal[2] & 0x01) << 9) |
668 (gpadc_cal[3] << 1) |
669 ((gpadc_cal[4] & 0x80) >> 7));
670
671 btemp_low = ((gpadc_cal[4] & 0x7C) >> 2);
672
673 gpadc->cal_data[ADC_INPUT_BTEMP].gain =
674 CALIB_SCALE * (1300 - 21) / (btemp_high - btemp_low);
675
676 gpadc->cal_data[ADC_INPUT_BTEMP].offset = CALIB_SCALE * 1300 -
677 (CALIB_SCALE * (1300 - 21) /
678 (btemp_high - btemp_low)) * btemp_high;
679 } else {
680 gpadc->cal_data[ADC_INPUT_BTEMP].gain = 0;
681 }
682
683 /* Calculate gain and offset for VBAT if all reads succeeded */
684 if (!(ret[4] < 0 || ret[5] < 0 || ret[6] < 0)) {
685 vbat_high = (((gpadc_cal[4] & 0x03) << 8) | gpadc_cal[5]);
686 vbat_low = ((gpadc_cal[6] & 0xFC) >> 2);
687
688 gpadc->cal_data[ADC_INPUT_VBAT].gain = CALIB_SCALE *
689 (4700 - 2380) / (vbat_high - vbat_low);
690
691 gpadc->cal_data[ADC_INPUT_VBAT].offset = CALIB_SCALE * 4700 -
692 (CALIB_SCALE * (4700 - 2380) /
693 (vbat_high - vbat_low)) * vbat_high;
694 } else {
695 gpadc->cal_data[ADC_INPUT_VBAT].gain = 0;
696 }
697
698 dev_dbg(gpadc->dev, "VMAIN gain %llu offset %llu\n",
699 gpadc->cal_data[ADC_INPUT_VMAIN].gain,
700 gpadc->cal_data[ADC_INPUT_VMAIN].offset);
701
702 dev_dbg(gpadc->dev, "BTEMP gain %llu offset %llu\n",
703 gpadc->cal_data[ADC_INPUT_BTEMP].gain,
704 gpadc->cal_data[ADC_INPUT_BTEMP].offset);
705
706 dev_dbg(gpadc->dev, "VBAT gain %llu offset %llu\n",
707 gpadc->cal_data[ADC_INPUT_VBAT].gain,
708 gpadc->cal_data[ADC_INPUT_VBAT].offset);
709}
710
Lee Jones5f8aaef2013-02-04 08:33:13 +0000711static int ab8500_gpadc_runtime_suspend(struct device *dev)
712{
713 struct ab8500_gpadc *gpadc = dev_get_drvdata(dev);
714
715 regulator_disable(gpadc->regu);
716 return 0;
717}
718
719static int ab8500_gpadc_runtime_resume(struct device *dev)
720{
721 struct ab8500_gpadc *gpadc = dev_get_drvdata(dev);
722
723 regulator_enable(gpadc->regu);
724 return 0;
725}
726
727static int ab8500_gpadc_runtime_idle(struct device *dev)
728{
Lee Jones5f8aaef2013-02-04 08:33:13 +0000729 pm_runtime_suspend(dev);
730 return 0;
731}
732
Daniel WILLERUD774c50a2012-04-12 08:15:05 +0200733static int ab8500_gpadc_suspend(struct device *dev)
734{
735 struct ab8500_gpadc *gpadc = dev_get_drvdata(dev);
736
737 mutex_lock(&gpadc->ab8500_gpadc_lock);
738
739 pm_runtime_get_sync(dev);
740
741 regulator_disable(gpadc->regu);
742 return 0;
743}
744
745static int ab8500_gpadc_resume(struct device *dev)
746{
747 struct ab8500_gpadc *gpadc = dev_get_drvdata(dev);
748
749 regulator_enable(gpadc->regu);
750
751 pm_runtime_mark_last_busy(gpadc->dev);
752 pm_runtime_put_autosuspend(gpadc->dev);
753
754 mutex_unlock(&gpadc->ab8500_gpadc_lock);
755 return 0;
756}
757
Bill Pembertonf791be42012-11-19 13:23:04 -0500758static int ab8500_gpadc_probe(struct platform_device *pdev)
Arun Murthydae2db32011-02-22 10:11:13 +0100759{
760 int ret = 0;
761 struct ab8500_gpadc *gpadc;
762
763 gpadc = kzalloc(sizeof(struct ab8500_gpadc), GFP_KERNEL);
764 if (!gpadc) {
765 dev_err(&pdev->dev, "Error: No memory\n");
766 return -ENOMEM;
767 }
768
Lee Jones73482342013-02-26 10:06:55 +0000769 gpadc->irq_sw = platform_get_irq_byname(pdev, "SW_CONV_END");
Lee Jonesc0eda9a2013-02-12 15:04:09 +0000770 if (gpadc->irq_sw < 0)
771 dev_err(gpadc->dev, "failed to get platform sw_conv_end irq\n");
Lee Jones73482342013-02-26 10:06:55 +0000772
773 gpadc->irq_hw = platform_get_irq_byname(pdev, "HW_CONV_END");
Lee Jonesc0eda9a2013-02-12 15:04:09 +0000774 if (gpadc->irq_hw < 0)
775 dev_err(gpadc->dev, "failed to get platform hw_conv_end irq\n");
Arun Murthydae2db32011-02-22 10:11:13 +0100776
777 gpadc->dev = &pdev->dev;
Michel JAOUEN20bf4282012-02-09 12:06:47 +0100778 gpadc->parent = dev_get_drvdata(pdev->dev.parent);
Daniel Willerud63219922011-03-05 11:46:13 +0100779 mutex_init(&gpadc->ab8500_gpadc_lock);
Arun Murthydae2db32011-02-22 10:11:13 +0100780
781 /* Initialize completion used to notify completion of conversion */
782 init_completion(&gpadc->ab8500_gpadc_complete);
783
Lee Jones73482342013-02-26 10:06:55 +0000784 /* Register interrupts */
Lee Jonesc0eda9a2013-02-12 15:04:09 +0000785 if (gpadc->irq_sw >= 0) {
786 ret = request_threaded_irq(gpadc->irq_sw, NULL,
787 ab8500_bm_gpadcconvend_handler,
788 IRQF_NO_SUSPEND | IRQF_SHARED, "ab8500-gpadc-sw",
789 gpadc);
790 if (ret < 0) {
791 dev_err(gpadc->dev,
792 "Failed to register interrupt irq: %d\n",
793 gpadc->irq_sw);
794 goto fail;
795 }
Lee Jones73482342013-02-26 10:06:55 +0000796 }
Lee Jonesc0eda9a2013-02-12 15:04:09 +0000797
798 if (gpadc->irq_hw >= 0) {
799 ret = request_threaded_irq(gpadc->irq_hw, NULL,
800 ab8500_bm_gpadcconvend_handler,
801 IRQF_NO_SUSPEND | IRQF_SHARED, "ab8500-gpadc-hw",
802 gpadc);
803 if (ret < 0) {
804 dev_err(gpadc->dev,
805 "Failed to register interrupt irq: %d\n",
806 gpadc->irq_hw);
807 goto fail_irq;
808 }
Arun Murthydae2db32011-02-22 10:11:13 +0100809 }
810
811 /* VTVout LDO used to power up ab8500-GPADC */
812 gpadc->regu = regulator_get(&pdev->dev, "vddadc");
813 if (IS_ERR(gpadc->regu)) {
814 ret = PTR_ERR(gpadc->regu);
815 dev_err(gpadc->dev, "failed to get vtvout LDO\n");
Daniel Willerud633e0fa2011-03-05 11:46:27 +0100816 goto fail_irq;
Arun Murthydae2db32011-02-22 10:11:13 +0100817 }
Lee Jones5f8aaef2013-02-04 08:33:13 +0000818
819 platform_set_drvdata(pdev, gpadc);
820
821 regulator_enable(gpadc->regu);
822
823 pm_runtime_set_autosuspend_delay(gpadc->dev, GPADC_AUDOSUSPEND_DELAY);
824 pm_runtime_use_autosuspend(gpadc->dev);
825 pm_runtime_set_active(gpadc->dev);
826 pm_runtime_enable(gpadc->dev);
827
Johan Palsson586f3312011-03-05 11:46:37 +0100828 ab8500_gpadc_read_calibration_data(gpadc);
Daniel Willerud63219922011-03-05 11:46:13 +0100829 list_add_tail(&gpadc->node, &ab8500_gpadc_list);
Arun Murthydae2db32011-02-22 10:11:13 +0100830 dev_dbg(gpadc->dev, "probe success\n");
Lee Jonesc0eda9a2013-02-12 15:04:09 +0000831
Arun Murthydae2db32011-02-22 10:11:13 +0100832 return 0;
Lee Jonesc0eda9a2013-02-12 15:04:09 +0000833
Daniel Willerud633e0fa2011-03-05 11:46:27 +0100834fail_irq:
Lee Jones73482342013-02-26 10:06:55 +0000835 free_irq(gpadc->irq_sw, gpadc);
836 free_irq(gpadc->irq_hw, gpadc);
Arun Murthydae2db32011-02-22 10:11:13 +0100837fail:
838 kfree(gpadc);
839 gpadc = NULL;
840 return ret;
841}
842
Bill Pemberton4740f732012-11-19 13:26:01 -0500843static int ab8500_gpadc_remove(struct platform_device *pdev)
Arun Murthydae2db32011-02-22 10:11:13 +0100844{
845 struct ab8500_gpadc *gpadc = platform_get_drvdata(pdev);
846
Daniel Willerud63219922011-03-05 11:46:13 +0100847 /* remove this gpadc entry from the list */
848 list_del(&gpadc->node);
Arun Murthydae2db32011-02-22 10:11:13 +0100849 /* remove interrupt - completion of Sw ADC conversion */
Lee Jonesc0eda9a2013-02-12 15:04:09 +0000850 if (gpadc->irq_sw >= 0)
851 free_irq(gpadc->irq_sw, gpadc);
852 if (gpadc->irq_hw >= 0)
853 free_irq(gpadc->irq_hw, gpadc);
Lee Jones5f8aaef2013-02-04 08:33:13 +0000854
855 pm_runtime_get_sync(gpadc->dev);
856 pm_runtime_disable(gpadc->dev);
857
858 regulator_disable(gpadc->regu);
859
860 pm_runtime_set_suspended(gpadc->dev);
861
862 pm_runtime_put_noidle(gpadc->dev);
863
Arun Murthydae2db32011-02-22 10:11:13 +0100864 kfree(gpadc);
865 gpadc = NULL;
866 return 0;
867}
868
Lee Jones5f8aaef2013-02-04 08:33:13 +0000869static const struct dev_pm_ops ab8500_gpadc_pm_ops = {
870 SET_RUNTIME_PM_OPS(ab8500_gpadc_runtime_suspend,
871 ab8500_gpadc_runtime_resume,
872 ab8500_gpadc_runtime_idle)
Daniel WILLERUD774c50a2012-04-12 08:15:05 +0200873 SET_SYSTEM_SLEEP_PM_OPS(ab8500_gpadc_suspend,
874 ab8500_gpadc_resume)
875
Lee Jones5f8aaef2013-02-04 08:33:13 +0000876};
877
Arun Murthydae2db32011-02-22 10:11:13 +0100878static struct platform_driver ab8500_gpadc_driver = {
879 .probe = ab8500_gpadc_probe,
Bill Pemberton84449212012-11-19 13:20:24 -0500880 .remove = ab8500_gpadc_remove,
Arun Murthydae2db32011-02-22 10:11:13 +0100881 .driver = {
882 .name = "ab8500-gpadc",
883 .owner = THIS_MODULE,
Lee Jones5f8aaef2013-02-04 08:33:13 +0000884 .pm = &ab8500_gpadc_pm_ops,
Arun Murthydae2db32011-02-22 10:11:13 +0100885 },
886};
887
888static int __init ab8500_gpadc_init(void)
889{
890 return platform_driver_register(&ab8500_gpadc_driver);
891}
892
893static void __exit ab8500_gpadc_exit(void)
894{
895 platform_driver_unregister(&ab8500_gpadc_driver);
896}
897
898subsys_initcall_sync(ab8500_gpadc_init);
899module_exit(ab8500_gpadc_exit);
900
901MODULE_LICENSE("GPL v2");
Lee Jones73482342013-02-26 10:06:55 +0000902MODULE_AUTHOR("Arun R Murthy, Daniel Willerud, Johan Palsson,"
903 "M'boumba Cedric Madianga");
Arun Murthydae2db32011-02-22 10:11:13 +0100904MODULE_ALIAS("platform:ab8500_gpadc");
905MODULE_DESCRIPTION("AB8500 GPADC driver");