@@ -89,8 +89,8 @@ struct mc_vsc8541_data {
89
89
uint8_t link_monitor_thread_stack [STACK_SIZE ];
90
90
};
91
91
92
- static int phy_mc_vsc8541_read (const struct device * dev , uint16_t reg_addr , uint32_t * data );
93
- static int phy_mc_vsc8541_write (const struct device * dev , uint16_t reg_addr , uint32_t data );
92
+ static int phy_mc_vsc8541_read (const struct device * dev , uint16_t reg_addr , uint16_t * data );
93
+ static int phy_mc_vsc8541_write (const struct device * dev , uint16_t reg_addr , uint16_t data );
94
94
static void phy_mc_vsc8541_link_monitor (void * arg1 , void * arg2 , void * arg3 );
95
95
96
96
#if CONFIG_PHY_VERIFY_DEVICE_IDENTIFICATION
@@ -102,11 +102,11 @@ static int phy_mc_vsc8541_verify_phy_id(const struct device *dev)
102
102
uint16_t phy_id_1 ;
103
103
uint16_t phy_id_2 ;
104
104
105
- if (phy_mc_vsc8541_read (dev , MII_PHYID1R , ( uint32_t * ) & phy_id_1 ) < 0 ) {
105
+ if (phy_mc_vsc8541_read (dev , MII_PHYID1R , & phy_id_1 ) < 0 ) {
106
106
return - EINVAL ;
107
107
}
108
108
109
- if (phy_mc_vsc8541_read (dev , MII_PHYID2R , ( uint32_t * ) & phy_id_2 ) < 0 ) {
109
+ if (phy_mc_vsc8541_read (dev , MII_PHYID2R , & phy_id_2 ) < 0 ) {
110
110
return - EINVAL ;
111
111
}
112
112
@@ -133,7 +133,7 @@ static int phy_mc_vsc8541_reset(const struct device *dev)
133
133
{
134
134
const struct mc_vsc8541_config * cfg = dev -> config ;
135
135
int ret ;
136
- uint32_t reg = 0U ;
136
+ uint16_t reg = 0U ;
137
137
138
138
#if DT_ANY_INST_HAS_PROP_STATUS_OKAY (reset_gpios )
139
139
@@ -219,10 +219,10 @@ static int phy_mc_vsc8541_reset(const struct device *dev)
219
219
static int phy_mc_vsc8541_get_speed (const struct device * dev , struct phy_link_state * state )
220
220
{
221
221
int ret ;
222
- uint32_t aux_status ;
223
- uint32_t link10_status ;
224
- uint32_t link100_status ;
225
- uint32_t link1000_status ;
222
+ uint16_t aux_status ;
223
+ uint16_t link10_status ;
224
+ uint16_t link100_status ;
225
+ uint16_t link1000_status ;
226
226
bool is_duplex ;
227
227
228
228
ret = phy_mc_vsc8541_read (dev , PHY_REG_PAGE0_EXT_DEV_AUX , & aux_status );
@@ -317,8 +317,8 @@ static int phy_mc_vsc8541_init(const struct device *dev)
317
317
static int phy_mc_vsc8541_get_link (const struct device * dev , struct phy_link_state * state )
318
318
{
319
319
int ret ;
320
- uint32_t reg_sr ;
321
- uint32_t reg_cr ;
320
+ uint16_t reg_sr ;
321
+ uint16_t reg_cr ;
322
322
bool hasLink ;
323
323
bool auto_negotiation_finished = true;
324
324
@@ -412,7 +412,7 @@ void phy_mc_vsc8541_link_monitor(void *arg1, void *arg2, void *arg3)
412
412
* - to speed up, we store the last used page and only swap page if needed
413
413
*
414
414
*/
415
- static int phy_mc_vsc8541_read (const struct device * dev , uint16_t reg_addr , uint32_t * data )
415
+ static int phy_mc_vsc8541_read (const struct device * dev , uint16_t reg_addr , uint16_t * data )
416
416
{
417
417
const struct mc_vsc8541_config * cfg = dev -> config ;
418
418
struct mc_vsc8541_data * dev_data = dev -> data ;
@@ -421,7 +421,7 @@ static int phy_mc_vsc8541_read(const struct device *dev, uint16_t reg_addr, uint
421
421
* data = 0U ;
422
422
423
423
/* decode page */
424
- uint32_t page = reg_addr >> 8 ;
424
+ uint16_t page = reg_addr >> 8 ;
425
425
426
426
/* mask out lower byte */
427
427
reg_addr &= 0x00ff ;
@@ -431,15 +431,15 @@ static int phy_mc_vsc8541_read(const struct device *dev, uint16_t reg_addr, uint
431
431
432
432
/* select page, given by register upper byte */
433
433
if (dev_data -> active_page != page ) {
434
- ret = mdio_write (cfg -> mdio_dev , cfg -> addr , PHY_REG_PAGE_SELECTOR , ( uint16_t ) page );
434
+ ret = mdio_write (cfg -> mdio_dev , cfg -> addr , PHY_REG_PAGE_SELECTOR , page );
435
435
if (ret < 0 ) {
436
436
goto read_end ;
437
437
}
438
438
dev_data -> active_page = (int )page ;
439
439
}
440
440
441
441
/* select register, given by register lower byte */
442
- ret = mdio_read (cfg -> mdio_dev , cfg -> addr , reg_addr , ( uint16_t * ) data );
442
+ ret = mdio_read (cfg -> mdio_dev , cfg -> addr , reg_addr , data );
443
443
444
444
read_end :
445
445
mdio_bus_disable (cfg -> mdio_dev );
@@ -448,6 +448,15 @@ static int phy_mc_vsc8541_read(const struct device *dev, uint16_t reg_addr, uint
448
448
return ret ;
449
449
}
450
450
451
+ /**
452
+ * @brief Reading of phy register content at given address via mdio interface
453
+ * For external API using uint32_t as data type
454
+ */
455
+ static int phy_mc_vsc8541_read_ext (const struct device * dev , uint16_t reg_addr , uint32_t * data )
456
+ {
457
+ return phy_mc_vsc8541_read (dev , reg_addr , (uint16_t * )data );
458
+ }
459
+
451
460
/**
452
461
* @brief Writing of new value to phy register at given address via mdio interface
453
462
*
@@ -456,14 +465,14 @@ static int phy_mc_vsc8541_read(const struct device *dev, uint16_t reg_addr, uint
456
465
* - to speed up, we store the last used page and only swap page if needed
457
466
*
458
467
*/
459
- static int phy_mc_vsc8541_write (const struct device * dev , uint16_t reg_addr , uint32_t data )
468
+ static int phy_mc_vsc8541_write (const struct device * dev , uint16_t reg_addr , uint16_t data )
460
469
{
461
470
const struct mc_vsc8541_config * cfg = dev -> config ;
462
471
struct mc_vsc8541_data * dev_data = dev -> data ;
463
472
int ret ;
464
473
465
474
/* decode page */
466
- uint32_t page = reg_addr >> 8 ;
475
+ uint16_t page = reg_addr >> 8 ;
467
476
468
477
/* mask out lower byte */
469
478
reg_addr &= 0x00ff ;
@@ -481,7 +490,7 @@ static int phy_mc_vsc8541_write(const struct device *dev, uint16_t reg_addr, uin
481
490
}
482
491
483
492
/* write register, given by lower byte */
484
- ret = mdio_write (cfg -> mdio_dev , cfg -> addr , reg_addr , ( uint16_t ) data );
493
+ ret = mdio_write (cfg -> mdio_dev , cfg -> addr , reg_addr , data );
485
494
486
495
write_end :
487
496
mdio_bus_disable (cfg -> mdio_dev );
@@ -490,12 +499,21 @@ static int phy_mc_vsc8541_write(const struct device *dev, uint16_t reg_addr, uin
490
499
return ret ;
491
500
}
492
501
502
+ /**
503
+ * @brief Writing of new value to phy register at given address via mdio interface
504
+ * For external API using uint32_t as data type
505
+ */
506
+ static int phy_mc_vsc8541_write_ext (const struct device * dev , uint16_t reg_addr , uint32_t data )
507
+ {
508
+ return phy_mc_vsc8541_write (dev , reg_addr , (uint16_t )data );
509
+ }
510
+
493
511
static DEVICE_API (ethphy , mc_vsc8541_phy_api ) = {
494
512
.get_link = phy_mc_vsc8541_get_link ,
495
513
.cfg_link = phy_mc_vsc8541_cfg_link ,
496
514
.link_cb_set = phy_mc_vsc8541_link_cb_set ,
497
- .read = phy_mc_vsc8541_read ,
498
- .write = phy_mc_vsc8541_write ,
515
+ .read = phy_mc_vsc8541_read_ext ,
516
+ .write = phy_mc_vsc8541_write_ext ,
499
517
};
500
518
501
519
#if DT_ANY_INST_HAS_PROP_STATUS_OKAY (reset_gpios )
0 commit comments