summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuhua Xu <luhua.xu@mediatek.com>2019-10-30 10:03:54 +0100
committerMark Brown <broonie@kernel.org>2019-10-31 14:20:58 +0100
commitd948e6ca189985495a21cd622c31e30e72b6b688 (patch)
tree96e13ac26e6f25d1d860ea133d87f2928579a2ea
parentspi: zynq-qspi: Drop GPIO header (diff)
downloadlinux-d948e6ca189985495a21cd622c31e30e72b6b688.tar.xz
linux-d948e6ca189985495a21cd622c31e30e72b6b688.zip
spi: add power control when set_cs
As to set_cs takes effect immediately, power spi is needed when setup spi. Cc: Mark Brown <broonie@kernel.org> Signed-off-by: Luhua Xu <luhua.xu@mediatek.com> Link: https://lore.kernel.org/r/1572426234-30019-1-git-send-email-luhua.xu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/spi/spi.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 5ba19ef809c2..294d0038eea6 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3261,7 +3261,20 @@ int spi_setup(struct spi_device *spi)
if (spi->controller->setup)
status = spi->controller->setup(spi);
- spi_set_cs(spi, false);
+ if (spi->controller->auto_runtime_pm && spi->controller->set_cs) {
+ status = pm_runtime_get_sync(spi->controller->dev.parent);
+ if (status < 0) {
+ pm_runtime_put_noidle(spi->controller->dev.parent);
+ dev_err(&spi->controller->dev, "Failed to power device: %d\n",
+ status);
+ return status;
+ }
+ spi_set_cs(spi, false);
+ pm_runtime_mark_last_busy(spi->controller->dev.parent);
+ pm_runtime_put_autosuspend(spi->controller->dev.parent);
+ } else {
+ spi_set_cs(spi, false);
+ }
if (spi->rt && !spi->controller->rt) {
spi->controller->rt = true;