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>
This commit is contained in:
@@ -250,6 +250,8 @@ static int init_hw(struct nmk_i2c_dev *dev)
|
|||||||
{
|
{
|
||||||
int stat;
|
int stat;
|
||||||
|
|
||||||
|
clk_enable(dev->clk);
|
||||||
|
|
||||||
stat = flush_i2c_fifo(dev);
|
stat = flush_i2c_fifo(dev);
|
||||||
if (stat)
|
if (stat)
|
||||||
return stat;
|
return stat;
|
||||||
@@ -263,6 +265,8 @@ static int init_hw(struct nmk_i2c_dev *dev)
|
|||||||
|
|
||||||
dev->cli.operation = I2C_NO_OPERATION;
|
dev->cli.operation = I2C_NO_OPERATION;
|
||||||
|
|
||||||
|
clk_disable(dev->clk);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,6 +562,8 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
|
|||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
clk_enable(dev->clk);
|
||||||
|
|
||||||
/* setup the i2c controller */
|
/* setup the i2c controller */
|
||||||
setup_i2c_controller(dev);
|
setup_i2c_controller(dev);
|
||||||
|
|
||||||
@@ -590,10 +596,13 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
|
|||||||
dev_err(&dev->pdev->dev, "%s\n",
|
dev_err(&dev->pdev->dev, "%s\n",
|
||||||
cause >= ARRAY_SIZE(abort_causes)
|
cause >= ARRAY_SIZE(abort_causes)
|
||||||
? "unknown reason" : abort_causes[cause]);
|
? "unknown reason" : abort_causes[cause]);
|
||||||
|
clk_disable(dev->clk);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
mdelay(1);
|
mdelay(1);
|
||||||
}
|
}
|
||||||
|
clk_disable(dev->clk);
|
||||||
|
|
||||||
/* return the no. messages processed */
|
/* return the no. messages processed */
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
@@ -857,8 +866,6 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev)
|
|||||||
goto err_no_clk;
|
goto err_no_clk;
|
||||||
}
|
}
|
||||||
|
|
||||||
clk_enable(dev->clk);
|
|
||||||
|
|
||||||
adap = &dev->adap;
|
adap = &dev->adap;
|
||||||
adap->dev.parent = &pdev->dev;
|
adap->dev.parent = &pdev->dev;
|
||||||
adap->owner = THIS_MODULE;
|
adap->owner = THIS_MODULE;
|
||||||
@@ -895,7 +902,6 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_init_hw:
|
err_init_hw:
|
||||||
clk_disable(dev->clk);
|
|
||||||
err_add_adap:
|
err_add_adap:
|
||||||
clk_put(dev->clk);
|
clk_put(dev->clk);
|
||||||
err_no_clk:
|
err_no_clk:
|
||||||
@@ -928,7 +934,6 @@ static int __devexit nmk_i2c_remove(struct platform_device *pdev)
|
|||||||
iounmap(dev->virtbase);
|
iounmap(dev->virtbase);
|
||||||
if (res)
|
if (res)
|
||||||
release_mem_region(res->start, resource_size(res));
|
release_mem_region(res->start, resource_size(res));
|
||||||
clk_disable(dev->clk);
|
|
||||||
clk_put(dev->clk);
|
clk_put(dev->clk);
|
||||||
platform_set_drvdata(pdev, NULL);
|
platform_set_drvdata(pdev, NULL);
|
||||||
kfree(dev);
|
kfree(dev);
|
||||||
|
Reference in New Issue
Block a user