微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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将被调用

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐