This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335x eMAC phy configuration in the linux device tree

Hi all,

   My customer wants to configure their own eMAC phy on linux through the device tree, but not found where to configure it?

   I read some code, found that the dts file, just configure the phy id, but not point out the phy name in the dts, so do you know where to configure it?

thanks!

Yaoming

  • I checked the old version code (ezsdk 6.0), found that in the baord file, there is the Macro AM335X_EVM_PHY_ID to identify the PHY ID, but there is no this kind of identification to link the cpsw to the phy.

  • Hi Yaoming,

    This has been moved inside the following driver:

    <linux_dir>/drivers/net/phy/at803x.c

    {
        /* ATHEROS 8031 */
        .phy_id        = 0x004dd074,
        .name        = "Atheros 8031 ethernet",
        .phy_id_mask    = 0xffffffef,
        .config_init    = at803x_config_init,
        .set_wol    = at803x_set_wol,
        .get_wol    = at803x_get_wol,
        .features    = PHY_GBIT_FEATURES,
        .flags        = PHY_HAS_INTERRUPT,
        .config_aneg    = &genphy_config_aneg,
        .read_status    = &genphy_read_status,
        .driver        = {
            .owner = THIS_MODULE,
        },
    }

    Best regards,
    Miroslav

  • Hi  Miroslav,

       Thanks for your quick response!

        I found this code as well, but i don't understand which code is used to choose the 8031 here, as there are 3 phys are registered to the kernel. Could you please give a hint here?

       Thanks!

        Yaoming

  • Yaoming, all of the drivers are registered:

    static int __init atheros_init(void)
    {
        return phy_drivers_register(at803x_driver,
                        ARRAY_SIZE(at803x_driver));
    }

    You can verify this by enabling the debug messages inside <linux_dir>/drivers/net/phy/phy_device.c:

    int phy_driver_register(struct phy_driver *new_driver)
    {
        int retval;

        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;

        retval = driver_register(&new_driver->driver);

        if (retval) {
            pr_err("%s: Error %d in registering driver\n",
                   new_driver->name, retval);

            return retval;
        }

        pr_debug("%s: Registered new driver\n", new_driver->name);

        return 0;
    }

    The result is:

    [    1.326797] libphy: Atheros 8035 ethernet: Registered new driver
    [    1.340385] libphy: Atheros 8030 ethernet: Registered new driver
    [    1.353994] libphy: Atheros 8031 ethernet: Registered new driver

    Best regards,
    Miroslav

  • My question is where in the Kernel to do the configuration to choose the at8031 as the phy on the board?

  • This happens during the bus initialization. The PHY's UID is read from its registers, then compared to the phy_id of the registered drivers.

    Please read the kernel documentation:

    http://free-electrons.com/kerneldoc/latest/networking/phy.txt

    Best regards,
    Miroslav