@@ -96,6 +96,7 @@ struct mc_t1s_config {
96
96
};
97
97
98
98
struct mc_t1s_data {
99
+ uint32_t phy_id ;
99
100
const struct device * dev ;
100
101
struct phy_link_state state ;
101
102
phy_callback_t cb ;
@@ -141,41 +142,41 @@ static int mdio_setup_c45_indirect_access(const struct device *dev, uint16_t dev
141
142
static int phy_mc_t1s_c45_read (const struct device * dev , uint8_t devad , uint16_t reg , uint16_t * val )
142
143
{
143
144
const struct mc_t1s_config * cfg = dev -> config ;
145
+ struct mc_t1s_data * data = dev -> data ;
144
146
int ret ;
145
147
146
- ret = mdio_read_c45 (cfg -> mdio , cfg -> phy_addr , devad , reg , val );
147
- /* @retval -ENOSYS if read using Clause 45 direct access is not supported */
148
- if (ret == - ENOSYS ) {
149
- /* Read C45 registers using C22 indirect access registers */
150
- ret = mdio_setup_c45_indirect_access (dev , devad , reg );
151
- if (ret ) {
152
- return ret ;
153
- }
148
+ /* C45 direct read access is only supported by LAN865x internal PHY */
149
+ if (data -> phy_id == PHY_ID_LAN865X_REVB ) {
150
+ return mdio_read_c45 (cfg -> mdio , cfg -> phy_addr , devad , reg , val );
151
+ }
154
152
155
- return mdio_read (cfg -> mdio , cfg -> phy_addr , MII_MMD_AADR , val );
153
+ /* Read C45 registers using C22 indirect access registers */
154
+ ret = mdio_setup_c45_indirect_access (dev , devad , reg );
155
+ if (ret ) {
156
+ return ret ;
156
157
}
157
158
158
- return ret ;
159
+ return mdio_read ( cfg -> mdio , cfg -> phy_addr , MII_MMD_AADR , val ) ;
159
160
}
160
161
161
162
static int phy_mc_t1s_c45_write (const struct device * dev , uint8_t devad , uint16_t reg , uint16_t val )
162
163
{
163
164
const struct mc_t1s_config * cfg = dev -> config ;
165
+ struct mc_t1s_data * data = dev -> data ;
164
166
int ret ;
165
167
166
- ret = mdio_write_c45 (cfg -> mdio , cfg -> phy_addr , devad , reg , val );
167
- /* @retval -ENOSYS if write using Clause 45 direct access is not supported */
168
- if (ret == - ENOSYS ) {
169
- /* Write C45 registers using C22 indirect access registers */
170
- ret = mdio_setup_c45_indirect_access (dev , devad , reg );
171
- if (ret ) {
172
- return ret ;
173
- }
168
+ /* C45 direct write access is only supported by LAN865x internal PHY */
169
+ if (data -> phy_id == PHY_ID_LAN865X_REVB ) {
170
+ return mdio_write_c45 (cfg -> mdio , cfg -> phy_addr , devad , reg , val );
171
+ }
174
172
175
- return mdio_write (cfg -> mdio , cfg -> phy_addr , MII_MMD_AADR , val );
173
+ /* Write C45 registers using C22 indirect access registers */
174
+ ret = mdio_setup_c45_indirect_access (dev , devad , reg );
175
+ if (ret ) {
176
+ return ret ;
176
177
}
177
178
178
- return ret ;
179
+ return mdio_write ( cfg -> mdio , cfg -> phy_addr , MII_MMD_AADR , val ) ;
179
180
}
180
181
181
182
static int phy_mc_t1s_get_link (const struct device * dev , struct phy_link_state * state )
@@ -478,17 +479,16 @@ static int phy_mc_t1s_set_dt_plca(const struct device *dev)
478
479
static int phy_mc_t1s_init (const struct device * dev )
479
480
{
480
481
struct mc_t1s_data * data = dev -> data ;
481
- uint32_t phy_id ;
482
482
int ret ;
483
483
484
484
data -> dev = dev ;
485
485
486
- ret = phy_mc_t1s_id (dev , & phy_id );
486
+ ret = phy_mc_t1s_id (dev , & data -> phy_id );
487
487
if (ret ) {
488
488
return ret ;
489
489
}
490
490
491
- switch (phy_id ) {
491
+ switch (data -> phy_id ) {
492
492
case PHY_ID_LAN867X_REVC1 :
493
493
case PHY_ID_LAN867X_REVC2 :
494
494
ret = phy_mc_lan867x_revc_config_init (dev );
@@ -505,7 +505,7 @@ static int phy_mc_t1s_init(const struct device *dev)
505
505
}
506
506
break ;
507
507
default :
508
- LOG_ERR ("Unsupported PHY ID: %x\n" , phy_id );
508
+ LOG_ERR ("Unsupported PHY ID: %x\n" , data -> phy_id );
509
509
return - ENODEV ;
510
510
}
511
511
0 commit comments