环境:xilinx zynq linux
linux系统:buildroot 2018
需求:通过GPIO模拟I2C实现RTC时钟配置及读取;
RTC芯片:RTC1338
内核配置
|
Device Drivers-> I2C support ---> I2C Hardware Bus support ---> <*> GPIO-based bitbanging I2C |
设备树配置
在amba节点中添加i2c虚拟节点,与PS其它节点在同一级,如下:
|
i2c5: i2c5 { #address-cells = <1>; #size-cells = <0>; compatible = "i2c-gpio"; gpios = < &gpio0 34 0x01>, // SDA < &gpio0 32 0x01>;// SCL i2c-gpio,delay-us = < 0x05 >; // 100 KHz status = "okay"; // 添加RTC子设备 rtc1: rtc1@68 { compatible = "dallas,ds1338"; reg = < 0x68 >; // DS1338设备地址 }; }; |
在aliases中添加i2c0=&i2c5或i2c0 = "/amba/i2c5";
验证测试
系统启动后增新了/dev/i2c-0总线设备,它就是我们新增的GPIO模拟I2C总线设备,可通过命令i2cdetect查看总线上挂载的设备,它将显示连接到I2C总线上的设备的地址。例如运行i2cdetect -y 0将扫描总线号为0的I2C总线上的设备。使用i2cdetect -l可列出可用I2C总线
42

被折叠的 条评论
为什么被折叠?



