本文主要是介绍MDIO总线相关_4,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
//mdio
在drivers/net/ethernet/hieth-gmac/下面有一个文件higmac.c里面实现了一个platform框架,并且创建了一个杂项设备.ret = platform_device_register(&higmac_platform_device);if (ret) {pr_err("register netdevice device failed!");goto _error_register_device;}ret = platform_driver_register(&higmac_dev_driver);if (ret) {pr_err("register netdevice driver failed!");goto _error_register_driver;}ret = misc_register(&gmac_dev);if (ret) {pr_err("register misc device failed!");goto _error_register_misc_dev;} elsemiscdev_registered = 1;
//platform device端
static struct platform_device higmac_platform_device = {.name = HIGMAC_DRIVER_NAME,.id = 0,.dev = {.dma_mask = &higmac_dmamask,.coherent_dma_mask = DMA_BIT_MASK(32),.release = higmac_platform_dev_release,},.num_resources = ARRAY_SIZE(higmac_resources),.resource = higmac_resources,
};
//platform driver端
static struct platform_driver higmac_dev_driver = {.probe = higmac_dev_probe,//init.remove = higmac_dev_remove,//remove.suspend = higmac_dev_suspend,//pause.resume = higmac_dev_resume,//reset.driver = {.owner = THIS_MODULE,.name = HIGMAC_DRIVER_NAME,},
};
//杂项设备
static struct miscdevice gmac_dev = {MISC_DYNAMIC_MINOR,"gmac",&gmac_fops
};
看driver 端的probe函数,驱动一经插入,就开始执行
/*1. init glb adapter*//*2. 填充id netdev 和 higmac_board_info*//*3. init hw controller*//*4. phy reset*//*5. fwd_setup*//*6. init hw desc queue*//*7. register mdio bus*//*8. connect phy*//*9. request irq*//*10. register netdevice*/
这篇关于MDIO总线相关_4的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!