summaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorWenyou Yang <wenyou.yang@atmel.com>2016-11-02 05:21:48 -0400
committerJonathan Cameron <jic23@kernel.org>2016-11-05 12:33:00 -0400
commitbc3ae982e2fb498e2f5492497ea927a161380bc1 (patch)
tree02a79c19e991cbe4e3a1fe802e6eb68f4879e5c6 /drivers/iio
parentab54163190f236e30772e6e8b4efc56a319ed0a6 (diff)
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: Wenyou Yang <wenyou.yang@atmel.com> Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/adc/at91_adc.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index bbdac07f4aaa..34b928cefeed 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -30,6 +30,7 @@
30#include <linux/iio/trigger.h> 30#include <linux/iio/trigger.h>
31#include <linux/iio/trigger_consumer.h> 31#include <linux/iio/trigger_consumer.h>
32#include <linux/iio/triggered_buffer.h> 32#include <linux/iio/triggered_buffer.h>
33#include <linux/pinctrl/consumer.h>
33 34
34/* Registers */ 35/* Registers */
35#define AT91_ADC_CR 0x00 /* Control Register */ 36#define AT91_ADC_CR 0x00 /* Control Register */
@@ -1347,6 +1348,32 @@ static int at91_adc_remove(struct platform_device *pdev)
1347 return 0; 1348 return 0;
1348} 1349}
1349 1350
1351#ifdef CONFIG_PM_SLEEP
1352static int at91_adc_suspend(struct device *dev)
1353{
1354 struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev));
1355 struct at91_adc_state *st = iio_priv(idev);
1356
1357 pinctrl_pm_select_sleep_state(dev);
1358 clk_disable_unprepare(st->clk);
1359
1360 return 0;
1361}
1362
1363static int at91_adc_resume(struct device *dev)
1364{
1365 struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev));
1366 struct at91_adc_state *st = iio_priv(idev);
1367
1368 clk_prepare_enable(st->clk);
1369 pinctrl_pm_select_default_state(dev);
1370
1371 return 0;
1372}
1373#endif
1374
1375static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume);
1376
1350static struct at91_adc_caps at91sam9260_caps = { 1377static struct at91_adc_caps at91sam9260_caps = {
1351 .calc_startup_ticks = calc_startup_ticks_9260, 1378 .calc_startup_ticks = calc_startup_ticks_9260,
1352 .num_channels = 4, 1379 .num_channels = 4,
@@ -1441,6 +1468,7 @@ static struct platform_driver at91_adc_driver = {
1441 .driver = { 1468 .driver = {
1442 .name = DRIVER_NAME, 1469 .name = DRIVER_NAME,
1443 .of_match_table = of_match_ptr(at91_adc_dt_ids), 1470 .of_match_table = of_match_ptr(at91_adc_dt_ids),
1471 .pm = &at91_adc_pm_ops,
1444 }, 1472 },
1445}; 1473};
1446 1474