1.设备树实例
interrupt-controller@1 {
compatible = "vendor,gic";
#interrupt-cells = <2>;
interrupt-controller;
reg = <0x01 0x1000>;
};
deviceA {
compatible = "vendor,device-a";
reg = <0x02 0x100>;
interrupts = <&interrupt-controller 3 1>;
};
of_parse_phandle_with_args(node, "interrupts", "#interrupt-cells", 0, &irq_args);
函数声明
int of_parse_phandle_with_args(const struct device_node *np,
const char *list_name, const char *cells_name,
int index, struct of_phandle_args *out_args)
参数说明:
np 指向当前节点;即 deviceA
list_name 指向节点中 phandle 列表的属性名; 即interrupts
cells_name 参数指明 phandle 指向的节点所含的 cells 个数;即 #interrupt-cells = <2>;
index 表示 phandle 列 表的索引,0 代表第一个 phandle,1 代表第二个 phandle;
out_args 参数用于存储 phandle 中的参数。即两个参数: 3 1