Skip to content

Commit 9687773

Browse files
decsnymmahadevan108
authored andcommitted
drivers: ethernet: ksz8081: Fix reset times
500 ms reset time is only for software reset and comes from IEEE spec. Datasheet mentions for hardware reset the assertion of the signal should only need to be 500 us, and 100 us after deassert to wait to access programming interface. Also remove an unused macro. Signed-off-by: Declan Snyder <[email protected]>
1 parent 7b4d8cf commit 9687773

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

drivers/ethernet/phy/phy_microchip_ksz8081.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
3030
#define PHY_MC_KSZ8081_CTRL2_REG 0x1F
3131
#define PHY_MC_KSZ8081_CTRL2_REF_CLK_SEL BIT(7)
3232

33-
#define PHY_MC_KSZ8081_RESET_HOLD_TIME
34-
3533
enum ksz8081_interface {
3634
KSZ8081_MII,
3735
KSZ8081_RMII,
@@ -289,20 +287,27 @@ static int phy_mc_ksz8081_reset(const struct device *dev)
289287
goto done;
290288
}
291289

292-
/* Wait for 500 ms as specified by datasheet */
293-
k_busy_wait(USEC_PER_MSEC * 500);
290+
/* Wait for at least 500 us as specified by datasheet */
291+
k_busy_wait(1000);
294292

295293
/* Reset over */
296294
ret = gpio_pin_set_dt(&config->reset_gpio, 1);
295+
296+
/* After deasserting reset, must wait at least 100 us to use programming interface */
297+
k_busy_wait(200);
298+
297299
goto done;
298300
skip_reset_gpio:
299301
#endif /* DT_ANY_INST_HAS_PROP_STATUS_OKAY(reset_gpios) */
300302
ret = phy_mc_ksz8081_write(dev, MII_BMCR, MII_BMCR_RESET);
301303
if (ret) {
302304
goto done;
303305
}
304-
/* Wait for 500 ms as specified by datasheet */
305-
k_busy_wait(USEC_PER_MSEC * 500);
306+
307+
/* According to IEEE 802.3, Section 2, Subsection 22.2.4.1.1,
308+
* a PHY reset may take up to 0.5 s.
309+
*/
310+
k_busy_wait(500 * USEC_PER_MSEC);
306311

307312
done:
308313
/* Unlock mutex */

0 commit comments

Comments
 (0)