Page 1 of 1

Doing CAN using mcp2510

Posted: Tue May 03, 2016 4:13 pm
by dienet
Hi

I'm trying to play with can controller using mcp2510 chip.
I created the overlay for this chip (based on mcp2515):

Code: Select all

/*
 * Device tree overlay for mcp251x/can0 on spi0.0
 */

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";
    /* disable spi-dev for spi0.0 */
    fragment@0 {
        target = <&spi0>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@1 {
	target = <&spidev0>;
	__overlay__ {
	    status = "disabled";
	};
    };

    /* the interrupt pin of the can-controller */
    fragment@2 {
        target = <&gpio>;
        __overlay__ {
            can0_pins: can0_pins {
                brcm,pins = <25>;
                brcm,function = <0>; /* input */
            };
        };
    };

    /* the clock/oscillator of the can-controller */
    fragment@3 {
        target-path = "/clocks";
        __overlay__ {
            /* external oscillator of mcp2510 on SPI0.0 */
            can0_osc: can0_osc {
                compatible = "fixed-clock";
                #clock-cells = <0>;
                clock-frequency  = <16000000>;
            };
        };
    };

    /* the spi config of the can-controller itself binding everything together */
    fragment@4 {
        target = <&spi0>;
        __overlay__ {
            /* needed to avoid dtc warning */
            #address-cells = <1>;
            #size-cells = <0>;
            can0: mcp2510@0 {
                reg = <0>;
                compatible = "microchip,mcp2510";
                pinctrl-names = "default";
                pinctrl-0 = <&can0_pins>;
                spi-max-frequency = <10000000>;
                interrupt-parent = <&gpio>;
                interrupts = <25 0x2>;
                clocks = <&can0_osc>;
            };
        };
    };
    __overrides__ {
        oscillator = <&can0_osc>,"clock-frequency:0";
        spimaxfrequency = <&can0>,"spi-max-frequency:0";
        interrupt = <&can0_pins>,"brcm,pins:0",<&can0>,"interrupts:0";
    };
};
But the driver returns this:

Code: Select all

[ 2930.200078] mcp251x spi0.0: could not find pctldev for node /soc/interrupt-controller@7e00b200, deferring probe
I don't know what this means.
There is no can0 interface in ip link command output.
Could someone explain what I'm missing here?
Also do You think we should have separated overlay for the mcp2510 chip (there is only one for mcp2515).

Re: Doing CAN using mcp2510

Posted: Wed May 04, 2016 12:25 pm
by edo1
have you compiled DT overlay? have you enabled it in config.txt?
which kernel version are you using?

P.S. why do you want to use mcp2510? it is outdated, mcp2515 is definitely better. mcp2510 isn't cheaper or easier to buy.

Re: Doing CAN using mcp2510

Posted: Wed May 04, 2016 2:06 pm
by dienet
edo1 wrote:have you compiled DT overlay? have you enabled it in config.txt?
Yes. Yes

Code: Select all

                        mcp2510@0 {
                                reg = <0x0>;
                                interrupts = <0x19 0x2>;
                                pinctrl-0 = <0x1>;
                                compatible = "microchip,mcp2510";
                                clocks = <0x2>;
                                spi-max-frequency = <0x989680>;
                                phandle = <0x39>;
                                pinctrl-names = "default";
                                linux,phandle = <0x39>;
                                interrupt-parent = <0xa>;
                        };
which kernel version are you using?
4.6.0-rc6-v7+
P.S. why do you want to use mcp2510? it is outdated, mcp2515 is definitely better. mcp2510 isn't cheaper or easier to buy.
This one I got. I quite sure there'll be the same problem ;)

Re: Doing CAN using mcp2510

Posted: Thu May 05, 2016 5:43 pm
by edo1
is it mainline kernel or raspberry kernel?

Re: Doing CAN using mcp2510

Posted: Thu May 05, 2016 6:10 pm
by dienet
It's from Raspberry linux repo.

Re: Doing CAN using mcp2510

Posted: Thu May 05, 2016 6:35 pm
by edo1
I have no issues with raspberry 4.4 tree (and mcp2515, but it shouldn't matter), could you check it?

Re: Doing CAN using mcp2510

Posted: Thu May 05, 2016 7:27 pm
by dienet
OK I will try that tomorrow and post my results. Thanks!

Re: Doing CAN using mcp2510

Posted: Fri May 06, 2016 3:03 pm
by dienet
The same thing:

Code: Select all

mcp251x spi0.0: could not find pctldev for node /soc/interrupt-controller@7e00b200, deferring probe
I wonder if this might be something with my wiring...

Re: Doing CAN using mcp2510

Posted: Fri Jul 01, 2016 2:41 pm
by staroselskii
Hello there!

I'm getting exactly the same error on 4.4.8 on Raspberry Pi 3. Have you overcome the issue anyhow? It'd be great to hear if you did.

Re: Doing CAN using mcp2510

Posted: Mon Jul 04, 2016 8:36 am
by edo1
staroselskii wrote:I'm getting exactly the same error on 4.4.8 on Raspberry Pi 3.
which DT overlay are you using?

Re: Doing CAN using mcp2510

Posted: Fri Jul 29, 2016 8:40 pm
by dienet
staroselskii wrote:Hello there!

I'm getting exactly the same error on 4.4.8 on Raspberry Pi 3. Have you overcome the issue anyhow? It'd be great to hear if you did.
I did not.

Re: Doing CAN using mcp2510

Posted: Mon Aug 01, 2016 6:58 pm
by edo1
I think there is something wrong with your device tree overlay.
Try to use mcp2515-can0-overlay.dts from current kernel
https://github.com/raspberrypi/linux/bl ... verlay.dts
(you need to replace mcp2515 with mcp2510 on line 58)