Custom Device Tree with CAN controller (MCP2515)

  • So I have a MCP2515 CAN bus controller that I've been trying to get working on the Omega2 by modifying the device tree. I was able to get it to work without modifying the device tree using GBert's bitbanged version as just a proof of concept. I just use insmod to manually load up the driver and pass in the gpio pins that I'm going to use for the spi as args to the kernel module. Only change I made in that code was changing the oscillator frequency to 8MHz instead of 16.

    But I want to be able to use the built-in MCP251x kernel module and set it up through a custom device tree. Something is missing in my understanding because I cannot get it to properly probe the device. On Startup the mcp251x module's probe fails and returns a -2 error.

    For testing purposes, I've just been modifying the Omega2.dtsi file that's included in the source. Basically I'm using the spi-gpio drivers to setup the spi bus that the MCP2515 sits on. Pin 11 is the interrupt for the MCP2515, 4 sck, 5 miso, 19 mosi, 18 chipselect

    I've added the following to the root node of the omega2.dtsi file. I've also added "disabled" to the i2c node because I use its pins for the bitbanged spi bus.

            can0Clock: can0Clock {
    	  compatible = "fixed-clock";
    	  #clock-cells = <0>;
    	  clock-frequency = <8000000>;  
    		compatible = "spi-gpio";
    		#address-cells = <0x1>;
    		gpio-sck = <&gpio0 4 0>;
    		gpio-miso = <&gpio0 5 0>;
    		gpio-mosi = <&gpio0 19 0>;
    		cs-gpios = <&gpio0 18 1>;
    		num-chipselects = <1>;
    		can0: mcp2515@0 {
    		    compatible = "microchip,mcp2515";
    		    reg = <0>;
    		    spi-max-frequency = <40000000>;
    		    interrupt-parent = <&gpio0>;
    		    interrupts = <&gpio0 11 8>;
    		    clocks = <&can0Clock>;
    ///outside root node
    &i2c {
    	status = "disabled";

Log in to reply

Looks like your connection to Community was lost, please wait while we try to reconnect.