Skip to content

Commit a8b6e37

Browse files
xhackerustcbroonie
authored andcommitted
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>
1 parent db6a59c commit a8b6e37

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

drivers/spi/spi-dw-mmio.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,38 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
392392
return ret;
393393
}
394394

395+
static int dw_spi_mmio_suspend(struct device *dev)
396+
{
397+
struct dw_spi_mmio *dwsmmio = dev_get_drvdata(dev);
398+
int ret;
399+
400+
ret = dw_spi_suspend_controller(&dwsmmio->dws);
401+
if (ret)
402+
return ret;
403+
404+
reset_control_assert(dwsmmio->rstc);
405+
406+
clk_disable_unprepare(dwsmmio->pclk);
407+
clk_disable_unprepare(dwsmmio->clk);
408+
409+
return 0;
410+
}
411+
412+
static int dw_spi_mmio_resume(struct device *dev)
413+
{
414+
struct dw_spi_mmio *dwsmmio = dev_get_drvdata(dev);
415+
416+
clk_prepare_enable(dwsmmio->clk);
417+
clk_prepare_enable(dwsmmio->pclk);
418+
419+
reset_control_deassert(dwsmmio->rstc);
420+
421+
return dw_spi_resume_controller(&dwsmmio->dws);
422+
}
423+
424+
static DEFINE_SIMPLE_DEV_PM_OPS(dw_spi_mmio_pm_ops,
425+
dw_spi_mmio_suspend, dw_spi_mmio_resume);
426+
395427
static void dw_spi_mmio_remove(struct platform_device *pdev)
396428
{
397429
struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev);
@@ -435,6 +467,7 @@ static struct platform_driver dw_spi_mmio_driver = {
435467
.name = DRIVER_NAME,
436468
.of_match_table = dw_spi_mmio_of_match,
437469
.acpi_match_table = ACPI_PTR(dw_spi_mmio_acpi_match),
470+
.pm = pm_sleep_ptr(&dw_spi_mmio_pm_ops),
438471
},
439472
};
440473
module_platform_driver(dw_spi_mmio_driver);

0 commit comments

Comments
 (0)