diff options
-rw-r--r-- | drivers/spi/spi-omap2-mcspi.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index cd87f90588e7..9340974404c4 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c | |||
@@ -260,16 +260,6 @@ static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi) | |||
260 | list_for_each_entry(cs, &ctx->cs, node) | 260 | list_for_each_entry(cs, &ctx->cs, node) |
261 | __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); | 261 | __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); |
262 | } | 262 | } |
263 | static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi) | ||
264 | { | ||
265 | pm_runtime_mark_last_busy(mcspi->dev); | ||
266 | pm_runtime_put_autosuspend(mcspi->dev); | ||
267 | } | ||
268 | |||
269 | static int omap2_mcspi_enable_clocks(struct omap2_mcspi *mcspi) | ||
270 | { | ||
271 | return pm_runtime_get_sync(mcspi->dev); | ||
272 | } | ||
273 | 263 | ||
274 | static int omap2_prepare_transfer(struct spi_master *master) | 264 | static int omap2_prepare_transfer(struct spi_master *master) |
275 | { | 265 | { |
@@ -848,12 +838,13 @@ static int omap2_mcspi_setup(struct spi_device *spi) | |||
848 | return ret; | 838 | return ret; |
849 | } | 839 | } |
850 | 840 | ||
851 | ret = omap2_mcspi_enable_clocks(mcspi); | 841 | ret = pm_runtime_get_sync(mcspi->dev); |
852 | if (ret < 0) | 842 | if (ret < 0) |
853 | return ret; | 843 | return ret; |
854 | 844 | ||
855 | ret = omap2_mcspi_setup_transfer(spi, NULL); | 845 | ret = omap2_mcspi_setup_transfer(spi, NULL); |
856 | omap2_mcspi_disable_clocks(mcspi); | 846 | pm_runtime_mark_last_busy(mcspi->dev); |
847 | pm_runtime_put_autosuspend(mcspi->dev); | ||
857 | 848 | ||
858 | return ret; | 849 | return ret; |
859 | } | 850 | } |
@@ -1067,7 +1058,7 @@ static int __devinit omap2_mcspi_master_setup(struct omap2_mcspi *mcspi) | |||
1067 | struct omap2_mcspi_regs *ctx = &mcspi->ctx; | 1058 | struct omap2_mcspi_regs *ctx = &mcspi->ctx; |
1068 | int ret = 0; | 1059 | int ret = 0; |
1069 | 1060 | ||
1070 | ret = omap2_mcspi_enable_clocks(mcspi); | 1061 | ret = pm_runtime_get_sync(mcspi->dev); |
1071 | if (ret < 0) | 1062 | if (ret < 0) |
1072 | return ret; | 1063 | return ret; |
1073 | 1064 | ||
@@ -1076,7 +1067,8 @@ static int __devinit omap2_mcspi_master_setup(struct omap2_mcspi *mcspi) | |||
1076 | ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN; | 1067 | ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN; |
1077 | 1068 | ||
1078 | omap2_mcspi_set_master_mode(master); | 1069 | omap2_mcspi_set_master_mode(master); |
1079 | omap2_mcspi_disable_clocks(mcspi); | 1070 | pm_runtime_mark_last_busy(mcspi->dev); |
1071 | pm_runtime_put_autosuspend(mcspi->dev); | ||
1080 | return 0; | 1072 | return 0; |
1081 | } | 1073 | } |
1082 | 1074 | ||
@@ -1253,7 +1245,8 @@ static int __devexit omap2_mcspi_remove(struct platform_device *pdev) | |||
1253 | mcspi = spi_master_get_devdata(master); | 1245 | mcspi = spi_master_get_devdata(master); |
1254 | dma_channels = mcspi->dma_channels; | 1246 | dma_channels = mcspi->dma_channels; |
1255 | 1247 | ||
1256 | omap2_mcspi_disable_clocks(mcspi); | 1248 | pm_runtime_mark_last_busy(mcspi->dev); |
1249 | pm_runtime_put_autosuspend(mcspi->dev); | ||
1257 | pm_runtime_disable(&pdev->dev); | 1250 | pm_runtime_disable(&pdev->dev); |
1258 | 1251 | ||
1259 | spi_unregister_master(master); | 1252 | spi_unregister_master(master); |
@@ -1278,7 +1271,7 @@ static int omap2_mcspi_resume(struct device *dev) | |||
1278 | struct omap2_mcspi_regs *ctx = &mcspi->ctx; | 1271 | struct omap2_mcspi_regs *ctx = &mcspi->ctx; |
1279 | struct omap2_mcspi_cs *cs; | 1272 | struct omap2_mcspi_cs *cs; |
1280 | 1273 | ||
1281 | omap2_mcspi_enable_clocks(mcspi); | 1274 | pm_runtime_get_sync(mcspi->dev); |
1282 | list_for_each_entry(cs, &ctx->cs, node) { | 1275 | list_for_each_entry(cs, &ctx->cs, node) { |
1283 | if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE) == 0) { | 1276 | if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE) == 0) { |
1284 | /* | 1277 | /* |
@@ -1291,7 +1284,8 @@ static int omap2_mcspi_resume(struct device *dev) | |||
1291 | __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); | 1284 | __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); |
1292 | } | 1285 | } |
1293 | } | 1286 | } |
1294 | omap2_mcspi_disable_clocks(mcspi); | 1287 | pm_runtime_mark_last_busy(mcspi->dev); |
1288 | pm_runtime_put_autosuspend(mcspi->dev); | ||
1295 | return 0; | 1289 | return 0; |
1296 | } | 1290 | } |
1297 | #else | 1291 | #else |