diff options
| author | Jisheng Zhang <jszhang@kernel.org> | 2026-01-22 18:50:46 +0300 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2026-01-27 15:46:30 +0300 |
| commit | a8b6e3738c872d35f1cf7b3cd3ce67d86d38e7cf (patch) | |
| tree | 5f9aa61a58c6c9193c80d2b344d327ca861be0f7 | |
| parent | db6a59cfcc9364dec501993690a320d916ae3904 (diff) | |
| download | linux-a8b6e3738c872d35f1cf7b3cd3ce67d86d38e7cf.tar.xz | |
spi: dw-mmio: support suspend/resume
Add system wide suspend and resume support, the implementation is
straightforward, just call spi_controller_suspend() then assert the
reset and disable clks for suspend, enable clks and deassert reset
then call spi_controller_resume() for resume.
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Link: https://patch.msgid.link/20260122155046.12848-1-jszhang@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
| -rw-r--r-- | drivers/spi/spi-dw-mmio.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index 33239b4778cb..b8123db4ad55 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -392,6 +392,38 @@ out_reset: return ret; } +static int dw_spi_mmio_suspend(struct device *dev) +{ + struct dw_spi_mmio *dwsmmio = dev_get_drvdata(dev); + int ret; + + ret = dw_spi_suspend_controller(&dwsmmio->dws); + if (ret) + return ret; + + reset_control_assert(dwsmmio->rstc); + + clk_disable_unprepare(dwsmmio->pclk); + clk_disable_unprepare(dwsmmio->clk); + + return 0; +} + +static int dw_spi_mmio_resume(struct device *dev) +{ + struct dw_spi_mmio *dwsmmio = dev_get_drvdata(dev); + + clk_prepare_enable(dwsmmio->clk); + clk_prepare_enable(dwsmmio->pclk); + + reset_control_deassert(dwsmmio->rstc); + + return dw_spi_resume_controller(&dwsmmio->dws); +} + +static DEFINE_SIMPLE_DEV_PM_OPS(dw_spi_mmio_pm_ops, + dw_spi_mmio_suspend, dw_spi_mmio_resume); + static void dw_spi_mmio_remove(struct platform_device *pdev) { struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev); @@ -435,6 +467,7 @@ static struct platform_driver dw_spi_mmio_driver = { .name = DRIVER_NAME, .of_match_table = dw_spi_mmio_of_match, .acpi_match_table = ACPI_PTR(dw_spi_mmio_acpi_match), + .pm = pm_sleep_ptr(&dw_spi_mmio_pm_ops), }, }; module_platform_driver(dw_spi_mmio_driver); |
