From: "Luhua Xu" <luhua.xu@xxxxxxxxxxxx> As to set_cs takes effect immediately, power spi is needed when setup spi. Signed-off-by: Luhua Xu <luhua.xu@xxxxxxxxxxxx> --- V2: - move set_cs PM control from .set_cs callback in vendor driver to spi_setup in spi framework drivers/spi/spi.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index f9502db..19007e0 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3091,7 +3091,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; -- 2.6.4