mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jisheng Zhang <jszhang@kernel.org>
To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] spi: cadence-xspi: support suspend/resume
Date: Thu, 22 Jan 2026 23:51:19 +0800	[thread overview]
Message-ID: <20260122155119.12865-1-jszhang@kernel.org> (raw)

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>
---
 drivers/spi/spi-cadence-xspi.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index 72384d90d113..895b4b3276a5 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -350,6 +350,7 @@ static const int cdns_mrvl_xspi_clk_div_list[] = {
 
 struct cdns_xspi_dev {
 	struct platform_device *pdev;
+	struct spi_controller *host;
 	struct device *dev;
 
 	void __iomem *iobase;
@@ -1159,9 +1160,10 @@ static int cdns_xspi_probe(struct platform_device *pdev)
 	}
 	host->bus_num = -1;
 
-	platform_set_drvdata(pdev, host);
+	platform_set_drvdata(pdev, cdns_xspi);
 
 	cdns_xspi->pdev = pdev;
+	cdns_xspi->host = host;
 	cdns_xspi->dev = &pdev->dev;
 	cdns_xspi->cur_cs = 0;
 
@@ -1250,6 +1252,30 @@ static int cdns_xspi_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static int cdns_xspi_suspend(struct device *dev)
+{
+	struct cdns_xspi_dev *cdns_xspi = dev_get_drvdata(dev);
+
+	return spi_controller_suspend(cdns_xspi->host);
+}
+
+static int cdns_xspi_resume(struct device *dev)
+{
+	struct cdns_xspi_dev *cdns_xspi = dev_get_drvdata(dev);
+
+	if (cdns_xspi->driver_data->mrvl_hw_overlay) {
+		cdns_mrvl_xspi_setup_clock(cdns_xspi, MRVL_DEFAULT_CLK);
+		cdns_xspi_configure_phy(cdns_xspi);
+	}
+
+	cdns_xspi->set_interrupts_handler(cdns_xspi, false);
+
+	return spi_controller_resume(cdns_xspi->host);
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(cdns_xspi_pm_ops,
+				cdns_xspi_suspend, cdns_xspi_resume);
+
 static const struct of_device_id cdns_xspi_of_match[] = {
 	{
 		.compatible = "cdns,xspi-nor",
@@ -1268,6 +1294,7 @@ static struct platform_driver cdns_xspi_platform_driver = {
 	.driver = {
 		.name = CDNS_XSPI_NAME,
 		.of_match_table = cdns_xspi_of_match,
+		.pm = pm_sleep_ptr(&cdns_xspi_pm_ops),
 	},
 };
 
-- 
2.51.0


             reply	other threads:[~2026-01-22 16:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-22 15:51 Jisheng Zhang [this message]
2026-01-27 22:36 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260122155119.12865-1-jszhang@kernel.org \
    --to=jszhang@kernel.org \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®