mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 15:03:52 +08:00
net: phy: realtek: support for TRIGGER_NETDEV_LINK on RTL8211E and RTL8211F
This patch adds support for the TRIGGER_NETDEV_LINK trigger. It activates the LED when a link is established, regardless of the speed. Tested on Orange Pi PC2 with RTL8211E PHY. Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://patch.msgid.link/20250825211059.143231-1-olek2@wp.pl Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
2420411643
commit
f63f21e82e
@@ -756,7 +756,8 @@ static int rtl8211f_resume(struct phy_device *phydev)
|
||||
static int rtl8211x_led_hw_is_supported(struct phy_device *phydev, u8 index,
|
||||
unsigned long rules)
|
||||
{
|
||||
const unsigned long mask = BIT(TRIGGER_NETDEV_LINK_10) |
|
||||
const unsigned long mask = BIT(TRIGGER_NETDEV_LINK) |
|
||||
BIT(TRIGGER_NETDEV_LINK_10) |
|
||||
BIT(TRIGGER_NETDEV_LINK_100) |
|
||||
BIT(TRIGGER_NETDEV_LINK_1000) |
|
||||
BIT(TRIGGER_NETDEV_RX) |
|
||||
@@ -814,6 +815,12 @@ static int rtl8211f_led_hw_control_get(struct phy_device *phydev, u8 index,
|
||||
if (val & RTL8211F_LEDCR_LINK_1000)
|
||||
__set_bit(TRIGGER_NETDEV_LINK_1000, rules);
|
||||
|
||||
if ((val & RTL8211F_LEDCR_LINK_10) &&
|
||||
(val & RTL8211F_LEDCR_LINK_100) &&
|
||||
(val & RTL8211F_LEDCR_LINK_1000)) {
|
||||
__set_bit(TRIGGER_NETDEV_LINK, rules);
|
||||
}
|
||||
|
||||
if (val & RTL8211F_LEDCR_ACT_TXRX) {
|
||||
__set_bit(TRIGGER_NETDEV_RX, rules);
|
||||
__set_bit(TRIGGER_NETDEV_TX, rules);
|
||||
@@ -831,14 +838,20 @@ static int rtl8211f_led_hw_control_set(struct phy_device *phydev, u8 index,
|
||||
if (index >= RTL8211x_LED_COUNT)
|
||||
return -EINVAL;
|
||||
|
||||
if (test_bit(TRIGGER_NETDEV_LINK_10, &rules))
|
||||
if (test_bit(TRIGGER_NETDEV_LINK, &rules) ||
|
||||
test_bit(TRIGGER_NETDEV_LINK_10, &rules)) {
|
||||
reg |= RTL8211F_LEDCR_LINK_10;
|
||||
}
|
||||
|
||||
if (test_bit(TRIGGER_NETDEV_LINK_100, &rules))
|
||||
if (test_bit(TRIGGER_NETDEV_LINK, &rules) ||
|
||||
test_bit(TRIGGER_NETDEV_LINK_100, &rules)) {
|
||||
reg |= RTL8211F_LEDCR_LINK_100;
|
||||
}
|
||||
|
||||
if (test_bit(TRIGGER_NETDEV_LINK_1000, &rules))
|
||||
if (test_bit(TRIGGER_NETDEV_LINK, &rules) ||
|
||||
test_bit(TRIGGER_NETDEV_LINK_1000, &rules)) {
|
||||
reg |= RTL8211F_LEDCR_LINK_1000;
|
||||
}
|
||||
|
||||
if (test_bit(TRIGGER_NETDEV_RX, &rules) ||
|
||||
test_bit(TRIGGER_NETDEV_TX, &rules)) {
|
||||
@@ -886,6 +899,12 @@ static int rtl8211e_led_hw_control_get(struct phy_device *phydev, u8 index,
|
||||
if (cr2 & RTL8211E_LEDCR2_LINK_1000)
|
||||
__set_bit(TRIGGER_NETDEV_LINK_1000, rules);
|
||||
|
||||
if ((cr2 & RTL8211E_LEDCR2_LINK_10) &&
|
||||
(cr2 & RTL8211E_LEDCR2_LINK_100) &&
|
||||
(cr2 & RTL8211E_LEDCR2_LINK_1000)) {
|
||||
__set_bit(TRIGGER_NETDEV_LINK, rules);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -913,14 +932,20 @@ static int rtl8211e_led_hw_control_set(struct phy_device *phydev, u8 index,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (test_bit(TRIGGER_NETDEV_LINK_10, &rules))
|
||||
if (test_bit(TRIGGER_NETDEV_LINK, &rules) ||
|
||||
test_bit(TRIGGER_NETDEV_LINK_10, &rules)) {
|
||||
cr2 |= RTL8211E_LEDCR2_LINK_10;
|
||||
}
|
||||
|
||||
if (test_bit(TRIGGER_NETDEV_LINK_100, &rules))
|
||||
if (test_bit(TRIGGER_NETDEV_LINK, &rules) ||
|
||||
test_bit(TRIGGER_NETDEV_LINK_100, &rules)) {
|
||||
cr2 |= RTL8211E_LEDCR2_LINK_100;
|
||||
}
|
||||
|
||||
if (test_bit(TRIGGER_NETDEV_LINK_1000, &rules))
|
||||
if (test_bit(TRIGGER_NETDEV_LINK, &rules) ||
|
||||
test_bit(TRIGGER_NETDEV_LINK_1000, &rules)) {
|
||||
cr2 |= RTL8211E_LEDCR2_LINK_1000;
|
||||
}
|
||||
|
||||
cr2 <<= RTL8211E_LEDCR2_SHIFT * index;
|
||||
ret = rtl821x_modify_ext_page(phydev, RTL8211E_LEDCR_EXT_PAGE,
|
||||
|
||||
Reference in New Issue
Block a user