Skip to content

Commit 10d5c88

Browse files
claudiubezneaAndi Shyti
authored andcommitted
i2c: riic: Enable runtime PM autosuspend support
Enable runtime PM autosuspend support for the RIIC driver. With this, in case there are consecutive xfer requests the device wouldn't be runtime enabled/disabled after each consecutive xfer but after the the delay configured by user. With this, we can avoid touching hardware registers involved in runtime PM suspend/resume saving in this way some cycles. The default chosen autosuspend delay is zero to keep the previous driver behavior. Reviewed-by: Wolfram Sang <[email protected]> Signed-off-by: Claudiu Beznea <[email protected]> Signed-off-by: Andi Shyti <[email protected]>
1 parent 3149a9c commit 10d5c88

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/i2c/busses/i2c-riic.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
171171
}
172172

173173
out:
174-
pm_runtime_put(dev);
174+
pm_runtime_mark_last_busy(dev);
175+
pm_runtime_put_autosuspend(dev);
175176

176177
return riic->err ?: num;
177178
}
@@ -399,7 +400,8 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
399400

400401
riic_clear_set_bit(riic, ICCR1_IICRST, 0, RIIC_ICCR1);
401402

402-
pm_runtime_put(dev);
403+
pm_runtime_mark_last_busy(dev);
404+
pm_runtime_put_autosuspend(dev);
403405
return 0;
404406
}
405407

@@ -479,6 +481,9 @@ static int riic_i2c_probe(struct platform_device *pdev)
479481

480482
i2c_parse_fw_timings(dev, &i2c_t, true);
481483

484+
/* Default 0 to save power. Can be overridden via sysfs for lower latency. */
485+
pm_runtime_set_autosuspend_delay(dev, 0);
486+
pm_runtime_use_autosuspend(dev);
482487
pm_runtime_enable(dev);
483488

484489
ret = riic_init_hw(riic, &i2c_t);
@@ -496,6 +501,7 @@ static int riic_i2c_probe(struct platform_device *pdev)
496501

497502
out:
498503
pm_runtime_disable(dev);
504+
pm_runtime_dont_use_autosuspend(dev);
499505
return ret;
500506
}
501507

@@ -512,6 +518,7 @@ static void riic_i2c_remove(struct platform_device *pdev)
512518
}
513519
i2c_del_adapter(&riic->adapter);
514520
pm_runtime_disable(dev);
521+
pm_runtime_dont_use_autosuspend(dev);
515522
}
516523

517524
static const struct riic_of_data riic_rz_a_info = {

0 commit comments

Comments
 (0)