Browse Source

i2c: omap: switch over to autosuspend API

this helps us reduce unnecessary pm transitions
in case we have another i2c message starting soon.

Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Felipe Balbi 12 năm trước cách đây
mục cha
commit
6d8451d55a
1 tập tin đã thay đổi với 10 bổ sung2 xóa
  1. 10 2
      drivers/i2c/busses/i2c-omap.c

+ 10 - 2
drivers/i2c/busses/i2c-omap.c

@@ -55,6 +55,9 @@
 /* timeout waiting for the controller to respond */
 /* timeout waiting for the controller to respond */
 #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
 #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
 
 
+/* timeout for pm runtime autosuspend */
+#define OMAP_I2C_PM_TIMEOUT		1000	/* ms */
+
 /* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */
 /* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */
 enum {
 enum {
 	OMAP_I2C_REV_REG = 0,
 	OMAP_I2C_REV_REG = 0,
@@ -645,7 +648,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
 
 
 	omap_i2c_wait_for_bb(dev);
 	omap_i2c_wait_for_bb(dev);
 out:
 out:
-	pm_runtime_put(dev->dev);
+	pm_runtime_mark_last_busy(dev->dev);
+	pm_runtime_put_autosuspend(dev->dev);
 	return r;
 	return r;
 }
 }
 
 
@@ -1113,6 +1117,9 @@ omap_i2c_probe(struct platform_device *pdev)
 		dev->regs = (u8 *)reg_map_ip_v1;
 		dev->regs = (u8 *)reg_map_ip_v1;
 
 
 	pm_runtime_enable(dev->dev);
 	pm_runtime_enable(dev->dev);
+	pm_runtime_set_autosuspend_delay(dev->dev, OMAP_I2C_PM_TIMEOUT);
+	pm_runtime_use_autosuspend(dev->dev);
+
 	r = pm_runtime_get_sync(dev->dev);
 	r = pm_runtime_get_sync(dev->dev);
 	if (IS_ERR_VALUE(r))
 	if (IS_ERR_VALUE(r))
 		goto err_free_mem;
 		goto err_free_mem;
@@ -1190,7 +1197,8 @@ omap_i2c_probe(struct platform_device *pdev)
 
 
 	of_i2c_register_devices(adap);
 	of_i2c_register_devices(adap);
 
 
-	pm_runtime_put(dev->dev);
+	pm_runtime_mark_last_busy(dev->dev);
+	pm_runtime_put_autosuspend(dev->dev);
 
 
 	return 0;
 	return 0;