[PATCH] net: phy: realtek: Add support for LED configuration

Artur Rojek artur at conclusive.pl
Thu Nov 30 21:39:19 CET 2023


From: Jakub Klama <jakub at conclusive.pl>

Introduce an ability to configure LED and Fiber LEDs found in RTL8211F
PHYs. This is achieved through two optional Device Tree properties:
* rtl,lcr  for LED control
* rtl,flcr for Fiber LED control

Signed-off-by: Jakub Klama <jakub at conclusive.pl>
Signed-off-by: Artur Rojek <artur at conclusive.pl>
---
 drivers/net/phy/realtek.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 396cac76d6..d078f41bee 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -59,6 +59,7 @@
 #define MIIM_RTL8211F_TX_DELAY		0x100
 #define MIIM_RTL8211F_RX_DELAY		0x8
 #define MIIM_RTL8211F_LCR		0x10
+#define MIIM_RTL8211F_FLCR		0x12
 
 #define RTL8201F_RMSR			0x10
 
@@ -220,6 +221,8 @@ default_delay:
 
 static int rtl8211f_config(struct phy_device *phydev)
 {
+	ofnode node = phy_get_ofnode(phydev);
+	u32 lcr, flcr;
 	u16 reg;
 
 	if (phydev->flags & PHY_RTL8211F_FORCE_EEE_RXC_ON) {
@@ -254,14 +257,17 @@ static int rtl8211f_config(struct phy_device *phydev)
 		reg &= ~MIIM_RTL8211F_RX_DELAY;
 	phy_write(phydev, MDIO_DEVAD_NONE, 0x15, reg);
 
-	/* restore to default page 0 */
-	phy_write(phydev, MDIO_DEVAD_NONE,
-		  MIIM_RTL8211F_PAGE_SELECT, 0x0);
-
-	/* Set green LED for Link, yellow LED for Active */
 	phy_write(phydev, MDIO_DEVAD_NONE,
 		  MIIM_RTL8211F_PAGE_SELECT, 0xd04);
-	phy_write(phydev, MDIO_DEVAD_NONE, 0x10, 0x617f);
+
+	if (ofnode_valid(node) && !ofnode_read_u32(node, "rtl,lcr", &lcr))
+		phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_LCR, lcr);
+	else /* Set green LED for Link, yellow LED for Active */
+		phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_LCR, 0x617f);
+
+	if (ofnode_valid(node) && !ofnode_read_u32(node, "rtl,flcr", &flcr))
+		phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_FLCR, flcr);
+
 	phy_write(phydev, MDIO_DEVAD_NONE,
 		  MIIM_RTL8211F_PAGE_SELECT, 0x0);
 
-- 
2.34.1



More information about the U-Boot mailing list