summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdlavinitha Reddy <adlavinitha.reddy@mediatek.com>2026-03-18 16:46:16 +0800
committerAndi Shyti <andi.shyti@kernel.org>2026-04-15 00:54:34 +0200
commitfaed986de5250e1cd1296e82d1fcb4c03997e02a (patch)
treed7fc9f239d563c399155ccf6d86f10710b5f48b5
parent60c8a400fbef3592b8d718dc49f92914a9c8d762 (diff)
i2c: mediatek: add bus regulator control for power saving
Add conditional bus regulator enable/disable in mtk_i2c_transfer() to support I2C bus power gating for platforms that require it. This implementation: - Enables bus_regulator before clk_bulk_enable() if vbus-supply is defined - Disables bus_regulator after clk_bulk_disable() - Only activates when vbus-supply is provided in device tree - Has no impact on platforms without vbus-supply defined This approach provides power savings for platforms with an extra I2C bus regulator, while avoiding runtime PM complexity. Tested on MT8188. Signed-off-by: Adlavinitha Reddy <adlavinitha.reddy@mediatek.com> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20260318084621.4127757-2-adlavinitha.reddy@mediatek.com
-rw-r--r--drivers/i2c/busses/i2c-mt65xx.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
index cb4d3aa709d0..126040ca05f1 100644
--- a/drivers/i2c/busses/i2c-mt65xx.c
+++ b/drivers/i2c/busses/i2c-mt65xx.c
@@ -21,6 +21,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
#include <linux/scatterlist.h>
#include <linux/sched.h>
#include <linux/slab.h>
@@ -1244,9 +1245,15 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap,
bool write_then_read_en = false;
struct mtk_i2c *i2c = i2c_get_adapdata(adap);
+ if (i2c->adap.bus_regulator) {
+ ret = regulator_enable(i2c->adap.bus_regulator);
+ if (ret)
+ return ret;
+ }
+
ret = clk_bulk_enable(I2C_MT65XX_CLK_MAX, i2c->clocks);
if (ret)
- return ret;
+ goto err_regulator;
i2c->auto_restart = i2c->dev_comp->auto_restart;
@@ -1301,6 +1308,10 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap,
err_exit:
clk_bulk_disable(I2C_MT65XX_CLK_MAX, i2c->clocks);
+err_regulator:
+ if (i2c->adap.bus_regulator)
+ regulator_disable(i2c->adap.bus_regulator);
+
return ret;
}