Skip to contentSkip to conversation

Add basic SPI support for SG2042 SoC

PATCH Superseded Zixian Zeng 3 participants 6 messages Apr 7, 2025 – Apr 25, 2025

Subsystems (4)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add basic SPI support for SG2042 SoC

Implemented basic SPI support for SG2042 SoC[1] using the upstreamed Synopsys DW-SPI IP.

This is tested on milkv-pioneer board on bus level. Using driver/spi/spidev.c for creating virtual /dev/spidevX.Y and tools/spi/spidev_test for testing functionality.

---
Changes in v4:
- Adjust the order of spi nodes
- Place the binding after Renesas
- Fix the description issues of patches
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Remove the spi status on sg2042-milkv-pioneer board
- Remove remove clock GATE_CLK_SYSDMA_AXI from spi[2]
- Create dt-binding of compatible property
- Replace the general compatible property with SoC-specific in dts
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Rebase v1 to sophgo/master(github.com/sophgo/linux.git).
- Order properties in device node.
- Remove unevaluated properties clock-frequency.
- Set default status to disable.
- Link to v1: https://lore.kernel.org/r/[email protected]

[1] https://github.com/sophgo/sophgo-doc/blob/main/SG2042/TRM/source/SPI.rst
[2] https://github.com/sophgo/sophgo-doc/blob/main/SG2042/TRM/source/clock.rst#clock-tree

---
Zixian Zeng (2):
spi: dt-bindings: snps,dw-apb-ssi: Add compatible for SOPHGO SG2042 SoC
riscv: sophgo: dts: Add spi controller for SG2042

 .../devicetree/bindings/spi/snps,dw-apb-ssi.yaml   |  4 ++++
 arch/riscv/boot/dts/sophgo/sg2042.dtsi             | 26 ++++++++++++++++++++++
 2 files changed, 30 insertions(+)

---
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
change-id: 20250228-sfg-spi-e3f2aeca09ab

Best regards,

Signature · 1 line
Zixian Zeng <[email protected]>
#1 lore raw

PATCH v4 1/2 spi: dt-bindings: snps,dw-apb-ssi: Add compatible for SOPHGO SG2042 SoC

add compatible property to include "sophgo,sg2042-spi" for the SOPHGO SG2042 SoC SPI Controller.

---
 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml +4 -0
index bccd00a1ddd0ad92b437eed5b525a6ea1963db57..94102d94ed5dffe889a8a11c1c637d466713c208 100644
@@ -88,6 +88,10 @@ properties:
               - renesas,r9a06g032-spi # RZ/N1D
               - renesas,r9a06g033-spi # RZ/N1S
           - const: renesas,rzn1-spi   # RZ/N1
+      - description: SOPHGO SG2042 SoC SPI Controller
+        items:
+          - const: sophgo,sg2042-spi
+          - const: snps,dw-apb-ssi
       - description: T-HEAD TH1520 SoC SPI Controller
         items:
           - const: thead,th1520-spi
Signature · 1 line
2.49.0
maintainer
#2 lore raw

Re: [PATCH v4 1/2] spi: dt-bindings: snps,dw-apb-ssi: Add compatible for SOPHGO SG2042 SoC

Quoted 13 lines · Zixian Zeng

add compatible property to include "sophgo,sg2042-spi" for the SOPHGO SG2042 SoC SPI Controller.

---
 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml +0 -0
index bccd00a1ddd0ad92b437eed5b525a6ea1963db57..94102d94ed5dffe889a8a11c1c637d466713c208 100644

Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml properties: · line 94

Quoted 7 lines
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml +4 -0
@@ -88,6 +88,10 @@ properties:
               - renesas,r9a06g032-spi # RZ/N1D
               - renesas,r9a06g033-spi # RZ/N1S
           - const: renesas,rzn1-spi   # RZ/N1
+      - description: SOPHGO SG2042 SoC SPI Controller
+        items:
+          - const: sophgo,sg2042-spi
+          - const: snps,dw-apb-ssi

This and all the other cases with snps,dw-apb-ssi fallback should be combined into 1 entry.

Quoted 7 lines
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml +0 -0
       - description: T-HEAD TH1520 SoC SPI Controller
         items:
           - const: thead,th1520-spi
Signature · 2 lines
-- 
2.49.0
#3 lore raw

Re: [PATCH v4 1/2] spi: dt-bindings: snps,dw-apb-ssi: Add compatible for SOPHGO SG2042 SoC

Quoted 9 lines · Rob Herring
Quoted 8 lines · Zixian Zeng

add compatible property to include "sophgo,sg2042-spi" for the SOPHGO SG2042 SoC SPI Controller.

---
 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 16 lines

Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml properties: · line 94

Quoted 12 lines
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml +4 -0
index bccd00a1ddd0ad92b437eed5b525a6ea1963db57..94102d94ed5dffe889a8a11c1c637d466713c208 100644
@@ -88,6 +88,10 @@ properties:
               - renesas,r9a06g032-spi # RZ/N1D
               - renesas,r9a06g033-spi # RZ/N1S
           - const: renesas,rzn1-spi   # RZ/N1
+      - description: SOPHGO SG2042 SoC SPI Controller
+        items:
+          - const: sophgo,sg2042-spi
+          - const: snps,dw-apb-ssi

This and all the other cases with snps,dw-apb-ssi fallback should be combined into 1 entry.

Sounds good, did you mean conbining "SOPHGO SG2042" "T-HEAD TH1520" and "Renesas RZ/N1" together? But How about the description?

Quoted 7 lines
Quoted 7 lines
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml +0 -0
       - description: T-HEAD TH1520 SoC SPI Controller
         items:
           - const: thead,th1520-spi
Signature · 2 lines
-- 
2.49.0

Best regards,
Zixian

#4 lore raw

PATCH v4 2/2 riscv: sophgo: dts: Add spi controller for SG2042

In reply to Zixian Zeng

Add spi controllers for SG2042.

SG2042 uses the upstreamed Synopsys DW SPI IP.

---
 arch/riscv/boot/dts/sophgo/sg2042.dtsi | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
arch/riscv/boot/dts/sophgo/sg2042.dtsi +26 -0
index aa8b7fcc125d71eec12b09493964d90f5dfed27c..ddde4c613c4734db191de500b016b322a9602efc 100644
@@ -537,6 +537,32 @@ uart0: serial@7040000000 {
 			status = "disabled";
 		};
 
+		spi0: spi@7040004000 {
+			compatible = "sophgo,sg2042-spi", "snps,dw-apb-ssi";
+			reg = <0x70 0x40004000 0x00 0x1000>;
+			clocks = <&clkgen GATE_CLK_APB_SPI>;
+			interrupt-parent = <&intc>;
+			interrupts = <110 IRQ_TYPE_LEVEL_HIGH>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			num-cs = <2>;
+			resets = <&rstgen RST_SPI0>;
+			status = "disabled";
+		};
+
+		spi1: spi@7040005000 {
+			compatible = "sophgo,sg2042-spi", "snps,dw-apb-ssi";
+			reg = <0x70 0x40005000 0x00 0x1000>;
+			clocks = <&clkgen GATE_CLK_APB_SPI>;
+			interrupt-parent = <&intc>;
+			interrupts = <111 IRQ_TYPE_LEVEL_HIGH>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			num-cs = <2>;
+			resets = <&rstgen RST_SPI1>;
+			status = "disabled";
+		};
+
 		emmc: mmc@704002a000 {
 			compatible = "sophgo,sg2042-dwcmshc";
 			reg = <0x70 0x4002a000 0x0 0x1000>;
Signature · 1 line
2.49.0
maintainer
#5 lore raw

Re: (subset) [PATCH v4 0/2] Add basic SPI support for SG2042 SoC

In reply to Zixian Zeng
Quoted 8 lines · Zixian Zeng

Implemented basic SPI support for SG2042 SoC[1] using the upstreamed Synopsys DW-SPI IP.

This is tested on milkv-pioneer board on bus level. Using driver/spi/spidev.c for creating virtual /dev/spidevX.Y and tools/spi/spidev_test for testing functionality.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/2] spi: dt-bindings: snps,dw-apb-ssi: Add compatible for SOPHGO SG2042 SoC

      commit: 0889c4d28ad79b55ee8cf3c818e9d86203ace8f0

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark