mcp2515工作原理及使用spi_board_info描述设备的方式请参考:http://blog.csdn.net/jklinux/article/details/74347820
mcp2515设备驱动在内核里的配置:
make menuconfig ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
[*] Networking support --->
<*> CAN bus subsystem support --->
CAN Device Drivers --->
<*> Platform CAN drivers with Netlink support
[*] CAN bit-timing calculation
CAN SPI interfaces --->
<*> Microchip MCP251x SPI CAN controllers
保存退出后重编并更新内核镜像.
设备树里mcp2515设备节点的描述:
//连接在spi1控制器, 模块的int脚接PA12
&spi1 {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&spi1_pins &spi1_cs_pins>;
cs-gpios = <&pio 0 13 GPIO_ACTIVE_HIGH>;
myspidev {
compatible = "microchip,mcp2515";
reg = <0>;
clocks = <&osc24M>;
status = "okay";
spi-max-frequency = <5000000>;
interrupt-parent = <&pio>;
interrupts = <0 12 IRQ_TYPE_EDGE_FALLING>;
vdd-supply = <®_vcc3v3>;
xceiver-supply = <®_vcc3v3>;
};
};
驱动好后,可通过”ifconfig -a”查看到有can0设备.