Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BBB/BBG can't find ethernet phy sometimes #10

Closed
turmary opened this issue May 7, 2018 · 4 comments
Closed

BBB/BBG can't find ethernet phy sometimes #10

turmary opened this issue May 7, 2018 · 4 comments

Comments

@turmary
Copy link
Contributor

turmary commented May 7, 2018

I found BBB/BBG can't find ethernet phy sometimes
and the u-boot print 'Could not get PHY for cpsw: addr 0'.
There is a small posibility that the PHY(LAN8710A) enter RMII mode which will cause ethernet can't work without a power-on reset even in linux .
A bad power (USB power is bad than DC power) will increse the posibility.

So I want to enumerate 32 phy addresses to find the phy real address,
and power-on reset the board when it find the phy can't work,
I will commit a pull request later with above function.

@turmary
Copy link
Contributor Author

turmary commented May 7, 2018

Hi Robert,
Which branch should I commit, "v2018.03" or "v2018.05-rc1"?

@RobertCNelson
Copy link
Owner

later TI evm designs (am4x family) wire a gpio directly to the phy's reset line to accomplish this.

On the BBB family, the am3x's reset line is directly connected to the phy reset, so if you reset one you reset the other.

Regards,

@RobertCNelson
Copy link
Owner

Here is the linux patch we use to work-around this issue, well most of the time it works, just not 100%...

https://github.com/RobertCNelson/linux-dev/blob/master/patches/drivers/ti/cpsw/0001-cpsw-search-for-phy.patch

Regards,

@turmary
Copy link
Contributor Author

turmary commented May 8, 2018

OK Robert,
I understand the linux patch and the connection of am335x's reset and the phy reset.

Instead of software warm reset the phy/am335x, I issue a Power-On reset to the board through RTCSS/PMIC if the phy's interface mode is RMII(it should MII mode when it's work).
The RMII/MII mode could not be modified without a Power-On reset.

I think below patch could let the phy works 100% .

diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
+       /*
+        *  Power-on reset the board if phy don't work
+        */
+       if (!board_is_pb()
+          && (board_is_bone()
+             || (board_is_bone_lt() && !board_is_bone_lt_enhanced() && !board_is_m10a())
+             || board_is_idk()
+             || board_is_beaglelogic()
+             )
+       ) {
+
+               struct phy_device *phy;
+               const char *devname;
+               unsigned short v;
+               int r;
+
+               devname = miiphy_get_current_dev();
+               phy = mdio_phydev_for_ethname(devname);
+
+               if (phy != NULL && (phy->phy_id & 0xffff0) == 0x0007c0f0) {
+                       /* LAN8710 Special Modes */
+                       r = miiphy_read(devname, phy->addr, 18, &v);
+                       if (!r && (v & (0x1 << 14))) {
+                               printf("PHY: %s not in MII mode\n", phy->drv->name);
+
+                               /* for some boards can't sleep, delay is needed here */
+                               mdelay(1000);
+
+                               /* Power On reset the board through a RTC controlled PMIC sleep & wakeup.
+                                * Actually the board/PMIC will off then on
+                                */
+                               rtcss_pmic_sleep(2, 2);
+                               mdelay(2500);
+                       }
+               }
+       }

I tried apply the above patch on U-boot branch v2018.05-rc1, but this branch can't bootup still now.

Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants