1 基于太极派的SDK添加
//设备树添加can0: can@2504000 {compatible = "allwinner,sun20i-d1-can";reg = <0x0 0x02504000 0x0 0x400>;interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;clocks = <&ccu CLK_BUS_CAN0>;resets = <&ccu RST_BUS_CAN0>;pinctrl-names = "default";pinctrl-0 = <&can0_pins>;status = "okay";};can1: can@2504400 {compatible = "allwinner,sun20i-d1-can";reg = <0x0 0x02504400 0x0 0x400>;interrupts = <GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>;clocks = <&ccu CLK_BUS_CAN1>;resets = <&ccu RST_BUS_CAN1>;pinctrl-names = "default";pinctrl-0 = <&can1_pins>;status = "disabled";};//驱动放置 kernel/linux-5.4_d1_t113/drivers/net/can/sun4i_can.c//添加 Makefile 编译
obj-$(CONFIG_CAN_SUN8I) += sun4i_can.o//添加 Kconfig 配置config CAN_SUN8Itristate "Allwinner CAN controller"depends on ARCH_SUNXI---help---Say Y here if you want to use CAN controller found on AllwinnerA10/A20/D1/T113 SoCs.To compile this driver as a module, choose M here: the module willbe called sun4i_can.
1 替换ccu-sun8iw20.c增加CAN的时钟; 否则不能设置CAN的波特兰,也就是CAN的时钟没打开
t113-s3打开can失败,感觉象是没打开can时钟? / 全志 SOC / WhyCan Forum(哇酷开发者社区)
static SUNXI_CCU_GATE(bus_can0_clk, "bus-can0", "apb1", 0x92c, BIT(0), 0);
static SUNXI_CCU_GATE(bus_can1_clk, "bus-can1", "apb1", 0x92c, BIT(1), 0);
&bus_can0_clk.common,&bus_can1_clk.common,
2 在 sun8iw20-ccu.h 添加, 否则会报错
T113-s3 CAN linux 下已调通 | 全志在线开发者论坛
#define CLK_BUS_CAN0 73
#define CLK_BUS_CAN1 74
#define RST_BUS_CAN0 28
#define RST_BUS_CAN1 29
3 make kernal_menuconfig
打开CAN驱动
然后make , pack进去;
4 启动日志 ifconfig -a
5 设置波特率-- 需要用新的IP工具iproute2
如果用老的IP工具就会有问题