This adds I2C support in the device tree of the T-Head TH1520 RISCV-SoC
and a default configuration for the BeagleV-Ahead. It appears that the
TH1520 I2C is already supported in the upstream kernel through the
Synopsis Designware I2C adapter driver.
This patch depends on the clock patch from Drew Fustini
Link: https://lore.kernel.org/linux-riscv/[email protected]
and the pinctrl patch from Emil Renner Berthing
Link: https://lore.kernel.org/linux-riscv/[email protected]
Changed from v1:
1. Remove redundant example for Synopsis DesignWare-I2C bindings
2. Remove Node Ordering commit as it has already been taken
3. Remove EEPROM label
4. Rebase on pinctrl and clock driver patches
5. Add pinctrl configuration
6. Replaced the fixed-clock with a correct configuration
Signed-off-by: Thomas Bonnefille <[email protected]>
---
Thomas Bonnefille (3):
dt-bindings: i2c: dw: Document compatible thead,th1520-i2c
riscv: dts: thead: Add TH1520 I2C nodes
riscv: dts: thead: Enable I2C on the BeagleV-Ahead
.../bindings/i2c/snps,designware-i2c.yaml | 4 ++
arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts | 84 ++++++++++++++++++++++
arch/riscv/boot/dts/thead/th1520.dtsi | 50 +++++++++++++
3 files changed, 138 insertions(+)
---
base-commit: e1fb0b71c746f863fa49ff359d58c949538ce181
change-id: 20240425-i2c-th1520-fc3ce1a8b472
Best regards,
--
Thomas Bonnefille <[email protected]>
This commit enables the I2C0 controller of the TH1520, together with
the FT24C32A EEPROM that is connected to it.
In addition, this commit also enables the I2C controllers I2C2, I2C4
and I2C5 as they are all three exposed on headers (P9 19 and 20 for I2C2,
P9 17 and 18 for I2C5 and MikroBus 7 and 5 for I2C4).
It also defined the required pinctrl nodes.
Signed-off-by: Thomas Bonnefille <[email protected]>
---
arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts | 84 ++++++++++++++++++++++
1 file changed, 84 insertions(+)
diff --git a/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts b/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts
index 57a2578123eb..aeb04f5159d5 100644
--- a/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts
+++ b/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts
@@ -121,6 +121,47 @@ led-pins {
};
};
+&padctrl1_apsys {
+ i2c0_pins: i2c0-0 {
+ i2c-pins {
+ pins = "I2C0_SDA",
+ "I2C0_SCL";
+ function = "i2c";
+ bias-pull-up = <2100>;
+ drive-strength = <7>;
+ input-enable;
+ input-schmitt-enable;
+ slew-rate = <0>;
+ };
+ };
+
+ i2c4_pins: i2c4-0 {
+ i2c-pins {
+ pins = "GPIO0_19", /*I2C4_SDA*/
+ "GPIO0_18"; /*I2C4_SCL*/
+ function = "i2c";
+ bias-pull-up = <2100>;
+ drive-strength = <7>;
+ input-enable;
+ input-schmitt-enable;
+ slew-rate = <0>;
+ };
+ };
+
+ i2c5_pins: i2c5-0 {
+ i2c-pins {
+ pins = "QSPI1_D0_MOSI", /*I2C5_SDA*/
+ "QSPI1_CSN0"; /*I2C5_SCL*/
+ function = "i2c";
+ bias-pull-up = <2100>;
+ drive-strength = <7>;
+ input-enable;
+ input-schmitt-enable;
+ slew-rate = <0>;
+ };
+ };
+};
+
&padctrl0_apsys {
uart0_pins: uart0-0 {
tx-pins {
@@ -143,6 +184,19 @@ rx-pins {
slew-rate = <0>;
};
};
+
+ i2c2_pins: i2c2-0 {
+ i2c-pins {
+ pins = "I2C2_SDA",
+ "I2C2_SCL";
+ function = "i2c";
+ bias-pull-up = <2100>;
+ drive-strength = <7>;
+ input-enable;
+ input-schmitt-enable;
+ slew-rate = <0>;
+ };
+ };
};
&uart0 {
@@ -150,3 +204,33 @@ &uart0 {
pinctrl-0 = <&uart0_pins>;
status = "okay";
};
+
+&i2c0 {
+ status = "okay";
+ clock-frequency = <100000>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c0_pins>;
+
+ eeprom@50 {
+ compatible = "atmel,24c32";
+ reg = <0x50>;
+ };
+};
+
+&i2c2 {
+ status = "okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c2_pins>;
+};
+
+&i2c4 {
+ status = "okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c4_pins>;
+};
+
+&i2c5 {
+ status = "okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c5_pins>;
+};
--
2.45.1
Add documentation for compatible string thead,th1520-i2c which can be
used specifically for the TH1520 SoC.
Signed-off-by: Thomas Bonnefille <[email protected]>
---
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml b/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
index d9293c57f573..60035a787e5c 100644
--- a/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
+++ b/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
@@ -33,6 +33,10 @@ properties:
- const: snps,designware-i2c
- description: Baikal-T1 SoC System I2C controller
const: baikal,bt1-sys-i2c
+ - description: T-HEAD TH1520 SoCs I2C controller
+ items:
+ - const: thead,th1520-i2c
+ - const: snps,designware-i2c
reg:
minItems: 1
--
2.45.1
Add nodes for the five I2C on the T-Head TH1520 RISCV SoC.
Signed-off-by: Thomas Bonnefille <[email protected]>
---
arch/riscv/boot/dts/thead/th1520.dtsi | 50 +++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi
index de7116290ca4..ae6cf4c441cf 100644
--- a/arch/riscv/boot/dts/thead/th1520.dtsi
+++ b/arch/riscv/boot/dts/thead/th1520.dtsi
@@ -252,6 +252,36 @@ gpio2: gpio-controller@0 {
};
};
+ i2c0: i2c@ffe7f20000 {
+ compatible = "thead,th1520-i2c", "snps,designware-i2c";
+ reg = <0xff 0xe7f20000 0x0 0x4000>;
+ interrupts = <44 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clk CLK_I2C0>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
+ i2c1: i2c@ffe7f24000 {
+ compatible = "thead,th1520-i2c", "snps,designware-i2c";
+ reg = <0xff 0xe7f24000 0x0 0x4000>;
+ interrupts = <45 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clk CLK_I2C1>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
+ i2c4: i2c@ffe7f28000 {
+ compatible = "thead,th1520-i2c", "snps,designware-i2c";
+ reg = <0xff 0xe7f28000 0x0 0x4000>;
+ interrupts = <48 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clk CLK_I2C4>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
gpio@ffe7f38000 {
compatible = "snps,dw-apb-gpio";
reg = <0xff 0xe7f38000 0x0 0x1000>;
@@ -342,6 +372,16 @@ uart2: serial@ffec010000 {
status = "disabled";
};
+ i2c3: i2c@ffec014000 {
+ compatible = "thead,th1520-i2c", "snps,designware-i2c";
+ reg = <0xff 0xec014000 0x0 0x4000>;
+ interrupts = <47 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clk CLK_I2C3>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
dmac0: dma-controller@ffefc00000 {
compatible = "snps,axi-dma-1.01a";
reg = <0xff 0xefc00000 0x0 0x1000>;
@@ -416,6 +456,16 @@ uart5: serial@fff7f0c000 {
status = "disabled";
};
+ i2c5: i2c@fff7f2c000 {
+ compatible = "thead,th1520-i2c", "snps,designware-i2c";
+ reg = <0xff 0xf7f2c000 0x0 0x4000>;
+ interrupts = <49 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clk CLK_I2C5>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
timer4: timer@ffffc33000 {
compatible = "snps,dw-apb-timer";
reg = <0xff 0xffc33000 0x0 0x14>;
--
2.45.1
On Fri, May 17, 2024 at 11:09:53AM +0200, Thomas Bonnefille wrote:
> Add documentation for compatible string thead,th1520-i2c which can be
> used specifically for the TH1520 SoC.
>
> Signed-off-by: Thomas Bonnefille <[email protected]>
Acked-by: Conor Dooley <[email protected]>
Cheers,
Conor.
Hi Thomas,
Thanks for the patch. Some comments below.
Thomas Bonnefille wrote:
> Add nodes for the five I2C on the T-Head TH1520 RISCV SoC.
>
> Signed-off-by: Thomas Bonnefille <[email protected]>
> ---
> arch/riscv/boot/dts/thead/th1520.dtsi | 50 +++++++++++++++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
>
> diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi
> index de7116290ca4..ae6cf4c441cf 100644
> --- a/arch/riscv/boot/dts/thead/th1520.dtsi
> +++ b/arch/riscv/boot/dts/thead/th1520.dtsi
> @@ -252,6 +252,36 @@ gpio2: gpio-controller@0 {
> };
> };
>
> + i2c0: i2c@ffe7f20000 {
> + compatible = "thead,th1520-i2c", "snps,designware-i2c";
> + reg = <0xff 0xe7f20000 0x0 0x4000>;
> + interrupts = <44 IRQ_TYPE_LEVEL_HIGH>;
> + clocks = <&clk CLK_I2C0>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> + status = "disabled";
> + };
> +
> + i2c1: i2c@ffe7f24000 {
> + compatible = "thead,th1520-i2c", "snps,designware-i2c";
> + reg = <0xff 0xe7f24000 0x0 0x4000>;
> + interrupts = <45 IRQ_TYPE_LEVEL_HIGH>;
> + clocks = <&clk CLK_I2C1>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> + status = "disabled";
> + };
> +
> + i2c4: i2c@ffe7f28000 {
> + compatible = "thead,th1520-i2c", "snps,designware-i2c";
> + reg = <0xff 0xe7f28000 0x0 0x4000>;
> + interrupts = <48 IRQ_TYPE_LEVEL_HIGH>;
> + clocks = <&clk CLK_I2C4>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> + status = "disabled";
> + };
> +
These nodes should be ordered by their memory addres, but the gpio2 controller
above has address 0xffe7f34000 which is greater than i2c0 at 0xffe7f20000.
> gpio@ffe7f38000 {
> compatible = "snps,dw-apb-gpio";
> reg = <0xff 0xe7f38000 0x0 0x1000>;
> @@ -342,6 +372,16 @@ uart2: serial@ffec010000 {
> status = "disabled";
> };
>
> + i2c3: i2c@ffec014000 {
> + compatible = "thead,th1520-i2c", "snps,designware-i2c";
> + reg = <0xff 0xec014000 0x0 0x4000>;
> + interrupts = <47 IRQ_TYPE_LEVEL_HIGH>;
> + clocks = <&clk CLK_I2C3>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> + status = "disabled";
> + };
> +
> dmac0: dma-controller@ffefc00000 {
> compatible = "snps,axi-dma-1.01a";
> reg = <0xff 0xefc00000 0x0 0x1000>;
> @@ -416,6 +456,16 @@ uart5: serial@fff7f0c000 {
> status = "disabled";
> };
>
> + i2c5: i2c@fff7f2c000 {
> + compatible = "thead,th1520-i2c", "snps,designware-i2c";
> + reg = <0xff 0xf7f2c000 0x0 0x4000>;
> + interrupts = <49 IRQ_TYPE_LEVEL_HIGH>;
> + clocks = <&clk CLK_I2C5>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> + status = "disabled";
> + };
> +
I know it's probably hard to test i2c2 with the Ahead board, but chances are
very low that the disignware driver works with i2c0, i2c1, i2c3, i2c4 and i2c5,
but not i2c2, so plaese add that node too. The audio and aon i2cs are fine to
add later.
> timer4: timer@ffffc33000 {
> compatible = "snps,dw-apb-timer";
> reg = <0xff 0xffc33000 0x0 0x14>;
>
> --
> 2.45.1
>
>
> _______________________________________________
> linux-riscv mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-riscv
Thomas Bonnefille wrote:
> This commit enables the I2C0 controller of the TH1520, together with
> the FT24C32A EEPROM that is connected to it.
> In addition, this commit also enables the I2C controllers I2C2, I2C4
> and I2C5 as they are all three exposed on headers (P9 19 and 20 for I2C2,
> P9 17 and 18 for I2C5 and MikroBus 7 and 5 for I2C4).
> It also defined the required pinctrl nodes.
>
> Signed-off-by: Thomas Bonnefille <[email protected]>
> ---
> arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts | 84 ++++++++++++++++++++++
> 1 file changed, 84 insertions(+)
>
> diff --git a/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts b/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts
> index 57a2578123eb..aeb04f5159d5 100644
> --- a/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts
> +++ b/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts
> @@ -121,6 +121,47 @@ led-pins {
> };
> };
>
> +&padctrl1_apsys {
These node references should be ordered alphabetically, so please put this
below &padctrl0_apsys.
> + i2c0_pins: i2c0-0 {
> + i2c-pins {
> + pins = "I2C0_SDA",
> + "I2C0_SCL";
> + function = "i2c";
> + bias-pull-up = <2100>;
Are you sure the strong pull-up is needed here and below?
> + drive-strength = <7>;
> + input-enable;
> + input-schmitt-enable;
> + slew-rate = <0>;
> + };
> + };
> +
> + i2c4_pins: i2c4-0 {
> + i2c-pins {
> + pins = "GPIO0_19", /*I2C4_SDA*/
> + "GPIO0_18"; /*I2C4_SCL*/
Please add spaces here like other kernel comments. Eg. /* I2C4_SDA */
> + function = "i2c";
> + bias-pull-up = <2100>;
> + drive-strength = <7>;
> + input-enable;
> + input-schmitt-enable;
> + slew-rate = <0>;
> + };
> + };
> +
> + i2c5_pins: i2c5-0 {
> + i2c-pins {
> + pins = "QSPI1_D0_MOSI", /*I2C5_SDA*/
> + "QSPI1_CSN0"; /*I2C5_SCL*/
Same here.
> + function = "i2c";
> + bias-pull-up = <2100>;
> + drive-strength = <7>;
> + input-enable;
> + input-schmitt-enable;
> + slew-rate = <0>;
> + };
> + };
> +};
> +
> &padctrl0_apsys {
> uart0_pins: uart0-0 {
> tx-pins {
> @@ -143,6 +184,19 @@ rx-pins {
> slew-rate = <0>;
> };
> };
> +
> + i2c2_pins: i2c2-0 {
i2c2-0 sorts before uart0-0 alphabetically.
> + i2c-pins {
> + pins = "I2C2_SDA",
> + "I2C2_SCL";
> + function = "i2c";
> + bias-pull-up = <2100>;
> + drive-strength = <7>;
> + input-enable;
> + input-schmitt-enable;
> + slew-rate = <0>;
> + };
> + };
> };
>
> &uart0 {
> @@ -150,3 +204,33 @@ &uart0 {
> pinctrl-0 = <&uart0_pins>;
> status = "okay";
> };
> +
> +&i2c0 {
Again please sort these references alphabetically.
> + status = "okay";
And the properties. Eg. move status below pinctrl-0.
> + clock-frequency = <100000>;
> + pinctrl-names = "default";
> + pinctrl-0 = <&i2c0_pins>;
> +
> + eeprom@50 {
> + compatible = "atmel,24c32";
> + reg = <0x50>;
> + };
> +};
> +
> +&i2c2 {
> + status = "okay";
> + pinctrl-names = "default";
> + pinctrl-0 = <&i2c2_pins>;
> +};
> +
> +&i2c4 {
> + status = "okay";
> + pinctrl-names = "default";
> + pinctrl-0 = <&i2c4_pins>;
> +};
> +
> +&i2c5 {
> + status = "okay";
> + pinctrl-names = "default";
> + pinctrl-0 = <&i2c5_pins>;
> +};
>
> --
> 2.45.1
>
>
> _______________________________________________
> linux-riscv mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-riscv