设备树文本文件的写入顺序是否重要? [英] The order in which the device-tree text file is written, does it matter?

查看:322
本文介绍了设备树文本文件的写入顺序是否重要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设备树文本文件(.dts)的写入顺序是否全部重要?

Does the order in which a device-tree text file (.dts) is written matter at all ?

例如,如果您从文件的顶部获取一个节点并将其移至底部,它将改变硬件检测,IRQ配置等的顺序吗?

For example, if you take a node from the top of the file and move it to the bottom, will it change the order of hardware detection, IRQ configuration, or whatever ?

推荐答案

设备树文本文件(.dtx)的写入顺序是否全部重要?

Does the order in which the device-tree text file (.dtx) is written matter at all ?

.dts .dtsi 源文件的答案是依赖".
设备树具有结构,因此节点的重新布置可能会或可能不会更改系统硬件配置.

The answer for .dts and .dtsi source files is "depends".
The Device Tree has a structure, so rearrangement of nodes may, or may not, change the system hardware configuration.

总体而言,设备树的结构如下(

Overall a Device Tree has a structure such as (slide 23 of Device Tree for Dummies)

/ {
    aliases { ... };
    cpus { ... };
    apb@80000000 {
        apbh@80000000 {
            /* Some devices */
        };
        apbx@80040000 {
            /* Some devices */
        };
    };
    ahb@80080000 {
        /* Some devices */
    };
};

设备将由节点描述.
连接到特定总线的设备节点(例如apbh @ 80000000)可以通过设备地址按数字顺序排列,也可以通过设备名称按字母顺序排列.节点(在总线内)的顺序不重要.
但是,如果您从文件顶部获取一个节点,然后将其移至底部" ,然后将该节点重新分配给另一条总线,那么显然您将定义不同的配置(这可能是错误的).

The devices would be described by nodes.
The device nodes attached to a particular bus (e.g. apbh@80000000) could be ordered numerically by device address or alphabetically by device name. This ordering of nodes (within a bus) is not significant.
But if "you take a node from the top of the file and move it to the bottom" and that reassigns the node to a different bus, then obviously you would be defining a different configuration (that's probably incorrect).

设备树"源文本的文件结构由 .dts 文件(对于板)和可选的 .dtsi 文件组成.理想情况下,应该为SoC提供一个 .dtsi 文件,该文件应是通用文件,并且可以由使用该SoC的每个 .dts 板文件包含.

The file structure of a Device Tree source text is composed of a .dts file (for the board) and optional .dtsi files. Ideally there should be a .dtsi file for the SoC that is generic and can be included by every .dts board file that utilizes that SoC.

SoC的 .dtsi 文件通常由供应商提供,并且应具有所有芯片设备的定义.基本设备(例如电源管理,DMA控制器)将被定义并启用.但是将禁用非必需的可选外围设备和/或将I/O连接到多路复用引脚的外围设备.

The .dtsi file for a SoC is typically provided by the vendor, and should have definitions for all chip devices. Essential devices (e.g. power management, DMA controller) would be defined and enabled. But optional peripheral devices that are not essential and/or those that have I/O connected to multiplexed pins would be disabled.

apbh@80000000 {
    [...]
    hsadc: hsadc@80002000 {
        reg = <0x80002000 0x2000>;
        [...]
        status = "disabled";
    };
    [...]
};

如果要在板上使用可选的外围设备,则不应仅为您的板上修改或自定义SoC .dtsi 文件.
而是应在顶级主板文件(其中包括SoC .dtsi 文件)中扩充该设备的节点,然后重新声明设备的状态.

If you want to use an optional peripheral on your board, you should not modify or customize the SoC .dtsi file just for your board.
Rather you should augment that device's node in the top-level board file (which included the SoC .dtsi file), and re-declare the status of the device.

#include "my_soc.dtsi"
/ {
    apb@80000000 {
        apbh@80000000 {

            hsadc: hsadc@80002000 {
                status = "okay";
            };

            [...]
        };
    };
};

要获得正确的配置,必须将具有status = "okay"的该节点放置在通用节点之后(在随附的 .dtsi 中),以便可以覆盖status = "disabled".
显然,这是位置依赖的另一种情况.

To obtain the proper configuration, this node with the status = "okay" has to be positioned after the generic node (in the included .dtsi) so that the status = "disabled" can be overridden.
So clearly this is another case of position dependence.

我的意思是,例如,如果您从文件的顶部获取一个节点并将其移至底部,它将改变硬件检测,irq配置等的顺序吗?

I mean if for example you take a node from the top of the file and move it to the bottom, will it change the order of hardware detection, irq configuration, or whatever ?

设备树仅用于定义系统硬件的配置.设备驱动程序的执行顺序由驱动程序的构建方式控制,即 initcall 宏.请参见对编译到内核的驱动程序进行初始化函数调用初始化时module_init和subsys_initcall有什么区别司机?
设备驱动程序获取资源是在该驱动程序的控制之下,而不是由设备树属性控制的,设备树属性仅由驱动程序读取.

The Device Tree is solely for defining the configuration of the system hardware. The execution order of device drivers is controlled by how the drivers are built, i.e. the initcall macros. See init function invocation of drivers compiled into kernel and What is the difference between module_init and subsys_initcall while initializing the driver?
The acquisition of resources by a device driver is under control of that driver, and not directed by the Device Tree properties, which are merely read by the driver.

这篇关于设备树文本文件的写入顺序是否重要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆