* [PATCH 1/2] dt-bindings: i2c: mt7621: Document an7581 compatible
@ 2026-10-21 15:39 Christian Marangi
2026-10-21 15:39 ` [PATCH 2/2] i2c: mt7621: limit SCL_STRETCH only to Mediatek SoC Christian Marangi
2026-10-30 17:48 ` [PATCH 1/2] dt-bindings: i2c: mt7621: Document an7581 compatible Rob Herring (Arm)
0 siblings, 2 replies; 4+ messages in thread
From: Christian Marangi @ 2026-10-21 15:39 UTC (permalink / raw)
To: Stefan Roese, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
linux-i2c, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek
Cc: Christian Marangi
Airoha SoC implement the same Mediatek logic for I2C bus with the only
difference of not having SCL_STRETCH bit.
Add a dedicated compatible for the Airoha AN7581 SoC to abbount for this
minor bit variant.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
.../devicetree/bindings/i2c/mediatek,mt7621-i2c.yaml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/i2c/mediatek,mt7621-i2c.yaml b/Documentation/devicetree/bindings/i2c/mediatek,mt7621-i2c.yaml
index 118ec00fc190..e6ea5bc1c681 100644
--- a/Documentation/devicetree/bindings/i2c/mediatek,mt7621-i2c.yaml
+++ b/Documentation/devicetree/bindings/i2c/mediatek,mt7621-i2c.yaml
@@ -14,7 +14,9 @@ allOf:
properties:
compatible:
- const: mediatek,mt7621-i2c
+ enum:
+ - airoha,an7581-i2c
+ - mediatek,mt7621-i2c
reg:
maxItems: 1
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] i2c: mt7621: limit SCL_STRETCH only to Mediatek SoC
2026-10-21 15:39 [PATCH 1/2] dt-bindings: i2c: mt7621: Document an7581 compatible Christian Marangi
@ 2026-10-21 15:39 ` Christian Marangi
2026-10-30 17:48 ` Rob Herring
2026-10-30 17:48 ` [PATCH 1/2] dt-bindings: i2c: mt7621: Document an7581 compatible Rob Herring (Arm)
1 sibling, 1 reply; 4+ messages in thread
From: Christian Marangi @ 2026-10-21 15:39 UTC (permalink / raw)
To: Stefan Roese, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
linux-i2c, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek
Cc: Christian Marangi
The same I2C driver is also used for Airoha SoC with the only difference
that the i2c_reset should not enable SCL_STRETCH for Airoha SoC.
Introduce a new compatible for Airoha and limit the SCL_STRETCH only to
Mediatek SoC.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/i2c/busses/i2c-mt7621.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-mt7621.c b/drivers/i2c/busses/i2c-mt7621.c
index 0a288c998419..19dde7c4069e 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;
+ bool have_scl_stretch;
};
static int mtk_i2c_wait_idle(struct mtk_i2c *i2c)
@@ -83,6 +84,7 @@ static int mtk_i2c_wait_idle(struct mtk_i2c *i2c)
static void mtk_i2c_reset(struct mtk_i2c *i2c)
{
+ u32 reg;
int ret;
ret = device_reset(i2c->adap.dev.parent);
@@ -93,8 +95,11 @@ static void mtk_i2c_reset(struct mtk_i2c *i2c)
* Don't set SM0CTL0_ODRAIN as its bit meaning is inverted. To
* configure open-drain mode, this bit needs to be cleared.
*/
- iowrite32(((i2c->clk_div << 16) & SM0CTL0_CLK_DIV_MASK) | SM0CTL0_EN |
- SM0CTL0_SCL_STRETCH, i2c->base + REG_SM0CTL0_REG);
+ reg = ((i2c->clk_div << 16) & SM0CTL0_CLK_DIV_MASK) | SM0CTL0_EN;
+ if (i2c->have_scl_stretch)
+ reg |= SM0CTL0_SCL_STRETCH;
+
+ iowrite32(reg, i2c->base + REG_SM0CTL0_REG);
iowrite32(0, i2c->base + REG_SM0CFG2_REG);
}
@@ -249,6 +254,7 @@ static const struct i2c_algorithm mtk_i2c_algo = {
static const struct of_device_id i2c_mtk_dt_ids[] = {
{ .compatible = "mediatek,mt7621-i2c" },
+ { .compatible = "airoha,an7581-i2c" },
{ /* sentinel */ }
};
@@ -296,6 +302,10 @@ static int mtk_i2c_probe(struct platform_device *pdev)
return -EINVAL;
}
+ /* Set SCL_STRETCH only for Mediatek SoC */
+ if (device_is_compatible(i2c->dev, "mediatek,mt7621-i2c"))
+ i2c->have_scl_stretch = true;
+
adap = &i2c->adap;
adap->owner = THIS_MODULE;
adap->algo = &mtk_i2c_algo;
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] i2c: mt7621: limit SCL_STRETCH only to Mediatek SoC
2026-10-21 15:39 ` [PATCH 2/2] i2c: mt7621: limit SCL_STRETCH only to Mediatek SoC Christian Marangi
@ 2026-10-30 17:48 ` Rob Herring
0 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2026-10-30 17:48 UTC (permalink / raw)
To: Christian Marangi
Cc: Stefan Roese, Andi Shyti, Krzysztof Kozlowski, Conor Dooley,
Matthias Brugger, AngeloGioacchino Del Regno, linux-i2c,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
On Wed, Oct 21, 2026 at 05:39:52PM +0200, Christian Marangi wrote:
> The same I2C driver is also used for Airoha SoC with the only difference
> that the i2c_reset should not enable SCL_STRETCH for Airoha SoC.
>
> Introduce a new compatible for Airoha and limit the SCL_STRETCH only to
> Mediatek SoC.
>
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> ---
> drivers/i2c/busses/i2c-mt7621.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-mt7621.c b/drivers/i2c/busses/i2c-mt7621.c
> index 0a288c998419..19dde7c4069e 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;
> + bool have_scl_stretch;
> };
>
> static int mtk_i2c_wait_idle(struct mtk_i2c *i2c)
> @@ -83,6 +84,7 @@ static int mtk_i2c_wait_idle(struct mtk_i2c *i2c)
>
> static void mtk_i2c_reset(struct mtk_i2c *i2c)
> {
> + u32 reg;
> int ret;
>
> ret = device_reset(i2c->adap.dev.parent);
> @@ -93,8 +95,11 @@ static void mtk_i2c_reset(struct mtk_i2c *i2c)
> * Don't set SM0CTL0_ODRAIN as its bit meaning is inverted. To
> * configure open-drain mode, this bit needs to be cleared.
> */
> - iowrite32(((i2c->clk_div << 16) & SM0CTL0_CLK_DIV_MASK) | SM0CTL0_EN |
> - SM0CTL0_SCL_STRETCH, i2c->base + REG_SM0CTL0_REG);
> + reg = ((i2c->clk_div << 16) & SM0CTL0_CLK_DIV_MASK) | SM0CTL0_EN;
> + if (i2c->have_scl_stretch)
> + reg |= SM0CTL0_SCL_STRETCH;
> +
> + iowrite32(reg, i2c->base + REG_SM0CTL0_REG);
> iowrite32(0, i2c->base + REG_SM0CFG2_REG);
> }
>
> @@ -249,6 +254,7 @@ static const struct i2c_algorithm mtk_i2c_algo = {
>
> static const struct of_device_id i2c_mtk_dt_ids[] = {
> { .compatible = "mediatek,mt7621-i2c" },
> + { .compatible = "airoha,an7581-i2c" },
> { /* sentinel */ }
> };
>
> @@ -296,6 +302,10 @@ static int mtk_i2c_probe(struct platform_device *pdev)
> return -EINVAL;
> }
>
> + /* Set SCL_STRETCH only for Mediatek SoC */
> + if (device_is_compatible(i2c->dev, "mediatek,mt7621-i2c"))
> + i2c->have_scl_stretch = true;
Add match data for this. Calling device_is_compatible() doesn't scale.
Rob
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] dt-bindings: i2c: mt7621: Document an7581 compatible
2026-10-21 15:39 [PATCH 1/2] dt-bindings: i2c: mt7621: Document an7581 compatible Christian Marangi
2026-10-21 15:39 ` [PATCH 2/2] i2c: mt7621: limit SCL_STRETCH only to Mediatek SoC Christian Marangi
@ 2026-10-30 17:48 ` Rob Herring (Arm)
1 sibling, 0 replies; 4+ messages in thread
From: Rob Herring (Arm) @ 2026-10-30 17:48 UTC (permalink / raw)
To: Christian Marangi
Cc: linux-kernel, Matthias Brugger, Conor Dooley, Stefan Roese,
AngeloGioacchino Del Regno, devicetree, Krzysztof Kozlowski,
Andi Shyti, linux-arm-kernel, linux-i2c, linux-mediatek
On Wed, 21 Oct 2026 17:39:51 +0200, Christian Marangi wrote:
> Airoha SoC implement the same Mediatek logic for I2C bus with the only
> difference of not having SCL_STRETCH bit.
>
> Add a dedicated compatible for the Airoha AN7581 SoC to abbount for this
> minor bit variant.
>
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> ---
> .../devicetree/bindings/i2c/mediatek,mt7621-i2c.yaml | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-30 17:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-21 15:39 [PATCH 1/2] dt-bindings: i2c: mt7621: Document an7581 compatible Christian Marangi
2026-10-21 15:39 ` [PATCH 2/2] i2c: mt7621: limit SCL_STRETCH only to Mediatek SoC Christian Marangi
2026-10-30 17:48 ` Rob Herring
2026-10-30 17:48 ` [PATCH 1/2] dt-bindings: i2c: mt7621: Document an7581 compatible Rob Herring (Arm)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox