PCI设备枚举流程
//0、pci子系统首先注册pci bus struct bus_type pci_bus_type = { .name = "pci", .match = pci_bus_match, .uevent = pci_uevent, .probe = pci_device_probe, .remove = pci_device_remove, .shutdown = pci_device_shutdown, .dev_groups = pci_dev_groups, .bus_groups = pci_bus_groups, .drv_groups = pci_drv_groups, .pm = PCI_PM_OPS_PTR, .num_vf = pci_bus_num_vf, }; EXPORT_SYMBOL(pci_bus_type); static int __init pci_driver_init(void) { return bus_register(&pci_bus_type); } postcore_initcall(pci_driver_init);/* 将初始化函数放到内核代码特殊段,内核启动将会自动调用初始化函数 */ /* 设备的枚举流程和设备的驱动的调用过程 */ //1、pci控制器 设备树节点将会配转换成platform device pcie@3400000 { compatible = "fsl,ls1021a-pcie", "snps,dw-pcie"; .... } //2、pci控制器匹配platform driver static const struct of_device_id ls_pcie_of_match[] = { { .compatible = "fsl,ls1021a-pcie", .data = &ls1021_drvdata }, .. } static struct platform_driver ls_pcie_driver = { .driver = { .name = "layerscape-pcie", .of_match_table = ls_pcie_of_match, .suppress_bind_attrs = true, }, }; builtin_platform_driver_probe(ls_pcie_driver, ls_pcie_probe); //3、执行pci控制器驱动函数ls_pcie_probe函数将被调用,直到pci_bus_type.pci_device_probe被调用 ls_add_pcie_port pci_bus_add_devices pci_bus_add_device device_attach __device_attach __device_attach_driver driver_probe_device really_probe dev->bus->probe//将调用pci_bus_type.pci_device_probe //4、枚举pci设备调用设备驱动 pci_device_probe __pci_device_probe pci_call_probe local_pci_probe pci_drv->probe//设备的驱动的probe将被调用。
网页标题:PCI设备枚举流程
转载来源:http://hbruida.cn/article/ghjphh.html