设备树获取地址时碰的钉子

of_iomap()函数是从设备树获得地址并映射。但我始终获取失败,折腾了两天,终于找到原因,记录下坑位;

网上说

#address-cells = <1>;
#size-cells = <1>;

是指定其子节点的地址属性,只要子节点用reg =<>,即可。

但是,这样做并不见得奏效。后来参照了别人的设备树才发现:

最重要的是:    rangs;   对,是他,少了就不行。

 

原设备树:

   leds {
	#address-cells = <1>;
	#size-cells = <1>;
        compatible = "pwm-leds";
        led1 {
           	reg = <0x40000320 0x04>;
           	label = "power-led";/*HW control*/
	   	owner = "hd";
       	 };
       	led2 {
            	reg = <0x40000324 0x04>;
            	label = "sys-led";
	    	owner = "ps";
        };
       	led3 {
            	reg = <0x40000328 0x04>;
            	label = "link-led";
	    	owner = "pl";
        };
       	led4 {
            	reg = <0x4000032C 0x04>;
            	label = "act-led";
	    	owner = "ps";
        };
       	led5 {
            	reg = <0x40000330 0x04>;
            	label = "sync-led";
	    	owner = "pl";
        };
       	led6 {
            	reg = <0x40000334 0x04>;
            	label = "alarm-led";
	    	owner = "ps";
        };

   };



#address-cells = <1>;
#size-cells = <1>;

 

 

 

 现在正确的设备树:

   leds {
	#address-cells = <1>;
	#size-cells = <1>;
        compatible = "pwm-leds";
	ranges;
        led1 {
           	reg = <0x40000320 0x04>;
           	label = "power-led";/*HW control*/
	   	owner = "hd";
       	 };
       	led2 {
            	reg = <0x40000324 0x04>;
            	label = "sys-led";
	    	owner = "ps";
        };
       	led3 {
            	reg = <0x40000328 0x04>;
            	label = "link-led";
	    	owner = "pl";
        };
       	led4 {
            	reg = <0x4000032C 0x04>;
            	label = "act-led";
	    	owner = "ps";
        };
       	led5 {
            	reg = <0x40000330 0x04>;
            	label = "sync-led";
	    	owner = "pl";
        };
       	led6 {
            	reg = <0x40000334 0x04>;
            	label = "alarm-led";
	    	owner = "ps";
        };

   };

 

转载于:https://www.cnblogs.com/xxg1992/p/7444311.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值