Skip to content

Commit

Permalink
arm: emacps: lwip: Added Realtek RTL8211F PHY support
Browse files Browse the repository at this point in the history
Due to obsolescence of the RTL8211E, support for RTL8211F is desired.
The RTL8211F is already supported by u-boot and kernel starting 2016.1.

Signed-off-by: Elod Gyorgy <elod.gyorgy@digilent.ro>
  • Loading branch information
elodg committed Oct 13, 2021
1 parent 36d6a62 commit 037af98
Showing 1 changed file with 57 additions and 11 deletions.
Expand Up @@ -125,6 +125,8 @@
#define PHY_REALTEK_IDENTIFIER 0x001c
#define PHY_XILINX_PCS_PMA_ID1 0x0174
#define PHY_XILINX_PCS_PMA_ID2 0x0C00
#define PHY_REALTEK_RTL8211E 0xC915
#define PHY_REALTEK_RTL8211F 0xC916

#define XEMACPS_GMII2RGMII_SPEED1000_FD 0x140
#define XEMACPS_GMII2RGMII_SPEED100_FD 0x2100
Expand All @@ -139,6 +141,15 @@
#define PHY_TI_CR 0x10
#define PHY_TI_CFG4 0x31

#define RTL8211F_PAGSR (0x1f)
#define RTL8211F_PHYSR (0x1a)
#define RTL8211F_PHYSR_PAGE (0xa43)
#define RTL8211F_PHYSR_LINK_MASK (0x0004)
#define RTL8211F_PHYSR_SPEED_MASK (0x0030)
#define RTL8211F_PHYSR_1000 (0x0020)
#define RTL8211F_PHYSR_100 (0x0010)
#define RTL8211F_PHYSR_10 (0x0000)

#define PHY_REGCR_ADDR 0x001F
#define PHY_REGCR_DATA 0x401F
#define PHY_TI_CRVAL 0x5048
Expand Down Expand Up @@ -611,6 +622,7 @@ static u32_t get_Realtek_phy_speed(XEmacPs *xemacpsp, u32_t phy_addr)
u16_t status_speed;
u32_t timeout_counter = 0;
u32_t temp_speed;
u16_t phy_identity2 = 0;

xil_printf("Start PHY autonegotiation \r\n");

Expand Down Expand Up @@ -660,19 +672,53 @@ static u32_t get_Realtek_phy_speed(XEmacPs *xemacpsp, u32_t phy_addr)
}
xil_printf("autonegotiation complete \r\n");

XEmacPs_PhyRead(xemacpsp, phy_addr,IEEE_SPECIFIC_STATUS_REG,
&status_speed);
if (status_speed & 0x400) {
temp_speed = status_speed & IEEE_SPEED_MASK;
//Identify PHY model
XEmacPs_PhyRead(xemacpsp, phy_addr, PHY_IDENTIFIER_2_REG,
&phy_identity2);

if (temp_speed == IEEE_SPEED_1000)
return 1000;
else if(temp_speed == IEEE_SPEED_100)
return 100;
else
return 10;
switch (phy_identity2)
{
case PHY_REALTEK_RTL8211F:
{
xil_printf("detected RTL8211F \r\n");
//Switch to page 0xA43
XEmacPs_PhyWrite(xemacpsp, phy_addr, RTL8211F_PAGSR, RTL8211F_PHYSR_PAGE);
XEmacPs_PhyRead(xemacpsp, phy_addr, RTL8211F_PHYSR, &status_speed);
//Switch back to default page
XEmacPs_PhyWrite(xemacpsp, phy_addr, RTL8211F_PAGSR, 0);
//If there is link
if (status_speed & RTL8211F_PHYSR_LINK_MASK) {
temp_speed = status_speed & RTL8211F_PHYSR_SPEED_MASK;

if (temp_speed == RTL8211F_PHYSR_1000)
return 1000;
else if(temp_speed == RTL8211F_PHYSR_100)
return 100;
else
return 10;
}
break;
}
case PHY_REALTEK_RTL8211E:
xil_printf("detected RTL8211E \r\n");
//RTL8211E fall-back to default Realtek behaviour
default:
{
XEmacPs_PhyRead(xemacpsp, phy_addr,IEEE_SPECIFIC_STATUS_REG,
&status_speed);
if (status_speed & 0x400) {
temp_speed = status_speed & IEEE_SPEED_MASK;

if (temp_speed == IEEE_SPEED_1000)
return 1000;
else if(temp_speed == IEEE_SPEED_100)
return 100;
else
return 10;
}
break;
}
}

return XST_FAILURE;
}

Expand Down

1 comment on commit 037af98

@Lance-Manly
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have Updated the xemacpsif_physpeed.c with all the changes in this post. I still get a "phy set-up error" "phy setup failure init_emacps" message. I am using a Digilent PNQ Z1 rev F. on VItis 2021.1 on windows.
Has any one been successful in getting this library update to work ? If so did you have to do anything else?

Please sign in to comment.