All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dhruva Gole <d-gole@ti.com>
To: Mark Brown <broonie@kernel.org>
Cc: Dhruva Gole <d-gole@ti.com>, Vaishnav Achath <vaishnav.a@ti.com>,
	Vignesh <vigneshr@ti.com>, Apurva Nandan <a-nandan@ti.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-spi@vger.kernel.org>
Subject: [PATCH 2/2] spi: cadence-quadspi: fix suspend-resume implementations
Date: Mon, 17 Apr 2023 14:40:27 +0530	[thread overview]
Message-ID: <20230417091027.966146-3-d-gole@ti.com> (raw)
In-Reply-To: <20230417091027.966146-1-d-gole@ti.com>

The cadence QSPI driver misbehaves after performing a full system suspend
resume:
...
spi-nor spi0.0: resume() failed
...
This results in a flash connected via OSPI interface after system suspend-
resume to be unusable.
fix these suspend and resume functions.

Fixes: 140623410536 ("mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller")
Signed-off-by: Dhruva Gole <d-gole@ti.com>
---
 drivers/spi/spi-cadence-quadspi.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index d47e954fe809..91908e8cf92e 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -1816,17 +1816,30 @@ static void cqspi_remove(struct platform_device *pdev)
 static int cqspi_suspend(struct device *dev)
 {
 	struct cqspi_st *cqspi = dev_get_drvdata(dev);
+	struct spi_master *master = dev_get_drvdata(dev);
+	int ret;
 
+	ret = spi_master_suspend(master);
 	cqspi_controller_enable(cqspi, 0);
-	return 0;
+
+	clk_disable_unprepare(cqspi->clk);
+
+	return ret;
 }
 
 static int cqspi_resume(struct device *dev)
 {
 	struct cqspi_st *cqspi = dev_get_drvdata(dev);
+	struct spi_master *master = dev_get_drvdata(dev);
 
-	cqspi_controller_enable(cqspi, 1);
-	return 0;
+	clk_prepare_enable(cqspi->clk);
+	cqspi_wait_idle(cqspi);
+	cqspi_controller_init(cqspi);
+
+	cqspi->current_cs = -1;
+	cqspi->sclk = 0;
+
+	return spi_master_resume(master);
 }
 
 static SIMPLE_DEV_PM_OPS(cqspi__dev_pm_ops, cqspi_suspend, cqspi_resume);
-- 
2.25.1


WARNING: multiple messages have this Message-ID (diff)
From: Dhruva Gole <d-gole@ti.com>
To: Mark Brown <broonie@kernel.org>
Cc: Dhruva Gole <d-gole@ti.com>, Vaishnav Achath <vaishnav.a@ti.com>,
	Vignesh <vigneshr@ti.com>, Apurva Nandan <a-nandan@ti.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-spi@vger.kernel.org>
Subject: [PATCH 2/2] spi: cadence-quadspi: fix suspend-resume implementations
Date: Mon, 17 Apr 2023 14:40:27 +0530	[thread overview]
Message-ID: <20230417091027.966146-3-d-gole@ti.com> (raw)
In-Reply-To: <20230417091027.966146-1-d-gole@ti.com>

The cadence QSPI driver misbehaves after performing a full system suspend
resume:
...
spi-nor spi0.0: resume() failed
...
This results in a flash connected via OSPI interface after system suspend-
resume to be unusable.
fix these suspend and resume functions.

Fixes: 140623410536 ("mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller")
Signed-off-by: Dhruva Gole <d-gole@ti.com>
---
 drivers/spi/spi-cadence-quadspi.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index d47e954fe809..91908e8cf92e 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -1816,17 +1816,30 @@ static void cqspi_remove(struct platform_device *pdev)
 static int cqspi_suspend(struct device *dev)
 {
 	struct cqspi_st *cqspi = dev_get_drvdata(dev);
+	struct spi_master *master = dev_get_drvdata(dev);
+	int ret;
 
+	ret = spi_master_suspend(master);
 	cqspi_controller_enable(cqspi, 0);
-	return 0;
+
+	clk_disable_unprepare(cqspi->clk);
+
+	return ret;
 }
 
 static int cqspi_resume(struct device *dev)
 {
 	struct cqspi_st *cqspi = dev_get_drvdata(dev);
+	struct spi_master *master = dev_get_drvdata(dev);
 
-	cqspi_controller_enable(cqspi, 1);
-	return 0;
+	clk_prepare_enable(cqspi->clk);
+	cqspi_wait_idle(cqspi);
+	cqspi_controller_init(cqspi);
+
+	cqspi->current_cs = -1;
+	cqspi->sclk = 0;
+
+	return spi_master_resume(master);
 }
 
 static SIMPLE_DEV_PM_OPS(cqspi__dev_pm_ops, cqspi_suspend, cqspi_resume);
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-04-17  9:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-17  9:10 [PATCH 0/2] Fix PM Hooks in the Cadence Quad SPI Driver Dhruva Gole
2023-04-17  9:10 ` Dhruva Gole
2023-04-17  9:10 ` [PATCH 1/2] spi: cadence-quadspi: use macro SIMPLE_DEV_PM_OPS Dhruva Gole
2023-04-17  9:10   ` Dhruva Gole
2023-04-18 12:52   ` Mark Brown
2023-04-18 12:52     ` Mark Brown
2023-04-18 14:17     ` Gole, Dhruva
2023-04-18 14:17       ` Gole, Dhruva
2023-04-18 16:19       ` Mark Brown
2023-04-18 16:19         ` Mark Brown
2023-04-17  9:10 ` Dhruva Gole [this message]
2023-04-17  9:10   ` [PATCH 2/2] spi: cadence-quadspi: fix suspend-resume implementations Dhruva Gole
2023-04-18 16:21 ` (subset) [PATCH 0/2] Fix PM Hooks in the Cadence Quad SPI Driver Mark Brown
2023-04-18 16:21   ` 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=20230417091027.966146-3-d-gole@ti.com \
    --to=d-gole@ti.com \
    --cc=a-nandan@ti.com \
    --cc=broonie@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=vaishnav.a@ti.com \
    --cc=vigneshr@ti.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.