[PATCH v2 1/3] i2c: mt7621: assert and deassert the reset line
From: John Crispin
Date: Thu Nov 12 2026 - 14:22:02 EST
The driver resets the controller with device_reset(), which needs a
.reset operation in the reset controller. The EN7581 reset controller
implements assert and deassert only, so there every call fails, logs
"I2C reset failed!" and leaves the controller as it is, also after a
transfer timeout.
Get the optional reset line at probe and assert and deassert it. The
MT7621 and MT7628 reset controller does the same in its .reset
operation, with no delay in between, so nothing changes there. A board
without a reset line no longer logs an error, and a reset controller
that is not ready yet defers the probe.
Suggested-by: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
Signed-off-by: John Crispin <john@xxxxxxxxxxx>
---
Changes in v2:
- New patch. It replaces "clk: en7523: add a reset operation" from
the clk series (Philipp).
- Link to the discussion: https://lore.kernel.org/r/0c96f978571c569de6552fc11131e45b55cada1b.camel@xxxxxxxxxxxxxx
drivers/i2c/busses/i2c-mt7621.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-mt7621.c b/drivers/i2c/busses/i2c-mt7621.c
index 9ea5e3f9a763..7a31cc8b89ce 100644
--- a/drivers/i2c/busses/i2c-mt7621.c
+++ b/drivers/i2c/busses/i2c-mt7621.c
@@ -65,6 +65,7 @@ struct mtk_i2c {
u32 clk_div;
u32 flags;
struct clk *clk;
+ struct reset_control *rst;
};
static int mtk_i2c_wait_idle(struct mtk_i2c *i2c)
@@ -85,7 +86,9 @@ static void mtk_i2c_reset(struct mtk_i2c *i2c)
{
int ret;
- ret = device_reset(i2c->adap.dev.parent);
+ ret = reset_control_assert(i2c->rst);
+ if (!ret)
+ ret = reset_control_deassert(i2c->rst);
if (ret)
dev_err(i2c->dev, "I2C reset failed!\n");
@@ -288,6 +291,11 @@ static int mtk_i2c_probe(struct platform_device *pdev)
return PTR_ERR(i2c->clk);
}
+ i2c->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
+ if (IS_ERR(i2c->rst))
+ return dev_err_probe(&pdev->dev, PTR_ERR(i2c->rst),
+ "Failed to get reset\n");
+
i2c->dev = &pdev->dev;
if (of_property_read_u32(pdev->dev.of_node, "clock-frequency",
--
2.34.1