Hamster Linux I2C总线适配

2022/3/29 7:26:23

本文主要是介绍Hamster Linux I2C总线适配,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

Hamster Linux I2C总线适配

  • SoC - F1C200s

  • Kernel 版本 v5.17.0

适配过程如下

修改 arch/arm/boot/dts/suniv-f1c100s.dtsi

1. 添加ccu头文件
#include <dt-bindings/clock/suniv-ccu-f1c100s.h>
#include <dt-bindings/reset/suniv-ccu-f1c100s.h>
2. 在soc节点下添加如下节点
                i2c0: i2c@1c27000 {
                        compatible = "allwinner,sun4i-a10-i2c";
                        reg = <0x01C27000 0x1000>;
                        interrupts  = <7>;
                        clocks = <&ccu CLK_BUS_I2C0>, <&ccu CLK_BUS_I2C0>;
                        clock-names = "ahb", "mod";
                        resets = <&ccu RST_BUS_I2C0>;
                        status = "disabled";
                        #address-cells = <1>;
                        #size-cells = <0>;
                };
3. 在pio节点下添加如下引脚组
                        i2c0_pe_pins: i2c0-pe-pins {
                                pins = "PE11", "PE12";
                                function = "i2c0";
                        };

修改 arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts

  1. 修改aliases节点,添加i2c节点别名
        aliases {
                serial0 = &uart0;
                //serial1 = &uart1;
                i2c0 = &i2c0;
                spi0 = &spi0;
                spi1 = &spi1;
        };
  1. 引用i2c节点
&i2c0 {
        pinctl-names = "default";
        pinctrl-0 = <&i2c0_pe_pins>;
        status = "okay";
        i2c-max-frequency = <400000>;
};

确认内核开启i2c支持

重新编译后,设备节点 /dev/i2c-0 已经注册



这篇关于Hamster Linux I2C总线适配的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程