2 * exynos_adc.c - Support for ADC in EXYNOS SoCs
4 * 8 ~ 10 channel, 10/12-bit ADC
6 * Copyright (C) 2013 Naveen Krishna Chatradhi <ch.naveen@samsung.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <linux/module.h>
24 #include <linux/platform_device.h>
25 #include <linux/interrupt.h>
26 #include <linux/delay.h>
27 #include <linux/errno.h>
28 #include <linux/kernel.h>
29 #include <linux/slab.h>
31 #include <linux/clk.h>
32 #include <linux/completion.h>
34 #include <linux/of_irq.h>
35 #include <linux/regulator/consumer.h>
36 #include <linux/of_platform.h>
37 #include <linux/err.h>
39 #include <linux/iio/iio.h>
40 #include <linux/iio/machine.h>
41 #include <linux/iio/driver.h>
42 #include <linux/mfd/syscon.h>
43 #include <linux/regmap.h>
45 /* S3C/EXYNOS4412/5250 ADC_V1 registers definitions */
46 #define ADC_V1_CON(x) ((x) + 0x00)
47 #define ADC_V1_DLY(x) ((x) + 0x08)
48 #define ADC_V1_DATX(x) ((x) + 0x0C)
49 #define ADC_V1_INTCLR(x) ((x) + 0x18)
50 #define ADC_V1_MUX(x) ((x) + 0x1c)
52 /* S3C2410 ADC registers definitions */
53 #define ADC_S3C2410_MUX(x) ((x) + 0x18)
55 /* Future ADC_V2 registers definitions */
56 #define ADC_V2_CON1(x) ((x) + 0x00)
57 #define ADC_V2_CON2(x) ((x) + 0x04)
58 #define ADC_V2_STAT(x) ((x) + 0x08)
59 #define ADC_V2_INT_EN(x) ((x) + 0x10)
60 #define ADC_V2_INT_ST(x) ((x) + 0x14)
61 #define ADC_V2_VER(x) ((x) + 0x20)
63 /* Bit definitions for ADC_V1 */
64 #define ADC_V1_CON_RES (1u << 16)
65 #define ADC_V1_CON_PRSCEN (1u << 14)
66 #define ADC_V1_CON_PRSCLV(x) (((x) & 0xFF) << 6)
67 #define ADC_V1_CON_STANDBY (1u << 2)
69 /* Bit definitions for S3C2410 ADC */
70 #define ADC_S3C2410_CON_SELMUX(x) (((x) & 7) << 3)
71 #define ADC_S3C2410_DATX_MASK 0x3FF
72 #define ADC_S3C2416_CON_RES_SEL (1u << 3)
74 /* Bit definitions for ADC_V2 */
75 #define ADC_V2_CON1_SOFT_RESET (1u << 2)
77 #define ADC_V2_CON2_OSEL (1u << 10)
78 #define ADC_V2_CON2_ESEL (1u << 9)
79 #define ADC_V2_CON2_HIGHF (1u << 8)
80 #define ADC_V2_CON2_C_TIME(x) (((x) & 7) << 4)
81 #define ADC_V2_CON2_ACH_SEL(x) (((x) & 0xF) << 0)
82 #define ADC_V2_CON2_ACH_MASK 0xF
84 #define MAX_ADC_V2_CHANNELS 10
85 #define MAX_ADC_V1_CHANNELS 8
86 #define MAX_EXYNOS3250_ADC_CHANNELS 2
88 /* Bit definitions common for ADC_V1 and ADC_V2 */
89 #define ADC_CON_EN_START (1u << 0)
90 #define ADC_CON_EN_START_MASK (0x3 << 0)
91 #define ADC_DATX_MASK 0xFFF
93 #define EXYNOS_ADC_TIMEOUT (msecs_to_jiffies(100))
95 #define EXYNOS_ADCV1_PHY_OFFSET 0x0718
96 #define EXYNOS_ADCV2_PHY_OFFSET 0x0720
99 struct exynos_adc_data
*data
;
102 struct regmap
*pmu_map
;
106 struct regulator
*vdd
;
108 struct completion completion
;
111 unsigned int version
;
114 struct exynos_adc_data
{
121 void (*init_hw
)(struct exynos_adc
*info
);
122 void (*exit_hw
)(struct exynos_adc
*info
);
123 void (*clear_irq
)(struct exynos_adc
*info
);
124 void (*start_conv
)(struct exynos_adc
*info
, unsigned long addr
);
127 static void exynos_adc_unprepare_clk(struct exynos_adc
*info
)
129 if (info
->data
->needs_sclk
)
130 clk_unprepare(info
->sclk
);
131 clk_unprepare(info
->clk
);
134 static int exynos_adc_prepare_clk(struct exynos_adc
*info
)
138 ret
= clk_prepare(info
->clk
);
140 dev_err(info
->dev
, "failed preparing adc clock: %d\n", ret
);
144 if (info
->data
->needs_sclk
) {
145 ret
= clk_prepare(info
->sclk
);
147 clk_unprepare(info
->clk
);
149 "failed preparing sclk_adc clock: %d\n", ret
);
157 static void exynos_adc_disable_clk(struct exynos_adc
*info
)
159 if (info
->data
->needs_sclk
)
160 clk_disable(info
->sclk
);
161 clk_disable(info
->clk
);
164 static int exynos_adc_enable_clk(struct exynos_adc
*info
)
168 ret
= clk_enable(info
->clk
);
170 dev_err(info
->dev
, "failed enabling adc clock: %d\n", ret
);
174 if (info
->data
->needs_sclk
) {
175 ret
= clk_enable(info
->sclk
);
177 clk_disable(info
->clk
);
179 "failed enabling sclk_adc clock: %d\n", ret
);
187 static void exynos_adc_v1_init_hw(struct exynos_adc
*info
)
191 if (info
->data
->needs_adc_phy
)
192 regmap_write(info
->pmu_map
, info
->data
->phy_offset
, 1);
194 /* set default prescaler values and Enable prescaler */
195 con1
= ADC_V1_CON_PRSCLV(49) | ADC_V1_CON_PRSCEN
;
197 /* Enable 12-bit ADC resolution */
198 con1
|= ADC_V1_CON_RES
;
199 writel(con1
, ADC_V1_CON(info
->regs
));
202 static void exynos_adc_v1_exit_hw(struct exynos_adc
*info
)
206 if (info
->data
->needs_adc_phy
)
207 regmap_write(info
->pmu_map
, info
->data
->phy_offset
, 0);
209 con
= readl(ADC_V1_CON(info
->regs
));
210 con
|= ADC_V1_CON_STANDBY
;
211 writel(con
, ADC_V1_CON(info
->regs
));
214 static void exynos_adc_v1_clear_irq(struct exynos_adc
*info
)
216 writel(1, ADC_V1_INTCLR(info
->regs
));
219 static void exynos_adc_v1_start_conv(struct exynos_adc
*info
,
224 writel(addr
, ADC_V1_MUX(info
->regs
));
226 con1
= readl(ADC_V1_CON(info
->regs
));
227 writel(con1
| ADC_CON_EN_START
, ADC_V1_CON(info
->regs
));
230 static const struct exynos_adc_data exynos_adc_v1_data
= {
231 .num_channels
= MAX_ADC_V1_CHANNELS
,
232 .mask
= ADC_DATX_MASK
, /* 12 bit ADC resolution */
233 .needs_adc_phy
= true,
234 .phy_offset
= EXYNOS_ADCV1_PHY_OFFSET
,
236 .init_hw
= exynos_adc_v1_init_hw
,
237 .exit_hw
= exynos_adc_v1_exit_hw
,
238 .clear_irq
= exynos_adc_v1_clear_irq
,
239 .start_conv
= exynos_adc_v1_start_conv
,
242 static void exynos_adc_s3c2416_start_conv(struct exynos_adc
*info
,
247 /* Enable 12 bit ADC resolution */
248 con1
= readl(ADC_V1_CON(info
->regs
));
249 con1
|= ADC_S3C2416_CON_RES_SEL
;
250 writel(con1
, ADC_V1_CON(info
->regs
));
252 /* Select channel for S3C2416 */
253 writel(addr
, ADC_S3C2410_MUX(info
->regs
));
255 con1
= readl(ADC_V1_CON(info
->regs
));
256 writel(con1
| ADC_CON_EN_START
, ADC_V1_CON(info
->regs
));
259 static struct exynos_adc_data
const exynos_adc_s3c2416_data
= {
260 .num_channels
= MAX_ADC_V1_CHANNELS
,
261 .mask
= ADC_DATX_MASK
, /* 12 bit ADC resolution */
263 .init_hw
= exynos_adc_v1_init_hw
,
264 .exit_hw
= exynos_adc_v1_exit_hw
,
265 .start_conv
= exynos_adc_s3c2416_start_conv
,
268 static void exynos_adc_s3c2443_start_conv(struct exynos_adc
*info
,
273 /* Select channel for S3C2433 */
274 writel(addr
, ADC_S3C2410_MUX(info
->regs
));
276 con1
= readl(ADC_V1_CON(info
->regs
));
277 writel(con1
| ADC_CON_EN_START
, ADC_V1_CON(info
->regs
));
280 static struct exynos_adc_data
const exynos_adc_s3c2443_data
= {
281 .num_channels
= MAX_ADC_V1_CHANNELS
,
282 .mask
= ADC_S3C2410_DATX_MASK
, /* 10 bit ADC resolution */
284 .init_hw
= exynos_adc_v1_init_hw
,
285 .exit_hw
= exynos_adc_v1_exit_hw
,
286 .start_conv
= exynos_adc_s3c2443_start_conv
,
289 static void exynos_adc_s3c64xx_start_conv(struct exynos_adc
*info
,
294 con1
= readl(ADC_V1_CON(info
->regs
));
295 con1
&= ~ADC_S3C2410_CON_SELMUX(0x7);
296 con1
|= ADC_S3C2410_CON_SELMUX(addr
);
297 writel(con1
| ADC_CON_EN_START
, ADC_V1_CON(info
->regs
));
300 static struct exynos_adc_data
const exynos_adc_s3c24xx_data
= {
301 .num_channels
= MAX_ADC_V1_CHANNELS
,
302 .mask
= ADC_S3C2410_DATX_MASK
, /* 10 bit ADC resolution */
304 .init_hw
= exynos_adc_v1_init_hw
,
305 .exit_hw
= exynos_adc_v1_exit_hw
,
306 .start_conv
= exynos_adc_s3c64xx_start_conv
,
309 static struct exynos_adc_data
const exynos_adc_s3c64xx_data
= {
310 .num_channels
= MAX_ADC_V1_CHANNELS
,
311 .mask
= ADC_DATX_MASK
, /* 12 bit ADC resolution */
313 .init_hw
= exynos_adc_v1_init_hw
,
314 .exit_hw
= exynos_adc_v1_exit_hw
,
315 .clear_irq
= exynos_adc_v1_clear_irq
,
316 .start_conv
= exynos_adc_s3c64xx_start_conv
,
319 static void exynos_adc_v2_init_hw(struct exynos_adc
*info
)
323 if (info
->data
->needs_adc_phy
)
324 regmap_write(info
->pmu_map
, info
->data
->phy_offset
, 1);
326 con1
= ADC_V2_CON1_SOFT_RESET
;
327 writel(con1
, ADC_V2_CON1(info
->regs
));
329 con2
= ADC_V2_CON2_OSEL
| ADC_V2_CON2_ESEL
|
330 ADC_V2_CON2_HIGHF
| ADC_V2_CON2_C_TIME(0);
331 writel(con2
, ADC_V2_CON2(info
->regs
));
333 /* Enable interrupts */
334 writel(1, ADC_V2_INT_EN(info
->regs
));
337 static void exynos_adc_v2_exit_hw(struct exynos_adc
*info
)
341 if (info
->data
->needs_adc_phy
)
342 regmap_write(info
->pmu_map
, info
->data
->phy_offset
, 0);
344 con
= readl(ADC_V2_CON1(info
->regs
));
345 con
&= ~ADC_CON_EN_START
;
346 writel(con
, ADC_V2_CON1(info
->regs
));
349 static void exynos_adc_v2_clear_irq(struct exynos_adc
*info
)
351 writel(1, ADC_V2_INT_ST(info
->regs
));
354 static void exynos_adc_v2_start_conv(struct exynos_adc
*info
,
359 con2
= readl(ADC_V2_CON2(info
->regs
));
360 con2
&= ~ADC_V2_CON2_ACH_MASK
;
361 con2
|= ADC_V2_CON2_ACH_SEL(addr
);
362 writel(con2
, ADC_V2_CON2(info
->regs
));
364 con1
= readl(ADC_V2_CON1(info
->regs
));
365 writel(con1
| ADC_CON_EN_START
, ADC_V2_CON1(info
->regs
));
368 static const struct exynos_adc_data exynos_adc_v2_data
= {
369 .num_channels
= MAX_ADC_V2_CHANNELS
,
370 .mask
= ADC_DATX_MASK
, /* 12 bit ADC resolution */
371 .needs_adc_phy
= true,
372 .phy_offset
= EXYNOS_ADCV2_PHY_OFFSET
,
374 .init_hw
= exynos_adc_v2_init_hw
,
375 .exit_hw
= exynos_adc_v2_exit_hw
,
376 .clear_irq
= exynos_adc_v2_clear_irq
,
377 .start_conv
= exynos_adc_v2_start_conv
,
380 static const struct exynos_adc_data exynos3250_adc_data
= {
381 .num_channels
= MAX_EXYNOS3250_ADC_CHANNELS
,
382 .mask
= ADC_DATX_MASK
, /* 12 bit ADC resolution */
384 .needs_adc_phy
= true,
385 .phy_offset
= EXYNOS_ADCV1_PHY_OFFSET
,
387 .init_hw
= exynos_adc_v2_init_hw
,
388 .exit_hw
= exynos_adc_v2_exit_hw
,
389 .clear_irq
= exynos_adc_v2_clear_irq
,
390 .start_conv
= exynos_adc_v2_start_conv
,
393 static void exynos_adc_exynos7_init_hw(struct exynos_adc
*info
)
397 if (info
->data
->needs_adc_phy
)
398 regmap_write(info
->pmu_map
, info
->data
->phy_offset
, 1);
400 con1
= ADC_V2_CON1_SOFT_RESET
;
401 writel(con1
, ADC_V2_CON1(info
->regs
));
403 con2
= readl(ADC_V2_CON2(info
->regs
));
404 con2
&= ~ADC_V2_CON2_C_TIME(7);
405 con2
|= ADC_V2_CON2_C_TIME(0);
406 writel(con2
, ADC_V2_CON2(info
->regs
));
408 /* Enable interrupts */
409 writel(1, ADC_V2_INT_EN(info
->regs
));
412 static const struct exynos_adc_data exynos7_adc_data
= {
413 .num_channels
= MAX_ADC_V1_CHANNELS
,
414 .mask
= ADC_DATX_MASK
, /* 12 bit ADC resolution */
416 .init_hw
= exynos_adc_exynos7_init_hw
,
417 .exit_hw
= exynos_adc_v2_exit_hw
,
418 .clear_irq
= exynos_adc_v2_clear_irq
,
419 .start_conv
= exynos_adc_v2_start_conv
,
422 static const struct of_device_id exynos_adc_match
[] = {
424 .compatible
= "samsung,s3c2410-adc",
425 .data
= &exynos_adc_s3c24xx_data
,
427 .compatible
= "samsung,s3c2416-adc",
428 .data
= &exynos_adc_s3c2416_data
,
430 .compatible
= "samsung,s3c2440-adc",
431 .data
= &exynos_adc_s3c24xx_data
,
433 .compatible
= "samsung,s3c2443-adc",
434 .data
= &exynos_adc_s3c2443_data
,
436 .compatible
= "samsung,s3c6410-adc",
437 .data
= &exynos_adc_s3c64xx_data
,
439 .compatible
= "samsung,exynos-adc-v1",
440 .data
= &exynos_adc_v1_data
,
442 .compatible
= "samsung,exynos-adc-v2",
443 .data
= &exynos_adc_v2_data
,
445 .compatible
= "samsung,exynos3250-adc",
446 .data
= &exynos3250_adc_data
,
448 .compatible
= "samsung,exynos7-adc",
449 .data
= &exynos7_adc_data
,
453 MODULE_DEVICE_TABLE(of
, exynos_adc_match
);
455 static struct exynos_adc_data
*exynos_adc_get_data(struct platform_device
*pdev
)
457 const struct of_device_id
*match
;
459 match
= of_match_node(exynos_adc_match
, pdev
->dev
.of_node
);
460 return (struct exynos_adc_data
*)match
->data
;
463 static int exynos_read_raw(struct iio_dev
*indio_dev
,
464 struct iio_chan_spec
const *chan
,
469 struct exynos_adc
*info
= iio_priv(indio_dev
);
470 unsigned long timeout
;
473 if (mask
!= IIO_CHAN_INFO_RAW
)
476 mutex_lock(&indio_dev
->mlock
);
477 reinit_completion(&info
->completion
);
479 /* Select the channel to be used and Trigger conversion */
480 if (info
->data
->start_conv
)
481 info
->data
->start_conv(info
, chan
->address
);
483 timeout
= wait_for_completion_timeout
484 (&info
->completion
, EXYNOS_ADC_TIMEOUT
);
486 dev_warn(&indio_dev
->dev
, "Conversion timed out! Resetting\n");
487 if (info
->data
->init_hw
)
488 info
->data
->init_hw(info
);
496 mutex_unlock(&indio_dev
->mlock
);
501 static irqreturn_t
exynos_adc_isr(int irq
, void *dev_id
)
503 struct exynos_adc
*info
= (struct exynos_adc
*)dev_id
;
504 u32 mask
= info
->data
->mask
;
507 info
->value
= readl(ADC_V1_DATX(info
->regs
)) & mask
;
510 if (info
->data
->clear_irq
)
511 info
->data
->clear_irq(info
);
513 complete(&info
->completion
);
518 static int exynos_adc_reg_access(struct iio_dev
*indio_dev
,
519 unsigned reg
, unsigned writeval
,
522 struct exynos_adc
*info
= iio_priv(indio_dev
);
527 *readval
= readl(info
->regs
+ reg
);
532 static const struct iio_info exynos_adc_iio_info
= {
533 .read_raw
= &exynos_read_raw
,
534 .debugfs_reg_access
= &exynos_adc_reg_access
,
535 .driver_module
= THIS_MODULE
,
538 #define ADC_CHANNEL(_index, _id) { \
539 .type = IIO_VOLTAGE, \
543 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
544 .datasheet_name = _id, \
547 static const struct iio_chan_spec exynos_adc_iio_channels
[] = {
548 ADC_CHANNEL(0, "adc0"),
549 ADC_CHANNEL(1, "adc1"),
550 ADC_CHANNEL(2, "adc2"),
551 ADC_CHANNEL(3, "adc3"),
552 ADC_CHANNEL(4, "adc4"),
553 ADC_CHANNEL(5, "adc5"),
554 ADC_CHANNEL(6, "adc6"),
555 ADC_CHANNEL(7, "adc7"),
556 ADC_CHANNEL(8, "adc8"),
557 ADC_CHANNEL(9, "adc9"),
560 static int exynos_adc_remove_devices(struct device
*dev
, void *c
)
562 struct platform_device
*pdev
= to_platform_device(dev
);
564 platform_device_unregister(pdev
);
569 static int exynos_adc_probe(struct platform_device
*pdev
)
571 struct exynos_adc
*info
= NULL
;
572 struct device_node
*np
= pdev
->dev
.of_node
;
573 struct iio_dev
*indio_dev
= NULL
;
574 struct resource
*mem
;
581 indio_dev
= devm_iio_device_alloc(&pdev
->dev
, sizeof(struct exynos_adc
));
583 dev_err(&pdev
->dev
, "failed allocating iio device\n");
587 info
= iio_priv(indio_dev
);
589 info
->data
= exynos_adc_get_data(pdev
);
591 dev_err(&pdev
->dev
, "failed getting exynos_adc_data\n");
595 mem
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
596 info
->regs
= devm_ioremap_resource(&pdev
->dev
, mem
);
597 if (IS_ERR(info
->regs
))
598 return PTR_ERR(info
->regs
);
601 if (info
->data
->needs_adc_phy
) {
602 info
->pmu_map
= syscon_regmap_lookup_by_phandle(
604 "samsung,syscon-phandle");
605 if (IS_ERR(info
->pmu_map
)) {
606 dev_err(&pdev
->dev
, "syscon regmap lookup failed.\n");
607 return PTR_ERR(info
->pmu_map
);
611 irq
= platform_get_irq(pdev
, 0);
613 dev_err(&pdev
->dev
, "no irq resource?\n");
618 info
->dev
= &pdev
->dev
;
620 init_completion(&info
->completion
);
622 info
->clk
= devm_clk_get(&pdev
->dev
, "adc");
623 if (IS_ERR(info
->clk
)) {
624 dev_err(&pdev
->dev
, "failed getting clock, err = %ld\n",
626 return PTR_ERR(info
->clk
);
629 if (info
->data
->needs_sclk
) {
630 info
->sclk
= devm_clk_get(&pdev
->dev
, "sclk");
631 if (IS_ERR(info
->sclk
)) {
633 "failed getting sclk clock, err = %ld\n",
634 PTR_ERR(info
->sclk
));
635 return PTR_ERR(info
->sclk
);
639 info
->vdd
= devm_regulator_get(&pdev
->dev
, "vdd");
640 if (IS_ERR(info
->vdd
)) {
641 dev_err(&pdev
->dev
, "failed getting regulator, err = %ld\n",
643 return PTR_ERR(info
->vdd
);
646 ret
= regulator_enable(info
->vdd
);
650 ret
= exynos_adc_prepare_clk(info
);
652 goto err_disable_reg
;
654 ret
= exynos_adc_enable_clk(info
);
656 goto err_unprepare_clk
;
658 platform_set_drvdata(pdev
, indio_dev
);
660 indio_dev
->name
= dev_name(&pdev
->dev
);
661 indio_dev
->dev
.parent
= &pdev
->dev
;
662 indio_dev
->dev
.of_node
= pdev
->dev
.of_node
;
663 indio_dev
->info
= &exynos_adc_iio_info
;
664 indio_dev
->modes
= INDIO_DIRECT_MODE
;
665 indio_dev
->channels
= exynos_adc_iio_channels
;
666 indio_dev
->num_channels
= info
->data
->num_channels
;
668 ret
= request_irq(info
->irq
, exynos_adc_isr
,
669 0, dev_name(&pdev
->dev
), info
);
671 dev_err(&pdev
->dev
, "failed requesting irq, irq = %d\n",
673 goto err_disable_clk
;
676 ret
= iio_device_register(indio_dev
);
680 if (info
->data
->init_hw
)
681 info
->data
->init_hw(info
);
683 ret
= of_platform_populate(np
, exynos_adc_match
, NULL
, &indio_dev
->dev
);
685 dev_err(&pdev
->dev
, "failed adding child nodes\n");
686 goto err_of_populate
;
692 device_for_each_child(&indio_dev
->dev
, NULL
,
693 exynos_adc_remove_devices
);
694 iio_device_unregister(indio_dev
);
696 free_irq(info
->irq
, info
);
698 if (info
->data
->exit_hw
)
699 info
->data
->exit_hw(info
);
700 exynos_adc_disable_clk(info
);
702 exynos_adc_unprepare_clk(info
);
704 regulator_disable(info
->vdd
);
708 static int exynos_adc_remove(struct platform_device
*pdev
)
710 struct iio_dev
*indio_dev
= platform_get_drvdata(pdev
);
711 struct exynos_adc
*info
= iio_priv(indio_dev
);
713 device_for_each_child(&indio_dev
->dev
, NULL
,
714 exynos_adc_remove_devices
);
715 iio_device_unregister(indio_dev
);
716 free_irq(info
->irq
, info
);
717 if (info
->data
->exit_hw
)
718 info
->data
->exit_hw(info
);
719 exynos_adc_disable_clk(info
);
720 exynos_adc_unprepare_clk(info
);
721 regulator_disable(info
->vdd
);
726 #ifdef CONFIG_PM_SLEEP
727 static int exynos_adc_suspend(struct device
*dev
)
729 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
730 struct exynos_adc
*info
= iio_priv(indio_dev
);
732 if (info
->data
->exit_hw
)
733 info
->data
->exit_hw(info
);
734 exynos_adc_disable_clk(info
);
735 regulator_disable(info
->vdd
);
740 static int exynos_adc_resume(struct device
*dev
)
742 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
743 struct exynos_adc
*info
= iio_priv(indio_dev
);
746 ret
= regulator_enable(info
->vdd
);
750 ret
= exynos_adc_enable_clk(info
);
754 if (info
->data
->init_hw
)
755 info
->data
->init_hw(info
);
761 static SIMPLE_DEV_PM_OPS(exynos_adc_pm_ops
,
765 static struct platform_driver exynos_adc_driver
= {
766 .probe
= exynos_adc_probe
,
767 .remove
= exynos_adc_remove
,
769 .name
= "exynos-adc",
770 .of_match_table
= exynos_adc_match
,
771 .pm
= &exynos_adc_pm_ops
,
775 module_platform_driver(exynos_adc_driver
);
777 MODULE_AUTHOR("Naveen Krishna Chatradhi <ch.naveen@samsung.com>");
778 MODULE_DESCRIPTION("Samsung EXYNOS5 ADC driver");
779 MODULE_LICENSE("GPL v2");