Skip to contentSkip to conversation

Add MediaTek MT8365 I2C support

PATCH In review Alexandre Mergnat 3 participants 7 messages Mar 28, 2023 – Mar 31, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v6 cover Add MediaTek MT8365 I2C support

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]
This dependancy has been applied by Matthias Brugger [3]

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/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/
[3]: https://lore.kernel.org/all/[email protected]/

---
Changes in v6:
- Remove mediatek,pull-up-adv which is a deprecated pin-control property.
- Link to v5: https://lore.kernel.org/r/[email protected]

Changes in v5:
- Remove mediatek,drive-strength-adv which is a deprecated pin-control property.
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Fix some properties order.
- Remove the useless properties.
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Rebased to v6.3-rc1.
- Move i2c3 node to be consistent with the SoC address order.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Drop the patch which do useless change in i2c-mt65xx.c driver.
- Change 2 lines compatible/reg in oneline.
- Link to v1: https://lore.kernel.org/r/[email protected]

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

 arch/arm64/boot/dts/mediatek/mt8365-evk.dts | 15 +++++++++
 arch/arm64/boot/dts/mediatek/mt8365.dtsi    | 48 +++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)

---
base-commit: 5c6b974d24c21a6aa5d8b524067d7d9bc7fcc4f2
change-id: 20221122-mt8365-i2c-support-fc048da261ea

Best regards,

Signature · 1 line
Alexandre Mergnat <[email protected]>
#1 lore raw

PATCH v6 1/2 arm64: dts: mediatek: add i2c support for mt8365 SoC

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

---
 arch/arm64/boot/dts/mediatek/mt8365.dtsi | 48 ++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
arch/arm64/boot/dts/mediatek/mt8365.dtsi +48 -0
index 15ac4c1f0966..b70f4d256f63 100644
@@ -282,6 +282,42 @@ 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";
+		};
+
 		spi: spi@1100a000 {
 			compatible = "mediatek,mt8365-spi", "mediatek,mt7622-spi";
 			reg = <0 0x1100a000 0 0x100>;
@@ -295,6 +331,18 @@ spi: spi@1100a000 {
 			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";
+		};
+
 		ssusb: usb@11201000 {
 			compatible = "mediatek,mt8365-mtu3", "mediatek,mtu3";
 			reg = <0 0x11201000 0 0x2e00>, <0 0x11203e00 0 0x0100>;
Signature · 1 line
2.25.1
#2 lore raw

PATCH v6 2/2 arm64: dts: mediatek: enable i2c0 for mt8365-evk board

In reply to Alexandre Mergnat

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.

---
 arch/arm64/boot/dts/mediatek/mt8365-evk.dts | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm64/boot/dts/mediatek/mt8365-evk.dts +15 -0
index 4683704ea235..adc79ba14b33 100644
@@ -87,6 +87,13 @@ optee_reserved: optee@43200000 {
 	};
 };
 
+&i2c0 {
+	clock-frequency = <100000>;
+	pinctrl-0 = <&i2c0_pins>;
+	pinctrl-names = "default";
+	status = "okay";
+};
+
 &pio {
 	gpio_keys: gpio-keys-pins {
 		pins {
@@ -96,6 +103,14 @@ pins {
 		};
 	};
 
+	i2c0_pins: i2c0-pins {
+		pins {
+			bias-pull-up;
+			pinmux = <MT8365_PIN_57_SDA0__FUNC_SDA0_0>,
+				 <MT8365_PIN_58_SCL0__FUNC_SCL0_0>;
+		};
+	};
+
 	uart0_pins: uart0-pins {
 		pins {
 			pinmux = <MT8365_PIN_35_URXD0__FUNC_URXD0>,
Signature · 1 line
2.25.1
maintainer Reviewed-by on v6 2/2
#3 lore raw

Re: [PATCH v6 2/2] arm64: dts: mediatek: enable i2c0 for mt8365-evk board

Il 28/03/23 11:04, Alexandre Mergnat ha scritto:

Quoted 30 lines

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.

---
  arch/arm64/boot/dts/mediatek/mt8365-evk.dts | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
arch/arm64/boot/dts/mediatek/mt8365-evk.dts +7 -0
index 4683704ea235..adc79ba14b33 100644
@@ -87,6 +87,13 @@ optee_reserved: optee@43200000 {
  	};
  };
 
+&i2c0 {
+	clock-frequency = <100000>;
+	pinctrl-0 = <&i2c0_pins>;
+	pinctrl-names = "default";
+	status = "okay";
+};
+
  &pio {
  	gpio_keys: gpio-keys-pins {
  		pins {

arch/arm64/boot/dts/mediatek/mt8365-evk.dts pins { · line 108

Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt8365-evk.dts +3 -0
@@ -96,6 +103,14 @@ pins {
  		};
  	};
 
+	i2c0_pins: i2c0-pins {
+		pins {
+			bias-pull-up;

I prefer seeing pinmux first, any other properties last.... If Matthias can please fix that while applying...

#4 lore raw

Re: [PATCH v6 2/2] arm64: dts: mediatek: enable i2c0 for mt8365-evk board

Quoted 35 lines · AngeloGioacchino Del Regno

Il 28/03/23 11:04, Alexandre Mergnat ha scritto:

Quoted 33 lines

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.

---
  arch/arm64/boot/dts/mediatek/mt8365-evk.dts | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
arch/arm64/boot/dts/mediatek/mt8365-evk.dts +7 -0
index 4683704ea235..adc79ba14b33 100644
@@ -87,6 +87,13 @@ optee_reserved: optee@43200000 {
      };
  };
 
+&i2c0 {
+     clock-frequency = <100000>;
+     pinctrl-0 = <&i2c0_pins>;
+     pinctrl-names = "default";
+     status = "okay";
+};
+
  &pio {
      gpio_keys: gpio-keys-pins {
              pins {
@@ -96,6 +103,14 @@ pins {
              };
      };
 
Quoted 5 lines

arch/arm64/boot/dts/mediatek/mt8365-evk.dts pins { · line 108

Quoted 3 lines
arch/arm64/boot/dts/mediatek/mt8365-evk.dts +3 -0
+     i2c0_pins: i2c0-pins {
+             pins {
+                     bias-pull-up;

I prefer seeing pinmux first, any other properties last....

Here the pinctrl binding cleanup [1]

Regards,
Alex

[1]: https://lore.kernel.org/all/[email protected]/

maintainer
#5 lore raw

Re: [PATCH v6 2/2] arm64: dts: mediatek: enable i2c0 for mt8365-evk board

In reply to AngeloGioacchino Del Regno
Quoted 30 lines · AngeloGioacchino Del Regno

Il 28/03/23 11:04, Alexandre Mergnat ha scritto:

Quoted 29 lines

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.

---
  arch/arm64/boot/dts/mediatek/mt8365-evk.dts | 15 +++++++++++++++

  1 file changed, 15 insertions(+)
arch/arm64/boot/dts/mediatek/mt8365-evk.dts +7 -0
index 4683704ea235..adc79ba14b33 100644
@@ -87,6 +87,13 @@ optee_reserved: optee@43200000 {
       };
   };
+&i2c0 {
+    clock-frequency = <100000>;
+    pinctrl-0 = <&i2c0_pins>;
+    pinctrl-names = "default";
+    status = "okay";
+};
+
   &pio {
       gpio_keys: gpio-keys-pins {
           pins {
@@ -96,6 +103,14 @@ pins {
Quoted 9 lines

arch/arm64/boot/dts/mediatek/mt8365-evk.dts pins { · line 108

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt8365-evk.dts +3 -0
           };
       };
+    i2c0_pins: i2c0-pins {
+        pins {
+            bias-pull-up;

I prefer seeing pinmux first, any other properties last.... If Matthias can please fix that while applying...

Done and queued the whole series.

Thanks!
Matthias

Quoted 3 lines
#6 lore raw

Re: [PATCH v6 2/2] arm64: dts: mediatek: enable i2c0 for mt8365-evk board

Thanks Angelo and Matthis for your time !

Alex

Quoted 53 lines · Matthias Brugger
Quoted 31 lines · AngeloGioacchino Del Regno

Il 28/03/23 11:04, Alexandre Mergnat ha scritto:

Quoted 30 lines

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.

---
  arch/arm64/boot/dts/mediatek/mt8365-evk.dts | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
arch/arm64/boot/dts/mediatek/mt8365-evk.dts +7 -0
index 4683704ea235..adc79ba14b33 100644
@@ -87,6 +87,13 @@ optee_reserved: optee@43200000 {
      };
  };
+&i2c0 {
+    clock-frequency = <100000>;
+    pinctrl-0 = <&i2c0_pins>;
+    pinctrl-names = "default";
+    status = "okay";
+};
+
  &pio {
      gpio_keys: gpio-keys-pins {
          pins {
@@ -96,6 +103,14 @@ pins {
Quoted 9 lines

arch/arm64/boot/dts/mediatek/mt8365-evk.dts pins { · line 108

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt8365-evk.dts +3 -0
          };
      };
+    i2c0_pins: i2c0-pins {
+        pins {
+            bias-pull-up;

I prefer seeing pinmux first, any other properties last.... If Matthias can please fix that while applying...

Done and queued the whole series.

Thanks!
Matthias

Quoted 3 lines