public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [v1,PATCH 1/1] i2c: mediatek: add bus regulator control for power saving
       [not found] <20260318081126.4098146-1-adlavinitha.reddy@mediatek.com>
@ 2026-03-18  8:11 ` adlavinitha reddy
  0 siblings, 0 replies; 6+ messages in thread
From: adlavinitha reddy @ 2026-03-18  8:11 UTC (permalink / raw)
  To: Qii Wang, Andi Shyti, Matthias Brugger,
	AngeloGioacchino Del Regno
  Cc: linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	Project_Global_Chrome_Upstream_Group, adlavinitha reddy

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 savinggs for platforms with an extra I2C bus
regulator, while avoiding runtime PM complexity.

TEST= Build and boot on MT8188

Signed-off-by: adlavinitha reddy <adlavinitha.reddy@mediatek.com>
---
 drivers/i2c/busses/i2c-mt65xx.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

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;
 }

--
2.45.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [v1,PATCH 1/1] i2c: mediatek: add bus regulator control for power saving
  2026-03-18  8:42 [v1,PATCH 0/1] " adlavinitha reddy
@ 2026-03-18  8:42 ` adlavinitha reddy
  0 siblings, 0 replies; 6+ messages in thread
From: adlavinitha reddy @ 2026-03-18  8:42 UTC (permalink / raw)
  To: Qii Wang, Andi Shyti, Matthias Brugger,
	AngeloGioacchino Del Regno
  Cc: linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	Project_Global_Chrome_Upstream_Group, adlavinitha reddy

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 savinggs for platforms with an extra I2C bus
regulator, while avoiding runtime PM complexity.

TEST= Build and boot on MT8188

Signed-off-by: adlavinitha reddy <adlavinitha.reddy@mediatek.com>
---
 drivers/i2c/busses/i2c-mt65xx.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

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;
 }

--
2.45.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [v1,PATCH 0/1] i2c: mediatek: add bus regulator control for power saving
@ 2026-03-18  8:46 adlavinitha reddy
  2026-03-18  8:46 ` [v1,PATCH 1/1] " adlavinitha reddy
  0 siblings, 1 reply; 6+ messages in thread
From: adlavinitha reddy @ 2026-03-18  8:46 UTC (permalink / raw)
  To: Qii Wang, Andi Shyti, Matthias Brugger,
	AngeloGioacchino Del Regno
  Cc: linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	Project_Global_Chrome_Upstream_Group, adlavinitha reddy

This patch adds conditional bus regulator enable/disable support in
mtk_i2c_transfer() to allow I2C bus power gating on platforms that
provide a vbus-supply in the device tree.

The 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.

Based on linux-next, tag: next-20260305

adlavinitha reddy (1):
  i2c: mediatek: add bus regulator control for power saving

 drivers/i2c/busses/i2c-mt65xx.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

--
2.45.2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [v1,PATCH 1/1] i2c: mediatek: add bus regulator control for power saving
  2026-03-18  8:46 [v1,PATCH 0/1] i2c: mediatek: add bus regulator control for power saving adlavinitha reddy
@ 2026-03-18  8:46 ` adlavinitha reddy
  2026-03-26  9:49   ` Chen-Yu Tsai
  2026-04-14 23:03   ` Andi Shyti
  0 siblings, 2 replies; 6+ messages in thread
From: adlavinitha reddy @ 2026-03-18  8:46 UTC (permalink / raw)
  To: Qii Wang, Andi Shyti, Matthias Brugger,
	AngeloGioacchino Del Regno
  Cc: linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	Project_Global_Chrome_Upstream_Group, adlavinitha reddy

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 savinggs for platforms with an extra I2C bus
regulator, while avoiding runtime PM complexity.

TEST= Build and boot on MT8188

Signed-off-by: adlavinitha reddy <adlavinitha.reddy@mediatek.com>
---
 drivers/i2c/busses/i2c-mt65xx.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

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;
 }

--
2.45.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [v1,PATCH 1/1] i2c: mediatek: add bus regulator control for power saving
  2026-03-18  8:46 ` [v1,PATCH 1/1] " adlavinitha reddy
@ 2026-03-26  9:49   ` Chen-Yu Tsai
  2026-04-14 23:03   ` Andi Shyti
  1 sibling, 0 replies; 6+ messages in thread
From: Chen-Yu Tsai @ 2026-03-26  9:49 UTC (permalink / raw)
  To: adlavinitha reddy
  Cc: Qii Wang, Andi Shyti, Matthias Brugger,
	AngeloGioacchino Del Regno, linux-i2c, linux-kernel,
	linux-arm-kernel, linux-mediatek,
	Project_Global_Chrome_Upstream_Group

On Wed, Mar 18, 2026 at 4:46 PM adlavinitha reddy
<adlavinitha.reddy@mediatek.com> wrote:
>
> 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 savinggs for platforms with an extra I2C bus
> regulator, while avoiding runtime PM complexity.
>
> TEST= Build and boot on MT8188
>
> Signed-off-by: adlavinitha reddy <adlavinitha.reddy@mediatek.com>

Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [v1,PATCH 1/1] i2c: mediatek: add bus regulator control for power saving
  2026-03-18  8:46 ` [v1,PATCH 1/1] " adlavinitha reddy
  2026-03-26  9:49   ` Chen-Yu Tsai
@ 2026-04-14 23:03   ` Andi Shyti
  1 sibling, 0 replies; 6+ messages in thread
From: Andi Shyti @ 2026-04-14 23:03 UTC (permalink / raw)
  To: adlavinitha reddy
  Cc: Qii Wang, Matthias Brugger, AngeloGioacchino Del Regno, linux-i2c,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Project_Global_Chrome_Upstream_Group

Hi Adlavinitha,

On Wed, Mar 18, 2026 at 04:46:16PM +0800, adlavinitha reddy wrote:
> 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 savinggs for platforms with an extra I2C bus

I changed /savinggs/savings/.

> regulator, while avoiding runtime PM complexity.
> 
> TEST= Build and boot on MT8188

'"TEST=..." is a tag. There is no need to save characters in the
commit log. I changed it to "Tested on MT8188.".'

> Signed-off-by: adlavinitha reddy <adlavinitha.reddy@mediatek.com>

Please use capital letters for your name and for the committer's
name as well. I fixed it.

Now you have to explain me why you sent three times this same
patch.

Next time, please use the format '[PATCH v1 1/1]' instead of
'[v1,PATCH 1/1]'. Normally for the first version you can omit v1.

For single patches you don't need the 0/1 cover letter. Just send
as [PATCH].

Please read Documentation/SubmittingPatches.

For now I merged this patch in i2c/i2c-host-2.

Thanks,
Andi

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-04-14 23:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-18  8:46 [v1,PATCH 0/1] i2c: mediatek: add bus regulator control for power saving adlavinitha reddy
2026-03-18  8:46 ` [v1,PATCH 1/1] " adlavinitha reddy
2026-03-26  9:49   ` Chen-Yu Tsai
2026-04-14 23:03   ` Andi Shyti
  -- strict thread matches above, loose matches on Subject: below --
2026-03-18  8:42 [v1,PATCH 0/1] " adlavinitha reddy
2026-03-18  8:42 ` [v1,PATCH 1/1] " adlavinitha reddy
     [not found] <20260318081126.4098146-1-adlavinitha.reddy@mediatek.com>
2026-03-18  8:11 ` adlavinitha reddy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox