[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1571834322-1121-2-git-send-email-luhua.xu@mediatek.com>
Date: Wed, 23 Oct 2019 08:38:42 -0400
From: Luhua Xu <luhua.xu@...iatek.com>
To: Mark Brown <broonie@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>
CC: <linux-spi@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-mediatek@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <wsd_upstream@...iatek.com>,
<luhua.xu@...iatek.com>
Subject: [PATCH 1/1] spi: mediatek: add power control when set_cs
From: "luhua.xu" <luhua.xu@...iatek.com>
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@...iatek.com>
---
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
Powered by blists - more mailing lists