设备树

1、查找结点:
a、通过节点名字查找:
np = of_find_node_by_name(NULL, “ethernet”);
b、通过节点属性查找:
np = of_find_compatible_node(NULL, NULL, “davicom,dm9000”);
c、通过路径名查找:
np = of_find_compatible_node(”/key”);
2、设备树如下:
srom-cs1@5000000 {
compatible = “simple-bus”;
#address-cells = <1>;
#size-cells = <1>;
reg = <0x5000000 0x1000000>;
ranges;
ethernet@5000000 {
compatible = “davicom,dm9000”;
reg = <0x5000000 0x2 0x5000004 0x2>;
interrupt-parent = <&gpx0>;
interrupts = <6 4>;
davicom,no-eeprom;
mac-address = [00 0a 2d a6 55 a2];
};
};
a、提取地址属性:注意是地址属性reg中的第0和第1个元素;
struct resource con;
struct resource dat;
ret = of_address_to_resource(np, 0, &con);
ret = of_address_to_resource(np, 1, &dat);

b、得到软中断号(映射过的)// interrupts = <6 4>;
irq = of_irq_get(np, 0);

c、找到属性值(私有属性),放到属性结构体中,再从属性结构体中提取name(名字),length(长度),value(属性值)
prop = of_find_property(np, “davicom,no-eeprom”, NULL);

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值