From: qianfan Zhao <[email protected]>
Data maybe written to the B register if the B register is reading
immediately after 'sun4i_mdio_write' write a value to A register.
Wait write done and fix it.
Signed-off-by: qianfan Zhao <[email protected]>
---
drivers/net/mdio/mdio-sun4i.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mdio/mdio-sun4i.c b/drivers/net/mdio/mdio-sun4i.c
index 168e2a375535..72ac142f2edf 100644
--- a/drivers/net/mdio/mdio-sun4i.c
+++ b/drivers/net/mdio/mdio-sun4i.c
@@ -79,7 +79,10 @@ static int sun4i_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
/* and write data */
writel(value, data->membase + EMAC_MAC_MWTD_REG);
- return 0;
+ /* Wait write complete */
+ return read_poll_timeout(readl, tmp, (tmp & 1) == 0,
+ 20, 10000, false,
+ data->membase + EMAC_MAC_MIND_REG);
}
static int sun4i_mdio_probe(struct platform_device *pdev)
--
2.25.1