Skip to content

Commit

Permalink
spi: atmel: adopt pinctrl support
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wenyou Yang authored and Mark Brown committed Mar 5, 2014
1 parent ad6f33d commit 5bdfd49
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/spi/spi-atmel.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <linux/io.h>
#include <linux/gpio.h>
#include <linux/pinctrl/consumer.h>

/* SPI register offsets */
#define SPI_CR 0x0000
Expand Down Expand Up @@ -1292,6 +1293,9 @@ static int atmel_spi_probe(struct platform_device *pdev)
struct spi_master *master;
struct atmel_spi *as;

/* Select default pin state */
pinctrl_pm_select_default_state(&pdev->dev);

regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!regs)
return -ENXIO;
Expand Down Expand Up @@ -1446,6 +1450,9 @@ static int atmel_spi_suspend(struct device *dev)
struct atmel_spi *as = spi_master_get_devdata(master);

clk_disable_unprepare(as->clk);

pinctrl_pm_select_sleep_state(dev);

return 0;
}

Expand All @@ -1454,6 +1461,8 @@ static int atmel_spi_resume(struct device *dev)
struct spi_master *master = dev_get_drvdata(dev);
struct atmel_spi *as = spi_master_get_devdata(master);

pinctrl_pm_select_default_state(dev);

clk_prepare_enable(as->clk);
return 0;
}
Expand Down

0 comments on commit 5bdfd49

Please sign in to comment.