Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: cadence-xspi: support suspend/resume

Add system wide suspend and resume support, the suspend hook
implementation is straightforward, just call spi_controller_suspend()
While the resume hook implementation is a bit complex, we need to redo
something which is done during probe, such as enable the interrupts,
setup clk and config the phy for mrvl hw overlay.

Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Link: https://patch.msgid.link/20260122155119.12865-1-jszhang@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Jisheng Zhang and committed by
Mark Brown
db6a59cf e73eb6a7

+28 -1
+28 -1
drivers/spi/spi-cadence-xspi.c
··· 350 350 351 351 struct cdns_xspi_dev { 352 352 struct platform_device *pdev; 353 + struct spi_controller *host; 353 354 struct device *dev; 354 355 355 356 void __iomem *iobase; ··· 1160 1159 } 1161 1160 host->bus_num = -1; 1162 1161 1163 - platform_set_drvdata(pdev, host); 1162 + platform_set_drvdata(pdev, cdns_xspi); 1164 1163 1165 1164 cdns_xspi->pdev = pdev; 1165 + cdns_xspi->host = host; 1166 1166 cdns_xspi->dev = &pdev->dev; 1167 1167 cdns_xspi->cur_cs = 0; 1168 1168 ··· 1252 1250 return 0; 1253 1251 } 1254 1252 1253 + static int cdns_xspi_suspend(struct device *dev) 1254 + { 1255 + struct cdns_xspi_dev *cdns_xspi = dev_get_drvdata(dev); 1256 + 1257 + return spi_controller_suspend(cdns_xspi->host); 1258 + } 1259 + 1260 + static int cdns_xspi_resume(struct device *dev) 1261 + { 1262 + struct cdns_xspi_dev *cdns_xspi = dev_get_drvdata(dev); 1263 + 1264 + if (cdns_xspi->driver_data->mrvl_hw_overlay) { 1265 + cdns_mrvl_xspi_setup_clock(cdns_xspi, MRVL_DEFAULT_CLK); 1266 + cdns_xspi_configure_phy(cdns_xspi); 1267 + } 1268 + 1269 + cdns_xspi->set_interrupts_handler(cdns_xspi, false); 1270 + 1271 + return spi_controller_resume(cdns_xspi->host); 1272 + } 1273 + 1274 + static DEFINE_SIMPLE_DEV_PM_OPS(cdns_xspi_pm_ops, 1275 + cdns_xspi_suspend, cdns_xspi_resume); 1276 + 1255 1277 static const struct of_device_id cdns_xspi_of_match[] = { 1256 1278 { 1257 1279 .compatible = "cdns,xspi-nor", ··· 1294 1268 .driver = { 1295 1269 .name = CDNS_XSPI_NAME, 1296 1270 .of_match_table = cdns_xspi_of_match, 1271 + .pm = pm_sleep_ptr(&cdns_xspi_pm_ops), 1297 1272 }, 1298 1273 }; 1299 1274