[PATCH 1/8] OMAP: convert I2C driver to PM QoS for latency constraints

2011-10-12 Thread jean . pihet
From: Jean Pihet j-pi...@ti.com

Convert the driver from the outdated omap_pm_set_max_mpu_wakeup_lat
API to the new PM QoS API.
Since the constraint is on the MPU subsystem, use the PM_QOS_CPU_DMA_LATENCY
class of PM QoS. The resulting MPU constraints are used by cpuidle to
decide the next power state of the MPU subsystem.

The I2C device latency timing is derived from the FIFO size and the
clock speed and so is applicable to all OMAP SoCs.

Signed-off-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/plat-omap/i2c.c  |   20 
 drivers/i2c/busses/i2c-omap.c |   30 +++---
 include/linux/i2c-omap.h  |1 -
 3 files changed, 15 insertions(+), 36 deletions(-)

diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index 3341ca4..e1e2502 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -34,7 +34,6 @@
 #include mach/irqs.h
 #include plat/mux.h
 #include plat/i2c.h
-#include plat/omap-pm.h
 #include plat/omap_device.h
 
 #define OMAP_I2C_SIZE  0x3f
@@ -113,16 +112,6 @@ static inline int omap1_i2c_add_bus(int bus_id)
 
 
 #ifdef CONFIG_ARCH_OMAP2PLUS
-/*
- * XXX This function is a temporary compatibility wrapper - only
- * needed until the I2C driver can be converted to call
- * omap_pm_set_max_dev_wakeup_lat() and handle a return code.
- */
-static void omap_pm_set_max_mpu_wakeup_lat_compat(struct device *dev, long t)
-{
-   omap_pm_set_max_mpu_wakeup_lat(dev, t);
-}
-
 static struct omap_device_pm_latency omap_i2c_latency[] = {
[0] = {
.deactivate_func= omap_device_idle_hwmods,
@@ -151,15 +140,6 @@ static inline int omap2_i2c_add_bus(int bus_id)
}
 
pdata = i2c_pdata[bus_id - 1];
-   /*
-* When waiting for completion of a i2c transfer, we need to
-* set a wake up latency constraint for the MPU. This is to
-* ensure quick enough wakeup from idle, when transfer
-* completes.
-* Only omap3 has support for constraints
-*/
-   if (cpu_is_omap34xx())
-   pdata-set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat;
od = omap_device_build(name, bus_id, oh, pdata,
sizeof(struct omap_i2c_bus_platform_data),
omap_i2c_latency, ARRAY_SIZE(omap_i2c_latency), 0);
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 1a766cf..95e5205 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -40,6 +40,7 @@
 #include linux/slab.h
 #include linux/i2c-omap.h
 #include linux/pm_runtime.h
+#include linux/pm_qos.h
 
 /* I2C controller revisions */
 #define OMAP_I2C_REV_2 0x20
@@ -179,8 +180,7 @@ struct omap_i2c_dev {
struct completion   cmd_complete;
struct resource *ioarea;
u32 latency;/* maximum mpu wkup latency */
-   void(*set_mpu_wkup_lat)(struct device *dev,
-   long latency);
+   struct pm_qos_request   pm_qos_request;
u32 speed;  /* Speed of bus in Khz */
u16 cmd_err;
u8  *buf;
@@ -648,8 +648,14 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
msgs[], int num)
if (r  0)
goto out;
 
-   if (dev-set_mpu_wkup_lat != NULL)
-   dev-set_mpu_wkup_lat(dev-dev, dev-latency);
+   /*
+* When waiting for completion of a i2c transfer, we need to
+* set a wake up latency constraint for the MPU. This is to
+* ensure quick enough wakeup from idle, when transfer
+* completes.
+*/
+   pm_qos_add_request(dev-pm_qos_request, PM_QOS_CPU_DMA_LATENCY,
+  dev-latency);
 
for (i = 0; i  num; i++) {
r = omap_i2c_xfer_msg(adap, msgs[i], (i == (num - 1)));
@@ -657,8 +663,7 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
msgs[], int num)
break;
}
 
-   if (dev-set_mpu_wkup_lat != NULL)
-   dev-set_mpu_wkup_lat(dev-dev, -1);
+   pm_qos_remove_request(dev-pm_qos_request);
 
if (r == 0)
r = num;
@@ -1007,13 +1012,10 @@ omap_i2c_probe(struct platform_device *pdev)
goto err_release_region;
}
 
-   if (pdata != NULL) {
+   if (pdata != NULL)
speed = pdata-clkrate;
-   dev-set_mpu_wkup_lat = pdata-set_mpu_wkup_lat;
-   } else {
+   else
speed = 100;/* Default speed */
-   dev-set_mpu_wkup_lat = NULL;
-   }
 
dev-speed = speed;
dev-idle = 1;
@@ -1066,10 +1068,8 @@ omap_i2c_probe(struct platform_device *pdev)
dev-fifo_size = (dev-fifo_size / 2);
dev-b_hw = 1; /* Enable hardware fixes */
}
-  

[PATCH 1/8] OMAP: convert I2C driver to PM QoS for latency constraints

2011-09-21 Thread Jean Pihet
Convert the driver from the outdated omap_pm_set_max_mpu_wakeup_lat
API to the new PM QoS API.
Since the constraint is on the MPU subsystem, use the PM_QOS_CPU_DMA_LATENCY
class of PM QoS. The resulting MPU constraints are used by cpuidle to
decide the next power state of the MPU subsystem.

The I2C device latency timing is derived from the FIFO size and the
clock speed and so is applicable to all OMAP SoCs.

Signed-off-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/plat-omap/i2c.c  |   20 
 drivers/i2c/busses/i2c-omap.c |   30 +++---
 include/linux/i2c-omap.h  |1 -
 3 files changed, 15 insertions(+), 36 deletions(-)

diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index 3341ca4..e1e2502 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -34,7 +34,6 @@
 #include mach/irqs.h
 #include plat/mux.h
 #include plat/i2c.h
-#include plat/omap-pm.h
 #include plat/omap_device.h
 
 #define OMAP_I2C_SIZE  0x3f
@@ -113,16 +112,6 @@ static inline int omap1_i2c_add_bus(int bus_id)
 
 
 #ifdef CONFIG_ARCH_OMAP2PLUS
-/*
- * XXX This function is a temporary compatibility wrapper - only
- * needed until the I2C driver can be converted to call
- * omap_pm_set_max_dev_wakeup_lat() and handle a return code.
- */
-static void omap_pm_set_max_mpu_wakeup_lat_compat(struct device *dev, long t)
-{
-   omap_pm_set_max_mpu_wakeup_lat(dev, t);
-}
-
 static struct omap_device_pm_latency omap_i2c_latency[] = {
[0] = {
.deactivate_func= omap_device_idle_hwmods,
@@ -151,15 +140,6 @@ static inline int omap2_i2c_add_bus(int bus_id)
}
 
pdata = i2c_pdata[bus_id - 1];
-   /*
-* When waiting for completion of a i2c transfer, we need to
-* set a wake up latency constraint for the MPU. This is to
-* ensure quick enough wakeup from idle, when transfer
-* completes.
-* Only omap3 has support for constraints
-*/
-   if (cpu_is_omap34xx())
-   pdata-set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat;
od = omap_device_build(name, bus_id, oh, pdata,
sizeof(struct omap_i2c_bus_platform_data),
omap_i2c_latency, ARRAY_SIZE(omap_i2c_latency), 0);
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 1a766cf..95e5205 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -40,6 +40,7 @@
 #include linux/slab.h
 #include linux/i2c-omap.h
 #include linux/pm_runtime.h
+#include linux/pm_qos.h
 
 /* I2C controller revisions */
 #define OMAP_I2C_REV_2 0x20
@@ -179,8 +180,7 @@ struct omap_i2c_dev {
struct completion   cmd_complete;
struct resource *ioarea;
u32 latency;/* maximum mpu wkup latency */
-   void(*set_mpu_wkup_lat)(struct device *dev,
-   long latency);
+   struct pm_qos_request   pm_qos_request;
u32 speed;  /* Speed of bus in Khz */
u16 cmd_err;
u8  *buf;
@@ -648,8 +648,14 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
msgs[], int num)
if (r  0)
goto out;
 
-   if (dev-set_mpu_wkup_lat != NULL)
-   dev-set_mpu_wkup_lat(dev-dev, dev-latency);
+   /*
+* When waiting for completion of a i2c transfer, we need to
+* set a wake up latency constraint for the MPU. This is to
+* ensure quick enough wakeup from idle, when transfer
+* completes.
+*/
+   pm_qos_add_request(dev-pm_qos_request, PM_QOS_CPU_DMA_LATENCY,
+  dev-latency);
 
for (i = 0; i  num; i++) {
r = omap_i2c_xfer_msg(adap, msgs[i], (i == (num - 1)));
@@ -657,8 +663,7 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
msgs[], int num)
break;
}
 
-   if (dev-set_mpu_wkup_lat != NULL)
-   dev-set_mpu_wkup_lat(dev-dev, -1);
+   pm_qos_remove_request(dev-pm_qos_request);
 
if (r == 0)
r = num;
@@ -1007,13 +1012,10 @@ omap_i2c_probe(struct platform_device *pdev)
goto err_release_region;
}
 
-   if (pdata != NULL) {
+   if (pdata != NULL)
speed = pdata-clkrate;
-   dev-set_mpu_wkup_lat = pdata-set_mpu_wkup_lat;
-   } else {
+   else
speed = 100;/* Default speed */
-   dev-set_mpu_wkup_lat = NULL;
-   }
 
dev-speed = speed;
dev-idle = 1;
@@ -1066,10 +1068,8 @@ omap_i2c_probe(struct platform_device *pdev)
dev-fifo_size = (dev-fifo_size / 2);
dev-b_hw = 1; /* Enable hardware fixes */
}
-   /* calculate wakeup latency 

[PATCH 1/8] OMAP: convert I2C driver to PM QoS for latency constraints

2011-09-21 Thread jean . pihet
From: Jean Pihet j-pi...@ti.com

Convert the driver from the outdated omap_pm_set_max_mpu_wakeup_lat
API to the new PM QoS API.
Since the constraint is on the MPU subsystem, use the PM_QOS_CPU_DMA_LATENCY
class of PM QoS. The resulting MPU constraints are used by cpuidle to
decide the next power state of the MPU subsystem.

The I2C device latency timing is derived from the FIFO size and the
clock speed and so is applicable to all OMAP SoCs.

Signed-off-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/plat-omap/i2c.c  |   20 
 drivers/i2c/busses/i2c-omap.c |   30 +++---
 include/linux/i2c-omap.h  |1 -
 3 files changed, 15 insertions(+), 36 deletions(-)

diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index 3341ca4..e1e2502 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -34,7 +34,6 @@
 #include mach/irqs.h
 #include plat/mux.h
 #include plat/i2c.h
-#include plat/omap-pm.h
 #include plat/omap_device.h
 
 #define OMAP_I2C_SIZE  0x3f
@@ -113,16 +112,6 @@ static inline int omap1_i2c_add_bus(int bus_id)
 
 
 #ifdef CONFIG_ARCH_OMAP2PLUS
-/*
- * XXX This function is a temporary compatibility wrapper - only
- * needed until the I2C driver can be converted to call
- * omap_pm_set_max_dev_wakeup_lat() and handle a return code.
- */
-static void omap_pm_set_max_mpu_wakeup_lat_compat(struct device *dev, long t)
-{
-   omap_pm_set_max_mpu_wakeup_lat(dev, t);
-}
-
 static struct omap_device_pm_latency omap_i2c_latency[] = {
[0] = {
.deactivate_func= omap_device_idle_hwmods,
@@ -151,15 +140,6 @@ static inline int omap2_i2c_add_bus(int bus_id)
}
 
pdata = i2c_pdata[bus_id - 1];
-   /*
-* When waiting for completion of a i2c transfer, we need to
-* set a wake up latency constraint for the MPU. This is to
-* ensure quick enough wakeup from idle, when transfer
-* completes.
-* Only omap3 has support for constraints
-*/
-   if (cpu_is_omap34xx())
-   pdata-set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat;
od = omap_device_build(name, bus_id, oh, pdata,
sizeof(struct omap_i2c_bus_platform_data),
omap_i2c_latency, ARRAY_SIZE(omap_i2c_latency), 0);
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 1a766cf..95e5205 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -40,6 +40,7 @@
 #include linux/slab.h
 #include linux/i2c-omap.h
 #include linux/pm_runtime.h
+#include linux/pm_qos.h
 
 /* I2C controller revisions */
 #define OMAP_I2C_REV_2 0x20
@@ -179,8 +180,7 @@ struct omap_i2c_dev {
struct completion   cmd_complete;
struct resource *ioarea;
u32 latency;/* maximum mpu wkup latency */
-   void(*set_mpu_wkup_lat)(struct device *dev,
-   long latency);
+   struct pm_qos_request   pm_qos_request;
u32 speed;  /* Speed of bus in Khz */
u16 cmd_err;
u8  *buf;
@@ -648,8 +648,14 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
msgs[], int num)
if (r  0)
goto out;
 
-   if (dev-set_mpu_wkup_lat != NULL)
-   dev-set_mpu_wkup_lat(dev-dev, dev-latency);
+   /*
+* When waiting for completion of a i2c transfer, we need to
+* set a wake up latency constraint for the MPU. This is to
+* ensure quick enough wakeup from idle, when transfer
+* completes.
+*/
+   pm_qos_add_request(dev-pm_qos_request, PM_QOS_CPU_DMA_LATENCY,
+  dev-latency);
 
for (i = 0; i  num; i++) {
r = omap_i2c_xfer_msg(adap, msgs[i], (i == (num - 1)));
@@ -657,8 +663,7 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
msgs[], int num)
break;
}
 
-   if (dev-set_mpu_wkup_lat != NULL)
-   dev-set_mpu_wkup_lat(dev-dev, -1);
+   pm_qos_remove_request(dev-pm_qos_request);
 
if (r == 0)
r = num;
@@ -1007,13 +1012,10 @@ omap_i2c_probe(struct platform_device *pdev)
goto err_release_region;
}
 
-   if (pdata != NULL) {
+   if (pdata != NULL)
speed = pdata-clkrate;
-   dev-set_mpu_wkup_lat = pdata-set_mpu_wkup_lat;
-   } else {
+   else
speed = 100;/* Default speed */
-   dev-set_mpu_wkup_lat = NULL;
-   }
 
dev-speed = speed;
dev-idle = 1;
@@ -1066,10 +1068,8 @@ omap_i2c_probe(struct platform_device *pdev)
dev-fifo_size = (dev-fifo_size / 2);
dev-b_hw = 1; /* Enable hardware fixes */
}
-  

Re: [PATCH 1/8] OMAP: convert I2C driver to PM QoS for latency constraints

2011-09-16 Thread Jean Pihet
Kevin,

On Fri, Sep 16, 2011 at 12:46 AM, Kevin Hilman khil...@ti.com wrote:
 Hi Jean,

 Jean Pihet jean.pi...@newoldbits.com writes:

 Convert the driver from the outdated omap_pm_set_max_mpu_wakeup_lat
 API to the new PM QoS API.
 Since the constraint is on the MPU subsystem, use the PM_QOS_CPU_DMA_LATENCY
 class of PM QoS. The resulting MPU constraints are used by cpuidle to
 decide the next power state of the MPU subsystem.

 Currently only OMAP3 is placing constraints on the MPU.

 Signed-off-by: Jean Pihet j-pi...@ti.com

 [...]

 @@ -648,8 +648,16 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
 msgs[], int num)
       if (r  0)
               goto out;

 -     if (dev-set_mpu_wkup_lat != NULL)
 -             dev-set_mpu_wkup_lat(dev-dev, dev-latency);
 +     /*
 +      * When waiting for completion of a i2c transfer, we need to
 +      * set a wake up latency constraint for the MPU. This is to
 +      * ensure quick enough wakeup from idle, when transfer
 +      * completes.
 +      * Used on OMAP3 Only
 +      */
 +     if (cpu_is_omap34xx())

 We don't want any cpu_is_* checking  in drivers.

 If this is only done on certain SoCs, then a flag should be passed from
 device init code via pdata.

 That being said, I don't see why this shouldn't be set for all SoCs
 since it's using the FIFO size to determine the latency.
I am OK to have the constraints active for all OMAPs. Side question:
what if different SOCs need different values for the constraint?


 Kevin


Regards,
Jean
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/8] OMAP: convert I2C driver to PM QoS for latency constraints

2011-09-16 Thread Kevin Hilman
Jean Pihet jean.pi...@newoldbits.com writes:

 Kevin,

 On Fri, Sep 16, 2011 at 12:46 AM, Kevin Hilman khil...@ti.com wrote:
 Hi Jean,

 Jean Pihet jean.pi...@newoldbits.com writes:

 Convert the driver from the outdated omap_pm_set_max_mpu_wakeup_lat
 API to the new PM QoS API.
 Since the constraint is on the MPU subsystem, use the PM_QOS_CPU_DMA_LATENCY
 class of PM QoS. The resulting MPU constraints are used by cpuidle to
 decide the next power state of the MPU subsystem.

 Currently only OMAP3 is placing constraints on the MPU.

 Signed-off-by: Jean Pihet j-pi...@ti.com

 [...]

 @@ -648,8 +648,16 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
 msgs[], int num)
       if (r  0)
               goto out;

 -     if (dev-set_mpu_wkup_lat != NULL)
 -             dev-set_mpu_wkup_lat(dev-dev, dev-latency);
 +     /*
 +      * When waiting for completion of a i2c transfer, we need to
 +      * set a wake up latency constraint for the MPU. This is to
 +      * ensure quick enough wakeup from idle, when transfer
 +      * completes.
 +      * Used on OMAP3 Only
 +      */
 +     if (cpu_is_omap34xx())

 We don't want any cpu_is_* checking  in drivers.

 If this is only done on certain SoCs, then a flag should be passed from
 device init code via pdata.

 That being said, I don't see why this shouldn't be set for all SoCs
 since it's using the FIFO size to determine the latency.
 I am OK to have the constraints active for all OMAPs. Side question:
 what if different SOCs need different values for the constraint?

This latency calculation is based on FIFO size and drain rate, so it
should be completely SoC independent.

However, if for some reason there are SoC dependencies, the SoC specific
parts need to be passed in to the driver.

Kevin
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/8] OMAP: convert I2C driver to PM QoS for latency constraints

2011-09-15 Thread Kevin Hilman
Hi Jean,

Jean Pihet jean.pi...@newoldbits.com writes:

 Convert the driver from the outdated omap_pm_set_max_mpu_wakeup_lat
 API to the new PM QoS API.
 Since the constraint is on the MPU subsystem, use the PM_QOS_CPU_DMA_LATENCY
 class of PM QoS. The resulting MPU constraints are used by cpuidle to
 decide the next power state of the MPU subsystem.

 Currently only OMAP3 is placing constraints on the MPU.

 Signed-off-by: Jean Pihet j-pi...@ti.com

[...]

 @@ -648,8 +648,16 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
 msgs[], int num)
   if (r  0)
   goto out;
  
 - if (dev-set_mpu_wkup_lat != NULL)
 - dev-set_mpu_wkup_lat(dev-dev, dev-latency);
 + /*
 +  * When waiting for completion of a i2c transfer, we need to
 +  * set a wake up latency constraint for the MPU. This is to
 +  * ensure quick enough wakeup from idle, when transfer
 +  * completes.
 +  * Used on OMAP3 Only
 +  */
 + if (cpu_is_omap34xx())

We don't want any cpu_is_* checking  in drivers.

If this is only done on certain SoCs, then a flag should be passed from
device init code via pdata.

That being said, I don't see why this shouldn't be set for all SoCs
since it's using the FIFO size to determine the latency.

Kevin

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/8] OMAP: convert I2C driver to PM QoS for latency constraints

2011-09-02 Thread Jean Pihet
Convert the driver from the outdated omap_pm_set_max_mpu_wakeup_lat
API to the new PM QoS API.
Since the constraint is on the MPU subsystem, use the PM_QOS_CPU_DMA_LATENCY
class of PM QoS. The resulting MPU constraints are used by cpuidle to
decide the next power state of the MPU subsystem.

Currently only OMAP3 is placing constraints on the MPU.

Signed-off-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/plat-omap/i2c.c  |   20 
 drivers/i2c/busses/i2c-omap.c |   31 ++-
 2 files changed, 18 insertions(+), 33 deletions(-)

diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index 3341ca4..e1e2502 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -34,7 +34,6 @@
 #include mach/irqs.h
 #include plat/mux.h
 #include plat/i2c.h
-#include plat/omap-pm.h
 #include plat/omap_device.h
 
 #define OMAP_I2C_SIZE  0x3f
@@ -113,16 +112,6 @@ static inline int omap1_i2c_add_bus(int bus_id)
 
 
 #ifdef CONFIG_ARCH_OMAP2PLUS
-/*
- * XXX This function is a temporary compatibility wrapper - only
- * needed until the I2C driver can be converted to call
- * omap_pm_set_max_dev_wakeup_lat() and handle a return code.
- */
-static void omap_pm_set_max_mpu_wakeup_lat_compat(struct device *dev, long t)
-{
-   omap_pm_set_max_mpu_wakeup_lat(dev, t);
-}
-
 static struct omap_device_pm_latency omap_i2c_latency[] = {
[0] = {
.deactivate_func= omap_device_idle_hwmods,
@@ -151,15 +140,6 @@ static inline int omap2_i2c_add_bus(int bus_id)
}
 
pdata = i2c_pdata[bus_id - 1];
-   /*
-* When waiting for completion of a i2c transfer, we need to
-* set a wake up latency constraint for the MPU. This is to
-* ensure quick enough wakeup from idle, when transfer
-* completes.
-* Only omap3 has support for constraints
-*/
-   if (cpu_is_omap34xx())
-   pdata-set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat;
od = omap_device_build(name, bus_id, oh, pdata,
sizeof(struct omap_i2c_bus_platform_data),
omap_i2c_latency, ARRAY_SIZE(omap_i2c_latency), 0);
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 1a766cf..1c762ba 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -40,6 +40,7 @@
 #include linux/slab.h
 #include linux/i2c-omap.h
 #include linux/pm_runtime.h
+#include linux/pm_qos.h
 
 /* I2C controller revisions */
 #define OMAP_I2C_REV_2 0x20
@@ -179,8 +180,7 @@ struct omap_i2c_dev {
struct completion   cmd_complete;
struct resource *ioarea;
u32 latency;/* maximum mpu wkup latency */
-   void(*set_mpu_wkup_lat)(struct device *dev,
-   long latency);
+   struct pm_qos_request   pm_qos_request;
u32 speed;  /* Speed of bus in Khz */
u16 cmd_err;
u8  *buf;
@@ -648,8 +648,16 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
msgs[], int num)
if (r  0)
goto out;
 
-   if (dev-set_mpu_wkup_lat != NULL)
-   dev-set_mpu_wkup_lat(dev-dev, dev-latency);
+   /*
+* When waiting for completion of a i2c transfer, we need to
+* set a wake up latency constraint for the MPU. This is to
+* ensure quick enough wakeup from idle, when transfer
+* completes.
+* Used on OMAP3 Only
+*/
+   if (cpu_is_omap34xx())
+   pm_qos_add_request(dev-pm_qos_request, PM_QOS_CPU_DMA_LATENCY,
+  dev-latency);
 
for (i = 0; i  num; i++) {
r = omap_i2c_xfer_msg(adap, msgs[i], (i == (num - 1)));
@@ -657,8 +665,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
msgs[], int num)
break;
}
 
-   if (dev-set_mpu_wkup_lat != NULL)
-   dev-set_mpu_wkup_lat(dev-dev, -1);
+   if (cpu_is_omap34xx())
+   pm_qos_remove_request(dev-pm_qos_request);
 
if (r == 0)
r = num;
@@ -1007,13 +1015,10 @@ omap_i2c_probe(struct platform_device *pdev)
goto err_release_region;
}
 
-   if (pdata != NULL) {
+   if (pdata != NULL)
speed = pdata-clkrate;
-   dev-set_mpu_wkup_lat = pdata-set_mpu_wkup_lat;
-   } else {
+   else
speed = 100;/* Default speed */
-   dev-set_mpu_wkup_lat = NULL;
-   }
 
dev-speed = speed;
dev-idle = 1;
@@ -1066,8 +1071,8 @@ omap_i2c_probe(struct platform_device *pdev)
dev-fifo_size = (dev-fifo_size / 2);
dev-b_hw = 1; /* Enable hardware fixes */
}
-   /* calculate