设备树中相关函数

来源:互联网 发布:云计算第二版 编辑:程序博客网 时间:2024/06/06 13:04

1.结构关系

device_node 结构被 device 结构包含

struct device {...    struct device_node  *of_node; /* associated device tree node */...}

2.相关函数


drivers/of 目录下的相关文件封装了所有的 device dree的设备相关函数


2.1 base


// (1)判断 node 中是否有这个 name 名字的属性,没有就返回 null ☆const void *of_get_property(const struct device_node *np, const char *name, int *lenp)   //(2)判断设备结点是否被使能   Returns 1 if the status property is absent or set to "okay" or "ok", 0 otherwiseint of_device_is_available(const struct device_node *device) // (3)判断设备结点的 compatible 属性是否包含compat指定的字符串,有返回1,无返回0int of_device_is_compatible(const struct device_node *device,const char *compat);

这里写图片描述


2.2 driver


这里写图片描述


这里写图片描述


这里写图片描述


2.3 device


//为dev从 matches 结构数组中找到匹配的描述,返回这个matches中的结构 ---   用于一个驱动支持多种设备的情况 struct of_device_id *of_match_device(const struct of_device_id *matches,const struct device *dev)/*1. 将设备树中的内存资源获取到并且映射为虚拟内存 */    // 内存void __iomem *of_iomap(struct device_node *np, int index)    // 从设备树获取内存返回内存资源      of_address_to_resource(struct device_node *dev, int index,   struct resource *r)    // 从设备树节点中获取内存资源的起始地址和长度            of_get_address(struct device_node *dev, int index, u64 *size, unsigned int *flags)
0 0
原创粉丝点击