dt-bindings: i2c: mt7621: Document an7581 compatible
Subsystems (4)
PATCH 1/2 dt-bindings: i2c: mt7621: Document an7581 compatible
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.
--- .../devicetree/bindings/i2c/mediatek,mt7621-i2c.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/i2c/mediatek,mt7621-i2c.yaml +3 -1
@@ -14,7 +14,9 @@ allOf: properties: compatible: - const: mediatek,mt7621-i2c + enum: + - airoha,an7581-i2c + - mediatek,mt7621-i2c reg: maxItems: 1
Signature · 1 line
2.55.0
PATCH 2/2 i2c: mt7621: limit SCL_STRETCH only to Mediatek SoC
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.
--- drivers/i2c/busses/i2c-mt7621.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-mt7621.c +12 -2
@@ -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;
Signature · 1 line
2.55.0
Rob Herring
maintainerRe: [PATCH 2/2] i2c: mt7621: limit SCL_STRETCH only to Mediatek SoC
Quoted 54 lines · Christian Marangi
The same I2C driver is also used for Airoha SoC with the only difference that the
i2c_resetshould not enableSCL_STRETCHfor Airoha SoC.Introduce a new compatible for Airoha and limit the
SCL_STRETCHonly to Mediatek SoC.Signed-off-by Christian Marangi <[email protected]>--- drivers/i2c/busses/i2c-mt7621.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-mt7621.c +8
-2@@ -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 */ } };
drivers/i2c/busses/i2c-mt7621.c static int mtk_i2c_probe(struct platform_device *pdev) · line 307
Quoted 6 lines
drivers/i2c/busses/i2c-mt7621.c +3
-0@@ -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
Quoted 11 lines · Christian Marangi
Airoha SoC implement the same Mediatek logic for I2C bus with the only difference of not having
SCL_STRETCHbit.Add a dedicated compatible for the Airoha AN7581 SoC to abbount for this minor bit variant.
Signed-off-by Christian Marangi <[email protected]>--- .../devicetree/bindings/i2c/mediatek,mt7621-i2c.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)