diff options
author | Linus Walleij <linus.walleij@stericsson.com> | 2010-09-23 03:03:55 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2010-10-24 21:40:38 -0400 |
commit | 8ef4f4e4afd55b6015d5b283172d240e22c91854 (patch) | |
tree | 5769f2ba31054d8053080f52822233103595533b /drivers/i2c | |
parent | 1804edd15c66a7af11f9e6194b4c783b37c5fe98 (diff) |
i2c-nomadik: dynamic clocking
This makes sure the Nomadik I2C bus driver silicon is only clocked
when really needed, saving some microamps here and there when
there is no I2C traffic.
Acked-by: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Signed-off-by: Sundar R Iyer <sundar.iyer@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-nomadik.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index a73c057f63fd..b2dbf7c468af 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c | |||
@@ -250,6 +250,8 @@ static int init_hw(struct nmk_i2c_dev *dev) | |||
250 | { | 250 | { |
251 | int stat; | 251 | int stat; |
252 | 252 | ||
253 | clk_enable(dev->clk); | ||
254 | |||
253 | stat = flush_i2c_fifo(dev); | 255 | stat = flush_i2c_fifo(dev); |
254 | if (stat) | 256 | if (stat) |
255 | return stat; | 257 | return stat; |
@@ -263,6 +265,8 @@ static int init_hw(struct nmk_i2c_dev *dev) | |||
263 | 265 | ||
264 | dev->cli.operation = I2C_NO_OPERATION; | 266 | dev->cli.operation = I2C_NO_OPERATION; |
265 | 267 | ||
268 | clk_disable(dev->clk); | ||
269 | |||
266 | return 0; | 270 | return 0; |
267 | } | 271 | } |
268 | 272 | ||
@@ -558,6 +562,8 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
558 | if (status) | 562 | if (status) |
559 | return status; | 563 | return status; |
560 | 564 | ||
565 | clk_enable(dev->clk); | ||
566 | |||
561 | /* setup the i2c controller */ | 567 | /* setup the i2c controller */ |
562 | setup_i2c_controller(dev); | 568 | setup_i2c_controller(dev); |
563 | 569 | ||
@@ -590,10 +596,13 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
590 | dev_err(&dev->pdev->dev, "%s\n", | 596 | dev_err(&dev->pdev->dev, "%s\n", |
591 | cause >= ARRAY_SIZE(abort_causes) | 597 | cause >= ARRAY_SIZE(abort_causes) |
592 | ? "unknown reason" : abort_causes[cause]); | 598 | ? "unknown reason" : abort_causes[cause]); |
599 | clk_disable(dev->clk); | ||
593 | return status; | 600 | return status; |
594 | } | 601 | } |
595 | mdelay(1); | 602 | mdelay(1); |
596 | } | 603 | } |
604 | clk_disable(dev->clk); | ||
605 | |||
597 | /* return the no. messages processed */ | 606 | /* return the no. messages processed */ |
598 | if (status) | 607 | if (status) |
599 | return status; | 608 | return status; |
@@ -857,8 +866,6 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev) | |||
857 | goto err_no_clk; | 866 | goto err_no_clk; |
858 | } | 867 | } |
859 | 868 | ||
860 | clk_enable(dev->clk); | ||
861 | |||
862 | adap = &dev->adap; | 869 | adap = &dev->adap; |
863 | adap->dev.parent = &pdev->dev; | 870 | adap->dev.parent = &pdev->dev; |
864 | adap->owner = THIS_MODULE; | 871 | adap->owner = THIS_MODULE; |
@@ -895,7 +902,6 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev) | |||
895 | return 0; | 902 | return 0; |
896 | 903 | ||
897 | err_init_hw: | 904 | err_init_hw: |
898 | clk_disable(dev->clk); | ||
899 | err_add_adap: | 905 | err_add_adap: |
900 | clk_put(dev->clk); | 906 | clk_put(dev->clk); |
901 | err_no_clk: | 907 | err_no_clk: |
@@ -928,7 +934,6 @@ static int __devexit nmk_i2c_remove(struct platform_device *pdev) | |||
928 | iounmap(dev->virtbase); | 934 | iounmap(dev->virtbase); |
929 | if (res) | 935 | if (res) |
930 | release_mem_region(res->start, resource_size(res)); | 936 | release_mem_region(res->start, resource_size(res)); |
931 | clk_disable(dev->clk); | ||
932 | clk_put(dev->clk); | 937 | clk_put(dev->clk); |
933 | platform_set_drvdata(pdev, NULL); | 938 | platform_set_drvdata(pdev, NULL); |
934 | kfree(dev); | 939 | kfree(dev); |