MCP2515 with Jetson TX2

Dear all,

We have been facing spi communication problem with MCP2515 CAN controller. MCP2515 was connected to SPI1 so we enabled MCP2515 in kernel configuration and made below device tree to probe this driver.

#include <dt-bindings/gpio/tegra186-gpio.h>

/ {
	mcp2515_clock: mcp2515_clock {
		compatible = "fixed-clock";
		#clock-cells = <0>;
		clock-frequency = <16000000>;
	};
	
	spi@c260000 {
		status = "okay";
		spi-max-frequency = <2000000>;
		spi-mcp251x_0@0 {
			status = "okay";
			compatible = "microchip,mcp2515";
			reg = <0>; /* spi chip select 0 */
			interrupt-parent = <&tegra_main_gpio>;
			interrupts = <TEGRA_MAIN_GPIO(I, 4) 0x01>; /* GPIO_PI4 */
			clocks = <&mcp2515_clock>;
			spi-max-frequency = <2000000>;
		};
	};
};

After reset manually by power off/on we could read CANSTAT register as 0x80 (reset default value) but CANCTRL value was not correct as reset default value. We did try to slow down spi speed to only 2MHz but it didn’t help.

It was seem we could not send the reset command to MCP2515 as below

/* Wait for oscillator startup timer after power up */
	mdelay(MCP251X_OST_DELAY_MS);
	
	priv->spi_tx_buf[0] = INSTRUCTION_RESET;
	ret = mcp251x_spi_trans(spi, 1);
	if (ret)
		return ret;

Any suggestion would be appreciated.

Thanks and Best Regards,
Vu Nguyen

SPI1 on J21 connector of baseboard is spi@3240000 on Tegra. Please try by moving the slave config under this SPI node.

Hi Vu Nguyen,
Did you try sending frames on CAN bus for your setup mentioned above? I am trying the same but facing problems.

Thanks & Regards,
Shubhi

Thank vishruthj, you are correct, NVIDIA naming problem.

Hi shgarg,

Yes, after changing to correct SPI port as vishruthj mention and some changes on hardware I could run it as well.

Hi Vu Nguyen,
Can you please share the steps you have done and changes you had to do on hardware?
My CAN bus is having two nodes:one is through mcp2515 which is connected via SPI4 on J21 and other is mttcan controller(on J26) with external TJA1050 Rx.
When I send frames from can0(mcp2515) to can1(mttcan), can0 is going in BUS-OFF state and can1 is going in ERROR-PASSIVE state.

Thanks & Regards,
Shubhi

Hi shgarg,

Actually I just check whether SPI connection is connected correctly or not.
If you already success to turn on can interface via mpc2515 so I think the last one is checking CAN connection.

Thanks and Best Regards,
Vu Nguyen