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.

TDA4VM: Reading the mdio register of external phy connected to mdio bus in userspace in linux

Part Number: TDA4VM

Hi,

We have our external phys connected the mdio bus. Our external switch is connected to the internal CPSW02 with mac-mac connection. The phys are listed during the boot in dmesg with the following information. 

[ 4.091099] libphy: 46000f00.mdio: probed
[ 4.100218] davinci_mdio 46000f00.mdio: phy[25]: device 46000f00.mdio:19, driver unknown
[ 4.114060] davinci_mdio 46000f00.mdio: phy[26]: device 46000f00.mdio:1a, driver unknown
[ 4.127798] davinci_mdio 46000f00.mdio: phy[27]: device 46000f00.mdio:1b, driver unknown
[ 4.140291] davinci_mdio 46000f00.mdio: phy[28]: device 46000f00.mdio:1c, driver unknown
[ 4.140293] davinci_mdio 46000f00.mdio: phy[29]: device 46000f00.mdio:1d, driver unknown
[ 4.152967] davinci_mdio 46000f00.mdio: phy[30]: device 46000f00.mdio:1e, driver unknown

They are also readable in uboot using mii tool:

=> mii info

PHY 0x19: OUI = 0x06EC, Model = 0x01, Rev = 0x01, 10baseT, HDX
PHY 0x1A: OUI = 0x06EC, Model = 0x01, Rev = 0x01, 10baseT, HDX
PHY 0x1B: OUI = 0x06EC, Model = 0x01, Rev = 0x01, 10baseT, HDX
PHY 0x1C: OUI = 0x06EC, Model = 0x01, Rev = 0x01, 10baseT, HDX
PHY 0x1D: OUI = 0x06EC, Model = 0x01, Rev = 0x01, 10baseT, HDX
PHY 0x1E: OUI = 0x06EC, Model = 0x01, Rev = 0x01, 10baseT, HDX
=> mii dump 0x19
0. (0000) -- PHY control register --
(8000:0000) 0.15 = 0 reset
(4000:0000) 0.14 = 0 loopback
(2040:0000) 0. 6,13 = b00 speed selection = 10 Mbps
(1000:0000) 0.12 = 0 A/N enable
(0800:0000) 0.11 = 0 power-down
(0400:0000) 0.10 = 0 isolate
(0200:0000) 0. 9 = 0 restart A/N
(0100:0000) 0. 8 = 0 duplex = half
(0080:0000) 0. 7 = 0 collision test enable
(003f:0000) 0. 5- 0 = 0 (reserved)

is there a way to read the mdio registers from these phys in Linux user space?

Do I need a driver here or I need to have the configuration done correctly in the device tree?

Any help would be appreciated.

Thanks,

Pouyan

  • Pouyan,

    You can dump registers using ethtool, but for read/write accesses to individual registers you can refer to mdio-tool. Please see https://github.com/PieVo/mdio-tool for reference.

     (see also similar post at https://e2e.ti.com/support/processors/f/791/t/920554 )

    Best regards,

    Dave

  • Dear Dave, 

    Thanks for the reply.

    the solution is only working, when the phys are configured as Ethernet devices in the Linux. But in my case they are connected directly to the external switch and are not used by Linux. So I need a simple way lets say with ioctl to to write and read to these phys. So do I need a driver here? And when yes do we have any example in the TI Linux SDK for this. 

    Best Regards,

    Pouyan

  • Pouyan,

    I'm not sure of the limitations of this tool. Are you directly controlling the PHYs through MDIO separately from the switch driver, or does the switch driver also support MDIO and has some utilities? Depending on the switch, it may support DSA - https://www.kernel.org/doc/html/latest/networking/dsa/dsa.html

    Best regards,

    Dave

  • Hi Dave,

    thanks for the answer. The phys are controlled by the external switch firmware. The switch also has mdio interface which let us read and write configuration to the phy from outside. This switch is connected with mac-mac connection to the TDA4VM internal 2 port switch. There is no switch driver available at the moment, and there is no need for this. We only want to gain access to the phys using mdio. As written in my first post. The are even found by davinci-mdio-bus. But we get driver unknown error. So the question I have at the moment is, where is this driver checked or where should I put my driver to gain access to the register without having them configured as eth devices in linux. What kind of driver do I need here to have a simple ioctl access to the mdio devices?

    PS: The first image is the switch side. The second image is TDA4VM side.

    Regards,

    Pouyan

  • Pouyan,

    Another tool you may try is https://github.com/wkz/phytool

    As this is not specific to the TI processor or SDK I would recommend to discuss in the public mailing list <netdev@vger.kernel.org> or other public resources for tips and tools.

    Best regards,

    Dave