提交 5bdfd491 编写于 作者: W Wenyou Yang 提交者: Mark Brown

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: NWenyou Yang <wenyou.yang@atmel.com>
Signed-off-by: NMark Brown <broonie@linaro.org>
上级 ad6f33d2
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/pinctrl/consumer.h>
/* SPI register offsets */ /* SPI register offsets */
#define SPI_CR 0x0000 #define SPI_CR 0x0000
...@@ -1292,6 +1293,9 @@ static int atmel_spi_probe(struct platform_device *pdev) ...@@ -1292,6 +1293,9 @@ static int atmel_spi_probe(struct platform_device *pdev)
struct spi_master *master; struct spi_master *master;
struct atmel_spi *as; struct atmel_spi *as;
/* Select default pin state */
pinctrl_pm_select_default_state(&pdev->dev);
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!regs) if (!regs)
return -ENXIO; return -ENXIO;
...@@ -1446,6 +1450,9 @@ static int atmel_spi_suspend(struct device *dev) ...@@ -1446,6 +1450,9 @@ static int atmel_spi_suspend(struct device *dev)
struct atmel_spi *as = spi_master_get_devdata(master); struct atmel_spi *as = spi_master_get_devdata(master);
clk_disable_unprepare(as->clk); clk_disable_unprepare(as->clk);
pinctrl_pm_select_sleep_state(dev);
return 0; return 0;
} }
...@@ -1454,6 +1461,8 @@ static int atmel_spi_resume(struct device *dev) ...@@ -1454,6 +1461,8 @@ static int atmel_spi_resume(struct device *dev)
struct spi_master *master = dev_get_drvdata(dev); struct spi_master *master = dev_get_drvdata(dev);
struct atmel_spi *as = spi_master_get_devdata(master); struct atmel_spi *as = spi_master_get_devdata(master);
pinctrl_pm_select_default_state(dev);
clk_prepare_enable(as->clk); clk_prepare_enable(as->clk);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册