mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] Add MediaTek MT8365 I2C support
@ 2023-01-17  8:49 Alexandre Mergnat
  2023-01-17  8:49 ` [PATCH 1/4] dt-bindings: i2c: i2c-mt65xx: add binding for MT8365 SoC Alexandre Mergnat
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Alexandre Mergnat @ 2023-01-17  8:49 UTC (permalink / raw)
  To: Rob Herring, Qii Wang, Krzysztof Kozlowski, Matthias Brugger
  Cc: linux-i2c, Rob Herring, Fabien Parent, linux-arm-kernel,
	Alexandre Mergnat, Kevin Hilman, linux-kernel, linux-mediatek,
	devicetree

Hi,
This patch series adds I2C support for MT8365-EVK board.
The I2C-0 is enabled, it can be used through the board pin header,
as described directly on the PCB.

This series depends to another one which add support for
MT8365 SoC and EVK board. Link [1]

One patch has been cherry-picked from [2], so I've addressed the comment
and kept the trailer.

Regards,
Alex

[1]: https://lore.kernel.org/linux-mediatek/20230101220149.3035048-1-bero@baylibre.com/
[2]: https://lore.kernel.org/all/20220531135026.238475-2-fparent@baylibre.com/

To: Qii Wang <qii.wang@mediatek.com>
To: Rob Herring <robh+dt@kernel.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: linux-i2c@vger.kernel.org
Cc: devicetree@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: Fabien Parent <fparent@baylibre.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Rob Herring <robh@kernel.org>
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>

---
Alexandre Mergnat (2):
      arm64: dts: mediatek: add i2c support for mt8365 SoC
      arm64: dts: mediatek: enable i2c0 for mt8365-evk board

Fabien Parent (2):
      dt-bindings: i2c: i2c-mt65xx: add binding for MT8365 SoC
      i2c: i2c-mt65xx: add MT8365 SoC support

 .../devicetree/bindings/i2c/i2c-mt65xx.yaml        |  4 ++
 arch/arm64/boot/dts/mediatek/mt8365-evk.dts        | 19 +++++++
 arch/arm64/boot/dts/mediatek/mt8365.dtsi           | 60 ++++++++++++++++++++++
 drivers/i2c/busses/i2c-mt65xx.c                    | 14 +++++
 4 files changed, 97 insertions(+)
---
base-commit: 8b6cfcce3ce939db11166680a57253c39110f07e
change-id: 20221122-mt8365-i2c-support-fc048da261ea

Best regards,
-- 
Alexandre Mergnat <amergnat@baylibre.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] dt-bindings: i2c: i2c-mt65xx: add binding for MT8365 SoC
  2023-01-17  8:49 [PATCH 0/4] Add MediaTek MT8365 I2C support Alexandre Mergnat
@ 2023-01-17  8:49 ` Alexandre Mergnat
  2023-01-17 12:50   ` AngeloGioacchino Del Regno
  2023-01-17  8:49 ` [PATCH 2/4] arm64: dts: mediatek: add i2c support for mt8365 SoC Alexandre Mergnat
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Alexandre Mergnat @ 2023-01-17  8:49 UTC (permalink / raw)
  To: Rob Herring, Qii Wang, Krzysztof Kozlowski, Matthias Brugger
  Cc: linux-i2c, Rob Herring, Fabien Parent, linux-arm-kernel,
	Alexandre Mergnat, Kevin Hilman, linux-kernel, linux-mediatek,
	devicetree

From: Fabien Parent <fparent@baylibre.com>

Add binding documentation for the MT8365 I2C controllers.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
---
 Documentation/devicetree/bindings/i2c/i2c-mt65xx.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/i2c/i2c-mt65xx.yaml b/Documentation/devicetree/bindings/i2c/i2c-mt65xx.yaml
index 421563bf576c..72ae2e01cf22 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-mt65xx.yaml
+++ b/Documentation/devicetree/bindings/i2c/i2c-mt65xx.yaml
@@ -41,6 +41,10 @@ properties:
               - mediatek,mt6797-i2c
               - mediatek,mt7623-i2c
           - const: mediatek,mt6577-i2c
+      - items:
+          - enum:
+              - mediatek,mt8365-i2c
+          - const: mediatek,mt8168-i2c
       - items:
           - enum:
               - mediatek,mt8195-i2c

-- 
b4 0.10.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/4] arm64: dts: mediatek: add i2c support for mt8365 SoC
  2023-01-17  8:49 [PATCH 0/4] Add MediaTek MT8365 I2C support Alexandre Mergnat
  2023-01-17  8:49 ` [PATCH 1/4] dt-bindings: i2c: i2c-mt65xx: add binding for MT8365 SoC Alexandre Mergnat
@ 2023-01-17  8:49 ` Alexandre Mergnat
  2023-01-17 12:52   ` AngeloGioacchino Del Regno
  2023-01-17  8:49 ` [PATCH 3/4] arm64: dts: mediatek: enable i2c0 for mt8365-evk board Alexandre Mergnat
  2023-01-17  8:49 ` [PATCH 4/4] i2c: i2c-mt65xx: add MT8365 SoC support Alexandre Mergnat
  3 siblings, 1 reply; 8+ messages in thread
From: Alexandre Mergnat @ 2023-01-17  8:49 UTC (permalink / raw)
  To: Rob Herring, Qii Wang, Krzysztof Kozlowski, Matthias Brugger
  Cc: linux-i2c, Rob Herring, Fabien Parent, linux-arm-kernel,
	Alexandre Mergnat, Kevin Hilman, linux-kernel, linux-mediatek,
	devicetree

There are four I2C master channels in MT8365 with a same HW architecture.

Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
---
 arch/arm64/boot/dts/mediatek/mt8365.dtsi | 60 ++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8365.dtsi b/arch/arm64/boot/dts/mediatek/mt8365.dtsi
index a32f2b7507be..3c2819bd32af 100644
--- a/arch/arm64/boot/dts/mediatek/mt8365.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8365.dtsi
@@ -282,6 +282,66 @@ pwm: pwm@11006000 {
 			clock-names = "top", "main", "pwm1", "pwm2", "pwm3";
 		};
 
+		i2c0: i2c@11007000 {
+			compatible = "mediatek,mt8365-i2c",
+				     "mediatek,mt8168-i2c";
+			reg = <0 0x11007000 0 0xa0>,
+			      <0 0x11000080 0 0x80>;
+			interrupts = <GIC_SPI 28 IRQ_TYPE_LEVEL_LOW>;
+			clock-div = <1>;
+			clocks = <&infracfg CLK_IFR_I2C0_AXI>,
+				 <&infracfg CLK_IFR_AP_DMA>;
+			clock-names = "main", "dma";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
+		i2c1: i2c@11008000 {
+			compatible = "mediatek,mt8365-i2c",
+				     "mediatek,mt8168-i2c";
+			reg = <0 0x11008000 0 0xa0>,
+			      <0 0x11000100 0 0x80>;
+			interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_LOW>;
+			clock-div = <1>;
+			clocks = <&infracfg CLK_IFR_I2C1_AXI>,
+				 <&infracfg CLK_IFR_AP_DMA>;
+			clock-names = "main", "dma";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
+		i2c2: i2c@11009000 {
+			compatible = "mediatek,mt8365-i2c",
+				     "mediatek,mt8168-i2c";
+			reg = <0 0x11009000 0 0xa0>,
+			      <0 0x11000180 0 0x80>;
+			interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_LOW>;
+			clock-div = <1>;
+			clocks = <&infracfg CLK_IFR_I2C2_AXI>,
+				 <&infracfg CLK_IFR_AP_DMA>;
+			clock-names = "main", "dma";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
+		i2c3: i2c@1100f000 {
+			compatible = "mediatek,mt8365-i2c",
+				     "mediatek,mt8168-i2c";
+			reg = <0 0x1100f000 0 0xa0>,
+			      <0 0x11000200 0 0x80>;
+			interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_LOW>;
+			clock-div = <1>;
+			clocks = <&infracfg CLK_IFR_I2C3_AXI>,
+				 <&infracfg CLK_IFR_AP_DMA>;
+			clock-names = "main", "dma";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
 		spi: spi@1100a000 {
 			compatible = "mediatek,mt8365-spi", "mediatek,mt7622-spi";
 			reg = <0 0x1100a000 0 0x100>;

-- 
b4 0.10.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/4] arm64: dts: mediatek: enable i2c0 for mt8365-evk board
  2023-01-17  8:49 [PATCH 0/4] Add MediaTek MT8365 I2C support Alexandre Mergnat
  2023-01-17  8:49 ` [PATCH 1/4] dt-bindings: i2c: i2c-mt65xx: add binding for MT8365 SoC Alexandre Mergnat
  2023-01-17  8:49 ` [PATCH 2/4] arm64: dts: mediatek: add i2c support for mt8365 SoC Alexandre Mergnat
@ 2023-01-17  8:49 ` Alexandre Mergnat
  2023-01-17  8:49 ` [PATCH 4/4] i2c: i2c-mt65xx: add MT8365 SoC support Alexandre Mergnat
  3 siblings, 0 replies; 8+ messages in thread
From: Alexandre Mergnat @ 2023-01-17  8:49 UTC (permalink / raw)
  To: Rob Herring, Qii Wang, Krzysztof Kozlowski, Matthias Brugger
  Cc: linux-i2c, Rob Herring, Fabien Parent, linux-arm-kernel,
	Alexandre Mergnat, Kevin Hilman, linux-kernel, linux-mediatek,
	devicetree

Enable the I2C0 bus provides communication with:
- The integrated RT9466 Switching Battery Charger.
- The integrated MT6691 LP4X buck for VDDQ.
- The integrated MT6691 LP4X buck for VDD2.
- The pin header, to plug external I2C devices.

Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
---
 arch/arm64/boot/dts/mediatek/mt8365-evk.dts | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8365-evk.dts b/arch/arm64/boot/dts/mediatek/mt8365-evk.dts
index 275ea3a0e708..d5d76a7dbd82 100644
--- a/arch/arm64/boot/dts/mediatek/mt8365-evk.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8365-evk.dts
@@ -88,6 +88,15 @@ optee_reserved: optee@43200000 {
 	};
 };
 
+&i2c0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&i2c0_pins>;
+	clock-frequency = <100000>;
+	status = "okay";
+	#address-cells = <1>;
+	#size-cells = <0>;
+};
+
 &pio {
 	gpio_keys: gpio-keys-pins {
 		pins {
@@ -97,6 +106,16 @@ pins {
 		};
 	};
 
+	i2c0_pins: i2c0 {
+		pins_i2c {
+			pinmux = <MT8365_PIN_57_SDA0__FUNC_SDA0_0>,
+				 <MT8365_PIN_58_SCL0__FUNC_SCL0_0>;
+			mediatek,pull-up-adv = <3>;
+			mediatek,drive-strength-adv = <00>;
+			bias-pull-up;
+		};
+	};
+
 	uart0_pins: uart0-pins {
 		pins {
 			pinmux = <MT8365_PIN_35_URXD0__FUNC_URXD0>,

-- 
b4 0.10.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/4] i2c: i2c-mt65xx: add MT8365 SoC support
  2023-01-17  8:49 [PATCH 0/4] Add MediaTek MT8365 I2C support Alexandre Mergnat
                   ` (2 preceding siblings ...)
  2023-01-17  8:49 ` [PATCH 3/4] arm64: dts: mediatek: enable i2c0 for mt8365-evk board Alexandre Mergnat
@ 2023-01-17  8:49 ` Alexandre Mergnat
  2023-01-17 12:49   ` AngeloGioacchino Del Regno
  3 siblings, 1 reply; 8+ messages in thread
From: Alexandre Mergnat @ 2023-01-17  8:49 UTC (permalink / raw)
  To: Rob Herring, Qii Wang, Krzysztof Kozlowski, Matthias Brugger
  Cc: linux-i2c, Rob Herring, Fabien Parent, linux-arm-kernel,
	Alexandre Mergnat, Kevin Hilman, linux-kernel, linux-mediatek,
	devicetree

From: Fabien Parent <fparent@baylibre.com>

Add support for I2C on MT8365 SoCs.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
---
 drivers/i2c/busses/i2c-mt65xx.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
index d80e59340d97..2c9dbb42861a 100644
--- a/drivers/i2c/busses/i2c-mt65xx.c
+++ b/drivers/i2c/busses/i2c-mt65xx.c
@@ -511,6 +511,19 @@ static const struct mtk_i2c_compatible mt8192_compat = {
 	.max_dma_support = 36,
 };
 
+static const struct mtk_i2c_compatible mt8365_compat = {
+	.regs = mt_i2c_regs_v1,
+	.pmic_i2c = 0,
+	.dcm = 1,
+	.auto_restart = 1,
+	.aux_len_reg = 1,
+	.timing_adjust = 1,
+	.dma_sync = 1,
+	.ltiming_adjust = 0,
+	.apdma_sync = 0,
+	.max_dma_support = 33,
+};
+
 static const struct of_device_id mtk_i2c_of_match[] = {
 	{ .compatible = "mediatek,mt2712-i2c", .data = &mt2712_compat },
 	{ .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat },
@@ -523,6 +536,7 @@ static const struct of_device_id mtk_i2c_of_match[] = {
 	{ .compatible = "mediatek,mt8186-i2c", .data = &mt8186_compat },
 	{ .compatible = "mediatek,mt8188-i2c", .data = &mt8188_compat },
 	{ .compatible = "mediatek,mt8192-i2c", .data = &mt8192_compat },
+	{ .compatible = "mediatek,mt8365-i2c", .data = &mt8365_compat },
 	{}
 };
 MODULE_DEVICE_TABLE(of, mtk_i2c_of_match);

-- 
b4 0.10.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/4] i2c: i2c-mt65xx: add MT8365 SoC support
  2023-01-17  8:49 ` [PATCH 4/4] i2c: i2c-mt65xx: add MT8365 SoC support Alexandre Mergnat
@ 2023-01-17 12:49   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 8+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-01-17 12:49 UTC (permalink / raw)
  To: Alexandre Mergnat, Rob Herring, Qii Wang, Krzysztof Kozlowski,
	Matthias Brugger
  Cc: linux-i2c, Rob Herring, Fabien Parent, linux-arm-kernel,
	Kevin Hilman, linux-kernel, linux-mediatek, devicetree

Il 17/01/23 09:49, Alexandre Mergnat ha scritto:
> From: Fabien Parent <fparent@baylibre.com>
> 
> Add support for I2C on MT8365 SoCs.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
> ---
>   drivers/i2c/busses/i2c-mt65xx.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
> index d80e59340d97..2c9dbb42861a 100644
> --- a/drivers/i2c/busses/i2c-mt65xx.c
> +++ b/drivers/i2c/busses/i2c-mt65xx.c
> @@ -511,6 +511,19 @@ static const struct mtk_i2c_compatible mt8192_compat = {
>   	.max_dma_support = 36,
>   };
>   
> +static const struct mtk_i2c_compatible mt8365_compat = {

This is exactly the same as mt8168_compat... so you can avoid adding this one
and you can also avoid adding the compatible to this driver.

This means that you can get it working with a devicetree declaring

compatible = "mediatek,mt8365-i2c", "mediatek,mt8168-i2c";

like you're already doing and without any addition to this driver at all.
So, you can drop this commit.

Regards,
Angelo



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] dt-bindings: i2c: i2c-mt65xx: add binding for MT8365 SoC
  2023-01-17  8:49 ` [PATCH 1/4] dt-bindings: i2c: i2c-mt65xx: add binding for MT8365 SoC Alexandre Mergnat
@ 2023-01-17 12:50   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 8+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-01-17 12:50 UTC (permalink / raw)
  To: Alexandre Mergnat, Rob Herring, Qii Wang, Krzysztof Kozlowski,
	Matthias Brugger
  Cc: linux-i2c, Rob Herring, Fabien Parent, linux-arm-kernel,
	Kevin Hilman, linux-kernel, linux-mediatek, devicetree

Il 17/01/23 09:49, Alexandre Mergnat ha scritto:
> From: Fabien Parent <fparent@baylibre.com>
> 
> Add binding documentation for the MT8365 I2C controllers.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> Acked-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] arm64: dts: mediatek: add i2c support for mt8365 SoC
  2023-01-17  8:49 ` [PATCH 2/4] arm64: dts: mediatek: add i2c support for mt8365 SoC Alexandre Mergnat
@ 2023-01-17 12:52   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 8+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-01-17 12:52 UTC (permalink / raw)
  To: Alexandre Mergnat, Rob Herring, Qii Wang, Krzysztof Kozlowski,
	Matthias Brugger
  Cc: linux-i2c, Rob Herring, Fabien Parent, linux-arm-kernel,
	Kevin Hilman, linux-kernel, linux-mediatek, devicetree

Il 17/01/23 09:49, Alexandre Mergnat ha scritto:
> There are four I2C master channels in MT8365 with a same HW architecture.
> 
> Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
> ---
>   arch/arm64/boot/dts/mediatek/mt8365.dtsi | 60 ++++++++++++++++++++++++++++++++
>   1 file changed, 60 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/mediatek/mt8365.dtsi b/arch/arm64/boot/dts/mediatek/mt8365.dtsi
> index a32f2b7507be..3c2819bd32af 100644
> --- a/arch/arm64/boot/dts/mediatek/mt8365.dtsi
> +++ b/arch/arm64/boot/dts/mediatek/mt8365.dtsi
> @@ -282,6 +282,66 @@ pwm: pwm@11006000 {
>   			clock-names = "top", "main", "pwm1", "pwm2", "pwm3";
>   		};
>   
> +		i2c0: i2c@11007000 {
> +			compatible = "mediatek,mt8365-i2c",
> +				     "mediatek,mt8168-i2c";
> +			reg = <0 0x11007000 0 0xa0>,
> +			      <0 0x11000080 0 0x80>;

Compatibles fit in one line (83 columns is fine);
regs fit in one line, reaching 76 columns.

Same comments for the other nodes that you're adding.

Regards,
Angelo



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-01-17 12:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-17  8:49 [PATCH 0/4] Add MediaTek MT8365 I2C support Alexandre Mergnat
2023-01-17  8:49 ` [PATCH 1/4] dt-bindings: i2c: i2c-mt65xx: add binding for MT8365 SoC Alexandre Mergnat
2023-01-17 12:50   ` AngeloGioacchino Del Regno
2023-01-17  8:49 ` [PATCH 2/4] arm64: dts: mediatek: add i2c support for mt8365 SoC Alexandre Mergnat
2023-01-17 12:52   ` AngeloGioacchino Del Regno
2023-01-17  8:49 ` [PATCH 3/4] arm64: dts: mediatek: enable i2c0 for mt8365-evk board Alexandre Mergnat
2023-01-17  8:49 ` [PATCH 4/4] i2c: i2c-mt65xx: add MT8365 SoC support Alexandre Mergnat
2023-01-17 12:49   ` AngeloGioacchino Del Regno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®