设备树的绑定文档说明

一.  简介

设备树是用来描述板子上的设备信息的,不同的设备其信息不同,反映到设备树中就是属 性不同。
那么,我们在设备树中添加一个硬件对应的节点的时候从哪里查阅相关的说明呢?
Linux 内核源码中有详细的 .txt 文档描述了如何添加节点,这些 .txt 文档叫做绑定文档,绑定文档可以理解为 设备树节点与属性的描述。

二.  设备树的绑定文档

设备树的绑定文档,所在目录:Linux 源码根目录:

 /Documentation/devicetree/bindings

目录下文件如下所示:

可以看出,Linux内核源码目录 /Documentation/devicetree/bindings目录下,分门别类存放了不同的绑定文档。

注意:不同的芯片,i2c节点的描述是不一样的。例如,nxp的,三星的等等。

例如,我们现在要想在 I.MX6ULL 这颗 SOC 的 I2C 下添加一个节点,那么就可以查看Documentation/devicetree/bindings/i2c/目录下的文档。该目录下的 文档 i2c-imx.txt,此文档详细的描述了 I.MX 系列的 SOC 如何在设备树中添加 I2C 设备节点,文档内容如下所示:

* Freescale Inter IC (I2C) and High Speed Inter IC (HS-I2C) for i.MX

Required properties:
- compatible :
  - "fsl,imx1-i2c" for I2C compatible with the one integrated on i.MX1 SoC
  - "fsl,imx21-i2c" for I2C compatible with the one integrated on i.MX21 SoC
  - "fsl,vf610-i2c" for I2C compatible with the one integrated on Vybrid vf610 SoC
- reg : Should contain I2C/HS-I2C registers location and length
- interrupts : Should contain I2C/HS-I2C interrupt
- clocks : Should contain the I2C/HS-I2C clock specifier

Optional properties:
- clock-frequency : Constains desired I2C/HS-I2C bus clock frequency in Hz.
  The absence of the propoerty indicates the default frequency 100 kHz.
- dmas: A list of two dma specifiers, one for each entry in dma-names.
- dma-names: should contain "tx" and "rx".

Examples:

i2c@83fc4000 { /* I2C2 on i.MX51 */
	compatible = "fsl,imx51-i2c", "fsl,imx21-i2c";
	reg = <0x83fc4000 0x4000>;
	interrupts = <63>;
};

i2c@70038000 { /* HS-I2C on i.MX51 */
	compatible = "fsl,imx51-i2c", "fsl,imx21-i2c";
	reg = <0x70038000 0x4000>;
	interrupts = <64>;
	clock-frequency = <400000>;
};

i2c0: i2c@40066000 { /* i2c0 on vf610 */
	compatible = "fsl,vf610-i2c";
	reg = <0x40066000 0x1000>;
	interrupts =<0 71 0x04>;
	dmas = <&edma0 0 50>,
		<&edma0 0 51>;
	dma-names = "rx","tx";
};

I.MX 系列的 SOC 芯片的设备树的绑定文档:

Required properties下面的为必须要求写的设备属性,包括 compatible,reg ,interrupts,clocks 这些属性。

Optional properties下面的为一些可选的属性,包括 clock-frequency,dmas,dma-names这些属性。

文档中还进行了举例说明。

三.  总结

有时使用的一些芯片在 Documentation/devicetree/bindings 目录下找不到对应的文档,这 个时候就要咨询芯片的提供商,让他们给你提供参考的设备树文件。

注意:绑定文档只是写设备节点时的一个参考,可能也不完善!

  • 11
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值