Skip to content

Commit

Permalink
spi: imx: fix runtime pm support for !CONFIG_PM
Browse files Browse the repository at this point in the history
[ Upstream commit 43b6bf4 ]

525c9e5 introduced pm_runtime support for the i.MX SPI driver. With
this pm_runtime is used to bring up the clocks initially. When CONFIG_PM
is disabled the clocks are no longer enabled and the driver doesn't work
anymore. Fix this by enabling the clocks in the probe function and
telling pm_runtime that the device is active using
pm_runtime_set_active().

Fixes: 525c9e5 spi: imx: enable runtime pm support
Tested-by: Christian Eggers <ceggers@arri.de> [tested for !CONFIG_PM only]
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.kernel.org/r/20201021104513.21560-1-s.hauer@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
saschahauer authored and gregkh committed Nov 18, 2020
1 parent 35b83f6 commit 1dfc44f
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions drivers/spi/spi-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1674,15 +1674,18 @@ static int spi_imx_probe(struct platform_device *pdev)
goto out_master_put;
}

pm_runtime_enable(spi_imx->dev);
ret = clk_prepare_enable(spi_imx->clk_per);
if (ret)
goto out_master_put;

ret = clk_prepare_enable(spi_imx->clk_ipg);
if (ret)
goto out_put_per;

pm_runtime_set_autosuspend_delay(spi_imx->dev, MXC_RPM_TIMEOUT);
pm_runtime_use_autosuspend(spi_imx->dev);

ret = pm_runtime_get_sync(spi_imx->dev);
if (ret < 0) {
dev_err(spi_imx->dev, "failed to enable clock\n");
goto out_runtime_pm_put;
}
pm_runtime_set_active(spi_imx->dev);
pm_runtime_enable(spi_imx->dev);

spi_imx->spi_clk = clk_get_rate(spi_imx->clk_per);
/*
Expand Down Expand Up @@ -1722,8 +1725,12 @@ static int spi_imx_probe(struct platform_device *pdev)
spi_imx_sdma_exit(spi_imx);
out_runtime_pm_put:
pm_runtime_dont_use_autosuspend(spi_imx->dev);
pm_runtime_put_sync(spi_imx->dev);
pm_runtime_set_suspended(&pdev->dev);
pm_runtime_disable(spi_imx->dev);

clk_disable_unprepare(spi_imx->clk_ipg);
out_put_per:
clk_disable_unprepare(spi_imx->clk_per);
out_master_put:
spi_master_put(master);

Expand Down

0 comments on commit 1dfc44f

Please sign in to comment.