summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/spi/spi-tegra.c93
1 files changed, 20 insertions, 73 deletions
diff --git a/drivers/spi/spi-tegra.c b/drivers/spi/spi-tegra.c
index 836b95e2d281..5fca5e62706c 100644
--- a/drivers/spi/spi-tegra.c
+++ b/drivers/spi/spi-tegra.c
@@ -42,8 +42,6 @@
#include <mach/dma.h>
#include <mach/clk.h>
-#define SPI_PM_RUNTIME_ENABLE 0
-
#define SLINK_COMMAND 0x000
#define SLINK_BIT_LENGTH(x) (((x) & 0x1f) << 0)
#define SLINK_WORD_SIZE(x) (((x) & 0x1f) << 5)
@@ -249,9 +247,6 @@ struct spi_tegra_data {
struct work_struct spi_transfer_work;
};
-static int tegra_spi_runtime_idle(struct device *dev);
-static int tegra_spi_runtime_resume(struct device *dev);
-
static inline unsigned long spi_tegra_readl(struct spi_tegra_data *tspi,
unsigned long reg)
{
@@ -308,22 +303,6 @@ static int tegra_spi_clk_enable(struct spi_tegra_data *tspi)
return 0;
}
-#if SPI_PM_RUNTIME_ENABLE
-#define spi_pm_runtime_get_sync(dev) pm_runtime_get_sync(dev)
-#define spi_pm_runtime_put_sync(dev) pm_runtime_put_sync(dev)
-#define spi_pm_runtime_enable(dev) pm_runtime_enable(dev)
-#define spi_pm_runtime_disable(dev) pm_runtime_disable(dev)
-#define spi_pm_runtime_enabled(dev) pm_runtime_enabled(dev)
-#define spi_pm_runtime_status_suspended(dev) pm_runtime_status_suspended(dev)
-#else
-#define spi_pm_runtime_get_sync(dev) tegra_spi_runtime_resume(dev)
-#define spi_pm_runtime_put_sync(dev) tegra_spi_runtime_idle(dev)
-#define spi_pm_runtime_enable(dev) do { } while(0)
-#define spi_pm_runtime_disable(dev) do { } while(0)
-#define spi_pm_runtime_enabled(dev) true
-#define spi_pm_runtime_status_suspended(dev) true
-#endif
-
static void cancel_dma(struct tegra_dma_channel *dma_chan,
struct tegra_dma_req *req)
{
@@ -794,12 +773,8 @@ static void spi_tegra_start_transfer(struct spi_device *spi,
command2 = tspi->def_command2_reg;
if (is_first_of_msg) {
- if ((ret = spi_pm_runtime_get_sync(&tspi->pdev->dev)) < 0) {
- dev_err(&tspi->pdev->dev,
- "%s: spi_pm_runtime_get_sync() returns %d\n",
- __func__, ret);
- return;
- }
+ pm_runtime_get_sync(&tspi->pdev->dev);
+ tegra_spi_clk_enable(tspi);
spi_tegra_clear_status(tspi);
@@ -911,7 +886,8 @@ static int spi_tegra_setup(struct spi_device *spi)
return -EINVAL;
}
- spi_pm_runtime_get_sync(&tspi->pdev->dev);
+ pm_runtime_get_sync(&tspi->pdev->dev);
+ tegra_spi_clk_enable(tspi);
spin_lock_irqsave(&tspi->lock, flags);
val = tspi->def_command_reg;
@@ -923,7 +899,8 @@ static int spi_tegra_setup(struct spi_device *spi)
spi_tegra_writel(tspi, tspi->def_command_reg, SLINK_COMMAND);
spin_unlock_irqrestore(&tspi->lock, flags);
- spi_pm_runtime_put_sync(&tspi->pdev->dev);
+ tegra_spi_clk_disable(tspi);
+ pm_runtime_put_sync(&tspi->pdev->dev);
return 0;
}
@@ -1073,7 +1050,8 @@ static void spi_tegra_curr_transfer_complete(struct spi_tegra_data *tspi,
/* Provide delay to stablize the signal state */
spin_unlock_irqrestore(&tspi->lock, *irq_flags);
udelay(10);
- spi_pm_runtime_put_sync(&tspi->pdev->dev);
+ tegra_spi_clk_disable(tspi);
+ pm_runtime_put_sync(&tspi->pdev->dev);
spin_lock_irqsave(&tspi->lock, *irq_flags);
tspi->is_transfer_in_progress = false;
/* Check if any new request has come between
@@ -1479,18 +1457,11 @@ static int __init spi_tegra_probe(struct platform_device *pdev)
tspi->def_command2_reg = SLINK_CS_ACTIVE_BETWEEN;
skip_dma_alloc:
- spi_pm_runtime_enable(&pdev->dev);
- if (!spi_pm_runtime_enabled(&pdev->dev)) {
- ret = tegra_spi_runtime_resume(&pdev->dev);
- if (ret) {
- dev_err(&pdev->dev, "runtime resume failed %d", ret);
- goto exit_pm_disable;
- }
- }
+ pm_runtime_enable(&pdev->dev);
/* Enable clock if it is require to be enable always */
if (tspi->is_clkon_always)
- spi_pm_runtime_get_sync(&pdev->dev);
+ tegra_spi_clk_enable(tspi);
/* create the workqueue for the spi transfer */
snprintf(spi_wq_name, sizeof(spi_wq_name), "spi_tegra-%d", pdev->id);
@@ -1517,13 +1488,9 @@ exit_destry_wq:
exit_fail_wq:
if (tspi->is_clkon_always)
- spi_pm_runtime_put_sync(&pdev->dev);
-
- if (!spi_pm_runtime_status_suspended(&pdev->dev))
- tegra_spi_runtime_idle(&pdev->dev);
+ tegra_spi_clk_disable(tspi);
-exit_pm_disable:
- spi_pm_runtime_disable(&pdev->dev);
+ pm_runtime_disable(&pdev->dev);
spi_tegra_deinit_dma_param(tspi, false);
@@ -1553,11 +1520,9 @@ static int __devexit spi_tegra_remove(struct platform_device *pdev)
/* Disable clock if it is always enabled */
if (tspi->is_clkon_always)
- spi_pm_runtime_put_sync(&pdev->dev);
+ tegra_spi_clk_disable(tspi);
- spi_pm_runtime_disable(&pdev->dev);
- if (!spi_pm_runtime_status_suspended(&pdev->dev))
- tegra_spi_runtime_idle(&pdev->dev);
+ pm_runtime_disable(&pdev->dev);
destroy_workqueue(tspi->spi_workqueue);
@@ -1612,7 +1577,7 @@ static int spi_tegra_suspend(struct device *dev)
/* Disable clock if it is always enabled */
if (tspi->is_clkon_always)
- spi_pm_runtime_put_sync(dev);
+ tegra_spi_clk_disable(tspi);
return 0;
}
@@ -1629,11 +1594,13 @@ static int spi_tegra_resume(struct device *dev)
/* Enable clock if it is always enabled */
if (tspi->is_clkon_always)
- spi_pm_runtime_get_sync(dev);
+ tegra_spi_clk_enable(tspi);
- spi_pm_runtime_get_sync(dev);
+ pm_runtime_get_sync(dev);
+ tegra_spi_clk_enable(tspi);
spi_tegra_writel(tspi, tspi->command_reg, SLINK_COMMAND);
- spi_pm_runtime_put_sync(dev);
+ tegra_spi_clk_disable(tspi);
+ pm_runtime_put_sync(dev);
spin_lock_irqsave(&tspi->lock, flags);
@@ -1656,27 +1623,7 @@ static int spi_tegra_resume(struct device *dev)
}
#endif
-static int tegra_spi_runtime_idle(struct device *dev)
-{
- struct spi_master *master = dev_get_drvdata(dev);
- struct spi_tegra_data *tspi = spi_master_get_devdata(master);
-
- return tegra_spi_clk_disable(tspi);
-}
-
-static int tegra_spi_runtime_resume(struct device *dev)
-{
- struct spi_master *master = dev_get_drvdata(dev);
- struct spi_tegra_data *tspi = spi_master_get_devdata(master);
-
- return tegra_spi_clk_enable(tspi);
-}
-
static const struct dev_pm_ops tegra_spi_dev_pm_ops = {
-#if defined(CONFIG_PM_RUNTIME)
- .runtime_idle = tegra_spi_runtime_idle,
- .runtime_resume = tegra_spi_runtime_resume,
-#endif
#ifdef CONFIG_PM
.suspend = spi_tegra_suspend,
.resume = spi_tegra_resume,