Skip to content

Commit db6a59c

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

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

drivers/spi/spi-cadence-xspi.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ static const int cdns_mrvl_xspi_clk_div_list[] = {
350350

351351
struct cdns_xspi_dev {
352352
struct platform_device *pdev;
353+
struct spi_controller *host;
353354
struct device *dev;
354355

355356
void __iomem *iobase;
@@ -1159,9 +1160,10 @@ static int cdns_xspi_probe(struct platform_device *pdev)
11591160
}
11601161
host->bus_num = -1;
11611162

1162-
platform_set_drvdata(pdev, host);
1163+
platform_set_drvdata(pdev, cdns_xspi);
11631164

11641165
cdns_xspi->pdev = pdev;
1166+
cdns_xspi->host = host;
11651167
cdns_xspi->dev = &pdev->dev;
11661168
cdns_xspi->cur_cs = 0;
11671169

@@ -1250,6 +1252,30 @@ static int cdns_xspi_probe(struct platform_device *pdev)
12501252
return 0;
12511253
}
12521254

1255+
static int cdns_xspi_suspend(struct device *dev)
1256+
{
1257+
struct cdns_xspi_dev *cdns_xspi = dev_get_drvdata(dev);
1258+
1259+
return spi_controller_suspend(cdns_xspi->host);
1260+
}
1261+
1262+
static int cdns_xspi_resume(struct device *dev)
1263+
{
1264+
struct cdns_xspi_dev *cdns_xspi = dev_get_drvdata(dev);
1265+
1266+
if (cdns_xspi->driver_data->mrvl_hw_overlay) {
1267+
cdns_mrvl_xspi_setup_clock(cdns_xspi, MRVL_DEFAULT_CLK);
1268+
cdns_xspi_configure_phy(cdns_xspi);
1269+
}
1270+
1271+
cdns_xspi->set_interrupts_handler(cdns_xspi, false);
1272+
1273+
return spi_controller_resume(cdns_xspi->host);
1274+
}
1275+
1276+
static DEFINE_SIMPLE_DEV_PM_OPS(cdns_xspi_pm_ops,
1277+
cdns_xspi_suspend, cdns_xspi_resume);
1278+
12531279
static const struct of_device_id cdns_xspi_of_match[] = {
12541280
{
12551281
.compatible = "cdns,xspi-nor",
@@ -1268,6 +1294,7 @@ static struct platform_driver cdns_xspi_platform_driver = {
12681294
.driver = {
12691295
.name = CDNS_XSPI_NAME,
12701296
.of_match_table = cdns_xspi_of_match,
1297+
.pm = pm_sleep_ptr(&cdns_xspi_pm_ops),
12711298
},
12721299
};
12731300

0 commit comments

Comments
 (0)