2

I've been trying to get an MCP2515 can controller working on a spi-gpio bus in my device tree, but the MCP251x driver's probe function never seems to actually be called. Oddly enough though, some probe function somewhere is being called because it returns -EPROBE_DEFER.

I modified /drivers/base/dd.c with a bunch of dev_dbg print calls to find out where I was actually returning from.

https://github.com/torvalds/linux/blob/v4.14/drivers/base/dd.c

On line 416 is where the driver probe is getting deferred

 else if (drv->probe) {
    ret = drv->probe(dev);
    if (ret)
        goto probe_failed;
}

If I add in a debug statement to this, I can see that the drv variable's name is MCP251x, which matches the driver.

dev_dbg(dev, "%s line %d ret: %d\n", drv->name, __LINE__,ret);

So I add some debug statements to the MCP251x driver's mcp251x_can_probe function https://github.com/torvalds/linux/blob/v4.14/drivers/net/can/spi/mcp251x.c

I never see any of the debug prints from the MCP251x's probe function. Why? I can't figure out why this probe function isn't being called, but something is managing to return -EPROBE_DEFER.

I don't know if there's some intermediary spi probe function being called that I'm not aware of or what, but it never makes it to the MCP251x's probe.

Here's the relevant snippet of my device tree just in case.

spi1{
    compatible = "spi-gpio";
    status="okay";

    #address-cells = <0x1>;
    ranges;

    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>;
        status = "okay"; 

        clocks = <&mcp2515_clk>;
        interrupt-parent = <&gpio0>;
        interrupts = <11 0x2>; //falling edge
        spi-max-frequency = <10000000>; 
        mcp2515_clk: oscillator {
            #clock-cells = <0>;
            compatible = "fixed-clock";
            clock-frequency = <8000000>; //8MHz
        }; 
    };
};
0

I've been trying to get an MCP2515 running on a Xilinx Zynq under Linux.

I found your post while suffering from exactly the same problem.

I was going down exactly the same route as you and littered the mpc251x driver with printk's expecting to find where the probe failed, but it wasn't called either.

Instead the probe function in the driver spi.c was called for me, from dd.c.

The deferred error was returned from:

https://github.com/torvalds/linux/blob/master/drivers/spi/spi.c#L397

Which in my case was due to the interrupt that I defined not being found.

For me it was as simple as the interrupt controller driver wasn't loaded and so the interrupt couldn't be found.

Built the interrupt controller driver and saw all my printk's in the mcp251x driver come alive.

Hope that helps!

Good luck,

Phil

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.