MCP2515 on ECSPI3 not working

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCP2515 on ECSPI3 not working

3,326 Views
jsmith883
Contributor III

Hello,

We have designed a custom board using the i.MX6UL that will have three CAN buses.  I'm using flexcan for the first two CAN buses, and using the Microchip MCP2515 via SPI on the thrird CAN bus.  I'm using kernel 4.1.15.  I have added the MCP251X driver to the kernel, but the driver is never loaded.  The only output from dmesg says the following:

# dmesg | grep spi
[ 0.437217] spi_imx 2010000.ecspi: probed

If I add a spidev node, it will load but not the driver for the MCP2515.  Could u-boot be doing something to the pins that would mess up spi in the kernel?  My device tree is found below...  any ideas why this is not working?

schematic1.JPG

schematic2.JPG

clocks {
      mcp251x_clock: mcp251x_clock {
      compatible = "fixed-clock";
      reg = <1>;
      #clock-cells = <0>;
      clock-frequency = <8000000>;
      clock-output-names = "mcp251x_clock";
   };
};

&ecspi3 {

   fsl,spi-num-chipselects = <1>;
   cs-gpios = <&gpio4 12 1>;
   pinctrl-names = "default";
   pinctrl-0 = <&pinctrl_ecspi3>;
   status = "okay";

   /* spidev@0x00 {
      compatible = "spidev";
      spi-max-frequency = <10000000>;
      reg = <0>;
   };*/

   can0: mcp2515@0 {
      compatible = "microchip,mcp2515";
      reg = <0>;
      clocks = <&mcp251x_clock>;
      interrupt-parent = <&gpio4>;
      interrupts = <11 0x2>;
      spi-max-frequency = <10000000>;
      xceiver-supply = <&reg_can_3v3>;
      vdd-supply = <&reg_can_3v3>;
      status = "okay";
      };
   };

/**iomuxc**/
pinctrl_ecspi3: ecspi3grp {
   fsl,pins = <
   MX6UL_PAD_NAND_CLE__ECSPI3_MISO 0x100B1
   MX6UL_PAD_NAND_CE1_B__ECSPI3_MOSI 0x100B1
   MX6UL_PAD_NAND_CE0_B__ECSPI3_SCLK 0x100B1
   MX6UL_PAD_NAND_WP_B__ECSPI3_RDY 0x100B1
   /*MX6UL_PAD_NAND_READY_B__ECSPI3_SS0 0x100B1*/
   MX6UL_PAD_NAND_READY_B__GPIO4_IO12 0x000B1
   >;
};

Labels (1)
0 Kudos
6 Replies

2,287 Views
igorpadykov
NXP Employee
NXP Employee

Hi jsmith883

one can look at ecspi debugging procedures described on below

thread for similar case (spi based lcd)

Porting small OLED display to i.MX6ULL 14x14 Evk 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

2,287 Views
jsmith883
Contributor III

igorpadykov‌, I reviewed this post, but I don't see how this is related or where the debugging procedures are located.  I added debug statements to the mcp251x.c driver and found that the error is the mcp251x_hw_reset function, where it reads the register.  The register that it reads is coming back as 0.  Any thoughts on why this would be happening?

https://github.com/torvalds/linux/blob/ba4dbdedd3edc2798659bcd8b1a184ea8bdd04dc/drivers/net/can/spi/...

0 Kudos

2,287 Views
igorpadykov
NXP Employee
NXP Employee

seems you can attach oscilloscope and check signals, to find why reads is coming back as 0.

Best regards
igor

0 Kudos

2,287 Views
jsmith883
Contributor III

igorpadykov‌,

The oscilloscope reads that I'm sending 0x0E, which according to the mcp251x.c driver, is correct (it's the very first thing that the driver transmits).  I updated the driver to match the latest version in the mainline kernel, and here is what I get from dmesg:

[ 0.444582] spi_imx 2010000.ecspi: probed
[ 0.457894] mcp251x spi2.0: Cannot initialize MCP2515. Wrong wiring?
[ 0.463077] mcp251x spi2.0: Probe failed, err=19

The issue is MISO never moves.  I've tried different MCP2515 chips, but nothing seems to ever come out of the chip.  Does my device tree and schematic look correct?  Anything else it may be?

spi_output.jpg

0 Kudos

2,287 Views
igorpadykov
NXP Employee
NXP Employee

since MISO never moves, it means that mcp251x does not send data, probably

it was incorrectly initialized or its schematic circuit is not correct, one can apply to Microchip tech support.

Best regards
igor

0 Kudos

2,287 Views
lphwork
Contributor I

我也遇到相同问题不是错误原因是mcp2515返回0,所以probe失败了,问题还没找到

0 Kudos