Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1513777 > unrolled thread
| Started by | Wenyou Yang <wenyou.yang@atmel.com> |
|---|---|
| First post | 2016-11-02 10:30 +0100 |
| Last post | 2016-11-05 17:40 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v2] iio: adc: at91: add suspend and resume callback Wenyou Yang <wenyou.yang@atmel.com> - 2016-11-02 10:30 +0100
Re: [PATCH v2] iio: adc: at91: add suspend and resume callback Ludovic Desroches <ludovic.desroches@atmel.com> - 2016-11-03 15:20 +0100
Re: [PATCH v2] iio: adc: at91: add suspend and resume callback Jonathan Cameron <jic23@kernel.org> - 2016-11-05 17:40 +0100
| From | Wenyou Yang <wenyou.yang@atmel.com> |
|---|---|
| Date | 2016-11-02 10:30 +0100 |
| Subject | [PATCH v2] iio: adc: at91: add suspend and resume callback |
| Message-ID | <sz01Q-4pv-15@gated-at.bofh.it> |
Add suspend/resume callback, support the pinctrl sleep state when
the system suspend as well.
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
---
Changes in v2:
- Use CONFIG_PM_SLEEP.
- Use SIMPLE_DEV_PM_OPS macro.
drivers/iio/adc/at91_adc.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index bbdac07..34b928c 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -30,6 +30,7 @@
#include <linux/iio/trigger.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
+#include <linux/pinctrl/consumer.h>
/* Registers */
#define AT91_ADC_CR 0x00 /* Control Register */
@@ -1347,6 +1348,32 @@ static int at91_adc_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int at91_adc_suspend(struct device *dev)
+{
+ struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev));
+ struct at91_adc_state *st = iio_priv(idev);
+
+ pinctrl_pm_select_sleep_state(dev);
+ clk_disable_unprepare(st->clk);
+
+ return 0;
+}
+
+static int at91_adc_resume(struct device *dev)
+{
+ struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev));
+ struct at91_adc_state *st = iio_priv(idev);
+
+ clk_prepare_enable(st->clk);
+ pinctrl_pm_select_default_state(dev);
+
+ return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume);
+
static struct at91_adc_caps at91sam9260_caps = {
.calc_startup_ticks = calc_startup_ticks_9260,
.num_channels = 4,
@@ -1441,6 +1468,7 @@ static struct platform_driver at91_adc_driver = {
.driver = {
.name = DRIVER_NAME,
.of_match_table = of_match_ptr(at91_adc_dt_ids),
+ .pm = &at91_adc_pm_ops,
},
};
--
2.7.4
[toc] | [next] | [standalone]
| From | Ludovic Desroches <ludovic.desroches@atmel.com> |
|---|---|
| Date | 2016-11-03 15:20 +0100 |
| Message-ID | <szr22-4Zd-15@gated-at.bofh.it> |
| In reply to | #1513777 |
On Wed, Nov 02, 2016 at 05:21:48PM +0800, Wenyou Yang wrote:
> Add suspend/resume callback, support the pinctrl sleep state when
> the system suspend as well.
>
> Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Thanks
> ---
>
> Changes in v2:
> - Use CONFIG_PM_SLEEP.
> - Use SIMPLE_DEV_PM_OPS macro.
>
> drivers/iio/adc/at91_adc.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index bbdac07..34b928c 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -30,6 +30,7 @@
> #include <linux/iio/trigger.h>
> #include <linux/iio/trigger_consumer.h>
> #include <linux/iio/triggered_buffer.h>
> +#include <linux/pinctrl/consumer.h>
>
> /* Registers */
> #define AT91_ADC_CR 0x00 /* Control Register */
> @@ -1347,6 +1348,32 @@ static int at91_adc_remove(struct platform_device *pdev)
> return 0;
> }
>
> +#ifdef CONFIG_PM_SLEEP
> +static int at91_adc_suspend(struct device *dev)
> +{
> + struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev));
> + struct at91_adc_state *st = iio_priv(idev);
> +
> + pinctrl_pm_select_sleep_state(dev);
> + clk_disable_unprepare(st->clk);
> +
> + return 0;
> +}
> +
> +static int at91_adc_resume(struct device *dev)
> +{
> + struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev));
> + struct at91_adc_state *st = iio_priv(idev);
> +
> + clk_prepare_enable(st->clk);
> + pinctrl_pm_select_default_state(dev);
> +
> + return 0;
> +}
> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume);
> +
> static struct at91_adc_caps at91sam9260_caps = {
> .calc_startup_ticks = calc_startup_ticks_9260,
> .num_channels = 4,
> @@ -1441,6 +1468,7 @@ static struct platform_driver at91_adc_driver = {
> .driver = {
> .name = DRIVER_NAME,
> .of_match_table = of_match_ptr(at91_adc_dt_ids),
> + .pm = &at91_adc_pm_ops,
> },
> };
>
> --
> 2.7.4
>
[toc] | [prev] | [next] | [standalone]
| From | Jonathan Cameron <jic23@kernel.org> |
|---|---|
| Date | 2016-11-05 17:40 +0100 |
| Message-ID | <sAcaC-1N0-13@gated-at.bofh.it> |
| In reply to | #1514549 |
On 03/11/16 14:16, Ludovic Desroches wrote:
> On Wed, Nov 02, 2016 at 05:21:48PM +0800, Wenyou Yang wrote:
>> Add suspend/resume callback, support the pinctrl sleep state when
>> the system suspend as well.
>>
>> Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
> Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Applied to the togreg branch of iio.git. Initially pushed out
as testing for the autobuilders to play with it.
Thanks,
Jonathan
>
> Thanks
>
>> ---
>>
>> Changes in v2:
>> - Use CONFIG_PM_SLEEP.
>> - Use SIMPLE_DEV_PM_OPS macro.
>>
>> drivers/iio/adc/at91_adc.c | 28 ++++++++++++++++++++++++++++
>> 1 file changed, 28 insertions(+)
>>
>> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
>> index bbdac07..34b928c 100644
>> --- a/drivers/iio/adc/at91_adc.c
>> +++ b/drivers/iio/adc/at91_adc.c
>> @@ -30,6 +30,7 @@
>> #include <linux/iio/trigger.h>
>> #include <linux/iio/trigger_consumer.h>
>> #include <linux/iio/triggered_buffer.h>
>> +#include <linux/pinctrl/consumer.h>
>>
>> /* Registers */
>> #define AT91_ADC_CR 0x00 /* Control Register */
>> @@ -1347,6 +1348,32 @@ static int at91_adc_remove(struct platform_device *pdev)
>> return 0;
>> }
>>
>> +#ifdef CONFIG_PM_SLEEP
>> +static int at91_adc_suspend(struct device *dev)
>> +{
>> + struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev));
>> + struct at91_adc_state *st = iio_priv(idev);
>> +
>> + pinctrl_pm_select_sleep_state(dev);
>> + clk_disable_unprepare(st->clk);
>> +
>> + return 0;
>> +}
>> +
>> +static int at91_adc_resume(struct device *dev)
>> +{
>> + struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev));
>> + struct at91_adc_state *st = iio_priv(idev);
>> +
>> + clk_prepare_enable(st->clk);
>> + pinctrl_pm_select_default_state(dev);
>> +
>> + return 0;
>> +}
>> +#endif
>> +
>> +static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume);
>> +
>> static struct at91_adc_caps at91sam9260_caps = {
>> .calc_startup_ticks = calc_startup_ticks_9260,
>> .num_channels = 4,
>> @@ -1441,6 +1468,7 @@ static struct platform_driver at91_adc_driver = {
>> .driver = {
>> .name = DRIVER_NAME,
>> .of_match_table = of_match_ptr(at91_adc_dt_ids),
>> + .pm = &at91_adc_pm_ops,
>> },
>> };
>>
>> --
>> 2.7.4
>>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web