mhc Posted September 12, 2020 Posted September 12, 2020 (edited) Armbianmonitor: http://ix.io/2xfy Hi all. Firstly, sorry I had posted this query in the wrong forum. I´m trying to add support for a raw SPI comunication through SPI0, as it´s a custom comunication with a little auxiliary board, I think best option is to have a spidev device. My scenario is: Banana pi m2 ultra Armbian 5.4.35-sunxi, server (No gui). I have been modifying .dts and .dtsi files, here are parts of the files that I modified: sun8i-r40.dtsi spi0_pins: spi0-pins { pins = "PC0", "PC1", "PC2"; function = "spi0"; }; spi0: spi@1c05000 { compatible = "allwinner,sun8i-spi"; device_type = "spidev"; reg = <0x01c05000 0x1000>; interrupts = <GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>; clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_SPI0>; clock-names = "ahb", "mod"; pinctrl-names = "default"; pinctrl-0 = <&spi0_pins>; resets = <&ccu RST_BUS_SPI0>; status = "disabled"; #address-cells = <1>; #size-cells = <0>; }; sun8i-r40-bananapi-m2-ultra.dts &spi0 { status = "okay"; num-chipselects = <1>; cs-gpios = <&pio 2 23 GPIO_ACTIVE_LOW>; // CS = PC23 spidev@0 { reg = <0>; compatible = "spidev"; status = "okay"; spi-max-frequency = <1000000>; }; }; I created a script to compile these files !/bin/bash sudo cpp -nostdinc -I include -I arch -undef -x assembler-with-cpp arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts preproc.dts dtc -I dts -O dtb -o sun8i-bananapi-m2-ultra.dtb preproc.dtc And I get my new dts. As a comment, the compilation of the device tree throws me this warning: sun8i-r40-bananapi-m2-ultra.dtb: Warning (unit_address_vs_reg): Node /clocks/clk@1 has a unit name, but no reg propert However, I think it is prior to my modifications, because if I delete all my changes the warning is already there. So, next step, I procede to replace original dtb in Banana pi with the one that I just generated, under /boot/dtb-5.4.35-sunxi/ And then, reboot. I expected to get spix.y device under /dev but there is no change here. If i decompile my new dtb, I can see spi spi0-pins { pins = "PC0", "PC1", "PC2"; function = "spi0"; phandle = <0x20>; }; spi@1c05000 { compatible = "allwinner,sun8i-spi"; reg = <0x1c05000 0x1000>; interrupts = <0x0 0xa 0x4>; clocks = <0x7 0x29 0x7 0x71>; clock-names = "ahb", "mod"; pinctrl-names = "default"; pinctrl-0 = <0x20>; resets = <0x7 0x11>; status = "okay"; #address-cells = <0x1>; #size-cells = <0x0>; num-chipselects = <0x1>; cs-gpios = <0xd 0x2 0x17 0x1>; So, Could somebody please tell me what thing (or probably things) I am doing wrong, or if there are any steps I am forgetting? Just in case, I modified the armbianEnv.txt that way overlay=spi-spidev param_spidev_spi_bus=0 to add the spidev overlays (although if I'm not wrong this shouldn't be necessary, since I already enabled spi from the dts, is that correct?) Thanks in advance to anyone who takes the time to read my issue, and if you have any suggestions, they will be more than welcome. Regards. mhc Edited September 14, 2020 by Werner Removed "moved" prefix
martinayotte Posted September 13, 2020 Posted September 13, 2020 On 9/12/2020 at 9:47 AM, mhc said: Thanks in advance to anyone who takes the time to read my issue, and if you have any suggestions, they will be more than welcome. Overlays on R40 is a bit different than the ones on H3 ... I've done tests on my BPiM2U using proper overlay which is "spi-spidev0" (not "spi-spidev") , without any needs for "param_spidev_spi_bus", and /dev/spidev0.0 appeared properly.
mhc Posted September 13, 2020 Author Posted September 13, 2020 Hi martinayotte, many thanks for your comments. I changed armbianEnv.txt file according your suggestion, but spi dev did not appear, however I modified compatible property in .dtsi (from "allwinner,sun8i-spi" to "allwinner,sun8i-h3-spi"; and after a reboot spidev0.0 does appear (even excluding overlay property in armbianEnv.txt). allwinner,sun8i-spi made sense to me, it is difficult for me to know which driver to use in each case. So, here is my working environment just in case someone has the same problem and wants to use it. sun8i-r40.dtsi spi0_pins: spi0-pins { pins = "PC0", "PC1", "PC2"; function = "spi0"; }; spi0: spi@1c05000 { compatible = "allwinner,sun8i-h3-spi"; device_type = "spidev"; reg = <0x01c05000 0x1000>; interrupts = <GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>; clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_SPI0>; clock-names = "ahb", "mod"; pinctrl-names = "default"; pinctrl-0 = <&spi0_pins>; resets = <&ccu RST_BUS_SPI0>; status = "disabled"; #address-cells = <1>; #size-cells = <0>; }; And sun8i-r40-bananapi-m2-ultra.dts &spi0 { status = "okay"; num-chipselects = <1>; cs-gpios = <&pio 2 23 GPIO_ACTIVE_LOW>; // CS = PC23 spidev@0 { reg = <0>; compatible = "spidev"; status = "okay"; spi-max-frequency = <1000000>; }; }; Thanks again! mhc 1
Recommended Posts