我在我的设备中找到孩子有问题。我正在编写linux驱动程序,我正在使用函数' of_match_device'和' of_find_matching_node'。当我在检查时,我找到了孩子,我发现这是我的父母。我做错了什么?父母和孩子的兼容性应该在相同的结构中定义' of_device_id&#39 ;?我的儿童标签是正确的吗?
这是我在devicetree中的声明:
soc: h2f_lw_bridge@0xff200000 {
compatible = "altr,socfpga-mysoftip";
reg = <0xff200000 0x00200000>;
//interrupts = <GIC_SPI 40 IRQ_TYPE_EDGE_RISING>;
#address-cells = < 2 >;
#size-cells = < 1 >;
ranges = <0 0x100 0xff200100 0x4
0 0x200 0xff200200 0x100>;
hw_tester_gpio: tester_gpio@0x000000100 {
compatible = "altr,socfpga-gpio";
reg = <0 0x100 0x4>;
//reg = <0xff200100 0x4>;
interrupt = <GIC_SPI 40 IRQ_TYPE_EDGE_RISING>;
};
reconig_data_clk: reconfig_pll@0x000000200 {
compatible = "altr,socfpga-pll";
reg = <0 0x200 0x100>;
//reg = <0xFF200200 0x100>;
};
};
我如何获取节点(我的linux驱动程序的片段):
struct h2f_lw_bridge *h2f_lw;
struct h2f_lw_bridge {
struct device *dev;
void __iomem *base;
void __iomem *base_of;
void __iomem *base_node;
const struct of_device_id *match;
struct device_node *node;
};
...
static const struct of_device_id _driver_id[] = {
{.compatible = "altr,socfpga-mysoftip"}, //parent
{.compatible = "altr,socfpga-gpio"}, //child
{.compatible = "altr,socfpga-pll"}, //child
{}
};
...
h2f_lw->match = of_match_device(_driver_id, &pdev->dev);
h2f_lw->node = of_find_matching_node(NULL,h2f_lw->match);
if (!h2f_lw->match)
return -EINVAL;
printk("h2f_lw->node: '%s' - pdev->dev.of_node: '%s' - h2f_lw->node: '%s'\n",h2f_lw->node->name,pdev->dev.of_node->name,h2f_lw->node->name);