Skip to content

Commit adda5fd

Browse files
committed
drivers: phy: rtl8211f: read chip ID in initialization
Read back chip ID firstly, it will be help to check MDIO works. Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
1 parent 7ebde9b commit adda5fd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/ethernet/phy/phy_realtek_rtl8211f.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
2727

2828
#include "phy_mii.h"
2929

30+
31+
#define RTL8211F_PHY_ID1 0x001c
32+
#define PHY_READID_TIMEOUT_COUNT 1000U
33+
3034
#define REALTEK_OUI_MSB (0x1CU)
3135

3236
#define PHY_RT_RTL8211F_PHYSR_REG (0x1A)
@@ -441,6 +445,8 @@ static int phy_rt_rtl8211f_init(const struct device *dev)
441445
{
442446
const struct rt_rtl8211f_config *config = dev->config;
443447
struct rt_rtl8211f_data *data = dev->data;
448+
uint32_t counter = PHY_READID_TIMEOUT_COUNT;
449+
uint16_t phy_id1 = 0, phy_id2 = 0;
444450
uint32_t reg_val;
445451
int ret;
446452

@@ -453,6 +459,18 @@ static int phy_rt_rtl8211f_init(const struct device *dev)
453459

454460
mdio_bus_enable(config->mdio_dev);
455461

462+
do {
463+
if (phy_rt_rtl8211f_read(dev, MII_PHYID1R, &reg_val) < 0) {
464+
return -EIO;
465+
}
466+
} while ((uint16_t)reg_val != RTL8211F_PHY_ID1 && counter-- > 0);
467+
phy_id1 = (uint16_t)reg_val;
468+
if (phy_rt_rtl8211f_read(dev, MII_PHYID2R, &reg_val) < 0) {
469+
return -EIO;
470+
}
471+
phy_id2 = (uint16_t)reg_val;
472+
LOG_INF("PHY (%d) ID %X\n", config->addr, ((uint32_t)phy_id1 << 16) | phy_id2);
473+
456474
#if DT_ANY_INST_HAS_PROP_STATUS_OKAY(reset_gpios)
457475
/* Configure reset pin */
458476
if (config->reset_gpio.port) {

0 commit comments

Comments
 (0)