diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2013-03-29 10:54:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-04-02 14:17:39 -0400 |
commit | e748783c55f074046134d2ef15a6e04dd467ecfc (patch) | |
tree | 1a3859351b825071f82131d86f2981b613f2f069 /drivers/iio/adc | |
parent | 47be16b6683b86653545bf98f6f57019bb99969c (diff) |
iio: at91_adc: add sleep mode support
The sleep mode will allow to put the adc in sleep between conversion.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/adc')
-rw-r--r-- | drivers/iio/adc/at91_adc.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 3fb3fe48a98c..7295bc5280bd 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c | |||
@@ -52,6 +52,7 @@ struct at91_adc_state { | |||
52 | void __iomem *reg_base; | 52 | void __iomem *reg_base; |
53 | struct at91_adc_reg_desc *registers; | 53 | struct at91_adc_reg_desc *registers; |
54 | u8 startup_time; | 54 | u8 startup_time; |
55 | bool sleep_mode; | ||
55 | struct iio_trigger **trig; | 56 | struct iio_trigger **trig; |
56 | struct at91_adc_trigger *trigger_list; | 57 | struct at91_adc_trigger *trigger_list; |
57 | u32 trigger_number; | 58 | u32 trigger_number; |
@@ -455,6 +456,8 @@ static int at91_adc_probe_dt(struct at91_adc_state *st, | |||
455 | } | 456 | } |
456 | st->num_channels = prop; | 457 | st->num_channels = prop; |
457 | 458 | ||
459 | st->sleep_mode = of_property_read_bool(node, "atmel,adc-sleep-mode"); | ||
460 | |||
458 | if (of_property_read_u32(node, "atmel,adc-startup-time", &prop)) { | 461 | if (of_property_read_u32(node, "atmel,adc-startup-time", &prop)) { |
459 | dev_err(&idev->dev, "Missing adc-startup-time property in the DT.\n"); | 462 | dev_err(&idev->dev, "Missing adc-startup-time property in the DT.\n"); |
460 | ret = -EINVAL; | 463 | ret = -EINVAL; |
@@ -580,6 +583,7 @@ static int at91_adc_probe(struct platform_device *pdev) | |||
580 | struct iio_dev *idev; | 583 | struct iio_dev *idev; |
581 | struct at91_adc_state *st; | 584 | struct at91_adc_state *st; |
582 | struct resource *res; | 585 | struct resource *res; |
586 | u32 reg; | ||
583 | 587 | ||
584 | idev = iio_device_alloc(sizeof(struct at91_adc_state)); | 588 | idev = iio_device_alloc(sizeof(struct at91_adc_state)); |
585 | if (idev == NULL) { | 589 | if (idev == NULL) { |
@@ -687,16 +691,13 @@ static int at91_adc_probe(struct platform_device *pdev) | |||
687 | */ | 691 | */ |
688 | ticks = round_up((st->startup_time * adc_clk / | 692 | ticks = round_up((st->startup_time * adc_clk / |
689 | 1000000) - 1, 8) / 8; | 693 | 1000000) - 1, 8) / 8; |
690 | 694 | reg = AT91_ADC_PRESCAL_(prsc) & AT91_ADC_PRESCAL; | |
695 | reg |= AT91_ADC_STARTUP_(ticks) & AT91_ADC_STARTUP; | ||
691 | if (st->low_res) | 696 | if (st->low_res) |
692 | at91_adc_writel(st, AT91_ADC_MR, | 697 | reg |= AT91_ADC_LOWRES; |
693 | AT91_ADC_LOWRES | | 698 | if (st->sleep_mode) |
694 | (AT91_ADC_PRESCAL_(prsc) & AT91_ADC_PRESCAL) | | 699 | reg |= AT91_ADC_SLEEP; |
695 | (AT91_ADC_STARTUP_(ticks) & AT91_ADC_STARTUP)); | 700 | at91_adc_writel(st, AT91_ADC_MR, reg); |
696 | else | ||
697 | at91_adc_writel(st, AT91_ADC_MR, | ||
698 | (AT91_ADC_PRESCAL_(prsc) & AT91_ADC_PRESCAL) | | ||
699 | (AT91_ADC_STARTUP_(ticks) & AT91_ADC_STARTUP)); | ||
700 | 701 | ||
701 | /* Setup the ADC channels available on the board */ | 702 | /* Setup the ADC channels available on the board */ |
702 | ret = at91_adc_channel_init(idev); | 703 | ret = at91_adc_channel_init(idev); |