MDIO总线相关

    xiaoxiao2021-03-25  5

    ##这里主要是driver端

    在drivers/net/phy里面针对某一品牌的网络交换设备有一个文件 例如 smsc ,有一个smsc.c

    该品牌有多个设备.每个设备对应一个结构体,因此组成了一个结构体数组

    数组元素类型 : struct phy_driver

    数组元素举例

    { .phy_id = 0x0007c0f0, /* OUI=0x00800f, Model#=0x0f */ .phy_id_mask = 0xfffffff0, .name = "SMSC LAN8710/LAN8720", .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause | SUPPORTED_Asym_Pause), .flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG, /* basic functions */ .config_aneg = genphy_config_aneg, .read_status = lan87xx_read_status, .config_init = smsc_phy_config_init, /* IRQ related */ .ack_interrupt = smsc_phy_ack_interrupt, .config_intr = smsc_phy_config_intr, .suspend = genphy_suspend, .resume = genphy_resume, .driver = { .owner = THIS_MODULE, } }

    针对数组中的每个元素都会注册一次 每个设备的注册流程

    1/填充数组元素中的driver结构体(类型struct device_driver)

    new_driver->driver.name = new_driver->name; new_driver->driver.bus = &mdio_bus_type; new_driver->driver.probe = phy_probe; new_driver->driver.remove = phy_remove;

    参数说明

    1/

    new_driver->name ="SMSC LAN911x Internal PHY";

    2/

    struct bus_type mdio_bus_type = { .name = "mdio_bus", .match = mdio_bus_match, .pm = MDIO_BUS_PM_OPS, .dev_attrs = mdio_dev_attrs, };

    3/ phy_probe 一品牌的设备共用一个 4/ phy_remove 一品牌的设备公用一个


    2/注册 driver_register(&new_driver->driver);


    配置内核

    Device Drivers ---> [*] Network device support ---> <*> PHY Device support and infrastructure ---> < > Drivers for SMSC PHYs

    注意,最后匹配的并不是 phy_driver 和 phy_device 而是phy_driver中的driver和phy_device匹配

    转载请注明原文地址: https://ju.6miu.com/read-200181.html

    最新回复(0)