diff options
author | Wenyou Yang <wenyou.yang@atmel.com> | 2014-03-04 20:58:49 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-03-04 22:21:47 -0500 |
commit | 5bdfd491a01955727a6b2382534ec7760174863e (patch) | |
tree | 42ee015bf457b62106e1d1fdb1f8de9db7b2670a /drivers/spi/spi-atmel.c | |
parent | ad6f33d22c25e7340107a330e6de60bba57ecf52 (diff) |
spi: atmel: adopt pinctrl support
Amend the spi atmel pin controller to optionally take a pin control
handle and set the state of the pins to:
- "default" on boot, resume and before performing an spitransfer
- "sleep" on suspend()
This should make it possible to optimize energy usage for the pins
both for the suspend/resume cycle
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-atmel.c')
-rw-r--r-- | drivers/spi/spi-atmel.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 4804586edd29..c83b0c620fa1 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c | |||
@@ -26,6 +26,7 @@ | |||
26 | 26 | ||
27 | #include <linux/io.h> | 27 | #include <linux/io.h> |
28 | #include <linux/gpio.h> | 28 | #include <linux/gpio.h> |
29 | #include <linux/pinctrl/consumer.h> | ||
29 | 30 | ||
30 | /* SPI register offsets */ | 31 | /* SPI register offsets */ |
31 | #define SPI_CR 0x0000 | 32 | #define SPI_CR 0x0000 |
@@ -1292,6 +1293,9 @@ static int atmel_spi_probe(struct platform_device *pdev) | |||
1292 | struct spi_master *master; | 1293 | struct spi_master *master; |
1293 | struct atmel_spi *as; | 1294 | struct atmel_spi *as; |
1294 | 1295 | ||
1296 | /* Select default pin state */ | ||
1297 | pinctrl_pm_select_default_state(&pdev->dev); | ||
1298 | |||
1295 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1299 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1296 | if (!regs) | 1300 | if (!regs) |
1297 | return -ENXIO; | 1301 | return -ENXIO; |
@@ -1446,6 +1450,9 @@ static int atmel_spi_suspend(struct device *dev) | |||
1446 | struct atmel_spi *as = spi_master_get_devdata(master); | 1450 | struct atmel_spi *as = spi_master_get_devdata(master); |
1447 | 1451 | ||
1448 | clk_disable_unprepare(as->clk); | 1452 | clk_disable_unprepare(as->clk); |
1453 | |||
1454 | pinctrl_pm_select_sleep_state(dev); | ||
1455 | |||
1449 | return 0; | 1456 | return 0; |
1450 | } | 1457 | } |
1451 | 1458 | ||
@@ -1454,6 +1461,8 @@ static int atmel_spi_resume(struct device *dev) | |||
1454 | struct spi_master *master = dev_get_drvdata(dev); | 1461 | struct spi_master *master = dev_get_drvdata(dev); |
1455 | struct atmel_spi *as = spi_master_get_devdata(master); | 1462 | struct atmel_spi *as = spi_master_get_devdata(master); |
1456 | 1463 | ||
1464 | pinctrl_pm_select_default_state(dev); | ||
1465 | |||
1457 | clk_prepare_enable(as->clk); | 1466 | clk_prepare_enable(as->clk); |
1458 | return 0; | 1467 | return 0; |
1459 | } | 1468 | } |