[PATCH 1/3] riscv: dts: spacemit: enable the i2c2 adapter on BPI-F3

Aurelien Jarno posted 3 patches 1 week, 3 days ago
There is a newer version of this series
[PATCH 1/3] riscv: dts: spacemit: enable the i2c2 adapter on BPI-F3
Posted by Aurelien Jarno 1 week, 3 days ago
Define properties for the I2C adapter, and enable it on the BPI-F3. It
will be used by the 24c02 eeprom.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts |  6 ++++++
 arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi    |  7 +++++++
 arch/riscv/boot/dts/spacemit/k1.dtsi            | 13 +++++++++++++
 3 files changed, 26 insertions(+)

diff --git a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
index 66375fd1e9974..3b6e4f52e9aad 100644
--- a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
+++ b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
@@ -111,6 +111,12 @@ rgmii1: phy@1 {
 	};
 };
 
+&i2c2 {
+	pinctrl-0 = <&i2c2_0_cfg>;
+	pinctrl-names = "default";
+	status = "okay";
+};
+
 &i2c8 {
 	pinctrl-0 = <&i2c8_cfg>;
 	pinctrl-names = "default";
diff --git a/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi b/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
index c9e9a844d2b1c..d565882c46dd7 100644
--- a/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
@@ -92,6 +92,13 @@ gmac1-pins {
 		};
 	};
 
+	i2c2_0_cfg: i2c2-0-cfg {
+		i2c2-0-pins {
+			pinmux = <K1_PADCONF(84, 4)>,	/* I2C2_SCL */
+				 <K1_PADCONF(85, 4)>;	/* I2C2_SDA */
+		};
+	};
+
 	i2c8_cfg: i2c8-cfg {
 		i2c8-0-pins {
 			pinmux = <K1_PADCONF(93, 0)>,	/* PWR_SCL */
diff --git a/arch/riscv/boot/dts/spacemit/k1.dtsi b/arch/riscv/boot/dts/spacemit/k1.dtsi
index bc61a380baca8..d4f38ded52c93 100644
--- a/arch/riscv/boot/dts/spacemit/k1.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k1.dtsi
@@ -497,6 +497,19 @@ pwm7: pwm@d401bc00 {
 			status = "disabled";
 		};
 
+		i2c2: i2c@d4012000 {
+			compatible = "spacemit,k1-i2c";
+			reg = <0x0 0xd4012000 0x0 0x38>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			clocks = <&syscon_apbc CLK_TWSI2>,
+				 <&syscon_apbc CLK_TWSI2_BUS>;
+			clock-names = "func", "bus";
+			clock-frequency = <400000>;
+			interrupts = <38>;
+			status = "disabled";
+		};
+
 		i2c8: i2c@d401d800 {
 			compatible = "spacemit,k1-i2c";
 			reg = <0x0 0xd401d800 0x0 0x38>;
-- 
2.47.2
Re: [PATCH 1/3] riscv: dts: spacemit: enable the i2c2 adapter on BPI-F3
Posted by Troy Mitchell 1 week, 2 days ago
On Sun, Sep 21, 2025 at 11:01:41PM +0200, Aurelien Jarno wrote:
> Define properties for the I2C adapter, and enable it on the BPI-F3. It
> will be used by the 24c02 eeprom.
> 
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
> --- a/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
> +++ b/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
> @@ -92,6 +92,13 @@ gmac1-pins {
>  		};
>  	};
>  
> +	i2c2_0_cfg: i2c2-0-cfg {
Should this be i2c2_4_cfg here?
From what I see, in the initial version the second cell was meant
to be the function number rather than the serial index.

It looks like the pwm part is also incorrect.

                - Troy
> +		i2c2-0-pins {
> +			pinmux = <K1_PADCONF(84, 4)>,	/* I2C2_SCL */
> +				 <K1_PADCONF(85, 4)>;	/* I2C2_SDA */
> +		};
> +	};
> +
>  	i2c8_cfg: i2c8-cfg {
>  		i2c8-0-pins {
>  			pinmux = <K1_PADCONF(93, 0)>,	/* PWR_SCL */
> diff --git a/arch/riscv/boot/dts/spacemit/k1.dtsi b/arch/riscv/boot/dts/spacemit/k1.dtsi
> index bc61a380baca8..d4f38ded52c93 100644
> --- a/arch/riscv/boot/dts/spacemit/k1.dtsi
> +++ b/arch/riscv/boot/dts/spacemit/k1.dtsi
> @@ -497,6 +497,19 @@ pwm7: pwm@d401bc00 {
>  			status = "disabled";
>  		};
>  
> +		i2c2: i2c@d4012000 {
> +			compatible = "spacemit,k1-i2c";
> +			reg = <0x0 0xd4012000 0x0 0x38>;
> +			#address-cells = <1>;
> +			#size-cells = <0>;
> +			clocks = <&syscon_apbc CLK_TWSI2>,
> +				 <&syscon_apbc CLK_TWSI2_BUS>;
> +			clock-names = "func", "bus";
> +			clock-frequency = <400000>;
> +			interrupts = <38>;
> +			status = "disabled";
> +		};
> +
>  		i2c8: i2c@d401d800 {
>  			compatible = "spacemit,k1-i2c";
>  			reg = <0x0 0xd401d800 0x0 0x38>;
> -- 
> 2.47.2
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH 1/3] riscv: dts: spacemit: enable the i2c2 adapter on BPI-F3
Posted by Aurelien Jarno 1 week, 1 day ago
Hi Troy,

Thanks for the review.

On 2025-09-23 09:32, Troy Mitchell wrote:
> On Sun, Sep 21, 2025 at 11:01:41PM +0200, Aurelien Jarno wrote:
> > Define properties for the I2C adapter, and enable it on the BPI-F3. It
> > will be used by the 24c02 eeprom.
> > 
> > Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> > ---
> > --- a/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
> > +++ b/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
> > @@ -92,6 +92,13 @@ gmac1-pins {
> >  		};
> >  	};
> >  
> > +	i2c2_0_cfg: i2c2-0-cfg {
> Should this be i2c2_4_cfg here?
> From what I see, in the initial version the second cell was meant
> to be the function number rather than the serial index.

Ok, I wasn't aware of that convention, I just reused the same numbering 
of the downstream 6.6 kernel. I'll fix that and use i2c2_4_cfg.

> It looks like the pwm part is also incorrect.

Yes, and also the submitted PCIE patches.

Aurelien

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                     http://aurel32.net
Re: [PATCH 1/3] riscv: dts: spacemit: enable the i2c2 adapter on BPI-F3
Posted by Troy Mitchell 1 week, 1 day ago
On Tue, Sep 23, 2025 at 09:16:50PM +0200, Aurelien Jarno wrote:
> Hi Troy,
> 
> Thanks for the review.
> 
> On 2025-09-23 09:32, Troy Mitchell wrote:
> > On Sun, Sep 21, 2025 at 11:01:41PM +0200, Aurelien Jarno wrote:
> > > Define properties for the I2C adapter, and enable it on the BPI-F3. It
> > > will be used by the 24c02 eeprom.
> > > 
> > > Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> > > ---
> > > --- a/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
> > > +++ b/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
> > > @@ -92,6 +92,13 @@ gmac1-pins {
> > >  		};
> > >  	};
> > >  
> > > +	i2c2_0_cfg: i2c2-0-cfg {
> > Should this be i2c2_4_cfg here?
> > From what I see, in the initial version the second cell was meant
> > to be the function number rather than the serial index.
> 
> Ok, I wasn't aware of that convention, I just reused the same numbering 
> of the downstream 6.6 kernel. I'll fix that and use i2c2_4_cfg.
I'm wrong..
The second number isn't function number.
You can find a more detailed discussion here:
(riscv: dts: spacemit: define a SPI controller node)

                - Troy
> 
> > It looks like the pwm part is also incorrect.
> 
> Yes, and also the submitted PCIE patches.
> 
> Aurelien
> 
> -- 
> Aurelien Jarno                          GPG: 4096R/1DDD8C9B
> aurelien@aurel32.net                     http://aurel32.net
>