* [PATCH V2] spi: add power control when set_cs
@ 2019-10-30 9:03 Luhua Xu
2019-10-31 13:23 ` Applied "spi: add power control when set_cs" to the spi tree Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Luhua Xu @ 2019-10-30 9:03 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: wsd_upstream, linux-kernel, linux-spi, Luhua Xu, linux-mediatek,
linux-arm-kernel
From: "Luhua Xu" <luhua.xu@mediatek.com>
As to set_cs takes effect immediately, power spi
is needed when setup spi.
Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Luhua Xu <luhua.xu@mediatek.com>
---
V2:
- move set_cs PM control from .set_cs callback in
vendor driver to spi_setup in spi framework.
drivers/spi/spi.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index f9502db..19007e0 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3091,7 +3091,20 @@ int spi_setup(struct spi_device *spi)
if (spi->controller->setup)
status = spi->controller->setup(spi);
- spi_set_cs(spi, false);
+ if (spi->controller->auto_runtime_pm && spi->controller->set_cs) {
+ status = pm_runtime_get_sync(spi->controller->dev.parent);
+ if (status < 0) {
+ pm_runtime_put_noidle(spi->controller->dev.parent);
+ dev_err(&spi->controller->dev, "Failed to power device: %d\n",
+ status);
+ return status;
+ }
+ spi_set_cs(spi, false);
+ pm_runtime_mark_last_busy(spi->controller->dev.parent);
+ pm_runtime_put_autosuspend(spi->controller->dev.parent);
+ } else {
+ spi_set_cs(spi, false);
+ }
if (spi->rt && !spi->controller->rt) {
spi->controller->rt = true;
--
2.6.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Applied "spi: add power control when set_cs" to the spi tree
2019-10-30 9:03 [PATCH V2] spi: add power control when set_cs Luhua Xu
@ 2019-10-31 13:23 ` Mark Brown
2019-11-11 19:54 ` Tony Lindgren
0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2019-10-31 13:23 UTC (permalink / raw)
To: Luhua Xu
Cc: wsd_upstream, linux-kernel, linux-spi, Mark Brown,
linux-mediatek, Matthias Brugger, linux-arm-kernel
The patch
spi: add power control when set_cs
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-5.5
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
From d948e6ca189985495a21cd622c31e30e72b6b688 Mon Sep 17 00:00:00 2001
From: Luhua Xu <luhua.xu@mediatek.com>
Date: Wed, 30 Oct 2019 17:03:54 +0800
Subject: [PATCH] spi: add power control when set_cs
As to set_cs takes effect immediately, power spi
is needed when setup spi.
Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Luhua Xu <luhua.xu@mediatek.com>
Link: https://lore.kernel.org/r/1572426234-30019-1-git-send-email-luhua.xu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
drivers/spi/spi.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 5ba19ef809c2..294d0038eea6 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3261,7 +3261,20 @@ int spi_setup(struct spi_device *spi)
if (spi->controller->setup)
status = spi->controller->setup(spi);
- spi_set_cs(spi, false);
+ if (spi->controller->auto_runtime_pm && spi->controller->set_cs) {
+ status = pm_runtime_get_sync(spi->controller->dev.parent);
+ if (status < 0) {
+ pm_runtime_put_noidle(spi->controller->dev.parent);
+ dev_err(&spi->controller->dev, "Failed to power device: %d\n",
+ status);
+ return status;
+ }
+ spi_set_cs(spi, false);
+ pm_runtime_mark_last_busy(spi->controller->dev.parent);
+ pm_runtime_put_autosuspend(spi->controller->dev.parent);
+ } else {
+ spi_set_cs(spi, false);
+ }
if (spi->rt && !spi->controller->rt) {
spi->controller->rt = true;
--
2.20.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: Applied "spi: add power control when set_cs" to the spi tree
2019-10-31 13:23 ` Applied "spi: add power control when set_cs" to the spi tree Mark Brown
@ 2019-11-11 19:54 ` Tony Lindgren
0 siblings, 0 replies; 4+ messages in thread
From: Tony Lindgren @ 2019-11-11 19:54 UTC (permalink / raw)
To: Mark Brown
Cc: wsd_upstream, linux-kernel, linux-spi, linux-mediatek,
Matthias Brugger, Luhua Xu, linux-arm-kernel
Hi,
* Mark Brown <broonie@kernel.org> [191031 13:24]:
> The patch
>
> spi: add power control when set_cs
>
> has been applied to the spi tree at
>
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-5.5
This patch causes a regression for many SPI devices as they
assume spi_setup() return 0 on success and not a positive value.
I've sent a fix for this as:
spi: Fix regression to return zero on success instead of positive value
Regards,
Tony
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH V2] spi: add power control when set_cs
@ 2019-10-30 8:08 Luhua Xu
0 siblings, 0 replies; 4+ messages in thread
From: Luhua Xu @ 2019-10-30 8:08 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: wsd_upstream, linux-kernel, linux-spi, Luhua Xu, linux-mediatek,
linux-arm-kernel
From: "Luhua Xu" <luhua.xu@mediatek.com>
As to set_cs takes effect immediately, power spi
is needed when setup spi.
Signed-off-by: Luhua Xu <luhua.xu@mediatek.com>
---
V2:
- move set_cs PM control from .set_cs callback in
vendor driver to spi_setup in spi framework
drivers/spi/spi.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index f9502db..19007e0 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3091,7 +3091,20 @@ int spi_setup(struct spi_device *spi)
if (spi->controller->setup)
status = spi->controller->setup(spi);
- spi_set_cs(spi, false);
+ if (spi->controller->auto_runtime_pm && spi->controller->set_cs) {
+ status = pm_runtime_get_sync(spi->controller->dev.parent);
+ if (status < 0) {
+ pm_runtime_put_noidle(spi->controller->dev.parent);
+ dev_err(&spi->controller->dev, "Failed to power device: %d\n",
+ status);
+ return status;
+ }
+ spi_set_cs(spi, false);
+ pm_runtime_mark_last_busy(spi->controller->dev.parent);
+ pm_runtime_put_autosuspend(spi->controller->dev.parent);
+ } else {
+ spi_set_cs(spi, false);
+ }
if (spi->rt && !spi->controller->rt) {
spi->controller->rt = true;
--
2.6.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-11 19:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 9:03 [PATCH V2] spi: add power control when set_cs Luhua Xu
2019-10-31 13:23 ` Applied "spi: add power control when set_cs" to the spi tree Mark Brown
2019-11-11 19:54 ` Tony Lindgren
-- strict thread matches above, loose matches on Subject: below --
2019-10-30 8:08 [PATCH V2] spi: add power control when set_cs Luhua Xu
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).