From: adlavinitha reddy <adlavinitha.reddy@mediatek.com>
To: Qii Wang <qii.wang@mediatek.com>,
Andi Shyti <andi.shyti@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Cc: <linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infraded.org>,
<Project_Global_Chrome_Upstream_Group@mediatek.com>,
adlavinitha reddy <adlavinitha.reddy@mediatek.com>
Subject: [v1,PATCH 1/1] i2c: mediatek: add bus regulator control for power saving
Date: Wed, 18 Mar 2026 16:11:19 +0800 [thread overview]
Message-ID: <20260318081126.4098146-2-adlavinitha.reddy@mediatek.com> (raw)
In-Reply-To: <20260318081126.4098146-1-adlavinitha.reddy@mediatek.com>
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
next parent reply other threads:[~2026-03-18 8:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260318081126.4098146-1-adlavinitha.reddy@mediatek.com>
2026-03-18 8:11 ` adlavinitha reddy [this message]
2026-03-18 8:42 [v1,PATCH 0/1] i2c: mediatek: add bus regulator control for power saving adlavinitha reddy
2026-03-18 8:42 ` [v1,PATCH 1/1] " adlavinitha reddy
-- strict thread matches above, loose matches on Subject: below --
2026-03-18 8:46 [v1,PATCH 0/1] " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260318081126.4098146-2-adlavinitha.reddy@mediatek.com \
--to=adlavinitha.reddy@mediatek.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=andi.shyti@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infraded.org \
--cc=matthias.bgg@gmail.com \
--cc=qii.wang@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox