diff options
Diffstat (limited to 'drivers/i2c/busses/i2c-omap.c')
-rw-r--r-- | drivers/i2c/busses/i2c-omap.c | 24 |
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 */ |