arch: riscv: thead: implement basic spi
Subsystems (4)
PATCH 1/1 arch: riscv: thead: implement basic spi
implemented basic spi support for TH1520 SoC.
created a fixed clock and a simple spi0 node.
updated the matching binding to include thead,th1520-spi as compatible. added a spidev device in devicetree which will utilise the spi0 node. this is usually reserved for a SPI NOR flash which is left unpopulated underneath the carrier board. I performed a SPI self loop test using tools/spi/spidev_test.c and tried sending \xDE\xAD\xBE\xEF and verified it is being received correctly. i updated the of_device_id struct in drivers/spi/spi-dw-mmio.c to include "thead,th1520-spi" as the compatible. this patch also adds basic spi support on beaglev ahead which shares the same TH1520 SoC. i have only tested on LicheePi 4A.
--- .../devicetree/bindings/spi/snps,dw-apb-ssi.yaml | 4 ++++ .../boot/dts/thead/th1520-beaglev-ahead.dts | 9 +++++++++ .../boot/dts/thead/th1520-lichee-module-4a.dtsi | 4 ++++ .../riscv/boot/dts/thead/th1520-lichee-pi-4a.dts | 10 ++++++++++ arch/riscv/boot/dts/thead/th1520.dtsi | 16 ++++++++++++++++ drivers/spi/spi-dw-mmio.c | 1 + 6 files changed, 44 insertions(+)
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: T-HEAD TH1520 SoC SPI Controller + items: + - const: thead,th1520-spi + - const: snps,dw-apb-ssi reg: minItems: 1
arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts +9 -0
@@ -17,6 +17,7 @@ aliases { gpio1 = &gpio1; gpio2 = &gpio2; gpio3 = &gpio3; + spi0 = &spi0; serial0 = &uart0; serial1 = &uart1; serial2 = &uart2;
@@ -52,6 +53,10 @@ &sdhci_clk { clock-frequency = <198000000>; }; +&spi_clk { + clock-frequency = <396000000>; +}; + &uart_sclk { clock-frequency = <100000000>; };
@@ -79,3 +84,7 @@ &sdio0 { &uart0 { status = "okay"; }; + +&spi0 { + status = "okay"; +};
arch/riscv/boot/dts/thead/th1520-lichee-module-4a.dtsi +4 -0
@@ -33,6 +33,10 @@ &sdhci_clk { clock-frequency = <198000000>; }; +&spi_clk { + clock-frequency = <396000000>; +}; + &uart_sclk { clock-frequency = <100000000>; };
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts +10 -0
@@ -14,6 +14,7 @@ aliases { gpio1 = &gpio1; gpio2 = &gpio2; gpio3 = &gpio3; + spi0 = &spi0; serial0 = &uart0; serial1 = &uart1; serial2 = &uart2;
@@ -30,3 +31,12 @@ chosen { &uart0 { status = "okay"; }; + +&spi0 { + status = "okay"; + spidev@0 { + compatible = "rohm,dh2228fv"; + reg = <0>; + spi-max-frequency = <500000>; + }; +};
arch/riscv/boot/dts/thead/th1520.dtsi +16 -0
@@ -140,6 +140,12 @@ apb_clk: apb-clk-clock { #clock-cells = <0>; }; + spi_clk: spi-clock { + compatible = "fixed-clock"; + clock-output-names = "spi_clk"; + #clock-cells = <0>; + }; + uart_sclk: uart-sclk-clock { compatible = "fixed-clock"; clock-output-names = "uart_sclk";
@@ -183,6 +189,16 @@ clint: timer@ffdc000000 { <&cpu3_intc 3>, <&cpu3_intc 7>; }; + spi0: spi@ffe700c000 { + compatible = "thead,th1520-spi", "snps,dw-apb-ssi"; + reg = <0xff 0xe700c000 0x0 0x1000>; + interrupts = <54 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&spi_clk>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + uart0: serial@ffe7014000 { compatible = "snps,dw-apb-uart"; reg = <0xff 0xe7014000 0x0 0x100>;
drivers/spi/spi-dw-mmio.c +1 -0
@@ -419,6 +419,7 @@ static const struct of_device_id dw_spi_mmio_of_match[] = { { .compatible = "microchip,sparx5-spi", dw_spi_mscc_sparx5_init}, { .compatible = "canaan,k210-spi", dw_spi_canaan_k210_init}, { .compatible = "amd,pensando-elba-spi", .data = dw_spi_elba_init}, + { .compatible = "thead,th1520-spi", .data = dw_spi_pssi_init}, { /* end of table */} };MODULE_DEVICE_TABLE (of, dw_spi_mmio_of_match);
Signature · 1 line
2.45.2
Quoted 12 lines · Kanak Shilledar
implemented basic spi support for TH1520 SoC.
created a fixed clock and a simple spi0 node.
updated the matching binding to include thead,th1520-spi as compatible. added a spidev device in devicetree which will utilise the spi0 node. this is usually reserved for a SPI NOR flash which is left unpopulated underneath the carrier board. I performed a SPI self loop test usingtools/spi/spidev_test.cand tried sending\xDE\xAD\xBE\xEFand verified it is being received correctly. i updated theof_device_idstruct indrivers/spi/spi-dw-mmio.cto include "thead,th1520-spi" as the compatible. this patch also adds basic spi support on beaglev ahead which shares the same TH1520 SoC. i have only tested on LicheePi 4A.
Quoted 8 lines
Signed-off-by Kanak Shilledar <[email protected]>--- .../devicetree/bindings/spi/snps,dw-apb-ssi.yaml | 4 ++++ .../boot/dts/thead/th1520-beaglev-ahead.dts | 9 +++++++++ .../boot/dts/thead/th1520-lichee-module-4a.dtsi | 4 ++++ .../riscv/boot/dts/thead/th1520-lichee-pi-4a.dts | 10 ++++++++++ arch/riscv/boot/dts/thead/th1520.dtsi | 16 ++++++++++++++++ drivers/spi/spi-dw-mmio.c | 1 +
This needs to be 3 different patches - one for the binding, one for the driver and a final one for the dts files.
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts chosen { · line 37
Quoted 4 lines
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts +4
-0+ +&spi0 { + status = "okay"; + spidev@0 {
"spidev" is not a type of device, the nodename should match the type.
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts chosen { · line 42
Quoted 5 lines
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts +5
-0+ compatible = "rohm,dh2228fv"; + reg = <0>; + spi-max-frequency = <500000>; + }; +};
I'll put money on you not having a dh2228fv on this board. Document what you actually have on it please, not what allows you to probe the spidev driver in linux.
Thanks,
Conor.
Quoted 23 lines · Conor Dooley
Quoted 12 lines · Kanak Shilledar
implemented basic spi support for TH1520 SoC.
created a fixed clock and a simple spi0 node.
updated the matching binding to include thead,th1520-spi as compatible. added a spidev device in devicetree which will utilise the spi0 node. this is usually reserved for a SPI NOR flash which is left unpopulated underneath the carrier board. I performed a SPI self loop test usingtools/spi/spidev_test.cand tried sending\xDE\xAD\xBE\xEFand verified it is being received correctly. i updated theof_device_idstruct indrivers/spi/spi-dw-mmio.cto include "thead,th1520-spi" as the compatible. this patch also adds basic spi support on beaglev ahead which shares the same TH1520 SoC. i have only tested on LicheePi 4A.Quoted 8 lines
Signed-off-by Kanak Shilledar <[email protected]>--- .../devicetree/bindings/spi/snps,dw-apb-ssi.yaml | 4 ++++ .../boot/dts/thead/th1520-beaglev-ahead.dts | 9 +++++++++ .../boot/dts/thead/th1520-lichee-module-4a.dtsi | 4 ++++ .../riscv/boot/dts/thead/th1520-lichee-pi-4a.dts | 10 ++++++++++ arch/riscv/boot/dts/thead/th1520.dtsi | 16 ++++++++++++++++ drivers/spi/spi-dw-mmio.c | 1 +
Quoted 2 lines
This needs to be 3 different patches - one for the binding, one for the driver and a final one for the dts files.
I will convert this into a patch set of 3 patch as you suggested.
Quoted 13 lines
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts chosen { · line 37
Quoted 4 lines
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts +4
-0+ +&spi0 { + status = "okay"; + spidev@0 {"spidev" is not a type of device, the nodename should match the type.
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts chosen { · line 42
Quoted 5 lines
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts +5
-0+ compatible = "rohm,dh2228fv"; + reg = <0>; + spi-max-frequency = <500000>; + }; +};
Quoted 3 lines
I'll put money on you not having a dh2228fv on this board. Document what you actually have on it please, not what allows you to probe the spidev driver in linux.
Yes, you are right! Actually as per the vendor's kernel it should be a "spi-nor" device from winbond.
I changed it to spidev for testing purposes. Shall I just leave it with status = "okay" or add the node for
that spi-nor flash?
Quoted 2 lines
Thanks,
Conor.
Thanks and Regards,
Kanak Shilledar
Quoted 46 lines · Kanak Shilledar
Quoted 23 lines · Conor Dooley
Quoted 12 lines · Kanak Shilledar
implemented basic spi support for TH1520 SoC.
created a fixed clock and a simple spi0 node.
updated the matching binding to include thead,th1520-spi as compatible. added a spidev device in devicetree which will utilise the spi0 node. this is usually reserved for a SPI NOR flash which is left unpopulated underneath the carrier board. I performed a SPI self loop test usingtools/spi/spidev_test.cand tried sending\xDE\xAD\xBE\xEFand verified it is being received correctly. i updated theof_device_idstruct indrivers/spi/spi-dw-mmio.cto include "thead,th1520-spi" as the compatible. this patch also adds basic spi support on beaglev ahead which shares the same TH1520 SoC. i have only tested on LicheePi 4A.Quoted 8 lines
Signed-off-by Kanak Shilledar <[email protected]>--- .../devicetree/bindings/spi/snps,dw-apb-ssi.yaml | 4 ++++ .../boot/dts/thead/th1520-beaglev-ahead.dts | 9 +++++++++ .../boot/dts/thead/th1520-lichee-module-4a.dtsi | 4 ++++ .../riscv/boot/dts/thead/th1520-lichee-pi-4a.dts | 10 ++++++++++ arch/riscv/boot/dts/thead/th1520.dtsi | 16 ++++++++++++++++ drivers/spi/spi-dw-mmio.c | 1 +Quoted 2 lines
This needs to be 3 different patches - one for the binding, one for the driver and a final one for the dts files.
I will convert this into a patch set of 3 patch as you suggested.
Quoted 13 lines
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts chosen { · line 37
Quoted 4 lines
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts +4
-0+ +&spi0 { + status = "okay"; + spidev@0 {"spidev" is not a type of device, the nodename should match the type.
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts chosen { · line 42
Quoted 5 lines
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts +5
-0+ compatible = "rohm,dh2228fv"; + reg = <0>; + spi-max-frequency = <500000>; + }; +};Quoted 3 lines
I'll put money on you not having a dh2228fv on this board. Document what you actually have on it please, not what allows you to probe the spidev driver in linux.
Quoted 5 lines
Yes, you are right! Actually as per the vendor's kernel it should be a "spi-nor" device from winbond.
I changed it to spidev for testing purposes. Shall I just leave it with status = "okay" or add the node for
that spi-nor flash?
If it isn't on the board, it shouldn't be in the devicetree. Please add the actual device that is here instead. If there's a board with nothing connected, then please don't add anything.
Thanks,
Conor.
Quoted 54 lines · Conor Dooley
Quoted 46 lines · Kanak Shilledar
Quoted 23 lines · Conor Dooley
Quoted 12 lines · Kanak Shilledar
implemented basic spi support for TH1520 SoC.
created a fixed clock and a simple spi0 node.
updated the matching binding to include thead,th1520-spi as compatible. added a spidev device in devicetree which will utilise the spi0 node. this is usually reserved for a SPI NOR flash which is left unpopulated underneath the carrier board. I performed a SPI self loop test usingtools/spi/spidev_test.cand tried sending\xDE\xAD\xBE\xEFand verified it is being received correctly. i updated theof_device_idstruct indrivers/spi/spi-dw-mmio.cto include "thead,th1520-spi" as the compatible. this patch also adds basic spi support on beaglev ahead which shares the same TH1520 SoC. i have only tested on LicheePi 4A.Quoted 8 lines
Signed-off-by Kanak Shilledar <[email protected]>--- .../devicetree/bindings/spi/snps,dw-apb-ssi.yaml | 4 ++++ .../boot/dts/thead/th1520-beaglev-ahead.dts | 9 +++++++++ .../boot/dts/thead/th1520-lichee-module-4a.dtsi | 4 ++++ .../riscv/boot/dts/thead/th1520-lichee-pi-4a.dts | 10 ++++++++++ arch/riscv/boot/dts/thead/th1520.dtsi | 16 ++++++++++++++++ drivers/spi/spi-dw-mmio.c | 1 +Quoted 2 lines
This needs to be 3 different patches - one for the binding, one for the driver and a final one for the dts files.
I will convert this into a patch set of 3 patch as you suggested.
Quoted 13 lines
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts chosen { · line 37
Quoted 4 lines
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts +4
-0+ +&spi0 { + status = "okay"; + spidev@0 {"spidev" is not a type of device, the nodename should match the type.
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts chosen { · line 42
Quoted 5 lines
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts +5
-0+ compatible = "rohm,dh2228fv"; + reg = <0>; + spi-max-frequency = <500000>; + }; +};Quoted 3 lines
I'll put money on you not having a dh2228fv on this board. Document what you actually have on it please, not what allows you to probe the spidev driver in linux.
Quoted 5 lines
Yes, you are right! Actually as per the vendor's kernel it should be a "spi-nor" device from winbond.
I changed it to spidev for testing purposes. Shall I just leave it with status = "okay" or add the node for
that spi-nor flash?
Quoted 3 lines
If it isn't on the board, it shouldn't be in the devicetree. Please add the actual device that is here instead. If there's a board with nothing connected, then please don't add anything.
Alright got it. The SPI flash pad is left unpopulated on the LicheePi 4A board. Thus, I will not mention it in the devicetree.
Quoted 2 lines
Thanks,
Conor.
Thanks and Regards,
Kanak Shilledar