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.

  • Resolved

AM3359: PRU Ethernet PHY configuration

Prodigy 160 points

Replies: 9

Views: 227

Part Number: AM3359

Hi everyone,

I'm working on a Product based on the am3359 using dual ethernet via prueth. Both PHYs are TI DP83822, and they recognized correct and are working just fine in Linux.

There is only one problem: I'd like to configure the PHY LED, which requieres me to configure two registers of the PHY.

Is there any way to access the registers from Linux, or how can i write to them?

Thanks in advance,

Dave

  • Hello Dave,

    1) What version of Linux are you using?

    2) What kind of MAC interface are you using? (e.g., MII, RMII)

    Regards,

    Nick

  • In reply to Nick Saulnier:

    Hello Nick,

    1. I'm using Yocto 2.7 with meta-ti layer and linux-ti-staging-4.19

    2. As i'm using dual PRU Ethernet, i'm limited to MII interface.

    Regards,

    Dave

  • In reply to DHardes:

    Hello Dave,

    I am sorry for the delayed response. I will have more information for you next week.

    Regards,

    Nick

  • In reply to Nick Saulnier:

    Hello Dave,

    You can access the PHY registers from uboot or from Linux.

    Uboot:
    use mii commands. I have not tried this myself, but here's a list from https://support.criticallink.com/redmine/boards/10/topics/1270 :
    MII commands 
    To access the Ethernet PHY use this commands: 
    Command Description 
    - mii device Lists available devices. 
    - mii device <device name> Set current device. 
    - mii read <addr > <reg> Reads register 'reg' from MII PHY 'addr'. 
    - mii write <addr > <reg> <data> Writes 'data' to register 'reg' at MII PHY 'addr'. 
    - mii dump <addr > <reg> Displays data of register 'reg' from MII PHY 'addr'.

    Linux:
    Our PRUETH Linux driver should support reads/writes to the PHY for AM335x, AM437x, AM57x. We will add that functionality to AM65x in the next SDK release.
    * Search the web for examples of ioctl using SIOCGMIIREG (read MII PHY register) and SIOCSMIIREG (write MII PHY register)
    * There are also non-TI tools for interacting with the PHY registers, for example https://github.com/wkz/phytool

    Regards,

    Nick

    Note: TI does not endorse any non-TI websites, tools, etc. These are just example sources from google searches.

  • In reply to Nick Saulnier:

    Hi Nick,

    I was not able to access the PHY registers via U-Boot, i think the necessary firmware hasn't been loaded to the PRU at this stage.

    On Linux, I've not been able to access the PHY registers by using either phytool, mii-tool or ethtool, and trying to access the registers directly via icoctl() didn't work either.

    The mentioned tools can put out a few basic informations like driver, device name and so on, but the necessary functions for register access/phy configuration are always outputting errors.

    As i've mentioned, the network access works just fine - so there is no hardware or software fault.

    At this stage i'm beginning to think that the PRUETH software doesn't support the register access, could this be the case?

    Regards,

    Dave

  • In reply to DHardes:

    Hello Dave,

    UBOOT

    You are right about the u-boot firmware. I would expect that method could work for AM65x (as of Processor SDK 6.0, if booting the Linux kernel over PRU Ethernet). But it would not work for am335x.

    LINUX

    Please check your PRU Ethernet driver for me at drivers/net/ethernet/ti/prueth.c

    In our Linux Processor SDK 6.0 release, I see

    static int emac_ndo_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
    {
            struct prueth_emac *emac = netdev_priv(ndev);
    
            if (!netif_running(ndev))
                    return -EINVAL;
    
            switch (cmd) {
            case SIOCSHWTSTAMP:
                    if (!PRUETH_HAS_PTP(emac->prueth))
                            return -ENOTSUPP;
    
                    return emac_hwtstamp_set(ndev, req);
            case SIOCGHWTSTAMP:
                    if (!PRUETH_HAS_PTP(emac->prueth))
                            return -ENOTSUPP;
    
                    return emac_hwtstamp_get(ndev, req);
            }
    
            return phy_mii_ioctl(emac->phydev, req, cmd);
    }
    ...
    static const struct net_device_ops emac_netdev_ops = {
    ...
            .ndo_do_ioctl = emac_ndo_ioctl,
    ...
    };

    That phy_mii_ioctl is necessary to pass the ioctl command down to the PHY driver. If your version of Linux does not have that line, please modify your driver to match our Linux Processor SDK code and try again.

    Regards,

    Nick

  • In reply to Nick Saulnier:

    Please note: linux-ti-staging-4.19 is associated with ti-linux-kernel. See my answer in the post PRU Ethernet firmware repository that explains the difference between ti-linux-kernel and processor-sdk-linux. On this forum, I can only support processor-sdk-linux.

    PRU Ethernet has many changes between ti-linux-kernel and processor-sdk-linux. So if you run into further issues, the help I can give might be limited.

    Regards,

    Nick

  • In reply to Nick Saulnier:

    Hi Nick,

    this solved my issue. While i do find it unfortunate that there are two kernel versions by TI, i am now able to create a workarround.

    Regards,

    Dave

  • In reply to DHardes:

    Glad to hear things are working for you Dave! Feel free to create a new post if you run into additional issues going forward.

    Regards,

    Nick

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.