【设备树使用】-- 3 中断

4 中断是如何工作的

与遵循树的自然结构的地址范围转换不同,中断信号可以源自并终止于机器中的任何设备。与在设备树中自然表达的设备寻址不同,中断信号表示为独立于树的节点之间的链路。四个属性用于描述中断连接:

  • interrupt-controller - 一个空属性,声明节点是接收中断信号的设备
  • #interrupt-cells - 这是中断控制器节点的属性。它说明了该中断控制器的中断说明符中有多少个单元(类似于#address-cells和#size-cells)。
  • interrupt-parent - 设备节点的属性,包含与其连接的中断控制器的phandle。没有interrupt-parent属性的节点也可以从其父节点继承该属性。
  • interrupts - 设备节点的属性,包含一个中断说明符列表,一个用于设备上的每个中断输出信号。

中断说明符是一个或多个数据单元(由#interrupt-cells指定),用于指定设备所连接的中断输入。大多数器件只有一个中断输出,如下例所示,可以在器件上有多个中断输出。中断说明符的含义完全取决于中断控制器设备的绑定。每个中断控制器可以决定唯一定义中断输入所需的单元数。

以下代码为我们Coyote's Revenge示例机器添加了中断连接:

/dts-v1/;

/ {
    compatible = "acme,coyotes-revenge";
    #address-cells = <1>;
    #size-cells = <1>;
    interrupt-parent = <&intc>;

    cpus {
        #address-cells = <1>;
        #size-cells = <0>;
        cpu@0 {
            compatible = "arm,cortex-a9";
            reg = <0>;
        };
        cpu@1 {
            compatible = "arm,cortex-a9";
            reg = <1>;
        };
    };

    serial@101f0000 {
        compatible = "arm,pl011";
        reg = <0x101f0000 0x1000 >;
        interrupts = < 1 0 >;
    };

    serial@101f2000 {
        compatible = "arm,pl011";
        reg = <0x101f2000 0x1000 >;
        interrupts = < 2 0 >;
    };

    gpio@101f3000 {
        compatible = "arm,pl061";
        reg = <0x101f3000 0x1000
               0x101f4000 0x0010>;
        interrupts = < 3 0 >;
    };

    intc: interrupt-controller@10140000 {
        compatible = "arm,pl190";
        reg = <0x10140000 0x1000 >;
        interrupt-controller;
        #interrupt-cells = <2>;
    };

    spi@10115000 {
        compatible = "arm,pl022";
        reg = <0x10115000 0x1000 >;
        interrupts = < 4 0 >;
    };

    external-bus {
        #address-cells = <2>
        #size-cells = <1>;
        ranges = <0 0  0x10100000   0x10000     // Chipselect 1, Ethernet
                  1 0  0x10160000   0x10000     // Chipselect 2, i2c controller
                  2 0  0x30000000   0x1000000>; // Chipselect 3, NOR Flash

        ethernet@0,0 {
            compatible = "smc,smc91c111";
            reg = <0 0 0x1000>;
            interrupts = < 5 2 >;
        };

        i2c@1,0 {
            compatible = "acme,a1234-i2c-bus";
            #address-cells = <1>;
            #size-cells = <0>;
            reg = <1 0 0x1000>;
            interrupts = < 6 2 >;
            rtc@58 {
                compatible = "maxim,ds1338";
                reg = <58>;
                interrupts = < 7 3 >;
            };
        };

        flash@2,0 {
            compatible = "samsung,k8f1315ebm", "cfi-flash";
            reg = <2 0 0x4000000>;
        };
    };
};

需要注意的是:

  • 机器有一个中断控制器, interrupt-controller@10140000。
  • 标签 'intc:' 已添加到中断控制器节点,标签用于将phandle分配给根节点中的interrupt-parent属性。 此中断父值成为系统的默认值,因为除非显式覆盖它,否则所有子节点都会继承它。
  • 每个器件都使用中断属性来指定不同的中断输入线。
  • #interrupt-cells 为2,因此每个中断说明符都有2个单元。 此示例使用使用第一个单元格编码中断行号的公共模式,以及编码标志的第二个单元格,例如活动高电平与低电平有效,或边沿与电平敏感。 对于任何给定的中断控制器,请参阅控制器的绑定文档以了解如何编码说明符。

原文:https://elinux.org/Device_Tree_Usage

其他关于设备树的教程:

[1] A Tutorial on the Device Tree (Zynq) -- Part I ,http://xillybus.com/tutorials/device-tree-zynq-1

[2] A Tutorial on the Device Tree (Zynq) -- Part II,http://xillybus.com/tutorials/device-tree-zynq-2

[3] A Tutorial on the Device Tree (Zynq) -- Part III,http://xillybus.com/tutorials/device-tree-zynq-3

[4] A Tutorial on the Device Tree (Zynq) -- Part IV,http://xillybus.com/tutorials/device-tree-zynq-4

[5] A Tutorial on the Device Tree (Zynq) -- Part V,http://xillybus.com/tutorials/device-tree-zynq-5

猜你喜欢

转载自blog.csdn.net/u013554213/article/details/81016599
今日推荐