216216#define MTK_PHY_LED_ON_LINK1000 BIT(0)
217217#define MTK_PHY_LED_ON_LINK100 BIT(1)
218218#define MTK_PHY_LED_ON_LINK10 BIT(2)
219+ #define MTK_PHY_LED_ON_LINK (MTK_PHY_LED_ON_LINK10 |\
220+ MTK_PHY_LED_ON_LINK100 |\
221+ MTK_PHY_LED_ON_LINK1000)
219222#define MTK_PHY_LED_ON_LINKDOWN BIT(3)
220223#define MTK_PHY_LED_ON_FDX BIT(4) /* Full duplex */
221224#define MTK_PHY_LED_ON_HDX BIT(5) /* Half duplex */
231234#define MTK_PHY_LED_BLINK_100RX BIT(3)
232235#define MTK_PHY_LED_BLINK_10TX BIT(4)
233236#define MTK_PHY_LED_BLINK_10RX BIT(5)
237+ #define MTK_PHY_LED_BLINK_RX (MTK_PHY_LED_BLINK_10RX |\
238+ MTK_PHY_LED_BLINK_100RX |\
239+ MTK_PHY_LED_BLINK_1000RX)
240+ #define MTK_PHY_LED_BLINK_TX (MTK_PHY_LED_BLINK_10TX |\
241+ MTK_PHY_LED_BLINK_100TX |\
242+ MTK_PHY_LED_BLINK_1000TX)
234243#define MTK_PHY_LED_BLINK_COLLISION BIT(6)
235244#define MTK_PHY_LED_BLINK_RX_CRC_ERR BIT(7)
236245#define MTK_PHY_LED_BLINK_RX_IDLE_ERR BIT(8)
@@ -1247,11 +1256,9 @@ static int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index,
12471256 if (blink < 0 )
12481257 return - EIO ;
12491258
1250- if ((on & (MTK_PHY_LED_ON_LINK1000 | MTK_PHY_LED_ON_LINK100 |
1251- MTK_PHY_LED_ON_LINK10 )) ||
1252- (blink & (MTK_PHY_LED_BLINK_1000RX | MTK_PHY_LED_BLINK_100RX |
1253- MTK_PHY_LED_BLINK_10RX | MTK_PHY_LED_BLINK_1000TX |
1254- MTK_PHY_LED_BLINK_100TX | MTK_PHY_LED_BLINK_10TX )))
1259+ if ((on & (MTK_PHY_LED_ON_LINK | MTK_PHY_LED_ON_FDX | MTK_PHY_LED_ON_HDX |
1260+ MTK_PHY_LED_ON_LINKDOWN )) ||
1261+ (blink & (MTK_PHY_LED_BLINK_RX | MTK_PHY_LED_BLINK_TX )))
12551262 set_bit (bit_netdev , & priv -> led_state );
12561263 else
12571264 clear_bit (bit_netdev , & priv -> led_state );
@@ -1269,7 +1276,7 @@ static int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index,
12691276 if (!rules )
12701277 return 0 ;
12711278
1272- if (on & ( MTK_PHY_LED_ON_LINK1000 | MTK_PHY_LED_ON_LINK100 | MTK_PHY_LED_ON_LINK10 ) )
1279+ if (on & MTK_PHY_LED_ON_LINK )
12731280 * rules |= BIT (TRIGGER_NETDEV_LINK );
12741281
12751282 if (on & MTK_PHY_LED_ON_LINK10 )
@@ -1287,10 +1294,10 @@ static int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index,
12871294 if (on & MTK_PHY_LED_ON_HDX )
12881295 * rules |= BIT (TRIGGER_NETDEV_HALF_DUPLEX );
12891296
1290- if (blink & ( MTK_PHY_LED_BLINK_1000RX | MTK_PHY_LED_BLINK_100RX | MTK_PHY_LED_BLINK_10RX ) )
1297+ if (blink & MTK_PHY_LED_BLINK_RX )
12911298 * rules |= BIT (TRIGGER_NETDEV_RX );
12921299
1293- if (blink & ( MTK_PHY_LED_BLINK_1000TX | MTK_PHY_LED_BLINK_100TX | MTK_PHY_LED_BLINK_10TX ) )
1300+ if (blink & MTK_PHY_LED_BLINK_TX )
12941301 * rules |= BIT (TRIGGER_NETDEV_TX );
12951302
12961303 return 0 ;
@@ -1323,15 +1330,19 @@ static int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index,
13231330 on |= MTK_PHY_LED_ON_LINK1000 ;
13241331
13251332 if (rules & BIT (TRIGGER_NETDEV_RX )) {
1326- blink |= MTK_PHY_LED_BLINK_10RX |
1327- MTK_PHY_LED_BLINK_100RX |
1328- MTK_PHY_LED_BLINK_1000RX ;
1333+ blink |= (on & MTK_PHY_LED_ON_LINK ) ?
1334+ (((on & MTK_PHY_LED_ON_LINK10 ) ? MTK_PHY_LED_BLINK_10RX : 0 ) |
1335+ ((on & MTK_PHY_LED_ON_LINK100 ) ? MTK_PHY_LED_BLINK_100RX : 0 ) |
1336+ ((on & MTK_PHY_LED_ON_LINK1000 ) ? MTK_PHY_LED_BLINK_1000RX : 0 )) :
1337+ MTK_PHY_LED_BLINK_RX ;
13291338 }
13301339
13311340 if (rules & BIT (TRIGGER_NETDEV_TX )) {
1332- blink |= MTK_PHY_LED_BLINK_10TX |
1333- MTK_PHY_LED_BLINK_100TX |
1334- MTK_PHY_LED_BLINK_1000TX ;
1341+ blink |= (on & MTK_PHY_LED_ON_LINK ) ?
1342+ (((on & MTK_PHY_LED_ON_LINK10 ) ? MTK_PHY_LED_BLINK_10TX : 0 ) |
1343+ ((on & MTK_PHY_LED_ON_LINK100 ) ? MTK_PHY_LED_BLINK_100TX : 0 ) |
1344+ ((on & MTK_PHY_LED_ON_LINK1000 ) ? MTK_PHY_LED_BLINK_1000TX : 0 )) :
1345+ MTK_PHY_LED_BLINK_TX ;
13351346 }
13361347
13371348 if (blink || on )
@@ -1344,9 +1355,7 @@ static int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index,
13441355 MTK_PHY_LED0_ON_CTRL ,
13451356 MTK_PHY_LED_ON_FDX |
13461357 MTK_PHY_LED_ON_HDX |
1347- MTK_PHY_LED_ON_LINK10 |
1348- MTK_PHY_LED_ON_LINK100 |
1349- MTK_PHY_LED_ON_LINK1000 ,
1358+ MTK_PHY_LED_ON_LINK ,
13501359 on );
13511360
13521361 if (ret )
0 commit comments