@@ -337,6 +337,28 @@ static int phy_mchp_ksz9131_cfg_link(const struct device *dev, enum phy_link_spe
337
337
goto done ;
338
338
}
339
339
340
+ ret = ksz9131_read (dev , MII_1KTCR , & c1kt );
341
+ if (ret < 0 ) {
342
+ goto done ;
343
+ }
344
+
345
+ if (adv_speeds & LINK_FULL_1000BASE ) {
346
+ c1kt |= MII_ADVERTISE_1000_FULL ;
347
+ } else {
348
+ c1kt &= ~MII_ADVERTISE_1000_FULL ;
349
+ }
350
+
351
+ if (adv_speeds & LINK_HALF_1000BASE ) {
352
+ c1kt |= MII_ADVERTISE_1000_HALF ;
353
+ } else {
354
+ c1kt &= ~MII_ADVERTISE_1000_HALF ;
355
+ }
356
+
357
+ ret = ksz9131_write (dev , MII_1KTCR , c1kt );
358
+ if (ret < 0 ) {
359
+ goto done ;
360
+ }
361
+
340
362
ret = phy_mchp_ksz9131_autonegotiate (dev );
341
363
done :
342
364
k_sem_give (& data -> sem );
@@ -353,6 +375,36 @@ static int phy_mchp_ksz9131_cfg_link(const struct device *dev, enum phy_link_spe
353
375
return ret ;
354
376
}
355
377
378
+ static bool phy_mchp_ksz9131_gigabit (const struct device * dev , enum phy_link_speed * speed , int * ret )
379
+ {
380
+ uint16_t mutual_capabilities = 0 ;
381
+ uint16_t mscr = 0 ;
382
+ uint16_t mssr = 0 ;
383
+
384
+ /* Read AUTO-NEGOTIATION MASTER SLAVE CONTROL REGISTER */
385
+ * ret = ksz9131_read (dev , MII_1KTCR , & mscr );
386
+ if (* ret < 0 ) {
387
+ return true;
388
+ }
389
+
390
+ /* Read AUTO-NEGOTIATION MASTER SLAVE STATUS REGISTER */
391
+ * ret = ksz9131_read (dev , MII_1KSTSR , & mssr );
392
+ if (* ret < 0 ) {
393
+ return true;
394
+ }
395
+
396
+ mutual_capabilities = mscr & (mssr >> 2 );
397
+ if (mutual_capabilities & MII_ADVERTISE_1000_FULL ) {
398
+ * speed = LINK_FULL_1000BASE ;
399
+ return true;
400
+ } else if (mutual_capabilities & MII_ADVERTISE_1000_HALF ) {
401
+ * speed = LINK_HALF_1000BASE ;
402
+ return true;
403
+ }
404
+
405
+ return false;
406
+ }
407
+
356
408
static int phy_mchp_ksz9131_get_link (const struct device * dev , struct phy_link_state * state )
357
409
{
358
410
const struct mchp_ksz9131_config * config = dev -> config ;
@@ -372,6 +424,10 @@ static int phy_mchp_ksz9131_get_link(const struct device *dev, struct phy_link_s
372
424
goto done ;
373
425
}
374
426
427
+ if (phy_mchp_ksz9131_gigabit (dev , & state -> speed , & ret )) {
428
+ goto done ;
429
+ }
430
+
375
431
/* Read currently configured advertising options */
376
432
ret = ksz9131_read (dev , MII_ANAR , & anar );
377
433
if (ret < 0 ) {
0 commit comments