aboutsummaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2020-07-06 01:40:42 +0100
committerJagan Teki <jagan@amarulasolutions.com>2020-10-21 23:44:52 +0530
commit2c5600c38ce642e1763afe4f3b5fb6dd8f442aa5 (patch)
tree459be96bd9ded49011363b7776bd85a252103ac2 /drivers/net
parent09501ff32eee22469daf9279a46bb3b9a1fe7625 (diff)
downloadu-boot-2c5600c38ce642e1763afe4f3b5fb6dd8f442aa5.zip
u-boot-2c5600c38ce642e1763afe4f3b5fb6dd8f442aa5.tar.gz
u-boot-2c5600c38ce642e1763afe4f3b5fb6dd8f442aa5.tar.bz2
net: sun8i_emac: Fix MAC soft reset
The EMAC soft reset routine was subtly broken, using an open coded timeout routine without any actual delay. Remove the unneeded initial reset bit read, and call wait_for_bit_le32() to handle the timeout correctly. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Acked-by: Maxime Ripard <mripard@kernel.org> Tested-by: Amit Singh Tomar <amittomer25@gmail.com> # Pine64+ Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/sun8i_emac.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index 1ae5bfd..f7c55b3 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -447,22 +447,15 @@ static void tx_descs_init(struct emac_eth_dev *priv)
static int sun8i_emac_eth_start(struct udevice *dev)
{
struct emac_eth_dev *priv = dev_get_priv(dev);
- u32 reg;
- int timeout = 100;
int ret;
- reg = readl((priv->mac_reg + EMAC_CTL1));
-
- if (!(reg & 0x1)) {
- /* Soft reset MAC */
- setbits_le32((priv->mac_reg + EMAC_CTL1), 0x1);
- do {
- reg = readl(priv->mac_reg + EMAC_CTL1);
- } while ((reg & 0x01) != 0 && (--timeout));
- if (!timeout) {
- printf("%s: Timeout\n", __func__);
- return -1;
- }
+ /* Soft reset MAC */
+ writel(EMAC_CTL1_SOFT_RST, priv->mac_reg + EMAC_CTL1);
+ ret = wait_for_bit_le32(priv->mac_reg + EMAC_CTL1,
+ EMAC_CTL1_SOFT_RST, false, 10, true);
+ if (ret) {
+ printf("%s: Timeout\n", __func__);
+ return ret;
}
/* Rewrite mac address after reset */