Hi,
I am trying to get a MCP2515 SPI CAN controller working on SPI0 of BBB.
The controller is connected to the CPU as follows
MCP2515 | AM3358 |
RST | U18 |
CS | C12 |
SCK | A13 |
MISO | B13 |
MOSI | D12 |
INT | R13 |
with the following pinmux configuration:
gpio1_pins: pinmux_gpio1_pins { pinctrl-single,pins = < AM33XX_IOPAD(0x878, PIN_OUTPUT_PULLUP | MUX_MODE7) /* (U18) gpmc_be1n.gpio1[28] */ >; }; spi1_pins: spi1_pins { pinctrl-single,pins = < AM33XX_IOPAD(0x990, PIN_OUTPUT | MUX_MODE3) /* (A13) mcasp0_aclkx.spi1_sclk */ AM33XX_IOPAD(0x994, PIN_INPUT | MUX_MODE3) /* (B13) mcasp0_fsx.spi1_d0 */ AM33XX_IOPAD(0x998, PIN_OUTPUT | MUX_MODE3) /* (D12) mcasp0_axr0.spi1_d1 */ AM33XX_IOPAD(0x99c, PIN_OUTPUT | MUX_MODE3) /* (C12) mcasp0_ahclkr.spi1_cs0 */ >; }; mcp2515_int: mcp2515_int { pinctrl-single,pins = < AM33XX_IOPAD(0x840, PIN_OUTPUT | MUX_MODE7) /* (R13) gpmc_a0.gpio1[16] */ >; }; mcp2515_clock: mcp2515_clock { compatible = "fixed-clock"; #clock-cells = <0>; clock-frequency = <8000000>; };
and these spi settings
&spi1 { #address-cells = <1>; #size-cells = <0>; status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&spi1_pins>; spidev@0 { status = "disabled"; /* spi-max-frequency = <24000000>; */ /* reg = <0>; */ /* compatible = "rohm,dh2228fv"; */ }; can0: mcp2515@0 { status = "okay"; reg = <0>; compatible = "microchip,mcp2515"; pinctrl-names = "default"; pinctrl-0 = <&mcp2515_int>; spi-max-frequency = <10000000>; interrupt-parent = <&gpio1>; interrupts = <16 2>; clocks = <&mcp2515_clock>; mcp251x,oscillator-frequency = <8000000>; mcp251x,irq-gpios = <&gpio1 16 0>; mcp251x,stay-awake = <1>; mcp251x,enable-clkout = <1>; }; };
I have taken the advise forthe mcp251x-specific configuration from https://groups.google.com/g/beagleboard/c/nyyq1wQtGQc and https://github.com/battlesnake/beaglebone-spi0-mcp2515/blob/master/MCP2515.dts.
When starting Linux, I get this error message:
Oct 27 20:14:17 arm kernel: [ 1.495630] mcp251x spi1.0: setup: speed 9600000, sample leading edge, clk normal Oct 27 20:14:17 arm kernel: [ 1.495648] mcp251x spi1.0: setup mode 0, 8 bits/w, 10000000 Hz max --> 0 Oct 27 20:14:17 arm kernel: [ 1.505949] mcp251x spi1.0: Cannot initialize MCP2515. Wrong wiring? Oct 27 20:14:17 arm kernel: [ 1.512400] mcp251x spi1.0: Probe failed, err=19
I have tested the SPI without the CAN controller, enabled the spidev section in the dtsi and connected MISO to MOSI running and SPI echo test tool. It worked fine.
Do you have any idea what I may have done wrong? My suspect is the irq configuration which I have just copied from the example and only adjusted the GPIO number but I am not very confident about that:
mcp2515_int: mcp2515_int { pinctrl-single,pins = < AM33XX_IOPAD(0x840, PIN_OUTPUT | MUX_MODE7) /* (R13) gpmc_a0.gpio1[16] */ >; }; pinctrl-0 = <&mcp2515_int>; interrupt-parent = <&gpio1>; interrupts = <16 2>; mcp251x,irq-gpios = <&gpio1 16 0>;
I am using Linux 4.19.59 from SDK version 06.01.00.08 and no specific code from the BBB distribution as we only need this as an intermediate step until an own design will be ready.
Thank you in advance for your support.
Regards
Peter