PCI device enumeration process
/ / 0, the pci subsystem first registers pci busstruct 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) / * put the initialization function into a special section of the kernel code, and the kernel startup will automatically call the initialization function * / / * the enumeration flow of the device and the calling process of the device driver * / / 1. The pci controller device tree node will be converted to platform device pcie@3400000 {compatible = "fsl,ls1021a-pcie", "snps,dw-pcie". .... } / / 2, pci controller matches platform driverstatic const struct of_device_id ls_pcie_of_match [] = {{.controllers = "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. Execute the pci controller driver function ls_pcie_probe function will be called Until pci_bus_type.pci_device_probe is called 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// will call pci_bus_type.pci_device_probe//4, Enumerate the probe of the pci device calling device driver pci_device_probe _ _ pci_device_probe pci_call_probe local_pci_probe pci_drv- > the driver of the probe// device will be called.