SPI and SPIDev on Edge/Captain

Hi,
I am trying to get SPI3 working on the Edge+Captain. I am using Ubuntu server 18.04.5 kernel 4.4.194 originally built with Fenix.
I have added this to the rk3399-khadas-captain-linux.dts device tree:

&spi3 {         
    status = "okay";
    spidev@0 {                                    
        compatible = "rockchip,spidev";  
        spi-max-frequency = <1000000>;  
        reg = <0>;                  
        status = "okay";           
    };
};

I get this in dmesg:

[    2.576890] rockchip-spi ff350000.spi: Failed to request TX DMA channel
[    2.577498] rockchip-spi ff350000.spi: Failed to request RX DMA channel
[    2.578099] rockchip-spi ff350000.spi: no high_speed pinctrl state
[    2.578835] rockchip-spi ff350000.spi: registered master spi32766 (dynamic)
[    2.578967] spi spi32766.0: setup mode 0, 8 bits/w, 1000000 Hz max --> 0
[    2.579286] rockchip-spi ff350000.spi: registered child spi32766.0
[    2.965892] rockchip-pinctrl pinctrl: pin gpio1-18 already requested by ff350000.spi; cannot claim for 4-001b
[  150.284407] rockchip-spi ff350000.spi: cr0 0x42c01, div 98

/dev/spidev32766.0 shows up (is there a reason its not spidev3.0?) but when I write to it nothing shows up on the logic analyzer.
Is there something I am missing?

Thanks

@ianwhamilton I’ve had this problem with Android. I don’t know if Ubuntu has this problem. You can try it

 &pmu_io_domains {
        status = "okay";
-       pmu1830-supply = <&vcc_3v0>;
+       pmu1830-supply = <&vcc_1v8>;
 };

Thanks for the reply. I will try it later and post the results.

Sorry for slow response, been busy with other stuff.

I checked the device tree rk3399-khadas-egde.dtsi already has this supply set properly.

Any other ideas are welcome.

Thanks

I remember that at that time, I couldn’t grasp the waveform with the oscilloscope, and then I used another method to catch it, that is, read and write 1000 times continuously. You can try this method.

Thanks for the info geonjoy.

I figured it out looking at the newest revision of the RK3399 datasheet.

This version I was running from Fenix had one of the SPI3 lines as pullup instead of pulldown.

        spi3 {
            spi3_clk: spi3-clk {
                rockchip,pins =
-                    <1 17 RK_FUNC_1 &pcfg_pull_up>; 
+                    <1 17 RK_FUNC_1 &pcfg_pull_down>;
            };
            spi3_cs0: spi3-cs0 {
                rockchip,pins =
                    <1 18 RK_FUNC_1 &pcfg_pull_up>;
            };
            spi3_rx: spi3-rx {
                rockchip,pins =
                    <1 15 RK_FUNC_1 &pcfg_pull_up>;
            };
            spi3_tx: spi3-tx {
                rockchip,pins =
                    <1 16 RK_FUNC_1 &pcfg_pull_up>;
            };
        };

Have the SPIDev portion in my own device tree ass the following:

&spi3 {
    status = "okay";

    spi_dev@0 {
        compatible = "rockchip,spidev";
        reg = <0>;
        spi-max-frequency = <1000000>;
    };
};

Had to turn down the frequency of the SPI bus to read it properly through my knock-off logic analyzer.

Thanks for the help everyone.

2 Likes

i am also facing issue on khadas edge-v
how to interface the spidev and mcp2515 module in spi ?
which dts file i have to change ?
please help me for this issue.

I am trying to get SPI3 working on the Edge-V
I have added this to the rk3399-khadas-captain-linux.dts device tree

&spi3 {         
    status = "okay";
    spidev@0 {                                    
        compatible = "rockchip,spidev";  
        spi-max-frequency = <1000000>;  
        reg = <0>;                  
        status = "okay";           
    };
};
Is there something I am missing?
please consider my issue and provide any solution for this.

@ramesh Have you modified the verification according to the instructions of @ianwhamilton ?

in which file i need to add for khadas rk3399 edge-v ??

@ramesh The SPI phandle to fix is in <path-to-linux-source>/arch/arm64/boot/dts/rockchip/rk3399.dtsi

This is for getting spidev to work properly. I tested it with a logic analyzer and it works but did also test with MCP2515 unsuccessfully.

This was my phandle for the MCP2515:

/ {                                                                                                                                                                                                         
  model = "Khadas Captain";                                                                                                                                                                                 
  compatible = "khadas,captain", "rockchip,rk3399";
  ...
  clocks {                                                                                                                                                                                                  
    eclk16m: eclk16m {                                                                                                                                                                                      
      compatible = "fixed-clock";                                                                                                                                                                           
      #clock-cells = <0>;                                                                                                                                                                                   
      clock-frequency = <16000000>;                                                                                                                                                                         
      clock-output-names = "eclk16m";                                                                                                                                                                       
    };
    ...
};
&spi3 {                                                                                                                                                                                                     
  status = "okay";                                                                                                                                                                                          
  can0: can@0 {                                                                                                                                                                                             
    compatible = "microchip,mcp2515";                                                                                                                                                                       
    reg = <0>;                                                                                                                                                                                              
    clocks = <&eclk16m>;                                                                                                                                                                                    
    pinctrl-names = "default";                                                                                                                                                                              
    interrupt-parent = <&tca9555_0>;                                                                                                                                                                        
    interrupts = <2 IRQ_TYPE_EDGE_FALLING>;                                                                                                                                                                 
    spi-max-frequency = <10000000>;                                                                                                                                                                         
    vdd-supply = <&vcc3v3_sys>;                                                                                                                                                                             
    xceiver-supply = <&vcc3v3_sys>;                                                                                                                                                                         
    status = "okay";                                                                                                                                                                                        
  };
};

It does come up in dmesg and starts talking over the SPI bus but doesn’t finish initialization. I think my problem is the interrupt controller so something similar to the above might work for you swapping out the interrupt-parent and interrupts lines.

Will have some time soon to test that chip out more but if you get it working post what you figured out.

Thanks

1 Like

Hello @ramesh

Please create a new topic for your issue, this topic is resolved.