比如如下的myip_led_0节点下面的子节点
/ {
amba_pl: amba_pl@0 {
#address-cells = <2>;
#size-cells = <2>;
compatible = "simple-bus";
ranges ;
myip_led_0: myip_led@80001000 {
compatible = "xlnx,myip-led-1.0";
reg = <0x0 0x80001000 0x0 0x1000>;
clock-names = "ref_clk", "pclk";
clocks = <&clk 31>, <&clk 32>;
/*clocks = <&clk 19>, <&clk 31>;*/
xlnx,s00-axi-addr-width = <0x4>;
xlnx,s00-axi-data-width = <0x20>;
led0: led0 {
#phy-cells = <4>;
};
led1: led1 {
#phy-cells = <4>;
};
led2: led2 {
#phy-cells = <4>;
};
};
};
};
用如下的代码打印出来!
static int led_simple_probe(struct platform_device *pdev)
{
struct device *dev=&pdev->dev;
struct device_node *np=dev->of_node;
struct device_node *child;
struct resource *res;
struct list_head *ptr = NULL;
struct list_head *pos;
struct list_head clklist=dev->devres_head;
int clkCnt=0;
int index=0;
struct myled_dev *ledDev;
ledDev=devm_kzalloc(dev, sizeof(*ledDev), GFP_KERNEL);
if(!ledDev)
return -ENOMEM;
ledDev->dev=dev;
res = platform_get_resource(pdev,IORESOURCE_MEM, 0);
printk(KERN_ERR "res.start=%llx,res.end=%llx\n",res->start,res->end);
printk(KERN_ERR"pdev->name is %s\n",pdev->name);
list_for_each(pos,&dev->devres_head){
clkCnt++;
}
printk(KERN_ERR"Total resource number clkCnt =%d\n",clkCnt);
clkCnt=0;
ledDev->pclk = devm_clk_get(&pdev->dev, "pclk");
if (IS_ERR(ledDev->pclk)) {
dev_err(dev, "pclk clock not found.\n");
return -1;
}
list_for_each(pos,&dev->devres_head){
clkCnt++;
}
for (index = 0; index < of_get_child_count(dev->of_node); index++) {
printk(KERN_ERR"Phy index =%d\n",index);
}
for_each_child_of_node(np, child)
printk(KERN_ERR"child->name=%s,child->full_name=%s,%p\n",child->name,child->full_name,child);
printk(KERN_ERR"Total resource number clkCnt =%d\n",clkCnt);
printk(KERN_ERR"led np->name=%s,np->full_name=%s\n",np->name,np->full_name);
printk(KERN_ERR"kobject name is %s\n",dev->kobj.name);
return 0;
}
打印结果如下: