UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor asafbit
Visitor
6,363 Views
Registered: ‎07-14-2016

MDC/MDIO bus on petalinux - how to use

zynq will have mdio bus to configure 3 PHY modules, 1 ethernet switch and 1 PCIe switch.

2 PHY - 88E1512 probably wont need any configuration change - will work exactly as on EVB.

1 PHY - 88E1512 will have to be configured as RGMII to SGMII protocol converter.

and i need to have the ability to configure both swithces via MDIO bus.

can please someone direct me to any documentation on how to work with mdio-bus module?

0 Kudos
15 Replies
Scholar trenz-al
Scholar
6,352 Views
Registered: ‎11-09-2013

Re: MDC/MDIO bus on petalinux - how to use

you can change the phy setttings in devicetree.

0 Kudos
Highlighted
Visitor asafbit
Visitor
6,306 Views
Registered: ‎07-14-2016

Re: MDC/MDIO bus on petalinux - how to use

thank you for replying.

i need to provide the ability to change configuration (via configuration menu which is written by me) at run-time -  if its possible.

Scholar trenz-al
Scholar
6,301 Views
Registered: ‎11-09-2013

Re: MDC/MDIO bus on petalinux - how to use

yes it is possible. there are application that do this, look at the source code and modify to your needs.

0 Kudos
Visitor asafbit
Visitor
6,031 Views
Registered: ‎07-14-2016

Re: MDC/MDIO bus on petalinux - how to use

can you tell which application for example?

Observer eliezer
Observer
344 Views
Registered: ‎03-21-2019

Re: MDC/MDIO bus on petalinux - how to use

I would also like an answer to this question

0 Kudos
Moderator
Moderator
329 Views
Registered: ‎09-12-2007

Re: MDC/MDIO bus on petalinux - how to use

You can use phytool (Can be enabled in the petalinux-config -c rootfs)

Or  you can manually access the MDIO via the phy management register. 0xff0e0034 (assuming using GEM3 on zynq ultrascale)

0 Kudos
Observer eliezer
Observer
325 Views
Registered: ‎03-21-2019

Re: MDC/MDIO bus on petalinux - how to use

I see no results when I search for "phytool" in the rootfs config (or the kernel config, for that matter.)

 

Using the Phy management register sounds promising. I've found the page that describes it, but the instructions on that page require the link to be down. The use case I am interested in is run-time configuration of the Phy, without disrupting the connection.

0 Kudos
Moderator
Moderator
318 Views
Registered: ‎09-12-2007

Re: MDC/MDIO bus on petalinux - how to use

To add phytool:

project-spec\meta-user\recipes-core\images\petalinux-image-full.bbappend:

#Note: Mention Each package in individual line

#      cascaded representation with line breaks are not valid in this file.

IMAGE_INSTALL_append = " peekpoke"

IMAGE_INSTALL_append = " gpio-demo"

IMAGE_INSTALL_append = " phytool"

Then

petalinux-config -c rootfs

phytool.png

To test:

test.png

Accessing directly:

You can read the phy registers while the link is up too. Not sure why I said that in the wiki

If you where to create your own app here, this could be the best way. The wiki shows how to do a read/write.

You can mmap this. 

Observer eliezer
Observer
308 Views
Registered: ‎03-21-2019

Re: MDC/MDIO bus on petalinux - how to use

To mmap the MDIO, I would want to map the address at 0xff0e0034, and then do the read/writes the same way as shown on the wiki?

0 Kudos
Moderator
Moderator
302 Views
Registered: ‎09-12-2007

Re: MDC/MDIO bus on petalinux - how to use

Yep. Pretty much.

If I have some time I'll add a simple app to the wiki.

 

I was doing this in python today

Observer eliezer
Observer
292 Views
Registered: ‎03-21-2019

Re: MDC/MDIO bus on petalinux - how to use

Thanks, I'll let you know how it goes.

0 Kudos
Observer eliezer
Observer
261 Views
Registered: ‎03-21-2019

Re: MDC/MDIO bus on petalinux - how to use

Update:

Writing to the base register (the first step of the instructions on the wiki) results in networking of my machine failing. I assume I am turning off the Phy recieve and transmit bits when I do this, thus killing the network connection:

devmem 0xff0e0000 32 0x00000010

I can query the value safely, and I see 0x10001C there. The bit already seems to be set correctly, so I am skipping this step.

The next instruction line,

devmem 0xff0e0034 32 0x66020000

claims that 0110011000000100000000000000000 = 66020000hex, which it does not. I assume there is a typo here somewhere, but I do not know which side to trust. I can query 0xff0e0034, and I see the value as 0x661201e1.

0 Kudos
Observer eliezer
Observer
194 Views
Registered: ‎03-21-2019

Re: MDC/MDIO bus on petalinux - how to use

For anyone else wondering about this, follow the phy_management register description in the linked wiki page.

This is how you construct commands:

Initial: 0 (always)
Clause (clause 22): 1 (0 for clause 45)
Operation (read 22): 10 (write bits will depend on clause)
phy C = 01100 (5 bits)
Register 0x1 = 00001 (5 bits)
Start of data: 10 (always)
Value (none, read): = 0000000000000000

Altogether:
                              01100110000001100000000000000000 = 0x66060000
Clause 45 version: 00100110000001100000000000000000 = 0x26060000

Then read the phy management register (0xff0e0034) and check bit 2 to see the result.
0 means no link, 1 means active link.

 

I was able to read/write these values directly using an mmap. I never got results from my read commands, but I could write just fine.

0 Kudos
Moderator
Moderator
173 Views
Registered: ‎09-12-2007

Re: MDC/MDIO bus on petalinux - how to use

can you mark this as solved if the issue is solved?

0 Kudos
Observer eliezer
Observer
170 Views
Registered: ‎03-21-2019

Re: MDC/MDIO bus on petalinux - how to use

Sorry, I'm not OP.

0 Kudos