0
Nao

SPI with NanoPi M4

Recommended Posts

Hi, I'm currently working to enable SPI on NanoPi M4 but it is not working...

I have edited main DT to the following one and now /dev/spidev0.0 appears.

Quote

        spi@ff1c0000 {

                compatible = "rockchip,rk3399-spi\0rockchip,rk3066-spi";

                reg = < 0x00 0xff1c0000 0x00 0x1000 >;

                clocks = < 0x08 0x47 0x08 0x15b >;

                clock-names = "spiclk\0apb_pclk";

                interrupts = < 0x00 0x44 0x04 0x00 >;

                pinctrl-names = "default";

                pinctrl-0 = < 0x4a 0x4b 0x4c 0x4d >;

                #address-cells = < 0x01 >;

                #size-cells = < 0x00 >;

                status = "okay";

                phandle = < 0x101 >;

                        spidev{

                    compatible = "spidev";

                    status = "okay";

                    reg = <0>;

                    spi-max-frequency = <10000000>;

                };

        };

 

 

But when I checked spi with this tool:https://github.com/torvalds/linux/blob/master/tools/spi/spidev_test.c

I only got the result below and no matrix appears...

spi mode: 0x0

bits per word: 8

max speed: 500000 Hz (500 KHz)

 

Here is what dmesg | grep spi returns 

Quote

[    1.560666] rockchip-spi ff1c0000.spi: Failed to request TX DMA channel

[    1.560679] rockchip-spi ff1c0000.spi: Failed to request RX DMA channel

[    1.560689] rockchip-spi ff1c0000.spi: no high_speed pinctrl state

[    1.561289] spidev spi0.0: buggy DT: spidev listed directly in DT

[    1.561365] WARNING: at drivers/spi/spidev.c:720

[    1.561421] PC is at spidev_probe+0x6c/0x1d8

[    1.561430] LR is at spidev_probe+0x68/0x1d8

[    1.564338] [<ffffff80086f86b0>] spidev_probe+0x6c/0x1d8

[    1.564348] [<ffffff80086f57c4>] spi_drv_probe+0x9c/0xb4

[    1.564433] [<ffffff80086f605c>] spi_add_device+0x12c/0x188

[    1.564443] [<ffffff80086f6424>] of_register_spi_device+0x2c0/0x2d8

[    1.564453] [<ffffff80086f78f8>] spi_register_master+0x448/0x484

[    1.564463] [<ffffff80086f7988>] devm_spi_register_master+0x54/0x94

[    1.564474] [<ffffff80086fac60>] rockchip_spi_probe+0x2ec/0x440

[    1.564568] [<ffffff80090f94f8>] rockchip_spi_driver_init+0x18/0x20

[    1.566326] rockchip-pinctrl pinctrl: pin gpio3-7 already requested by ff1c0000.spi; cannot claim for fe300000.ethernet

 

I have checked the output from the proper GPIO with oscilloscope but found nothing.

almost spent couple weeks on this 

 

Anyone had the same issue or knows what to do here?

Share this post


Link to post
Share on other sites

@Nao - Do you have any more details on how you got to this point ?

 

I have made an image using the Armbian repo:

https://github.com/armbian/build/

 

I then use the Device Tools to inspect the tree:
 

# fdtdump /boot/dtb/rockchip/rk3399-nanopi4-rev01.dtb > device_tree.txt

 

This shows:

...
	aliases {
		spi1 = "/spi@ff1d0000";
	};
...
    spi@ff1c0000 {
        compatible = "rockchip,rk3399-spi", "rockchip,rk3066-spi";
        reg = <0x00000000 0xff1c0000 0x00000000 0x00001000>;
        clocks = <0x00000008 0x00000047 0x00000008 0x0000015b>;
        clock-names = "spiclk", "apb_pclk";
        interrupts = <0x00000000 0x00000044 0x00000004 0x00000000>;
        pinctrl-names = "default";
        pinctrl-0 = <0x0000004c 0x0000004d 0x0000004e 0x0000004f>;
        #address-cells = <0x00000001>;
        #size-cells = <0x00000000>;
        status = "disabled";
        phandle = <0x00000105>;
    };
    spi@ff1d0000 {
        compatible = "rockchip,rk3399-spi", "rockchip,rk3066-spi";
        reg = <0x00000000 0xff1d0000 0x00000000 0x00001000>;
        clocks = <0x00000008 0x00000048 0x00000008 0x0000015c>;
        clock-names = "spiclk", "apb_pclk";
        interrupts = <0x00000000 0x00000035 0x00000004 0x00000000>;
        pinctrl-names = "default";
        pinctrl-0 = <0x00000050 0x00000051 0x00000052 0x00000053>;
        #address-cells = <0x00000001>;
        #size-cells = <0x00000000>;
        status = "disabled";
        cs-gpios = <0x00000035 0x0000000a 0x00000001>;
        phandle = <0x00000106>;
        spidev@0 {
            compatible = "rockchip,spidev";
            reg = <0x00000000>;
            spi-max-frequency = <0x00989680>;
            status = "okay";
            phandle = <0x00000107>;
        };
    };

 

I noticed it says its disabled, but if I enable it with:
 

# fdtput /boot/dtb/rockchip/rk3399-nanopi4-rev01.dtb spi1 status -t s "okay"

Then the device wont boot.

 

If you dont mind sharing some of the commands you used to get the debug output and enable the interface, that'd be great.

Share this post


Link to post
Share on other sites
On 2/18/2019 at 1:44 PM, Exie said:

If you dont mind sharing some of the commands you used to get the debug output and enable the interface, that'd be great.

sorry I edited a status at a wrong spi (actually it was spi@ff1c0000, which corresponds to the SPI0 which is only for SPIFlash) and after edited the status at spi@ff1d0000, my machine doesn't boot...

 

basically I followed an instruction mentioned here, 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
0