aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiner Kallweit <hkallweit1@gmail.com>2015-09-03 16:39:36 -0400
committerMark Brown <broonie@kernel.org>2015-09-14 13:57:31 -0400
commit483867ee2070e045eb0a18fb7bb2f79d2433339f (patch)
tree8862e8001c3ea6433f4ac0e7e82644ccd623d775
parent3c863792e9b882c9256b4396742a4b257fb9c557 (diff)
spi: s3c64xx: extend driver to make full use of runtime PM autosuspend
Extend the driver to make full use of runtime PM autosuspend. Before only the SPI core was instructed to use autosuspend by setting master->auto_runtime_pm. Nevertheless due to the missing pm_runtime_use_autosuspend call autosuspend wasn't active. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/spi/spi-s3c64xx.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 8a6ab880601a..d117fa638ee3 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -32,6 +32,7 @@
32#define MAX_SPI_PORTS 6 32#define MAX_SPI_PORTS 6
33#define S3C64XX_SPI_QUIRK_POLL (1 << 0) 33#define S3C64XX_SPI_QUIRK_POLL (1 << 0)
34#define S3C64XX_SPI_QUIRK_CS_AUTO (1 << 1) 34#define S3C64XX_SPI_QUIRK_CS_AUTO (1 << 1)
35#define AUTOSUSPEND_TIMEOUT 2000
35 36
36/* Registers and bit-fields */ 37/* Registers and bit-fields */
37 38
@@ -859,13 +860,15 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
859 } 860 }
860 } 861 }
861 862
862 pm_runtime_put(&sdd->pdev->dev); 863 pm_runtime_mark_last_busy(&sdd->pdev->dev);
864 pm_runtime_put_autosuspend(&sdd->pdev->dev);
863 if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) 865 if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO))
864 writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL); 866 writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL);
865 return 0; 867 return 0;
866 868
867setup_exit: 869setup_exit:
868 pm_runtime_put(&sdd->pdev->dev); 870 pm_runtime_mark_last_busy(&sdd->pdev->dev);
871 pm_runtime_put_autosuspend(&sdd->pdev->dev);
869 /* setup() returns with device de-selected */ 872 /* setup() returns with device de-selected */
870 if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) 873 if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO))
871 writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL); 874 writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL);
@@ -1162,6 +1165,12 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
1162 goto err2; 1165 goto err2;
1163 } 1166 }
1164 1167
1168 pm_runtime_set_autosuspend_delay(&pdev->dev, AUTOSUSPEND_TIMEOUT);
1169 pm_runtime_use_autosuspend(&pdev->dev);
1170 pm_runtime_set_active(&pdev->dev);
1171 pm_runtime_enable(&pdev->dev);
1172 pm_runtime_get_sync(&pdev->dev);
1173
1165 /* Setup Deufult Mode */ 1174 /* Setup Deufult Mode */
1166 s3c64xx_spi_hwinit(sdd, sdd->port_id); 1175 s3c64xx_spi_hwinit(sdd, sdd->port_id);
1167 1176
@@ -1180,13 +1189,10 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
1180 S3C64XX_SPI_INT_TX_OVERRUN_EN | S3C64XX_SPI_INT_TX_UNDERRUN_EN, 1189 S3C64XX_SPI_INT_TX_OVERRUN_EN | S3C64XX_SPI_INT_TX_UNDERRUN_EN,
1181 sdd->regs + S3C64XX_SPI_INT_EN); 1190 sdd->regs + S3C64XX_SPI_INT_EN);
1182 1191
1183 pm_runtime_set_active(&pdev->dev);
1184 pm_runtime_enable(&pdev->dev);
1185
1186 ret = devm_spi_register_master(&pdev->dev, master); 1192 ret = devm_spi_register_master(&pdev->dev, master);
1187 if (ret != 0) { 1193 if (ret != 0) {
1188 dev_err(&pdev->dev, "cannot register SPI master: %d\n", ret); 1194 dev_err(&pdev->dev, "cannot register SPI master: %d\n", ret);
1189 goto err4; 1195 goto err3;
1190 } 1196 }
1191 1197
1192 dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n", 1198 dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n",
@@ -1195,12 +1201,16 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
1195 mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1, 1201 mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1,
1196 sdd->rx_dma.dmach, sdd->tx_dma.dmach); 1202 sdd->rx_dma.dmach, sdd->tx_dma.dmach);
1197 1203
1204 pm_runtime_mark_last_busy(&pdev->dev);
1205 pm_runtime_put_autosuspend(&pdev->dev);
1206
1198 return 0; 1207 return 0;
1199 1208
1200err4: 1209err3:
1210 pm_runtime_put_noidle(&pdev->dev);
1201 pm_runtime_disable(&pdev->dev); 1211 pm_runtime_disable(&pdev->dev);
1202 pm_runtime_set_suspended(&pdev->dev); 1212 pm_runtime_set_suspended(&pdev->dev);
1203err3: 1213
1204 clk_disable_unprepare(sdd->src_clk); 1214 clk_disable_unprepare(sdd->src_clk);
1205err2: 1215err2:
1206 clk_disable_unprepare(sdd->clk); 1216 clk_disable_unprepare(sdd->clk);