@@ -110,8 +110,8 @@ struct mc_vsc8541_data {
110
110
uint8_t link_monitor_thread_stack [STACK_SIZE ];
111
111
};
112
112
113
- static int phy_mc_vsc8541_read (const struct device * dev , uint16_t reg_addr , uint32_t * data );
114
- static int phy_mc_vsc8541_write (const struct device * dev , uint16_t reg_addr , uint32_t data );
113
+ static int phy_mc_vsc8541_read (const struct device * dev , uint16_t reg_addr , uint16_t * data );
114
+ static int phy_mc_vsc8541_write (const struct device * dev , uint16_t reg_addr , uint16_t data );
115
115
static void phy_mc_vsc8541_link_monitor (void * arg1 , void * arg2 , void * arg3 );
116
116
117
117
#if CONFIG_PHY_VERIFY_DEVICE_IDENTIFICATION
@@ -123,11 +123,11 @@ static int phy_mc_vsc8541_verify_phy_id(const struct device *dev)
123
123
uint16_t phy_id_1 ;
124
124
uint16_t phy_id_2 ;
125
125
126
- if (0 != phy_mc_vsc8541_read (dev , PHY_REG_PAGE0_ID1 , ( uint32_t * ) & phy_id_1 )) {
126
+ if (0 != phy_mc_vsc8541_read (dev , PHY_REG_PAGE0_ID1 , & phy_id_1 )) {
127
127
return - EINVAL ;
128
128
}
129
129
130
- if (0 != phy_mc_vsc8541_read (dev , PHY_REG_PAGE0_ID2 , ( uint32_t * ) & phy_id_2 )) {
130
+ if (0 != phy_mc_vsc8541_read (dev , PHY_REG_PAGE0_ID2 , & phy_id_2 )) {
131
131
return - EINVAL ;
132
132
}
133
133
@@ -216,7 +216,7 @@ static int phy_mc_vsc8541_reset(const struct device *dev)
216
216
}
217
217
218
218
/* wait for phy finished software reset */
219
- uint32_t reg = 0 ;
219
+ uint16_t reg = 0 ;
220
220
221
221
do {
222
222
phy_mc_vsc8541_read (dev , PHY_REG_PAGE0_BMCR , & reg );
@@ -271,10 +271,10 @@ static int phy_mc_vsc8541_reset(const struct device *dev)
271
271
static int phy_mc_vsc8541_get_speed (const struct device * dev , struct phy_link_state * state )
272
272
{
273
273
int ret ;
274
- uint32_t status ;
275
- uint32_t link10_status ;
276
- uint32_t link100_status ;
277
- uint32_t link1000_status ;
274
+ uint16_t status ;
275
+ uint16_t link10_status ;
276
+ uint16_t link100_status ;
277
+ uint16_t link1000_status ;
278
278
279
279
ret = phy_mc_vsc8541_read (dev , PHY_REG_PAGE0_BMSR , & status );
280
280
if (ret ) {
@@ -361,8 +361,8 @@ static int phy_mc_vsc8541_init(const struct device *dev)
361
361
static int phy_mc_vsc8541_get_link (const struct device * dev , struct phy_link_state * state )
362
362
{
363
363
int ret ;
364
- uint32_t reg_sr ;
365
- uint32_t reg_cr ;
364
+ uint16_t reg_sr ;
365
+ uint16_t reg_cr ;
366
366
367
367
ret = phy_mc_vsc8541_read (dev , PHY_REG_PAGE0_BMSR , & reg_sr );
368
368
if (ret ) {
@@ -460,7 +460,7 @@ void phy_mc_vsc8541_link_monitor(void *arg1, void *arg2, void *arg3)
460
460
* - to speed up, we store the last used page and only swap page if needed
461
461
*
462
462
*/
463
- static int phy_mc_vsc8541_read (const struct device * dev , uint16_t reg_addr , uint32_t * data )
463
+ static int phy_mc_vsc8541_read (const struct device * dev , uint16_t reg_addr , uint16_t * data )
464
464
{
465
465
const struct mc_vsc8541_config * cfg = dev -> config ;
466
466
struct mc_vsc8541_data * dev_data = dev -> data ;
@@ -469,7 +469,7 @@ static int phy_mc_vsc8541_read(const struct device *dev, uint16_t reg_addr, uint
469
469
* data = 0U ;
470
470
471
471
/* decode page */
472
- uint32_t page = reg_addr >> 8 ;
472
+ uint16_t page = reg_addr >> 8 ;
473
473
474
474
/* mask out lower byte */
475
475
reg_addr &= 0x00ff ;
@@ -478,7 +478,7 @@ static int phy_mc_vsc8541_read(const struct device *dev, uint16_t reg_addr, uint
478
478
479
479
/* select page, given by register upper byte */
480
480
if (dev_data -> active_page != page ) {
481
- ret = mdio_write (cfg -> mdio_dev , cfg -> addr , PHY_REG_PAGE_SELECTOR , ( uint16_t ) page );
481
+ ret = mdio_write (cfg -> mdio_dev , cfg -> addr , PHY_REG_PAGE_SELECTOR , page );
482
482
if (ret ) {
483
483
mdio_bus_disable (cfg -> mdio_dev );
484
484
return ret ;
@@ -487,7 +487,7 @@ static int phy_mc_vsc8541_read(const struct device *dev, uint16_t reg_addr, uint
487
487
}
488
488
489
489
/* select register, given by register lower byte */
490
- ret = mdio_read (cfg -> mdio_dev , cfg -> addr , reg_addr , ( uint16_t * ) data );
490
+ ret = mdio_read (cfg -> mdio_dev , cfg -> addr , reg_addr , data );
491
491
mdio_bus_disable (cfg -> mdio_dev );
492
492
if (ret ) {
493
493
return ret ;
@@ -496,6 +496,15 @@ static int phy_mc_vsc8541_read(const struct device *dev, uint16_t reg_addr, uint
496
496
return 0 ;
497
497
}
498
498
499
+ /**
500
+ * @brief Reading of phy register content at given address via mdio interface
501
+ * For external API using uint32_t as data type
502
+ */
503
+ static int phy_mc_vsc8541_read_ext (const struct device * dev , uint16_t reg_addr , uint32_t * data )
504
+ {
505
+ return phy_mc_vsc8541_read (dev , reg_addr , (uint16_t * )data );
506
+ }
507
+
499
508
/**
500
509
* @brief Writing of new value to phy register at given address via mdio interface
501
510
*
@@ -504,14 +513,14 @@ static int phy_mc_vsc8541_read(const struct device *dev, uint16_t reg_addr, uint
504
513
* - to speed up, we store the last used page and only swap page if needed
505
514
*
506
515
*/
507
- static int phy_mc_vsc8541_write (const struct device * dev , uint16_t reg_addr , uint32_t data )
516
+ static int phy_mc_vsc8541_write (const struct device * dev , uint16_t reg_addr , uint16_t data )
508
517
{
509
518
const struct mc_vsc8541_config * cfg = dev -> config ;
510
519
struct mc_vsc8541_data * dev_data = dev -> data ;
511
520
int ret ;
512
521
513
522
/* decode page */
514
- uint32_t page = reg_addr >> 8 ;
523
+ uint16_t page = reg_addr >> 8 ;
515
524
516
525
/* mask out lower byte */
517
526
reg_addr &= 0x00ff ;
@@ -529,7 +538,7 @@ static int phy_mc_vsc8541_write(const struct device *dev, uint16_t reg_addr, uin
529
538
}
530
539
531
540
/* write register, given by lower byte */
532
- ret = mdio_write (cfg -> mdio_dev , cfg -> addr , reg_addr , ( uint16_t ) data );
541
+ ret = mdio_write (cfg -> mdio_dev , cfg -> addr , reg_addr , data );
533
542
mdio_bus_disable (cfg -> mdio_dev );
534
543
if (ret ) {
535
544
return ret ;
@@ -538,11 +547,16 @@ static int phy_mc_vsc8541_write(const struct device *dev, uint16_t reg_addr, uin
538
547
return 0 ;
539
548
}
540
549
550
+ static int phy_mc_vsc8541_write_ext (const struct device * dev , uint16_t reg_addr , uint32_t data )
551
+ {
552
+ return phy_mc_vsc8541_write (dev , reg_addr , (uint16_t )data );
553
+ }
554
+
541
555
static DEVICE_API (ethphy , mc_vsc8541_phy_api ) = {
542
556
.get_link = phy_mc_vsc8541_get_link ,
543
557
.link_cb_set = phy_mc_vsc8541_link_cb_set ,
544
- .read = phy_mc_vsc8541_read ,
545
- .write = phy_mc_vsc8541_write ,
558
+ .read = phy_mc_vsc8541_read_ext ,
559
+ .write = phy_mc_vsc8541_write_ext ,
546
560
};
547
561
548
562
#if DT_ANY_INST_HAS_PROP_STATUS_OKAY (reset_gpios )
0 commit comments