diff options
author | Richard Zhao <linuxzsc@gmail.com> | 2009-10-17 05:46:24 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2009-11-02 18:28:47 -0500 |
commit | db3a3d4ef7f676501325ae9c7ce0c193c2c1b28f (patch) | |
tree | 811858ab7f415c9e584d0704d0e8c234cd67d9c7 /drivers/i2c | |
parent | a4094a76e6a45691b8f9108060b750a48b4c4563 (diff) |
i2c: imx: disable clock when it's possible to save power.
Enable clock before START, disable it after STOP.
Signed-off-by: Richard Zhao <linuxzsc@gmail.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-imx.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 671d37c23f4c..e3654d683e15 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c | |||
@@ -121,6 +121,7 @@ struct imx_i2c_struct { | |||
121 | unsigned long i2csr; | 121 | unsigned long i2csr; |
122 | unsigned int disable_delay; | 122 | unsigned int disable_delay; |
123 | int stopped; | 123 | int stopped; |
124 | unsigned int ifdr; /* IMX_I2C_IFDR */ | ||
124 | }; | 125 | }; |
125 | 126 | ||
126 | /** Functions for IMX I2C adapter driver *************************************** | 127 | /** Functions for IMX I2C adapter driver *************************************** |
@@ -192,6 +193,8 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx) | |||
192 | 193 | ||
193 | dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__); | 194 | dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__); |
194 | 195 | ||
196 | clk_enable(i2c_imx->clk); | ||
197 | writeb(i2c_imx->ifdr, i2c_imx->base + IMX_I2C_IFDR); | ||
195 | /* Enable I2C controller */ | 198 | /* Enable I2C controller */ |
196 | writeb(0, i2c_imx->base + IMX_I2C_I2SR); | 199 | writeb(0, i2c_imx->base + IMX_I2C_I2SR); |
197 | writeb(I2CR_IEN, i2c_imx->base + IMX_I2C_I2CR); | 200 | 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 | 241 | ||
239 | /* Disable I2C controller */ | 242 | /* Disable I2C controller */ |
240 | writeb(0, i2c_imx->base + IMX_I2C_I2CR); | 243 | writeb(0, i2c_imx->base + IMX_I2C_I2CR); |
244 | clk_disable(i2c_imx->clk); | ||
241 | } | 245 | } |
242 | 246 | ||
243 | static void __init i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx, | 247 | 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 | else | 261 | else |
258 | for (i = 0; i2c_clk_div[i][0] < div; i++); | 262 | for (i = 0; i2c_clk_div[i][0] < div; i++); |
259 | 263 | ||
260 | /* Write divider value to register */ | 264 | /* Store divider value */ |
261 | writeb(i2c_clk_div[i][1], i2c_imx->base + IMX_I2C_IFDR); | 265 | i2c_imx->ifdr = i2c_clk_div[i][1]; |
262 | 266 | ||
263 | /* | 267 | /* |
264 | * There dummy delay is calculated. | 268 | * There dummy delay is calculated. |
@@ -528,7 +532,6 @@ static int __init i2c_imx_probe(struct platform_device *pdev) | |||
528 | dev_err(&pdev->dev, "can't get I2C clock\n"); | 532 | dev_err(&pdev->dev, "can't get I2C clock\n"); |
529 | goto fail3; | 533 | goto fail3; |
530 | } | 534 | } |
531 | clk_enable(i2c_imx->clk); | ||
532 | 535 | ||
533 | /* Request IRQ */ | 536 | /* Request IRQ */ |
534 | ret = request_irq(i2c_imx->irq, i2c_imx_isr, 0, pdev->name, i2c_imx); | 537 | 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 | fail5: | 580 | fail5: |
578 | free_irq(i2c_imx->irq, i2c_imx); | 581 | free_irq(i2c_imx->irq, i2c_imx); |
579 | fail4: | 582 | fail4: |
580 | clk_disable(i2c_imx->clk); | ||
581 | clk_put(i2c_imx->clk); | 583 | clk_put(i2c_imx->clk); |
582 | fail3: | 584 | fail3: |
583 | release_mem_region(i2c_imx->res->start, resource_size(res)); | 585 | 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 | if (pdata && pdata->exit) | 616 | if (pdata && pdata->exit) |
615 | pdata->exit(&pdev->dev); | 617 | pdata->exit(&pdev->dev); |
616 | 618 | ||
617 | /* Disable I2C clock */ | ||
618 | clk_disable(i2c_imx->clk); | ||
619 | clk_put(i2c_imx->clk); | 619 | clk_put(i2c_imx->clk); |
620 | 620 | ||
621 | release_mem_region(i2c_imx->res->start, resource_size(i2c_imx->res)); | 621 | release_mem_region(i2c_imx->res->start, resource_size(i2c_imx->res)); |