Commit bc3ae982 authored by Wenyou Yang's avatar Wenyou Yang Committed by Jonathan Cameron

iio: adc: at91: add suspend and resume callback

Add suspend/resume callback, support the pinctrl sleep state when
the system suspend as well.
Signed-off-by: default avatarWenyou Yang <wenyou.yang@atmel.com>
Acked-by: default avatarLudovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent ab541631
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/iio/trigger.h> #include <linux/iio/trigger.h>
#include <linux/iio/trigger_consumer.h> #include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h> #include <linux/iio/triggered_buffer.h>
#include <linux/pinctrl/consumer.h>
/* Registers */ /* Registers */
#define AT91_ADC_CR 0x00 /* Control Register */ #define AT91_ADC_CR 0x00 /* Control Register */
...@@ -1347,6 +1348,32 @@ static int at91_adc_remove(struct platform_device *pdev) ...@@ -1347,6 +1348,32 @@ static int at91_adc_remove(struct platform_device *pdev)
return 0; 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 = { static struct at91_adc_caps at91sam9260_caps = {
.calc_startup_ticks = calc_startup_ticks_9260, .calc_startup_ticks = calc_startup_ticks_9260,
.num_channels = 4, .num_channels = 4,
...@@ -1441,6 +1468,7 @@ static struct platform_driver at91_adc_driver = { ...@@ -1441,6 +1468,7 @@ static struct platform_driver at91_adc_driver = {
.driver = { .driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.of_match_table = of_match_ptr(at91_adc_dt_ids), .of_match_table = of_match_ptr(at91_adc_dt_ids),
.pm = &at91_adc_pm_ops,
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment