From 1804edd15c66a7af11f9e6194b4c783b37c5fe98 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 23 Sep 2010 09:03:40 +0200 Subject: i2c-nomadik: documentation fixes This fixes some kerneldoc and assorted documenatation in the Nomadik I2C driver without semantic impact. Acked-by: Srinidhi Kasagar Signed-off-by: Sundar R Iyer Signed-off-by: Linus Walleij Signed-off-by: Ben Dooks --- drivers/i2c/busses/i2c-nomadik.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/i2c') diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 73de8ade10b1..a73c057f63fd 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 ST-Ericsson + * Copyright (C) 2009 ST-Ericsson SA * Copyright (C) 2009 STMicroelectronics * * I2C master mode controller driver, used in Nomadik 8815 @@ -431,7 +431,6 @@ static int read_i2c(struct nmk_i2c_dev *dev) (void) init_hw(dev); status = -ETIMEDOUT; } - return status; } @@ -502,9 +501,9 @@ static int write_i2c(struct nmk_i2c_dev *dev) /** * nmk_i2c_xfer() - I2C transfer function used by kernel framework - * @i2c_adap - Adapter pointer to the controller - * @msgs[] - Pointer to data to be written. - * @num_msgs - Number of messages to be executed + * @i2c_adap: Adapter pointer to the controller + * @msgs: Pointer to data to be written. + * @num_msgs: Number of messages to be executed * * This is the function called by the generic kernel i2c_transfer() * or i2c_smbus...() API calls. Note that this code is protected by the @@ -605,6 +604,7 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, /** * disable_interrupts() - disable the interrupts * @dev: private data of controller + * @irq: interrupt number */ static int disable_interrupts(struct nmk_i2c_dev *dev, u32 irq) { -- cgit v1.2.2 From 8ef4f4e4afd55b6015d5b283172d240e22c91854 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 23 Sep 2010 09:03:55 +0200 Subject: 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 Signed-off-by: Sundar R Iyer Signed-off-by: Linus Walleij Signed-off-by: Ben Dooks --- drivers/i2c/busses/i2c-nomadik.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'drivers/i2c') 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) { int stat; + clk_enable(dev->clk); + stat = flush_i2c_fifo(dev); if (stat) return stat; @@ -263,6 +265,8 @@ static int init_hw(struct nmk_i2c_dev *dev) dev->cli.operation = I2C_NO_OPERATION; + clk_disable(dev->clk); + return 0; } @@ -558,6 +562,8 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, if (status) return status; + clk_enable(dev->clk); + /* setup the i2c controller */ 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", cause >= ARRAY_SIZE(abort_causes) ? "unknown reason" : abort_causes[cause]); + clk_disable(dev->clk); return status; } mdelay(1); } + clk_disable(dev->clk); + /* return the no. messages processed */ if (status) return status; @@ -857,8 +866,6 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev) goto err_no_clk; } - clk_enable(dev->clk); - adap = &dev->adap; adap->dev.parent = &pdev->dev; adap->owner = THIS_MODULE; @@ -895,7 +902,6 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev) return 0; err_init_hw: - clk_disable(dev->clk); err_add_adap: clk_put(dev->clk); err_no_clk: @@ -928,7 +934,6 @@ static int __devexit nmk_i2c_remove(struct platform_device *pdev) iounmap(dev->virtbase); if (res) release_mem_region(res->start, resource_size(res)); - clk_disable(dev->clk); clk_put(dev->clk); platform_set_drvdata(pdev, NULL); kfree(dev); -- cgit v1.2.2 From 5680bc6ec71f303956f5aa999a3c13e13466c561 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 23 Sep 2010 09:04:03 +0200 Subject: i2c-nomadik: support smbus emulation We can do smbus emulation so flag this and drop the duplicate flags implied from smbus emulation. Acked-by: Srinidhi Kasagar Signed-off-by: Sundar R Iyer Signed-off-by: Linus Walleij Signed-off-by: Ben Dooks --- drivers/i2c/busses/i2c-nomadik.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/i2c') diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index b2dbf7c468af..e461de7167e7 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -803,10 +803,7 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) static unsigned int nmk_i2c_functionality(struct i2c_adapter *adap) { - return I2C_FUNC_I2C - | I2C_FUNC_SMBUS_BYTE_DATA - | I2C_FUNC_SMBUS_WORD_DATA - | I2C_FUNC_SMBUS_I2C_BLOCK; + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; } static const struct i2c_algorithm nmk_i2c_algo = { -- cgit v1.2.2 From f868fc355ad852b476950c2fe4f5bae7480e8f04 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 23 Sep 2010 09:04:11 +0200 Subject: i2c-nomadik: fixup bus delays We were missing a transfer delay in one execution path leading to hangs and the bus timeout was too low leading to errors under stress tests. Acked-by: Srinidhi Kasagar Signed-off-by: Sundar R Iyer Signed-off-by: Linus Walleij Signed-off-by: Ben Dooks --- drivers/i2c/busses/i2c-nomadik.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/i2c') diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index e461de7167e7..c9fffd0389fe 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -103,6 +103,9 @@ /* maximum threshold value */ #define MAX_I2C_FIFO_THRESHOLD 15 +/* per-transfer delay, required for the hardware to stabilize */ +#define I2C_DELAY 150 + enum i2c_status { I2C_NOP, I2C_ON_GOING, @@ -118,7 +121,7 @@ enum i2c_operation { }; /* controller response timeout in ms */ -#define I2C_TIMEOUT_MS 500 +#define I2C_TIMEOUT_MS 2000 /** * struct i2c_nmk_client - client specific data @@ -267,6 +270,7 @@ static int init_hw(struct nmk_i2c_dev *dev) clk_disable(dev->clk); + udelay(I2C_DELAY); return 0; } @@ -599,7 +603,7 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, clk_disable(dev->clk); return status; } - mdelay(1); + udelay(I2C_DELAY); } clk_disable(dev->clk); -- cgit v1.2.2