2设备节点兼容性.docVIP

  • 10
  • 0
  • 约6.51千字
  • 约 4页
  • 2017-03-28 发布于重庆
  • 举报
2设备节点兼容性

设备节点兼容性 在.dts文件的每个设备节点中,都有一个兼容属性,兼容属性用于驱动和设备的绑定。兼容属性是一个字符串的列表,列表中的第一个字符串表征了节点代表的确切设备,形式为manu-facturer,model,其后的字符串表征可兼容的其他设备。可以说前面的是特指,后面的则涵盖更广的范围。如在vexpress-v2m.dtsi中的Flash节点如下: flash@0{ compatible = arm,vexpress-flash, cfi-flash; reg = 0 001 00 b1ank-width = 4; }; 兼容属性的第2个字符串cfi-flash明显比第1个字符串arm,vexpress-flash涵盖的范围更广。 再如,Freescale MPC8349SoC含一个串口设备,它实现了国家半导体(National Sem-iconductor)的NS16550寄存器接口。则MPC8349串口设备的兼容属性为compatible=fsl,mpc8349-uart,ns16550。其中,fsl,mpc8349-uart指代了确切的设备,ns16550代表该设备与NS16550UART保持了寄存器兼容。因此,设备节点的兼容性和根节点的兼容性是类似的,都是“从具体到抽象”。 使用设备树后,驱动需要与.dts中描述的设备节点进行匹配,从而使驱动的probe()函数执行。对于platform_driver而言,需要添加一个OF匹配表,如前文的.dts文件的acme,a1234-i2c-bus兼容I2C控制器节点的OF匹配表,具体代码如下所示。 1 static const struct of_device_id a1234_i2c_of_match[] = { 2 { .compatible = acme,a1234-i2c-bus, }, 3 {}, 4 }; 5 MODULE_DEVICE_TABLE(of, a1234_i2c_of_match); 6 7 static struct platform_driver i2c_a1234_driver = { 8 .driver = { 9 .name = a1234-i2c-bus, 10 .owner = THIS_MODULE, 11 .of_match_table = a1234_i2c_of_match, 12 }, 13 .probe = i2c_a1234_probe, 14 .remove = i2c_a1234_remove, 15 }; 16 module_platform_driver(i2c_a1234_driver); 对于I2C和SPI从设备而言,同样也可以通过of_match_ta-ble添加匹配的.dts中的相关节点的兼容属性,如sound/soc/codecs/wm8753.c中的针对WolfsonWM8753的of_match_ta-ble,具体代码如下所示。 1 static const struct of_device_id wm8753_of_match[] = { 2 { .compatible = wlf,wm8753, }, 3 { } 4 }; 5 MODULE_DEVICE_TABLE(of, wm8753_of_match); 6 static struct spi_driver wm8753_spi_driver = { 7 .driver = { 8 .name = wm8753, 9 .owner = THIS_MODULE, 10 .of_match_table = wm8753_of_match, 11 },12 .probe = wm8753_spi_probe, 13 .remove = wm8753_spi_remove, 14 }; 15 static struct i2c_driver wm8753_i2c_driver = { 16 .

文档评论(0)

1亿VIP精品文档

相关文档