From: Luhua Xu <luhua.xu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
To: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Matthias Brugger
<matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: wsd_upstream-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
luhua.xu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org,
linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: [PATCH 1/1] spi: mediatek: add power control when set_cs
Date: Wed, 23 Oct 2019 08:38:42 -0400 [thread overview]
Message-ID: <1571834322-1121-2-git-send-email-luhua.xu@mediatek.com> (raw)
In-Reply-To: <1571834322-1121-1-git-send-email-luhua.xu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
From: "luhua.xu" <luhua.xu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
Use runtime PM to power spi when set_cs
As set_cs may be called from interrupt context,
set runtime PM IRQ safe for spi.
Signed-off-by: luhua.xu <luhua.xu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
drivers/spi/spi-mt65xx.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
index 6888a4d..039b67d 100644
--- a/drivers/spi/spi-mt65xx.c
+++ b/drivers/spi/spi-mt65xx.c
@@ -262,8 +262,16 @@ static int mtk_spi_prepare_message(struct spi_master *master,
static void mtk_spi_set_cs(struct spi_device *spi, bool enable)
{
u32 reg_val;
+ int ret;
struct mtk_spi *mdata = spi_master_get_devdata(spi->master);
+ ret = pm_runtime_get_sync(spi->master->dev.parent);
+ if (ret < 0) {
+ pm_runtime_put_noidle(spi->master->dev.parent);
+ dev_err(&spi->dev, "failed to power device(%d)\n", ret);
+ return;
+ }
+
reg_val = readl(mdata->base + SPI_CMD_REG);
if (!enable) {
reg_val |= SPI_CMD_PAUSE_EN;
@@ -274,6 +282,9 @@ static void mtk_spi_set_cs(struct spi_device *spi, bool enable)
mdata->state = MTK_SPI_IDLE;
mtk_spi_reset(mdata);
}
+
+ pm_runtime_mark_last_busy(spi->master->dev.parent);
+ pm_runtime_put_autosuspend(spi->master->dev.parent);
}
static void mtk_spi_prepare_transfer(struct spi_master *master,
@@ -749,6 +760,7 @@ static int mtk_spi_probe(struct platform_device *pdev)
clk_disable_unprepare(mdata->spi_clk);
pm_runtime_enable(&pdev->dev);
+ pm_runtime_irq_safe(&pdev->dev);
ret = devm_spi_register_master(&pdev->dev, master);
if (ret) {
--
2.6.4
next prev parent reply other threads:[~2019-10-23 12:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-23 12:38 [PATCH 0/1] Add spi power control when set cs Luhua Xu
[not found] ` <1571834322-1121-1-git-send-email-luhua.xu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2019-10-23 12:38 ` Luhua Xu [this message]
2019-10-23 15:11 ` [PATCH 1/1] spi: mediatek: add power control when set_cs Mark Brown
2019-10-24 6:25 ` luhua xu
2019-10-24 10:11 ` luhua xu
2019-10-24 11:19 ` Mark Brown
2019-10-24 10:23 ` Mark Brown
2019-10-23 15:11 ` [PATCH 0/1] Add spi power control when set cs 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=1571834322-1121-2-git-send-email-luhua.xu@mediatek.com \
--to=luhua.xu-nus5lvnupcjwk0htik3j/w@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=wsd_upstream-NuS5LvNUpcJWk0Htik3J/w@public.gmane.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;
as well as URLs for NNTP newsgroup(s).