设备树是由节点和属性构成的一种树形结构,设备节点用来存储设备信息,一个节点内可以包括硬件的各种属性,这些属性采用链式结构存储
//根节点
/{
//子节点名
mynode@0x12345678{
//各种属性
compatible = "hqyj,mynode";
astring = "hello 22091";
unit = <0xaabbccdd 0x11223344>;
binarry = [00 0c 29 7b f9 be];
mixed = "hello,[11 22],<0x12345678>";
};
};
获取设备树节点信息API
//通过设备树节点的路径获取
struct device_node *of_find_node_by_path(const char *path);
//通过设备树节点的名字获取
struct device_node *of_find_node_by_name(struct device_node *from,const char *name);
//通过compatible属性获取
struct device_node *of_find_compatible_node(struct device_node *from,
const char *type,
const char *compat);
获取设备树节点属性API
struct property *of_find_property(const struct device_node *np,
const char *name,int *len);