216
216
#define MTK_PHY_LED_ON_LINK1000 BIT(0)
217
217
#define MTK_PHY_LED_ON_LINK100 BIT(1)
218
218
#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)
219
222
#define MTK_PHY_LED_ON_LINKDOWN BIT(3)
220
223
#define MTK_PHY_LED_ON_FDX BIT(4) /* Full duplex */
221
224
#define MTK_PHY_LED_ON_HDX BIT(5) /* Half duplex */
231
234
#define MTK_PHY_LED_BLINK_100RX BIT(3)
232
235
#define MTK_PHY_LED_BLINK_10TX BIT(4)
233
236
#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)
234
243
#define MTK_PHY_LED_BLINK_COLLISION BIT(6)
235
244
#define MTK_PHY_LED_BLINK_RX_CRC_ERR BIT(7)
236
245
#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,
1247
1256
if (blink < 0 )
1248
1257
return - EIO ;
1249
1258
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 )))
1255
1262
set_bit (bit_netdev , & priv -> led_state );
1256
1263
else
1257
1264
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,
1269
1276
if (!rules )
1270
1277
return 0 ;
1271
1278
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 )
1273
1280
* rules |= BIT (TRIGGER_NETDEV_LINK );
1274
1281
1275
1282
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,
1287
1294
if (on & MTK_PHY_LED_ON_HDX )
1288
1295
* rules |= BIT (TRIGGER_NETDEV_HALF_DUPLEX );
1289
1296
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 )
1291
1298
* rules |= BIT (TRIGGER_NETDEV_RX );
1292
1299
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 )
1294
1301
* rules |= BIT (TRIGGER_NETDEV_TX );
1295
1302
1296
1303
return 0 ;
@@ -1323,15 +1330,19 @@ static int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index,
1323
1330
on |= MTK_PHY_LED_ON_LINK1000 ;
1324
1331
1325
1332
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 ;
1329
1338
}
1330
1339
1331
1340
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 ;
1335
1346
}
1336
1347
1337
1348
if (blink || on )
@@ -1344,9 +1355,7 @@ static int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index,
1344
1355
MTK_PHY_LED0_ON_CTRL ,
1345
1356
MTK_PHY_LED_ON_FDX |
1346
1357
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 ,
1350
1359
on );
1351
1360
1352
1361
if (ret )
0 commit comments