diff options
author | Chaitanya Bandi <bandik@nvidia.com> | 2011-10-24 17:10:27 +0530 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2011-11-30 21:49:48 -0800 |
commit | e1f0b5d69f5ad86b96285361eeb49ec03e54799e (patch) | |
tree | d265926b78ac2b991c69c4588278749fe1867b16 /drivers/i2c | |
parent | c37dc757daf8e981b6511b4e3ed82dd8705af6ec (diff) |
i2c: tegra: slave: Add runtime PM support
Add runtime PM support for i2c slave.
Bug: 886802
Change-Id: I6649ab7e7b2e528d755e0a7167247a5a4440ef2f
Reviewed-on: http://git-master/r/59928
Tested-by: Bandi Krishna Chaitanya <bandik@nvidia.com>
Reviewed-by: Venu Byravarasu <vbyravarasu@nvidia.com>
Reviewed-by: Peter De Schrijver <pdeschrijver@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Rebase-Id: R3db59ff198a0d124c3f8fe60b592630207e7ef80
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-slave-tegra.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/drivers/i2c/busses/i2c-slave-tegra.c b/drivers/i2c/busses/i2c-slave-tegra.c index 03d782fac910..1e1e516b6415 100644 --- a/drivers/i2c/busses/i2c-slave-tegra.c +++ b/drivers/i2c/busses/i2c-slave-tegra.c @@ -33,7 +33,7 @@ #include <asm/unaligned.h> #include <mach/clk.h> #include <mach/pinmux.h> - +#include <linux/pm_runtime.h> #define BYTES_PER_FIFO_WORD 4 #define to_jiffies(msecs) msecs_to_jiffies(msecs) @@ -650,7 +650,7 @@ static int tegra_i2c_slave_start(struct i2c_slave_adapter *slv_adap, int addr, get_packet_headers(i2c_dev, 4096, 0, &i2c_dev->rx_pack_hdr1, &i2c_dev->rx_pack_hdr2, &i2c_dev->rx_pack_hdr3); - clk_enable(i2c_dev->clk); + pm_runtime_get_sync(i2c_dev->dev); configure_i2c_slave_packet_mode(i2c_dev); configure_i2c_slave_address(i2c_dev); do_tx_fifo_empty(i2c_dev, NULL); @@ -690,7 +690,7 @@ static void tegra_i2c_slave_stop(struct i2c_slave_adapter *slv_adap, writel(0, i2c_dev->base + I2C_INT_MASK); i2c_dev->curr_transfer = 0; i2c_dev->is_slave_started = false; - clk_disable(i2c_dev->clk); + pm_runtime_put_sync(i2c_dev->dev); if (is_buffer_clear) { i2c_dev->rx_msg_head = 0; i2c_dev->rx_msg_tail = 0; @@ -1018,6 +1018,7 @@ static int tegra_i2c_slave_probe(struct platform_device *pdev) } i2c_set_slave_adapdata(&i2c_bus->slv_adap, i2c_bus); dev_dbg(&pdev->dev, "%s() suucess\n", __func__); + pm_runtime_enable(i2c_dev->dev); return 0; err_free_irq: @@ -1039,6 +1040,7 @@ static int tegra_i2c_slave_remove(struct platform_device *pdev) struct tegra_i2c_slave_dev *i2c_dev = platform_get_drvdata(pdev); i2c_del_slave_adapter(&i2c_dev->bus.slv_adap); + pm_runtime_disable(i2c_dev->dev); free_irq(i2c_dev->irq, i2c_dev); clk_put(i2c_dev->clk); release_mem_region(i2c_dev->iomem->start, @@ -1060,6 +1062,26 @@ static int tegra_i2c_slave_resume(struct platform_device *pdev) return 0; } #endif +#if defined(CONFIG_PM_RUNTIME) +static int tegra_i2c_slave_runtime_idle(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct tegra_i2c_slave_dev *i2c_dev = platform_get_drvdata(pdev); + clk_disable(i2c_dev->clk); + return 0; +} +static int tegra_i2c_slave_runtime_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct tegra_i2c_slave_dev *i2c_dev = platform_get_drvdata(pdev); + clk_enable(i2c_dev->clk); + return 0; +} +static const struct dev_pm_ops tegra_i2c_slave_dev_pm_ops = { + .runtime_idle = tegra_i2c_slave_runtime_idle, + .runtime_resume = tegra_i2c_slave_runtime_resume, +}; +#endif static struct platform_driver tegra_i2c_slave_driver = { .probe = tegra_i2c_slave_probe, @@ -1071,6 +1093,9 @@ static struct platform_driver tegra_i2c_slave_driver = { .driver = { .name = "tegra-i2c-slave", .owner = THIS_MODULE, +#if defined(CONFIG_PM_RUNTIME) + .pm = &tegra_i2c_slave_dev_pm_ops, +#endif }, }; |