bm_dwmac_probe
-->stmmac_dvr_probe
-->stmmac_mdio_register
-->申请mii_bus,为bus的name read (stmmac_mdio_read)
-->__mdiobus_register 遍历32个phy addr,调用 mdiobus_scan
-->mdiobus_scan 扫码miibus,找到MDIO device
-->get_phy_device
-->get_phy_id 读取reg获取 phy_id
-->midobus_read
-->stmmac_mdio_read
-->判断phy_id只要bit28-0不全为1,就认为 phy_id 正常 0x1fff ffff
-->phy_device_create 为struct phy_device 申请内存,设置phy_device->mdio.dev.bus为mdio_bus_type,mdio_device->bus_match赋值为 phy_bus_match ,把 get_phy_id 获取的 phy_id 赋值给phy_device->phy_id (重要)
-->phy_device_register
-->device_add
-->bus_probe_device 遍历mdio_bus_type的bus上的driver为新设备( phy_device )probe driver
-->device_initial_probe
-->__device_attach
-->bus_for_each_drv 遍历mdio_bus_type的bus上的driver(bus->p->klist_drivers),回调__device_attach_driver
-->__device_attach_driver
-->driver_match_device(内联函数)
-->drv->bus->match (mdio_bus_match) (调用 mdio_driver_register 注册driver时,会把mido_driver->driver.bus赋值为 mdio_bus_type)
-->mido_device->bus_match(phy_bus_match) (调用 phy_device_create 时,mdio_device->bus_match赋值为 phy_bus_match)
phy_bus_match 把从reg获取的phy_device->phy_id 和 phy_drivers_register 初始化的phy_driver->phy_id 比较,匹配就返回1,匹配不上,一步步返回0
-->判断 driver_match_device 的返回值,只要小于等于0,意味着没有match成功,不会往下走到 driver_probe_device
-->driver_probe_device 能走到这里,说明前面的 driver_match_device 是把driver和device匹配上了,开始绑定对应的driver和device
-->really_probe
-->drv->probe(phy_probe)(调用 phy_driver_register 注册phydriver时会把phy_driver->mdiodrv.driver.probe赋值为phy_probe),这里最关键的就是把phy_driver赋值给phy_device->drv(也就是说走到这一步,phy_device->drv就不为NULL了)
-->phy_attach_info
-->phy_attached_print 使用phy_device->drv 打印,只要没有走到 phy_probe 这个函数,phy_device->drv就是NULL的
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载