设备树在文件系统中的体现: 在/proc/device-tree
    设备节点:
        struct device_node {
            const char *name; /* 节点名字 */
            const char *type; /* 设备类型 */
            phandle phandle;
            const char *full_name; /* 节点全名 */
            struct fwnode_handle fwnode;

struct property *properties; /* 属性 */
            struct property *deadprops; /* removed 属性 */
            struct device_node *parent; /* 父节点 */
            struct device_node *child; /* 子节点 */
            struct device_node *sibling;
            struct kobject kobj;
            unsigned long _flags;
            void *data;
    #if defined(CONFIG_SPARC)
            const char *path_component_name;
            unsigned int unique_id;
            struct of_irq_controller *irq_trans;
        #endif
        };
        
        OF函数:
            1、通过节点名查找指定节点:struct device_node * of_find_node_by_name(struct device_node *from_node,const char *name);
            2、通过device_type查找指定节点:struct device_node * of_fine_node_by_type(struct device_node *from_node,const char *type);
            3、通过compatible和device_type查找节点 struct device_node * of_find_compatible_node(struct device_node *from_node,const char *type,const char*compatible_name);
            4、通过of_device_id来查找节点:struct device_node * of_find_matching_node_and_match(struct device_node *from_node,const char matchs*,const char** match);
            5、通过路径来查找节点:struct device_node * of_find_by_name(const char *path);
            6、查找指定节点的父节点:struct device_node * of_get_parent(const struct device_node *node)
            7、迭代查找子节点:of_get_next_child(struct device_node *parent,struct device_node prev)
            
            8、查找指定属性:property * of_find_property(struct device_node *node,const char *name,int *len);len属性字节数
            9、获取属性元素的数量 :int of_property-count_elems_of_size(struct device_node *node,const char *prop_name,int len);//元素长度
            10、从属性中获取指定索引位置的u32数据 int of_property_read_u32_index(struct device_node *node,const propname,u32 index,u32 *value);
            11、读取属性中 u8、 u16、 u32 和 u64 类型的数组数据:
                int of_property_read_u8_array(const struct device_node *np,
                                                                        const char *propname,
                                                                        u8 *out_values,
                                                                        size_t sz)
                int of_property_read_u16_array(const struct device_node *np,
                                                                    const char *propname,
                                                                    u16 *out_values,
                                                                    size_t sz)
                int of_property_read_u32_array(const struct device_node *np,
                                                                const char *propname,
                                                                u32 *out_values,
                                                                size_t sz)
                int of_property_read_u64_array(const struct device_node *np,
                                                                const char *propname,
                                                                u32 *out_values,
                                                                size_t sz)
                                                                
            12、读取这种只有一个整形值的属性
                int of_property_read_u8(const struct device_node *np,
                                                                const char *propname,
                                                                u8 *out_value)
                int of_property_read_u16(const struct device_node *np,
                                                            const char *propname,
                                                            u16 *out_value)
                int of_property_read_u32(const struct device_node *np,
                                                            const char *propname,
                                                            u32 *out_value)
                int of_property_read_u64(const struct device_node *np,
                                                        const char *propname,
                                                        u64 *out_value)
                13、读取属性中的字符串:int of_property_read_string(const struct device_node *np,const char *propname,char **value_str)
                14、获取#address-cells数据 int of_n_addr_cells(const struct device_node *np);
                15、获取#size-cells数据 int of_n_size_cells(const struct device_node *np);
                
                ------------------------
                16、查看compatible属性是否包含conpat指定的字符串:of_device_is_compatible(const struct device_node *np,const char *compat_str);//返回 0 则包含
                17、获取地址相关的属性,主要是“reg”或者“assigned-addresses”属性值:of_get_addr();
                18、将从设备树得到的地址转换为物理地址:u64 of_translate_address(struct device_node *dev, const _be32 * in_addr);
                19、将reg属性抓换位resource结构数据:int of_address_to_resource(struct device_node *dev,int index,struct *resource *re);
                        struct resource {
                        resource_size_t start;
                        resource_size_t end;
                        const char *name;
                        unsigned long flags;//常见参数IORESOURCE_MEM 、 IORESOURCE_REG 和IORESOURCE_IRQ
                        struct resource *parent, *sibling, *child;
                        };
                20、获取内存地址对应的虚拟地址:of_iomap(struct device_node *np,int index);//index:reg 属性中要完成内存映射的段

Linux设备树相关相关推荐

  1. Linux驱动开发中与设备树相关的6种debug方法

    整理出了6种驱动开发时与设备注册.设备树相关的调试方法,彼此间没有优先级之分,每种方法不一定是最优解,但可以作为一种debug查找问题的手段,快速定位问题原因.例如在芯片验证时,不同时钟频率下系统启动 ...

  2. 我眼中的Linux设备树(一 概述)

    一 概述 设备树(Device tree)是一套用来描述硬件属相的规则.ARM Linux采用设备树机制源于2011年3月份Linux创始人Linus Torvalds发的一封邮件,在这封邮件中他提倡 ...

  3. Linux设备树语法详解【转】

    转自:http://www.cnblogs.com/xiaojiang1025/p/6131381.html 概念 Linux内核从3.x开始引入设备树的概念,用于实现驱动代码与设备信息相分离.在设备 ...

  4. linux spidev 应用_嵌入式Linux设备树语法总结

    1 设备树的说明 在写完嵌入式驱动总结后,对于设备树相关的语法和使用一直都想进行系统的描述,但是因为最近比较忙碌,所以一直拖到现在才完成初版,对于整个嵌入式Linux驱动开发中,设备树语法和构建是其中 ...

  5. Linux设备树相关函数

    Linux设备树相关函数 Linux内核提供了一系列函数来获取设备树中的节点和属性信息. 查找节点:of_find_node_by_name() 函数通过节点名字查找指定的节点of_find_node ...

  6. Linux 设备树的使用技巧

    Linux内核从3.x开始引入设备树的概念,用于实现驱动代码与设备信息相分离.在设备树出现以前,所有关于设备的具体信息都要写在驱动里,一旦外围设备变化,驱动代码就要重写.引入了设备树之后,驱动代码只负 ...

  7. 【正点原子MP157连载】第二十三章 Linux设备树-摘自【正点原子】STM32MP1嵌入式Linux驱动开发指南V1.7

    1)实验平台:正点原子STM32MP157开发板 2)购买链接:https://item.taobao.com/item.htm?&id=629270721801 3)全套实验源码+手册+视频 ...

  8. linux 设备树详解

    2 Linux 设备树 2.1 什么是设备树? 设备树(Device Tree),将这个词分开就是"设备"和"树",描述设备树的文件叫做DTS(Device T ...

  9. Linux设备树led,linux设备树下LED灯控制

    linux设备树下LED灯控制 linux设备树下LED灯控制 原理图: 所以在设备树下子节点下插入gpioled节点: gpioled { #address-cells = <1>; # ...

最新文章

  1. CentOS 安全配置
  2. 比特币地址可以查到本人吗_查看每一个地址有多少个比特币
  3. CF1063B Labyrinth
  4. esb 和mq_使用保险丝结构管理MQ和ESB的大型部署,第一部分
  5. python生成uuid_咸鱼高赞回答:有什么相见恨晚的Python技巧,附赠python最新教程...
  6. android动态渐变button,Android--自定义Button的样式以及动态渐变效果
  7. 期望dp--BZOJ3450 Easy
  8. 【Pygame实战】超有趣的泡泡游戏来袭——愿你童心不泯,永远快乐简单哦~
  9. 【CSDN】博文导入微信公众号
  10. java生成三位随机数_java工具类(三)之生成若干位随机数
  11. JS里给日期增加n个月的方法
  12. LLVM IR / LLVM指令集入门
  13. 《细节决定成败》读后感
  14. 流媒体传输 - HLS 协议
  15. 【微机原理与汇编语言】输出n位十进制数
  16. 计算机教室英语怎么读音,电脑教室,computer teaching room,音标,读音,翻译,英文例句,英语词典...
  17. BOM系列之Navigator对象
  18. 信贷风控指南丨人工智能专家直播解析信贷评分卡模型
  19. mat后缀名_mat文件扩展名,mat文件怎么打开?
  20. 使用Monkey对apk做稳定性测试

热门文章

  1. 一个类的java代码_求一段java代码,定义一个类
  2. c# static那些事
  3. linux输入influxdb密码,在RHEL 8/CentOS 8上安装InfluxDB的方法
  4. linux根目录缩减非lvm,vmware下linux非LVM管理的根目录扩容经历
  5. python什么是数据结构_Python中最有效的图形数据结构是什么?
  6. Java 并发编程之 FutureTask
  7. Java 算法 旅行家的预算
  8. sklearn模型使用贝叶斯优化调参(以随机森林为例)
  9. 微服务 数据库耦合_mysql – 与其他服务共享的微服务数据库
  10. 字符串截取mysql