Add simple PM operations to sifive-spi
Subsystems (3)
cover Add simple PM operations to sifive-spi
The patch has been tested on Unmatched using pm_test. The Unmatched board uses SD over SPI and it was tested by initiating S2RAM cycles for all devices while reading/writing files at the same time. We found no dropped connection to the card or corrupted filesystem during test cycles.
Andy Chiu (1):
spi: sifive: add PM callbacks to support suspend/resume
drivers/spi/spi-sifive.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
Signature · 1 line
2.36.0
PATCH 1/1 spi: sifive: add PM callbacks to support suspend/resume
--- drivers/spi/spi-sifive.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/spi/spi-sifive.c +39 -0
@@ -427,6 +427,44 @@ static int sifive_spi_remove(struct platform_device *pdev)return 0 ; } +static int sifive_spi_suspend (struct device *dev) +{ +struct spi_master *master =dev_get_drvdata (dev); +struct sifive_spi *spi =spi_master_get_devdata (master); +int ret; + + ret =spi_master_suspend (master); +if (ret) +return ret; + +/* Disable all the interrupts just in case */ +sifive_spi_write (spi,SIFIVE_SPI_REG_IE ,0 ); + +clk_disable_unprepare (spi->clk); + +return ret; +} + +static int sifive_spi_resume (struct device *dev) +{ +struct spi_master *master =dev_get_drvdata (dev); +struct sifive_spi *spi =spi_master_get_devdata (master); +int ret; + + ret =clk_prepare_enable (spi->clk); +if (ret) +return ret; + ret =spi_master_resume (master); +if (ret) +clk_disable_unprepare (spi->clk); + +return ret; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(sifive_spi_pm_ops, + sifive_spi_suspend, sifive_spi_resume); + +static const struct of_device_id sifive_spi_of_match[] = { { .compatible ="sifive,spi0" , }, {}
@@ -438,6 +476,7 @@ static struct platform_driver sifive_spi_driver = { .remove = sifive_spi_remove, .driver = { .name = SIFIVE_SPI_DRIVER_NAME, + .pm = &sifive_spi_pm_ops, .of_match_table = sifive_spi_of_match, }, };
Signature · 1 line
2.36.0
Mark Brown
maintainerRe: [PATCH next 1/1] spi: sifive: add PM callbacks to support suspend/resume
Quoted 4 lines · Andy Chiu
drivers/spi/spi-sifive.c +4
-0+static int sifive_spi_suspend (struct device *dev) +{ +struct spi_master *master =dev_get_drvdata (dev); +struct sifive_spi *spi =spi_master_get_devdata (master);
drivers/spi/spi-sifive.c static int sifive_spi_remove(struct platform_device *pdev) · line 443
Quoted 10 lines
drivers/spi/spi-sifive.c +10
-0+int ret; + + ret =spi_master_suspend (master); +if (ret) +return ret; + +/* Disable all the interrupts just in case */ +sifive_spi_write (spi,SIFIVE_SPI_REG_IE ,0 ); + +clk_disable_unprepare (spi->clk);
Seems like the clock managemnet could usefully be done as runtime PM too? In any case, that can be done as an incremental change.
Re: [PATCH next 1/1] spi: sifive: add PM callbacks to support suspend/resume
Quoted 2 lines
Seems like the clock managemnet could usefully be done as runtime PM too? In any case, that can be done as an incremental change.
Thanks for the suggestion. We will work on it soon in the future.
Re: [PATCH next 1/1] spi: sifive: add PM callbacks to support suspend/resume
In reply to Andy ChiuQuoted 1 line · Andy Chiu
Missed changelog.
Quoted 6 lines
Signed-off-by Andy Chiu <[email protected]>Reviewed-by Greentime Hu <[email protected]>.driver = {
.name =SIFIVE_SPI_DRIVER_NAME,
+ .pm =&sifive_spi_pm_ops,
Missed pm_sleep_ptr(). Have you compiled it with CONFIG_PM_SLEEP=n? Have you got warnings of unused functions?
Quoted 2 lines
.of_match_table =
sifive_spi_of_match,
},
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mark Brown
maintainerQuoted 4 lines · Andy Chiu
The patch has been tested on Unmatched using
pm_test. The Unmatched board uses SD over SPI and it was tested by initiating S2RAM cycles for all devices while reading/writing files at the same time. We found no dropped connection to the card or corrupted filesystem during test cycles.
Please don't send cover letters for single patches, if there is anything that needs saying put it in the changelog of the patch or after the --- if it's administrative stuff. This reduces mail volume and ensures that any important information is recorded in the changelog rather than being lost.
Mark Brown
maintainerQuoted 9 lines · Andy Chiu
The patch has been tested on Unmatched using
pm_test. The Unmatched board uses SD over SPI and it was tested by initiating S2RAM cycles for all devices while reading/writing files at the same time. We found no dropped connection to the card or corrupted filesystem during test cycles.Andy Chiu (1):
spi: sifive: add PM callbacks to support suspend/resume[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: sifive: add PM callbacks to support suspend/resume
commit: a1f0161eadbd7941c09b5f4c6a210c390d2b86d6
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