From: Ciprian Regus oa_tc6_init() waits a fixed 1 ms after deasserting the reset GPIO before accessing the MAC-PHY, and polls STATUS0 for RESETC right after the software reset. The reset timing parameters of a MAC-PHY device are outside of the OA TC6 scope. For example, the ADIN1110 needs up to 50 ms after RESET is deasserted and up to 10 ms after a software reset before its registers can be accessed, and it tristates its SDO pin during the reset. Add hwreset_settle_us and softreset_settle_us fields to struct oa_tc6_quirks so drivers can set these times. If hwreset_settle_us is not set, the GPIO reset keeps the existing 1 ms wait. If softreset_settle_us is not set, there is no wait after the software reset, as before. Signed-off-by: Ciprian Regus Co-developed-by: Iustin Stolniceanu Signed-off-by: Iustin Stolniceanu --- drivers/net/ethernet/oa_tc6.c | 18 +++++++++++------- include/linux/oa_tc6.h | 4 ++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/oa_tc6.c b/drivers/net/ethernet/oa_tc6.c index 8e86cfde6d1c..c05480b7920e 100644 --- a/drivers/net/ethernet/oa_tc6.c +++ b/drivers/net/ethernet/oa_tc6.c @@ -89,7 +89,7 @@ struct oa_tc6 { bool int_flag; bool disable_traffic; bool prot_ctrl; - enum oa_tc6_quirk_flag quirk_flags; + struct oa_tc6_quirks quirks; struct gpio_desc *reset_gpio; }; @@ -582,7 +582,7 @@ static int oa_tc6_phy_init(struct oa_tc6 *tc6) { int ret; - if (tc6->quirk_flags & OA_TC6_BROKEN_PHY) + if (tc6->quirks.quirk_flags & OA_TC6_BROKEN_PHY) return 0; ret = oa_tc6_check_phy_reg_direct_access_capability(tc6); @@ -621,7 +621,7 @@ static int oa_tc6_phy_init(struct oa_tc6 *tc6) static void oa_tc6_phy_exit(struct oa_tc6 *tc6) { - if (tc6->quirk_flags & OA_TC6_BROKEN_PHY) + if (tc6->quirks.quirk_flags & OA_TC6_BROKEN_PHY) return; phy_disconnect(tc6->phydev); @@ -652,6 +652,8 @@ static int oa_tc6_sw_reset_macphy(struct oa_tc6 *tc6) if (ret) return ret; + fsleep(tc6->quirks.softreset_settle_us); + /* Poll for soft reset complete for every 1ms until 1s timeout */ ret = readx_poll_timeout(oa_tc6_read_status0, tc6, regval, regval & OA_TC6_STATUS0_RESETC, @@ -1475,7 +1477,9 @@ struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev, spin_lock_init(&tc6->tx_skb_lock); if (quirks) - tc6->quirk_flags = quirks->quirk_flags; + tc6->quirks = *quirks; + if (!tc6->quirks.hwreset_settle_us) + tc6->quirks.hwreset_settle_us = 1000; /* Set the SPI controller to pump at realtime priority */ tc6->spi->rt = true; @@ -1515,12 +1519,12 @@ struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev, "failed to get reset gpio\n")); if (tc6->reset_gpio) { - /* Keep the reset asserted for 10 us and then allow 1 ms of - * settle time for the crystal oscillator startup. + /* Keep the reset asserted for 10 us and then allow the reset + * settle time (1 ms by default). */ fsleep(10); gpiod_set_value_cansleep(tc6->reset_gpio, 0); - fsleep(1000); + fsleep(tc6->quirks.hwreset_settle_us); } /* Check the PROTE bit status so that we can reset the device */ diff --git a/include/linux/oa_tc6.h b/include/linux/oa_tc6.h index 6eac6b842156..f676e712e75d 100644 --- a/include/linux/oa_tc6.h +++ b/include/linux/oa_tc6.h @@ -73,6 +73,10 @@ enum oa_tc6_quirk_flag { struct oa_tc6_quirks { enum oa_tc6_quirk_flag quirk_flags; + /* Wait after deasserting the reset GPIO, 1 ms if not set */ + u32 hwreset_settle_us; + /* Wait after the software reset, before polling for RESETC */ + u32 softreset_settle_us; }; struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev, -- 2.43.0