Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Wenyou Yang and committed by
Jonathan Cameron
bc3ae982 ab541631

+28
+28
drivers/iio/adc/at91_adc.c
··· 30 30 #include <linux/iio/trigger.h> 31 31 #include <linux/iio/trigger_consumer.h> 32 32 #include <linux/iio/triggered_buffer.h> 33 + #include <linux/pinctrl/consumer.h> 33 34 34 35 /* Registers */ 35 36 #define AT91_ADC_CR 0x00 /* Control Register */ ··· 1348 1347 return 0; 1349 1348 } 1350 1349 1350 + #ifdef CONFIG_PM_SLEEP 1351 + static int at91_adc_suspend(struct device *dev) 1352 + { 1353 + struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev)); 1354 + struct at91_adc_state *st = iio_priv(idev); 1355 + 1356 + pinctrl_pm_select_sleep_state(dev); 1357 + clk_disable_unprepare(st->clk); 1358 + 1359 + return 0; 1360 + } 1361 + 1362 + static int at91_adc_resume(struct device *dev) 1363 + { 1364 + struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev)); 1365 + struct at91_adc_state *st = iio_priv(idev); 1366 + 1367 + clk_prepare_enable(st->clk); 1368 + pinctrl_pm_select_default_state(dev); 1369 + 1370 + return 0; 1371 + } 1372 + #endif 1373 + 1374 + static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume); 1375 + 1351 1376 static struct at91_adc_caps at91sam9260_caps = { 1352 1377 .calc_startup_ticks = calc_startup_ticks_9260, 1353 1378 .num_channels = 4, ··· 1468 1441 .driver = { 1469 1442 .name = DRIVER_NAME, 1470 1443 .of_match_table = of_match_ptr(at91_adc_dt_ids), 1444 + .pm = &at91_adc_pm_ops, 1471 1445 }, 1472 1446 }; 1473 1447