其他分享
首页 > 其他分享> > 总线,设备,驱动模型架构与paltfrom平台总线

总线,设备,驱动模型架构与paltfrom平台总线

作者:互联网

驱动通用架构

注册总线

bus_register:bus_type_private的初始化,在这条总线目录下创建/bus/busname,/device, /driver 目录,初始化这条总线上的设备链表:struct klist klist_devices;初始化这条总线上的驱动链表:struct klist klist_drivers

注册驱动

driver_register->bus_add_driver->driver_attach->bus_for_each_dev->__driver_attach->driver_match_device/driver_probe_device->really_probe->(dev->bus->probe|drv->probe)

注册设备

device_register->device_add->bus_add_device/bus_probe_device->device_initial_probe->__device_attach->bus_for_each_drv->__device_attach_driver->driver_match_device/driver_probe_device

 

paltform总线

平台总线

kernel_init->do_basic_setup->driver_init(先于do_initcalls执行)->platform_bus_init(device_register(&platform_bus);bus_register(&platform_bus_type))

平台设备platform_device

arch_initcall(customize_machine)会把根的子节点都转换成platform_device节点;下图的两种方式都是从根节点遍历子节点,分配struct platform_device的内存,还分配了该platform device需要的resource的内存,加入统一设备模型系统中

 

设备树中的reg和interrupts资源将会被转换成platform_device内的struct resources资源;其他属性:platform_device->struct device dev->struct device_node *of_node直接指向设备树转换来的device_node

平台驱动platform_driver

platform_driver_register(struct platform_driver *drv)->driver_register(struct device_driver * drv)

匹配过程

先用设备树中的 compatible 属性和platform_driver中的driver中的 of_match_table 来匹配

再用 platform_driver 中的 id_table 中的 name 和 platform_device 中的 name来匹配

或者用platform_device中的name和 platform_driver 中的 driver 中的 name来匹配

 

 

标签:架构,paltfrom,总线,probe,driver,platform,bus,device,struct
来源: https://www.cnblogs.com/lzd626/p/15982693.html