Commit db3a3d4ef7f676501325ae9c7ce0c193c2c1b28f
Committed by
Ben Dooks
1 parent
a4094a76e6
Exists in
master
and in
4 other branches
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>
Showing 1 changed file with 6 additions and 6 deletions Side-by-side Diff
drivers/i2c/busses/i2c-imx.c
... | ... | @@ -121,6 +121,7 @@ |
121 | 121 | unsigned long i2csr; |
122 | 122 | unsigned int disable_delay; |
123 | 123 | int stopped; |
124 | + unsigned int ifdr; /* IMX_I2C_IFDR */ | |
124 | 125 | }; |
125 | 126 | |
126 | 127 | /** Functions for IMX I2C adapter driver *************************************** |
... | ... | @@ -192,6 +193,8 @@ |
192 | 193 | |
193 | 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 | 198 | /* Enable I2C controller */ |
196 | 199 | writeb(0, i2c_imx->base + IMX_I2C_I2SR); |
197 | 200 | writeb(I2CR_IEN, i2c_imx->base + IMX_I2C_I2CR); |
... | ... | @@ -238,6 +241,7 @@ |
238 | 241 | |
239 | 242 | /* Disable I2C controller */ |
240 | 243 | writeb(0, i2c_imx->base + IMX_I2C_I2CR); |
244 | + clk_disable(i2c_imx->clk); | |
241 | 245 | } |
242 | 246 | |
243 | 247 | static void __init i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx, |
... | ... | @@ -257,8 +261,8 @@ |
257 | 261 | else |
258 | 262 | for (i = 0; i2c_clk_div[i][0] < div; i++); |
259 | 263 | |
260 | - /* Write divider value to register */ | |
261 | - writeb(i2c_clk_div[i][1], i2c_imx->base + IMX_I2C_IFDR); | |
264 | + /* Store divider value */ | |
265 | + i2c_imx->ifdr = i2c_clk_div[i][1]; | |
262 | 266 | |
263 | 267 | /* |
264 | 268 | * There dummy delay is calculated. |
... | ... | @@ -528,7 +532,6 @@ |
528 | 532 | dev_err(&pdev->dev, "can't get I2C clock\n"); |
529 | 533 | goto fail3; |
530 | 534 | } |
531 | - clk_enable(i2c_imx->clk); | |
532 | 535 | |
533 | 536 | /* Request IRQ */ |
534 | 537 | ret = request_irq(i2c_imx->irq, i2c_imx_isr, 0, pdev->name, i2c_imx); |
... | ... | @@ -577,7 +580,6 @@ |
577 | 580 | fail5: |
578 | 581 | free_irq(i2c_imx->irq, i2c_imx); |
579 | 582 | fail4: |
580 | - clk_disable(i2c_imx->clk); | |
581 | 583 | clk_put(i2c_imx->clk); |
582 | 584 | fail3: |
583 | 585 | release_mem_region(i2c_imx->res->start, resource_size(res)); |
... | ... | @@ -614,8 +616,6 @@ |
614 | 616 | if (pdata && pdata->exit) |
615 | 617 | pdata->exit(&pdev->dev); |
616 | 618 | |
617 | - /* Disable I2C clock */ | |
618 | - clk_disable(i2c_imx->clk); | |
619 | 619 | clk_put(i2c_imx->clk); |
620 | 620 | |
621 | 621 | release_mem_region(i2c_imx->res->start, resource_size(i2c_imx->res)); |