Linux Ethernet PHY drivers

On this side of the IC with the FPGA to verify the MAC / PHY, based linux 3.6.4, summary of the code here.

phy initialization sequence
first step
phy_init
  mdio_bus_init
    bus_register (& mdio_bus_type); // AutoProbe
  phy_driver_register (& genphy_driver);

The second step, specific phy drive initialization (in Example icplus)
icplus_init
  phy_drivers_register (icplus_driver, ARRAY_SIZE (icplus_driver));
    phy_driver_register
      new_driver-> driver.bus = & mdio_bus_type; // also mdio_bus_type
      new_driver-> driver.probe = phy_probe;
      new_driver-> driver.remove = phy_remove;
      driver_register
        bus_add_driver
          driver_attach // did not run the following as the first registration of a driver, not the device match, only examples
            __driver_attach
              driver_match_device
                Drv-> BUS-> // match is mdio_bus_type inside mdio_bus_match

A third step, the network card driver
mt_eth_init
  platform_driver_register (& mt_eth_driver);
    mt_eth_drv_probe
      mt_eth_mii_init
        mdiobus_register
          device_register
            device_add
              bus_add_device
              bus_probe_device
                device_attach
                  __device_attach
                    driver_match_device
                      Drv-> BUS-> // match is mdio_bus_type inside mdio_bus_match
                    driver_probe_device
                      really_probe
                        the dev-> BUS-> // Probe i.e. phy_probe, the state at this time is PHY_READY
                          phydev-> drv-> probe // If so, then the probe phy specific calls, such as icplus of mdiobus_scan
            get_phy_device
              get_phy_id
              phy_device_create // PHY_DOWN state
          mdiobus_scan
            phy_device_register
              device_register // and then the above process as the
        mt_eth_mii_probe // same level and mdiobus_register , the call mt_eth_mii_init
          phy_connect
            bus_find_device_by_name
            phy_connect_direct
              phy_attach_direct // state at this time is PHY_READY
                phy_init_hw
                  phydev-> Drv-> config_init (phydev); // ICPLUS embodied in
            phy_start_machine
              Scheduling delayed_work, in fact, phy_state_machine
                mt_eth_adjust_link

Add mdio_bus_match, will find out is to look at ((phydrv-> phy_id & phydrv-> phy_id_mask) == (phydev-> phy_id & phydrv-> phy_id_mask)) or not.

Published 407 original articles · won praise 150 · views 380 000 +

Guess you like

Origin blog.csdn.net/ds1130071727/article/details/102626067