@@ -41,6 +41,9 @@ struct mchp_ksz9131_data {
41
41
#define PHY_ID_KSZ9131 0x00221640
42
42
#define PHY_ID_KSZ9131_MSK (~0xF)
43
43
44
+ #define PHY_KSZ9131_MSS_ADVERTISE_1000_FULL BIT(11)
45
+ #define PHY_KSZ9131_MSS_ADVERTISE_1000_HALF BIT(10)
46
+
44
47
#define PHY_KSZ9131_ICS_REG 0x1B
45
48
#define PHY_KSZ9131_ICS_LINK_DOWN_IE_MASK BIT(10)
46
49
#define PHY_KSZ9131_ICS_LINK_UP_IE_MASK BIT(8)
@@ -375,6 +378,8 @@ static int phy_mchp_ksz9131_get_link(const struct device *dev, struct phy_link_s
375
378
uint16_t mutual_capabilities = 0 ;
376
379
uint16_t anlpar = 0 ;
377
380
uint16_t anar = 0 ;
381
+ uint16_t mscr = 0 ;
382
+ uint16_t mssr = 0 ;
378
383
int ret = 0 ;
379
384
380
385
(void )config ; /* avoid warnings due to config is only used in LOG_DBG() */
@@ -386,6 +391,27 @@ static int phy_mchp_ksz9131_get_link(const struct device *dev, struct phy_link_s
386
391
goto done ;
387
392
}
388
393
394
+ /* Read AUTO-NEGOTIATION MASTER SLAVE CONTROL REGISTER */
395
+ ret = ksz9131_read (dev , MII_1KTCR , & mscr );
396
+ if (ret < 0 ) {
397
+ goto done ;
398
+ }
399
+
400
+ /* Read AUTO-NEGOTIATION MASTER SLAVE STATUS REGISTER */
401
+ ret = ksz9131_read (dev , MII_1KSTSR , & mssr );
402
+ if (ret < 0 ) {
403
+ goto done ;
404
+ }
405
+
406
+ if (mscr & MII_ADVERTISE_1000_FULL && mssr & PHY_KSZ9131_MSS_ADVERTISE_1000_FULL ) {
407
+ state -> speed = LINK_FULL_1000BASE ;
408
+ goto done ;
409
+ }
410
+ if (mscr & MII_ADVERTISE_1000_HALF && mssr & PHY_KSZ9131_MSS_ADVERTISE_1000_HALF ) {
411
+ state -> speed = LINK_HALF_1000BASE ;
412
+ goto done ;
413
+ }
414
+
389
415
/* Read currently configured advertising options */
390
416
ret = ksz9131_read (dev , MII_ANAR , & anar );
391
417
if (ret < 0 ) {
0 commit comments