A Tutorial on the Device Tree (Zynq) -- Part V

Application-specific data

之前提过,设备树中是一些特殊信息,这样一个驱动可以管理数片类似的硬件。例如,一个LCD显示驱动,分辨率信息和物理尺寸可能出现在设备树中。串口信息要告诉驱动当前的时钟频率。

最简单的,最常用的形式,这个信息由一条赋值语句组成:

  1. xlnx,slv-awidth = <0x20>;

"xlnx"前缀可以防止命名冲突。名字可以任意取,但最好能望文知意。这里的"xlnx"是使用软件自动生成设备树时加上的前缀。

为了抓取到这一条信息,代码可以这样写:

  1. void *ptr;
  2. ptr = of_get_property(op->dev.of_node, "xlnx,slv-awidth", NULL);
  3. if (!ptr) {
  4. /* Couldn't find the entry */
  5. }

第三个参数NULL,是一个长度指针,可以返回数据的长度。

这条语句的值是一个数字:

  1. int value;
  2. value = be32_to_cpup(ptr);

be32_to_cpup读“ptr”指向的数据,从大端转到处理器的小端,然后就得到想要的数字了。

drivers/of/base.c中有大量读取这些信息的API。

总结

为一个外置写一个设备树entry很简单:

  • 为"compatible"赋一个字符串"magic string",自动生成工具的生成格式一般是:名字+版本。
  • 在数据手册里查看总线上设备的地址分配信息, 写一条 "reg=" 语句。
  • "interrupt-parent=<&gic>"
  • 中断号 "interrupt="
  • 最后加上一些设备的自定义参数

翻译:A Tutorial on the Device Tree (Zynq) -- Part V的更多相关文章

  1. 翻译:A Tutorial on the Device Tree (Zynq) -- Part III

    A Tutorial on the Device Tree (Zynq) -- Part III 定义外设 可能你读本文是为了给你的设备写一个Linux驱动,在这方面要推荐著名的<Linux D ...

  2. 翻译:A Tutorial on the Device Tree (Zynq) -- Part II

    A Tutorial on the Device Tree (Zynq) -- Part II 设备树结构 Zynq的设备树如下: /dts-v1/; / { #address-cells = < ...

  3. 翻译:A Tutorial on the Device Tree (Zynq) -- Part I

    A Tutorial on the Device Tree (Zynq) -- Part I 此教程的目的 本教程是针对Xilinx' Zynq-7000 EPP设备(一个集成了FPGA的ARM Co ...

  4. 翻译:A Tutorial on the Device Tree (Zynq) -- Part IV

    获取资源信息 内核模块驱动加载之后,就开始把硬件资源管理起来,如读写寄存器.接收中断. 来看看设备树里的一条: xillybus_0: xillybus@50000000 { compatible = ...

  5. Device Tree Usage 【转】

    转自:http://blog.chinaunix.net/uid-20522771-id-3457184.html 原文链接:http://devicetree.org/Device_Tree_Usa ...

  6. Device Tree(二):基本概念

    转自:http://www.wowotech.net/linux_kenrel/dt_basic_concept.html 一.前言 一些背景知识(例如:为何要引入Device Tree,这个机制是用 ...

  7. Device Tree Usage( DTS文件语法)

    http://elinux.org/Device_Tree_Usage Device Tree Usage     Top Device Tree page This page walks throu ...

  8. 【转】Device Tree(二):基本概念

    原文网址:http://www.wowotech.net/linux_kenrel/dt_basic_concept.html 一.前言 一些背景知识(例如:为何要引入Device Tree,这个机制 ...

  9. Device Tree Usage(理解DTS文件语法)

    Basic Data Format The device tree is a simple tree structure of nodes and properties. Properties are ...

随机推荐

  1. STM32F407 I2C 个人笔记

    源代码;https://github.com/YuQiao0303/STM32F407-Examples/tree/master/24.IIC 概述 I2C (IIC, Inter-Integrate ...

  2. HDU-4848 Wow! Such Conquering! 爆搜+剪枝

    Wow! Such Conquering! 题意:一个n*n的数字格,Txy表示x到y的时间.最后一行n-1个数字代表分别到2-n的最晚时间,自己在1号点,求到达这些点的时间和的最少值,如果没有满足情 ...

  3. EasyUI 加载Tree

    function LoadTree(result) { mainMenu = $('#mainMenu').tree({ url: "/ajax/GetTreeJson.ashx" ...

  4. jQuery中文文档

    http://www.jquery123.com/ http://www.shifone.cc/

  5. Ubuntu Flask安装与配置(待整理)

    工作中开发需要用到python的flask框架,无奈网络上的资源很少,连基本的安装和配置都不全,在这做一下整理,方便以后用到. ———————————————————————————— 由于比较繁琐, ...

  6. yum update 出错解决办法

    卸载掉yum和python 于是我卸载了python和yum,觉得自己重新安装python和yum. 步骤1:卸载python rpm -qa|grep python|xargs rpm -e --a ...

  7. robotframework使用

    下面是ui自动化的使用,关于接口自动化的使用参照此博客:http://blog.csdn.net/wuxiaobingandbob/article/details/50747125 1.使用pytho ...

  8. Nastya Studies Informatics

    Nastya Studies Informatics   time limit per test 1 second   memory limit per test 256 megabytes   in ...

  9. msp430项目编程45

    msp430综合项目---蓝牙控制系统45 1.电路工作原理 2.代码(显示部分) 3.代码(功能实现) 4.项目总结

  10. 让Mac OS X下的终端像Linux那样拥有丰富多彩的颜色显示

    我们知道Linux下的命令行终端具有颜色回显功能,用ls命令查看目录或者文件,终端会以不同的颜色来区分:使用vim命令行编辑器打开脚本或其他源程序代码会以语法高亮模式显示.而Mac OS X下的终端却 ...