linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: spi-fsl-dspi: Adding shutdown hook
@ 2020-04-24  6:12 Peng Ma
  2020-04-24 12:56 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Peng Ma @ 2020-04-24  6:12 UTC (permalink / raw)
  To: broonie, leoyang.li; +Cc: linux-spi, linux-kernel, Peng Ma

We need to ensure dspi controller could be stopped in order for kexec
to start the next kernel.
So add the shutdown operation support.

Signed-off-by: Peng Ma <peng.ma@nxp.com>
---
 drivers/spi/spi-fsl-dspi.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 50e41f66a2d7..685afdf9e807 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 //
 // Copyright 2013 Freescale Semiconductor, Inc.
+// Copyright 2020 NXP
 //
 // Freescale DSPI driver
 // This file contains a driver for the Freescale DSPI
@@ -26,6 +27,9 @@
 #define SPI_MCR_CLR_TXF			BIT(11)
 #define SPI_MCR_CLR_RXF			BIT(10)
 #define SPI_MCR_XSPI			BIT(3)
+#define SPI_MCR_DIS_TXF			BIT(13)
+#define SPI_MCR_DIS_RXF			BIT(12)
+#define SPI_MCR_HALT			BIT(0)
 
 #define SPI_TCR				0x08
 #define SPI_TCR_GET_TCNT(x)		(((x) & GENMASK(31, 16)) >> 16)
@@ -1417,6 +1421,24 @@ static int dspi_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static void dspi_shutdown(struct platform_device *pdev)
+{
+	struct spi_controller *ctlr = platform_get_drvdata(pdev);
+	struct fsl_dspi *dspi = spi_controller_get_devdata(ctlr);
+
+	/* Disable RX and TX */
+	regmap_update_bits(dspi->regmap, SPI_MCR,
+			   SPI_MCR_DIS_TXF | SPI_MCR_DIS_RXF,
+			   SPI_MCR_DIS_TXF | SPI_MCR_DIS_RXF);
+
+	/* Stop Running */
+	regmap_update_bits(dspi->regmap, SPI_MCR, SPI_MCR_HALT, SPI_MCR_HALT);
+
+	dspi_release_dma(dspi);
+	clk_disable_unprepare(dspi->clk);
+	spi_unregister_controller(dspi->ctlr);
+}
+
 static struct platform_driver fsl_dspi_driver = {
 	.driver.name		= DRIVER_NAME,
 	.driver.of_match_table	= fsl_dspi_dt_ids,
@@ -1424,6 +1446,7 @@ static struct platform_driver fsl_dspi_driver = {
 	.driver.pm		= &dspi_pm,
 	.probe			= dspi_probe,
 	.remove			= dspi_remove,
+	.shutdown		= dspi_shutdown,
 };
 module_platform_driver(fsl_dspi_driver);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] spi: spi-fsl-dspi: Adding shutdown hook
  2020-04-24  6:12 [PATCH] spi: spi-fsl-dspi: Adding shutdown hook Peng Ma
@ 2020-04-24 12:56 ` Mark Brown
  2020-04-27  2:35   ` [EXT] " Peng Ma
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2020-04-24 12:56 UTC (permalink / raw)
  To: leoyang.li, Peng Ma; +Cc: linux-kernel, linux-spi

On Fri, 24 Apr 2020 14:12:16 +0800, Peng Ma wrote:
> We need to ensure dspi controller could be stopped in order for kexec
> to start the next kernel.
> So add the shutdown operation support.
> 
> Signed-off-by: Peng Ma <peng.ma@nxp.com>
> ---
>  drivers/spi/spi-fsl-dspi.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-5.8

Thanks!

[1/1] spi: spi-fsl-dspi: Adding shutdown hook
      commit: dc234825997ec6ff05980ca9e2204f4ac3f8d695

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [EXT] Re: [PATCH] spi: spi-fsl-dspi: Adding shutdown hook
  2020-04-24 12:56 ` Mark Brown
@ 2020-04-27  2:35   ` Peng Ma
  0 siblings, 0 replies; 3+ messages in thread
From: Peng Ma @ 2020-04-27  2:35 UTC (permalink / raw)
  To: Mark Brown, Leo Li; +Cc: linux-kernel, linux-spi

Hi Mark,

>-----Original Message-----
>From: Mark Brown <broonie@kernel.org>
>Sent: 2020年4月24日 20:57
>To: Leo Li <leoyang.li@nxp.com>; Peng Ma <peng.ma@nxp.com>
>Cc: linux-kernel@vger.kernel.org; linux-spi@vger.kernel.org
>Subject: [EXT] Re: [PATCH] spi: spi-fsl-dspi: Adding shutdown hook
>
>Caution: EXT Email
>
>On Fri, 24 Apr 2020 14:12:16 +0800, Peng Ma wrote:
>> We need to ensure dspi controller could be stopped in order for kexec
>> to start the next kernel.
>> So add the shutdown operation support.
>>
>> Signed-off-by: Peng Ma <peng.ma@nxp.com>
>> ---
>>  drivers/spi/spi-fsl-dspi.c | 23 +++++++++++++++++++++++
>>  1 file changed, 23 insertions(+)
>>
>> [...]
>
>Applied to
>
>
>https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kerne
>l.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fbroonie%2Fspi.git&amp;data
>=02%7C01%7Cpeng.ma%40nxp.com%7C1cae36a19be74172501c08d7e84ef418
>%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637233298112661854
>&amp;sdata=7WllSlzlH5AtoQ4T8DvvI7GCysPmXivnu4A8aghUxys%3D&amp;reser
>ved=0 for-5.8
>
>Thanks!
>
>[1/1] spi: spi-fsl-dspi: Adding shutdown hook
>      commit: dc234825997ec6ff05980ca9e2204f4ac3f8d695
>
>All being well this means that it will be integrated into the linux-next tree
>(usually sometime in the next 24 hours) and sent to Linus during the next merge
>window (or sooner if it is a bug fix), however if problems are discovered then
>the patch may be dropped or reverted.
>
>You may get further e-mails resulting from automated or manual testing and
>review of the tree, please engage with people reporting problems and send
>followup patches addressing any issues that are reported if needed.
>
>If any updates are required or you are submitting further changes they should
>be sent as incremental updates against current git, existing patches will not be
>replaced.
>
>Please add any relevant lists and maintainers to the CCs when replying to this
>mail.
>
[Peng Ma] OK, Got it, thanks very much!

Best Regards,
Peng
>Thanks,
>Mark

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-27  2:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24  6:12 [PATCH] spi: spi-fsl-dspi: Adding shutdown hook Peng Ma
2020-04-24 12:56 ` Mark Brown
2020-04-27  2:35   ` [EXT] " Peng Ma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).