MCP2515 + JETSON XAVIER NX - DTS

I’m beginner, some could help me to fix my DTS,

/dts-v1/;
/plugin/;

/ {
    overlay-name = "MCP2515 CAN on SPI1 (ReComputer J202)";
    compatible = "nvidia,p3449-0000+p3668-0001";
    jetson-header-name = "Jetson 40pin Header";

    fragment@0 {
        target = <&pinmux>;
        __overlay__ {
            spi1_pins: spi1_pins {
                nvidia,pins = "gpio13",  // SPI1_MOSI (Pin 19)
                              "gpio14",  // SPI1_MISO (Pin 21)
                              "gpio15",  // SPI1_SCK  (Pin 23)
                              "gpio16";  // SPI1_CS0  (Pin 24)
                nvidia,function = "spi1";
                nvidia,pull = <0>;          // No pull-up/down
                nvidia,tristate = <0>;
                nvidia,enable-input = <1>;
            };

            mcp2515_int_pin: mcp2515_int_pin {
                nvidia,pins = "gpio17";     // GPIO493 (Pin 15)
                nvidia,function = "gpio";
                nvidia,pull = <2>;          // Pull-down
                nvidia,tristate = <0>;
                nvidia,enable-input = <1>;
            };
        };
    };

    fragment@1 {
        target = <&spi1>;
        __overlay__ {
            status = "okay";
            #address-cells = <1>;
            #size-cells = <0>;
            pinctrl-names = "default";
            pinctrl-0 = <&spi1_pins>;

            mcp2515@0 {
                compatible = "microchip,mcp2515";
                reg = <0>;
                spi-max-frequency = <10000000>;
                interrupt-parent = <&gpio>;
                interrupts = <493 0x2>;  // GPIO493 = gpio17
                clocks = <&mcp2515_osc>;
            };
        };
    };

    fragment@2 {
        target-path = "/";
        __overlay__ {
            mcp2515_osc: mcp2515_osc {
                compatible = "fixed-clock";
                #clock-cells = <0>;
                clock-frequency = <8000000>;
            };
        };
    };
};

when I tried setup with jetsonIO , got:

|                                                                    |
 |                            FATAL ERROR!                            |
 |                                                                    |
 |                                                                    |
 Failed to get pin number for node /fragment@0/__overlay__/spi1_pins/!|
 |                                                                    |
 |                     Press any key to terminate                     |
 |                                                                    |
 |  

Hi leonardo.andrade,

Are you using the devkit or custom aboard for Xavier NX?
What’s the Jetpack version in use?

How do you refer to configure the pins like these?
You don’t need to specify these PINs since they are used for SPI1 by default.

Have you verified the SPI loopback test before porting MCP2515?

I’m using jetpack 5.1.3, recomputing card j2021 (Jetson Xavier NX). I didn’t test the SPI loopback, because I was focusing on this configuration first.

It seems you are using the custom carrier board from SeeedStudio.

SPI loopback test could help to clarify if you’ve configured the pin for SPI usage correctly.
(i.e. you have to configure the pinmux for those pins before use.)

In addition, Jetson-IO may not work for your custom carrier board since your board might have different pin definition as the devkit.
Please request your vendor for the pinmux spreadsheet or the steps to configure the SPI pins.

I checked the pin definition on vendor spreadsheet and got:


SPI0_SCK	91	SPI1_SCK	GPIO3_PZ.03	495
SPI0_MISO	93	SPI1_MISO	GPIO3_PZ.04	496
SPI0_MOSI	89	SPI1_MOSI	GPIO3_PZ.05	497
SPI0_CS0*	95	SPI1_CS0	GPIO3_PZ.06	498
SPI0_CS1*	97	SPI1_CS1	GPIO3_PZ.07	499
GPIO12	218	TOUCH_CLK	GPIO3_PCC.04	321 (on board pin 15, I tested control a led)

The last column are the numbers from


cat /sys/kernel/debug/gpio

As my first time doing this, I’m feeling lost .

You can refer to https://elinux.org/Jetson/L4T/peripheral/#MCP2515_Verification to know how we verify MCP2515 on Jetson device.

We don’t use the GPIO number read from /sys/kernel/debug/gpio for device tree.
We use something like TEGRA194_AON_GPIO(CC, 4) and its gpio controller &tegra_aon_gpio instead