aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-omap.c
diff options
context:
space:
mode:
authorKalle Jokiniemi <kalle.jokiniemi@digia.com>2010-05-11 14:35:08 -0400
committerBen Dooks <ben-linux@fluff.org>2010-05-19 19:18:59 -0400
commit20c9d2c4ab8243a1c311248232954b2c1da3ba75 (patch)
treee035de70d7b89618bb0e6923272849df7d1acb9a /drivers/i2c/busses/i2c-omap.c
parentf38e66e0077659e5d2ca3858fdb26fc9b1765b9f (diff)
i2c-omap: add mpu wake up latency constraint in i2c
While waiting for completion of the i2c transfer, the MPU could hit OFF mode and cause several msecs of delay that made i2c transfers fail more often. The extra delays and subsequent re-trys cause i2c clocks to be active more often. This has also an negative effect on power consumption. Created a mechanism for passing and using the constraint setting function in driver code. The used mpu wake up latency constraints are now set individually per bus, and they are calculated based on clock rate and fifo size. Thanks to Jarkko Nikula, Moiz Sonasath, Paul Walmsley, and Nishanth Menon for tuning out the details of this patch. Updates by Kevin as requested by Tony: - Remove omap_set_i2c_constraint_func() in favor of conditionally adding the flag in omap_i2c_add_bus() in order to keep all the OMAP conditional checking in a single location. - Update set_mpu_wkup_lat prototypes to match OMAP PM layer so OMAP PM function can be used directly in pdata. Cc: Moiz Sonasath <m-sonasath@ti.com> Cc: Jarkko Nikula <jhnikula@gmail.com> Cc: Paul Walmsley <paul@pwsan.com> Cc: Nishanth Menon <nm@ti.com> Signed-off-by: Kalle Jokiniemi <kalle.jokiniemi@digia.com> Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-omap.c')
-rw-r--r--drivers/i2c/busses/i2c-omap.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 46111ff18133..42c0b9108c7f 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -38,6 +38,7 @@
38#include <linux/clk.h> 38#include <linux/clk.h>
39#include <linux/io.h> 39#include <linux/io.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/i2c-omap.h>
41 42
42/* I2C controller revisions */ 43/* I2C controller revisions */
43#define OMAP_I2C_REV_2 0x20 44#define OMAP_I2C_REV_2 0x20
@@ -175,6 +176,9 @@ struct omap_i2c_dev {
175 struct clk *fclk; /* Functional clock */ 176 struct clk *fclk; /* Functional clock */
176 struct completion cmd_complete; 177 struct completion cmd_complete;
177 struct resource *ioarea; 178 struct resource *ioarea;
179 u32 latency; /* maximum mpu wkup latency */
180 void (*set_mpu_wkup_lat)(struct device *dev,
181 long latency);
178 u32 speed; /* Speed of bus in Khz */ 182 u32 speed; /* Speed of bus in Khz */
179 u16 cmd_err; 183 u16 cmd_err;
180 u8 *buf; 184 u8 *buf;
@@ -603,8 +607,12 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
603 * REVISIT: We should abort the transfer on signals, but the bus goes 607 * REVISIT: We should abort the transfer on signals, but the bus goes
604 * into arbitration and we're currently unable to recover from it. 608 * into arbitration and we're currently unable to recover from it.
605 */ 609 */
610 if (dev->set_mpu_wkup_lat != NULL)
611 dev->set_mpu_wkup_lat(dev->dev, dev->latency);
606 r = wait_for_completion_timeout(&dev->cmd_complete, 612 r = wait_for_completion_timeout(&dev->cmd_complete,
607 OMAP_I2C_TIMEOUT); 613 OMAP_I2C_TIMEOUT);
614 if (dev->set_mpu_wkup_lat != NULL)
615 dev->set_mpu_wkup_lat(dev->dev, -1);
608 dev->buf_len = 0; 616 dev->buf_len = 0;
609 if (r < 0) 617 if (r < 0)
610 return r; 618 return r;
@@ -927,6 +935,7 @@ omap_i2c_probe(struct platform_device *pdev)
927 struct omap_i2c_dev *dev; 935 struct omap_i2c_dev *dev;
928 struct i2c_adapter *adap; 936 struct i2c_adapter *adap;
929 struct resource *mem, *irq, *ioarea; 937 struct resource *mem, *irq, *ioarea;
938 struct omap_i2c_bus_platform_data *pdata = pdev->dev.platform_data;
930 irq_handler_t isr; 939 irq_handler_t isr;
931 int r; 940 int r;
932 u32 speed = 0; 941 u32 speed = 0;
@@ -956,10 +965,13 @@ omap_i2c_probe(struct platform_device *pdev)
956 goto err_release_region; 965 goto err_release_region;
957 } 966 }
958 967
959 if (pdev->dev.platform_data != NULL) 968 if (pdata != NULL) {
960 speed = *(u32 *)pdev->dev.platform_data; 969 speed = pdata->clkrate;
961 else 970 dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat;
962 speed = 100; /* Defualt speed */ 971 } else {
972 speed = 100; /* Default speed */
973 dev->set_mpu_wkup_lat = NULL;
974 }
963 975
964 dev->speed = speed; 976 dev->speed = speed;
965 dev->idle = 1; 977 dev->idle = 1;
@@ -1011,6 +1023,10 @@ omap_i2c_probe(struct platform_device *pdev)
1011 dev->fifo_size = (dev->fifo_size / 2); 1023 dev->fifo_size = (dev->fifo_size / 2);
1012 dev->b_hw = 1; /* Enable hardware fixes */ 1024 dev->b_hw = 1; /* Enable hardware fixes */
1013 } 1025 }
1026 /* calculate wakeup latency constraint for MPU */
1027 if (dev->set_mpu_wkup_lat != NULL)
1028 dev->latency = (1000000 * dev->fifo_size) /
1029 (1000 * speed / 8);
1014 } 1030 }
1015 1031
1016 /* reset ASAP, clearing any IRQs */ 1032 /* reset ASAP, clearing any IRQs */