Skip to content

Commit d1e993f

Browse files
committed
stm32/eth_phy: Add support for RTL8211 inititialization.
This gets the status indicator working on the RTL8211. Signed-off-by: Damien George <[email protected]>
1 parent 0acac07 commit d1e993f

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

ports/stm32/eth.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ int eth_init(eth_t *self, int mac_idx, uint32_t phy_addr, int phy_type) {
219219
} else if (phy_type == ETH_PHY_LAN8720 || phy_type == ETH_PHY_LAN8742) {
220220
self->phy_get_link_status = eth_phy_lan87xx_get_link_status;
221221
} else if (phy_type == ETH_PHY_RTL8211) {
222+
self->phy_init = eth_phy_rtl8211_init;
222223
self->phy_get_link_status = eth_phy_rtl8211_get_link_status;
223224
} else {
224225
return -1;

ports/stm32/eth_phy.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
#define PHY_RTL8211_PHYSR_SPEED_Pos (4)
4848
#define PHY_RTL8211_PHYSR_SPEED_Msk (3 << PHY_RTL8211_PHYSR_SPEED_Pos)
4949
#define PHY_RTL8211_PHYSR_DUPLEX_Msk (0x0008)
50+
#define PHY_RTL8211_LCR_PAGE (0xd04)
51+
#define PHY_RTL8211_LCR_ADDR (0x10)
5052

5153
void eth_phy_generic_init(uint32_t phy_addr) {
5254
// Reset the PHY.
@@ -81,6 +83,16 @@ int16_t eth_phy_dp838xx_get_link_status(uint32_t phy_addr) {
8183
return scsr;
8284
}
8385

86+
void eth_phy_rtl8211_init(uint32_t phy_addr) {
87+
// Perform generic PHY initialization.
88+
eth_phy_generic_init(phy_addr);
89+
90+
// Configure LED0 output to show 10/100/1000 link speed, and activity.
91+
eth_phy_write(phy_addr, PHY_RTL8211_PAGSR_ADDR, PHY_RTL8211_LCR_PAGE);
92+
eth_phy_write(phy_addr, PHY_RTL8211_LCR_ADDR, 0x001b);
93+
eth_phy_write(phy_addr, PHY_RTL8211_PAGSR_ADDR, PHY_RTL8211_DEFAULT_PAGE);
94+
}
95+
8496
int16_t eth_phy_rtl8211_get_link_status(uint32_t phy_addr) {
8597
// Get the link mode & speed
8698
eth_phy_write(phy_addr, PHY_RTL8211_PAGSR_ADDR, PHY_RTL8211_PHYSR_PAGE);

ports/stm32/eth_phy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ void eth_phy_write(uint32_t phy_addr, uint32_t reg, uint32_t val);
6464
void eth_phy_generic_init(uint32_t phy_addr);
6565
int16_t eth_phy_lan87xx_get_link_status(uint32_t phy_addr);
6666
int16_t eth_phy_dp838xx_get_link_status(uint32_t phy_addr);
67+
void eth_phy_rtl8211_init(uint32_t phy_addr);
6768
int16_t eth_phy_rtl8211_get_link_status(uint32_t phy_addr);
6869

6970
#endif

0 commit comments

Comments
 (0)