20 设备树里声明i2c设备
来源:互联网 发布:qq手机型号修改软件 编辑:程序博客网 时间:2024/04/30 08:13
参考内核源码目录里的Documentation/i2c/instantiating-devices
文档里主要的内容:
Method 1b: Declare the I2C devices via devicetree-------------------------------------------------This method has the same implications as method 1a. The declaration of I2Cdevices is here done via devicetree as subnodes of the master controller.Example: i2c1: i2c@400a0000 { /* ... master properties skipped ... */ clock-frequency = <100000>; flash@50 { compatible = "atmel,24c256"; reg = <0x50>; }; pca9532: gpio@60 { compatible = "nxp,pca9532"; gpio-controller; #gpio-cells = <2>; reg = <0x60>; }; };
通过文档里的内容, 可以得知: i2c设备节点需要作为i2c控制器节点的子节点.
i2c设备节点的compatible属性值除了用于与设备驱动匹配以外,还作为设备名.
reg属性值为设备地址.也可以在设备节点里加入额外的属性.
如dht12接在第0个i2c控制器上,则修改内核源码目录arch/arm64/boot/dts/allwinner/sunxi-h3-h5.dts:
i2c0: i2c@01c2ac00 { /* 控制器的设备节点 */ compatible = "allwinner,sun6i-a31-i2c"; reg = <0x01c2ac00 0x400>; interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>; clocks = <&ccu CLK_BUS_I2C0>; resets = <&ccu RST_BUS_I2C0>; pinctrl-names = "default"; pinctrl-0 = <&i2c0_pins>; status = "disabled"; #address-cells = <1>; #size-cells = <0>; mydht12 { /* 增加的设备子节点 */ compatible = "mydht12"; reg = <0x5c>; /* 设备地址 */ /* 额外增加的属性,供i2c设备驱动使用 */ led-gpios = <&pio 0 17 GPIO_ACTIVE_HIGH>; }; };
重编设备树并更新,重启系统后:
^_^ / # ls /sys/bus/i2c/devices/0-005c/ 0-0068/ i2c-0/ i2c-1/ i2c-2/^_^ / # cat /sys/bus/i2c/devices/0-005c/name mydht12
阅读全文
0 0
- 20 设备树里声明i2c设备
- 56 linux内核里声明I2C设备的方法
- I2C设备声明以及应用实现
- i2c设备/模拟i2c
- Linux里SPI与I2C创建设备的流程
- 24 设备树里描述spi设备
- tiny4412 设备树之i2c设备(二)
- 21 使用设备树的i2c设备驱动
- I2C设备驱动流程
- I2C设备地址
- I2C设备驱动流程
- i2c 具体设备驱动
- I2C设备驱动流程
- i2c 设备自动探测
- Linux I2C 设备注册
- S5PV210 I2C设备驱动
- 移植i2c设备驱动
- linux i2c设备驱动
- centos7 rpm 安装JDK8
- python中的随机函数
- 阿里巴巴跨物理界招人,世界级音频专家冯津伟入职人工智能团队iDST
- 事件处理
- JAVA选择结构语句和witchi和for循环判断语句jj基础介绍
- 20 设备树里声明i2c设备
- CSS3 Media Queries 实现响应式demo
- Python中数组及矩阵的大小
- 微信小程序有哪些商店案例
- 超简单实现Android自定义Toast(附源码)
- TensorFlow学习笔记-实现经典LeNet5模型
- LDA笔记
- 自定义View九宫格手势
- 面试题整理--Java设计模式--创建型模式