Skip to contentSkip to conversation

Using MCP2515 with half duplex driver fails on init

mcp251x Gerhard Bertelsmann 2 participants 3 messages Mar 30, 2021 CAN network drivers

lore
Share & tools
lore
#0 lore raw

Hi,

I'm trying to get a MCP2515 working with an OpenWRT router connected to the second SPI channel (CS1). The first one is used by the flash. Here the error message while loading the mcp251x module (Kernel 5.10.26):

[  112.226164] mcp251x spi0.1: spi transfer failed: ret = -22
[  112.231810] mcp251x spi0.1: Probe failed, err=22
[  112.237021] mcp251x: probe of spi0.1 failed with error -22

The DTS part looks like:

/ {
        compatible = "onion,omega2", "mediatek,mt7628an-soc";
};
...
&spi0 {
        status = "okay";

        pinctrl-names = "default";
        pinctrl-0 = <&spi_pins>, <&spi_cs1_pins>;

        flash@0 {
                compatible = "jedec,spi-nor";
                reg = <0>;
                spi-max-frequency = <40000000>;
                ...
        };
        can0: can@1 {
                compatible = "microchip,mcp2515";
                reg = <1>;
                clock-frequency = <8000000>;
                interrupt-parent = <&gpio>;
                interrupts = <16 8>;
                spi-max-frequency = <10000000>;
        };
};

I don't see any activity on the SPI bus/CS1 line. A cross check with spidev using following DTS sequence instead of can0:

        spidev@1 {
                #address-cells = <1>;
                #size-cells = <1>;
                compatible = "rohm,dh2228fv";
                reg = <1>;
                spi-max-frequency = <100000>;
        };

shows, that the setup using SPI bus with CS1 is working.

Of course, sharing the SPI bus with the flash isn't the best performance practice, but it should be ok because when the programms are loaded, it's unlikely that the SPI bus is occupied by the routers flash system anymore.

Does anybody have a hint why the init fails ?

Regards

Gerd

#1 lore raw
Quoted 3 lines · Gerhard Bertelsmann

I'm trying to get a MCP2515 working with an OpenWRT router connected to the second SPI channel (CS1). The first one is used by the flash. Here the error message while loading the mcp251x module (Kernel 5.10.26):

Can you try the patch I just send to the mailing list?

https://lore.kernel.org/r/[email protected]

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#2 lore raw

Hi Marc,

Am 2021-03-30 12:04, schrieb Marc Kleine-Budde:

Quoted 8 lines · Gerhard Bertelsmann
Quoted 3 lines

I'm trying to get a MCP2515 working with an OpenWRT router connected to the second SPI channel (CS1). The first one is used by the flash. Here the error message while loading the mcp251x module (Kernel 5.10.26):

Can you try the patch I just send to the mailing list?

https://lore.kernel.org/r/[email protected]

that looks much better now:

[  491.356961] mcp251x spi0.1 can0: MCP2515 successfully initialized.

I have to fix the GPIO irq before I can test the whole driver and giving the Tested-by tag.

Thx for your fast help.

Regards

Gerd