Commit db3a3d4e authored by Richard Zhao's avatar Richard Zhao Committed by Ben Dooks

i2c: imx: disable clock when it's possible to save power.

Enable clock before START, disable it after STOP.
Signed-off-by: default avatarRichard Zhao <linuxzsc@gmail.com>
Signed-off-by: default avatarBen Dooks <ben-linux@fluff.org>
parent a4094a76
...@@ -121,6 +121,7 @@ struct imx_i2c_struct { ...@@ -121,6 +121,7 @@ struct imx_i2c_struct {
unsigned long i2csr; unsigned long i2csr;
unsigned int disable_delay; unsigned int disable_delay;
int stopped; int stopped;
unsigned int ifdr; /* IMX_I2C_IFDR */
}; };
/** Functions for IMX I2C adapter driver *************************************** /** Functions for IMX I2C adapter driver ***************************************
...@@ -192,6 +193,8 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx) ...@@ -192,6 +193,8 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx)
dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__); dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__);
clk_enable(i2c_imx->clk);
writeb(i2c_imx->ifdr, i2c_imx->base + IMX_I2C_IFDR);
/* Enable I2C controller */ /* Enable I2C controller */
writeb(0, i2c_imx->base + IMX_I2C_I2SR); writeb(0, i2c_imx->base + IMX_I2C_I2SR);
writeb(I2CR_IEN, i2c_imx->base + IMX_I2C_I2CR); writeb(I2CR_IEN, i2c_imx->base + IMX_I2C_I2CR);
...@@ -238,6 +241,7 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx) ...@@ -238,6 +241,7 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx)
/* Disable I2C controller */ /* Disable I2C controller */
writeb(0, i2c_imx->base + IMX_I2C_I2CR); writeb(0, i2c_imx->base + IMX_I2C_I2CR);
clk_disable(i2c_imx->clk);
} }
static void __init i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx, static void __init i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
...@@ -257,8 +261,8 @@ static void __init i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx, ...@@ -257,8 +261,8 @@ static void __init i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
else else
for (i = 0; i2c_clk_div[i][0] < div; i++); for (i = 0; i2c_clk_div[i][0] < div; i++);
/* Write divider value to register */ /* Store divider value */
writeb(i2c_clk_div[i][1], i2c_imx->base + IMX_I2C_IFDR); i2c_imx->ifdr = i2c_clk_div[i][1];
/* /*
* There dummy delay is calculated. * There dummy delay is calculated.
...@@ -528,7 +532,6 @@ static int __init i2c_imx_probe(struct platform_device *pdev) ...@@ -528,7 +532,6 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "can't get I2C clock\n"); dev_err(&pdev->dev, "can't get I2C clock\n");
goto fail3; goto fail3;
} }
clk_enable(i2c_imx->clk);
/* Request IRQ */ /* Request IRQ */
ret = request_irq(i2c_imx->irq, i2c_imx_isr, 0, pdev->name, i2c_imx); ret = request_irq(i2c_imx->irq, i2c_imx_isr, 0, pdev->name, i2c_imx);
...@@ -577,7 +580,6 @@ static int __init i2c_imx_probe(struct platform_device *pdev) ...@@ -577,7 +580,6 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
fail5: fail5:
free_irq(i2c_imx->irq, i2c_imx); free_irq(i2c_imx->irq, i2c_imx);
fail4: fail4:
clk_disable(i2c_imx->clk);
clk_put(i2c_imx->clk); clk_put(i2c_imx->clk);
fail3: fail3:
release_mem_region(i2c_imx->res->start, resource_size(res)); release_mem_region(i2c_imx->res->start, resource_size(res));
...@@ -614,8 +616,6 @@ static int __exit i2c_imx_remove(struct platform_device *pdev) ...@@ -614,8 +616,6 @@ static int __exit i2c_imx_remove(struct platform_device *pdev)
if (pdata && pdata->exit) if (pdata && pdata->exit)
pdata->exit(&pdev->dev); pdata->exit(&pdev->dev);
/* Disable I2C clock */
clk_disable(i2c_imx->clk);
clk_put(i2c_imx->clk); clk_put(i2c_imx->clk);
release_mem_region(i2c_imx->res->start, resource_size(i2c_imx->res)); release_mem_region(i2c_imx->res->start, resource_size(i2c_imx->res));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment