翻译:A Tutorial on the Device Tree (Zynq) -- Part V
A Tutorial on the Device Tree (Zynq) -- Part V
Application-specific data
之前提过,设备树中是一些特殊信息,这样一个驱动可以管理数片类似的硬件。例如,一个LCD显示驱动,分辨率信息和物理尺寸可能出现在设备树中。串口信息要告诉驱动当前的时钟频率。
最简单的,最常用的形式,这个信息由一条赋值语句组成:
xlnx,slv-awidth = <0x20>;
"xlnx"前缀可以防止命名冲突。名字可以任意取,但最好能望文知意。这里的"xlnx"是使用软件自动生成设备树时加上的前缀。
为了抓取到这一条信息,代码可以这样写:
void *ptr;
ptr = of_get_property(op->dev.of_node, "xlnx,slv-awidth", NULL);
if (!ptr) {
/* Couldn't find the entry */
}
第三个参数NULL,是一个长度指针,可以返回数据的长度。
这条语句的值是一个数字:
int value;
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的更多相关文章
- 翻译:A Tutorial on the Device Tree (Zynq) -- Part III
A Tutorial on the Device Tree (Zynq) -- Part III 定义外设 可能你读本文是为了给你的设备写一个Linux驱动,在这方面要推荐著名的<Linux D ...
- 翻译:A Tutorial on the Device Tree (Zynq) -- Part II
A Tutorial on the Device Tree (Zynq) -- Part II 设备树结构 Zynq的设备树如下: /dts-v1/; / { #address-cells = < ...
- 翻译: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 ...
- 翻译:A Tutorial on the Device Tree (Zynq) -- Part IV
获取资源信息 内核模块驱动加载之后,就开始把硬件资源管理起来,如读写寄存器.接收中断. 来看看设备树里的一条: xillybus_0: xillybus@50000000 { compatible = ...
- Device Tree Usage 【转】
转自:http://blog.chinaunix.net/uid-20522771-id-3457184.html 原文链接:http://devicetree.org/Device_Tree_Usa ...
- Device Tree(二):基本概念
转自:http://www.wowotech.net/linux_kenrel/dt_basic_concept.html 一.前言 一些背景知识(例如:为何要引入Device Tree,这个机制是用 ...
- Device Tree Usage( DTS文件语法)
http://elinux.org/Device_Tree_Usage Device Tree Usage Top Device Tree page This page walks throu ...
- 【转】Device Tree(二):基本概念
原文网址:http://www.wowotech.net/linux_kenrel/dt_basic_concept.html 一.前言 一些背景知识(例如:为何要引入Device Tree,这个机制 ...
- Device Tree Usage(理解DTS文件语法)
Basic Data Format The device tree is a simple tree structure of nodes and properties. Properties are ...
随机推荐
- luogu3159 [CQOI2012]交换棋子
把每个点拆成 x y z 对于第 i 个点,x->y是表示流入的,y->z是表示流出的. #include <iostream> #include <cstring> ...
- jquery 页面加载效果
30个jquery 页面加载效果 30个jquery 页面加载效果 30 CSS Page Preload Animations 加载效果列表 Square Animations Demo 1 ...
- 大数据学习——scala入门程序
安装scala.msi https://blog.csdn.net/sinat_32867867/article/details/80305302 notepad++ object HelloScal ...
- unittest的discover方法使用
使用unittest进行测试,如果是需要实现上百个测试用例,把它们全部写在一个test.py文件中,文件会越来越臃肿,后期维护页麻烦.此时可以将这些用例按照测试功能进行拆分,分散到不同的测试文件中. ...
- 学习笔记5——wp主题开发
我觉得学习wordpress插件开发之前还是得先理解一下wp的主题开发,循序渐进才能学好wordpress开发,话不多说,接下来整理一下这两天学习的wordpress主题开发的一些心得和体会,与大家一 ...
- Linux 指令的快捷键
- TOJ 2017: N-Credible Mazes
2017: N-Credible Mazes Time Limit(Common/Java):1000MS/10000MS Memory Limit:65536KByteTotal Subm ...
- js对文字进行编码
js对文字进行编码涉及3个函数:escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decodeURIComponent 1 ...
- EasyUI 动态更新列
function UpdateRow() { var rows = $('#tbpmgridList').datagrid('getChecked'); var productid = ''; for ...
- [UOJ#220][BZOJ4651][Noi2016]网格
[UOJ#220][BZOJ4651][Noi2016]网格 试题描述 跳蚤国王和蛐蛐国王在玩一个游戏. 他们在一个 n 行 m 列的网格上排兵布阵.其中的 c 个格子中 (0≤c≤nm),每个格子有 ...