Skip to content

Commit faed986

Browse files
Adlavinitha ReddyAndi Shyti
authored andcommitted
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
1 parent 60c8a40 commit faed986

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

drivers/i2c/busses/i2c-mt65xx.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/module.h>
2222
#include <linux/of.h>
2323
#include <linux/platform_device.h>
24+
#include <linux/regulator/consumer.h>
2425
#include <linux/scatterlist.h>
2526
#include <linux/sched.h>
2627
#include <linux/slab.h>
@@ -1244,9 +1245,15 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap,
12441245
bool write_then_read_en = false;
12451246
struct mtk_i2c *i2c = i2c_get_adapdata(adap);
12461247

1248+
if (i2c->adap.bus_regulator) {
1249+
ret = regulator_enable(i2c->adap.bus_regulator);
1250+
if (ret)
1251+
return ret;
1252+
}
1253+
12471254
ret = clk_bulk_enable(I2C_MT65XX_CLK_MAX, i2c->clocks);
12481255
if (ret)
1249-
return ret;
1256+
goto err_regulator;
12501257

12511258
i2c->auto_restart = i2c->dev_comp->auto_restart;
12521259

@@ -1301,6 +1308,10 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap,
13011308

13021309
err_exit:
13031310
clk_bulk_disable(I2C_MT65XX_CLK_MAX, i2c->clocks);
1311+
err_regulator:
1312+
if (i2c->adap.bus_regulator)
1313+
regulator_disable(i2c->adap.bus_regulator);
1314+
13041315
return ret;
13051316
}
13061317

0 commit comments

Comments
 (0)