longsleep / linux-pine64

Pine64 Linux Kernel
Other
111 stars 104 forks source link

Unable to activate SPI #69

Closed fphammerle closed 4 years ago

fphammerle commented 4 years ago

I followed the instructions posted here: https://forum.pine64.org/showthread.php?tid=1297&pid=16138#pid16138

$ uname -r
3.10.105-0-pine64-longsleep
$ fdtget /boot/pine64/sun50i-a64-pine64-plus.dtb /soc@01c00000/spi@01c68000 status
disabled
$ sudo fdtput --verbose --type s /boot/pine64/sun50i-a64-pine64-plus.dtb /soc@01c00000/spi@01c68000 status okay
Decoding value:
        string: 'okay'
Value size 5
$ fdtget /boot/pine64/sun50i-a64-pine64-plus.dtb /soc@01c00000/spi@01c68000 status
okay
# reboot
$ dmesg -T | grep spi0
[So Sep  6 09:27:30 2020] spi spi0: master is unqueued, this is deprecated
$ ls -la /dev/*spi*
ls: cannot access '/dev/*spi*': No such file or directory
$ sudo modprobe spidev
$ ls -la /dev/*spi*
ls: cannot access '/dev/*spi*': No such file or directory

What further steps are required to enable /dev/spidev0.0 ?

fphammerle commented 4 years ago

spidev@0 section was missing in /boot/pine64/sun50i-a64-pine64-plus.dtb:

$ dtc -q -I dtb -O dts /boot/pine64/sun50i-a64-pine64-plus.dtb | grep -A 21 'spi@01c68000 {'
                spi@01c68000 {
                        #address-cells = < 0x01 >;
                        #size-cells = < 0x00 >;
                        compatible = "allwinner,sun50i-spi";
                        device_type = "spi0";
                        reg = < 0x00 0x1c68000 0x00 0x1000 >;
                        interrupts = < 0x00 0x41 0x04 >;
                        clocks = < 0x04 0x52 >;
                        clock-frequency = < 0x5f5e100 >;
                        pinctrl-names = "default\0sleep";
                        pinctrl-1 = < 0x55 >;
                        spi0_cs_number = < 0x01 >;
                        spi0_cs_bitmap = < 0x01 >;
                        status = "okay";
                        pinctrl-0 = < 0xa7 0xa8 >;

                        spidev@0 {
                                spi-max-frequency = < 0x2faf080 >;
                                reg = < 0x00 >;
                                compatible = "spidev";
                        };
                };

fix

$ sudo fdtput --verbose --create /boot/pine64/sun50i-a64-pine64-plus.dtb /soc@01c00000/spi@01c68000/spidev@0
$ sudo fdtput --verbose --type s /boot/pine64/sun50i-a64-pine64-plus.dtb /soc@01c00000/spi@01c68000/spidev@0 compatible spidev
Decoding value:
        string: 'spidev'
Value size 7
$ sudo fdtput --verbose --type i /boot/pine64/sun50i-a64-pine64-plus.dtb /soc@01c00000/spi@01c68000/spidev@0 reg 0
Decoding value:
        int: 0
Value size 4
$ sudo fdtput --verbose --type x /boot/pine64/sun50i-a64-pine64-plus.dtb /soc@01c00000/spi@01c68000/spidev@0 spi-max-frequency 0x2faf080
Decoding value:
        int: 50000000
Value size 4
# reboot
$ ls -la /dev/spidev0.0 
crw------- 1 root root 153, 0 2020-09-06 10:36 /dev/spidev0.0

as documented in http://synfare.com/599N105E/hwdocs/pine64/spidev.html and https://github.com/longsleep/build-pine64-image/blob/eba2f3dc859091e54d976624e6f5043bdfc9bb73/blobs/pine64.dts#L2050