* [PATCH v2 1/2] dt-bindings: i2c: mt7621: Document an7581 compatible
@ 2026-10-31 10:26 Christian Marangi
2026-10-31 10:26 ` [PATCH v2 2/2] i2c: mt7621: limit SCL_STRETCH only to Mediatek SoC Christian Marangi
0 siblings, 1 reply; 2+ messages in thread
From: Christian Marangi @ 2026-10-31 10:26 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>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
---
Changes v2:
- Add ACK tag
.../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] 2+ messages in thread
* [PATCH v2 2/2] i2c: mt7621: limit SCL_STRETCH only to Mediatek SoC
2026-10-31 10:26 [PATCH v2 1/2] dt-bindings: i2c: mt7621: Document an7581 compatible Christian Marangi
@ 2026-10-31 10:26 ` Christian Marangi
0 siblings, 0 replies; 2+ messages in thread
From: Christian Marangi @ 2026-10-31 10:26 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>
---
Changes v2:
- Use match data for storage
drivers/i2c/busses/i2c-mt7621.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-mt7621.c b/drivers/i2c/busses/i2c-mt7621.c
index 0a288c998419..fa1f32d4f046 100644
--- a/drivers/i2c/busses/i2c-mt7621.c
+++ b/drivers/i2c/busses/i2c-mt7621.c
@@ -57,9 +57,14 @@
/* timeout waiting for I2C devices to respond */
#define TIMEOUT_MS 1000
+struct mtk_i2c_data {
+ bool have_scl_stretch;
+};
+
struct mtk_i2c {
void __iomem *base;
struct device *dev;
+ const struct mtk_i2c_data *data;
struct i2c_adapter adap;
u32 bus_freq;
u32 clk_div;
@@ -83,6 +88,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 +99,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->data->have_scl_stretch)
+ reg |= SM0CTL0_SCL_STRETCH;
+
+ iowrite32(reg, i2c->base + REG_SM0CTL0_REG);
iowrite32(0, i2c->base + REG_SM0CFG2_REG);
}
@@ -247,8 +256,17 @@ static const struct i2c_algorithm mtk_i2c_algo = {
.functionality = mtk_i2c_func,
};
+static const struct mtk_i2c_data i2c_mt7621_data = {
+ .have_scl_stretch = true,
+};
+
+static const struct mtk_i2c_data i2c_an7581_data = {
+ .have_scl_stretch = false,
+};
+
static const struct of_device_id i2c_mtk_dt_ids[] = {
- { .compatible = "mediatek,mt7621-i2c" },
+ { .compatible = "mediatek,mt7621-i2c", .data = &i2c_mt7621_data },
+ { .compatible = "airoha,an7581-i2c", .data = &i2c_an7581_data },
{ /* sentinel */ }
};
@@ -286,6 +304,7 @@ static int mtk_i2c_probe(struct platform_device *pdev)
}
i2c->dev = &pdev->dev;
+ i2c->data = device_get_match_data(&pdev->dev);
if (of_property_read_u32(pdev->dev.of_node, "clock-frequency",
&i2c->bus_freq))
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-31 10:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-31 10:26 [PATCH v2 1/2] dt-bindings: i2c: mt7621: Document an7581 compatible Christian Marangi
2026-10-31 10:26 ` [PATCH v2 2/2] i2c: mt7621: limit SCL_STRETCH only to Mediatek SoC Christian Marangi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox