cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
asafbit
Visitor
Visitor
7,674 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
trenz-al
Scholar
Scholar
7,663 Views
Registered: ‎11-09-2013

you can change the phy setttings in devicetree.

0 Kudos
asafbit
Visitor
Visitor
7,617 Views
Registered: ‎07-14-2016

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.

trenz-al
Scholar
Scholar
7,612 Views
Registered: ‎11-09-2013

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

0 Kudos
asafbit
Visitor
Visitor
7,342 Views
Registered: ‎07-14-2016

can you tell which application for example?

eliezer
Explorer
Explorer
1,655 Views
Registered: ‎03-21-2019

I would also like an answer to this question

0 Kudos
stephenm
Moderator
Moderator
1,640 Views
Registered: ‎09-12-2007

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
eliezer
Explorer
Explorer
1,636 Views
Registered: ‎03-21-2019

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
stephenm
Moderator
Moderator
1,629 Views
Registered: ‎09-12-2007

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. 

eliezer
Explorer
Explorer
1,619 Views
Registered: ‎03-21-2019

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
stephenm
Moderator
Moderator
1,613 Views
Registered: ‎09-12-2007

Yep. Pretty much.

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

 

I was doing this in python today

eliezer
Explorer
Explorer
1,603 Views
Registered: ‎03-21-2019

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

0 Kudos
eliezer
Explorer
Explorer
1,572 Views
Registered: ‎03-21-2019

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
eliezer
Explorer
Explorer
1,505 Views
Registered: ‎03-21-2019

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
stephenm
Moderator
Moderator
1,484 Views
Registered: ‎09-12-2007

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

0 Kudos
eliezer
Explorer
Explorer
1,481 Views
Registered: ‎03-21-2019

Sorry, I'm not OP.

0 Kudos