Skip to contentSkip to conversation

lib: Add WATCHDOG_RESET to wait_bit.h

PATCH New Michal Simek 3 participants 4 messages Dec 12, 2016 – Feb 2, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 lib: Add WATCHDOG_RESET to wait_bit.h

wait_for_bit() is missing reset watchdog in case watchdog is configured.

---

 include/wait_bit.h | 2 ++
 1 file changed, 2 insertions(+)
include/wait_bit.h +2 -0
index 066e30c118af..06ad43a122d6 100644
@@ -11,6 +11,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <watchdog.h>
 #include <linux/errno.h>
 #include <asm/io.h>
 
@@ -59,6 +60,7 @@ static inline int wait_for_bit(const char *prefix, const u32 *reg,
 		}
 
 		udelay(1);
+		WATCHDOG_RESET();
 	}
 
 	debug("%s: Timeout (reg=%p mask=%08x wait_set=%i)\n", prefix, reg, mask,
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/2 net: gem: Use wait_for_bit() instead of private mdio_wait()

Using generic wait_for_bit() implementation instead of using private wait function.

---

 drivers/net/zynq_gem.c | 32 +++++++++-----------------------
 1 file changed, 9 insertions(+), 23 deletions(-)
drivers/net/zynq_gem.c +9 -23
index d2e5e7c7cd14..95b4d6e4f0aa 100644
@@ -183,33 +183,17 @@ struct zynq_gem_priv {
 	struct mii_dev *bus;
 };
 
-static inline int mdio_wait(struct zynq_gem_regs *regs)
-{
-	u32 timeout = 20000;
-
-	/* Wait till MDIO interface is ready to accept a new transaction. */
-	while (--timeout) {
-		if (readl(&regs->nwsr) & ZYNQ_GEM_NWSR_MDIOIDLE_MASK)
-			break;
-		WATCHDOG_RESET();
-	}
-
-	if (!timeout) {
-		printf("%s: Timeout\n", __func__);
-		return 1;
-	}
-
-	return 0;
-}
-
 static u32 phy_setup_op(struct zynq_gem_priv *priv, u32 phy_addr, u32 regnum,
 			u32 op, u16 *data)
 {
 	u32 mgtcr;
 	struct zynq_gem_regs *regs = priv->iobase;
+	int err;
 
-	if (mdio_wait(regs))
-		return 1;
+	err = wait_for_bit(__func__, &regs->nwsr, ZYNQ_GEM_NWSR_MDIOIDLE_MASK,
+			    true, 20000, true);
+	if (err)
+		return err;
 
 	/* Construct mgtcr mask for the operation */
 	mgtcr = ZYNQ_GEM_PHYMNTNC_OP_MASK | op |
@@ -219,8 +203,10 @@ static u32 phy_setup_op(struct zynq_gem_priv *priv, u32 phy_addr, u32 regnum,
 	/* Write mgtcr and wait for completion */
 	writel(mgtcr, &regs->phymntnc);
 
-	if (mdio_wait(regs))
-		return 1;
+	err = wait_for_bit(__func__, &regs->nwsr, ZYNQ_GEM_NWSR_MDIOIDLE_MASK,
+			    true, 20000, true);
+	if (err)
+		return err;
 
 	if (op == ZYNQ_GEM_PHYMNTNC_OP_R_MASK)
 		*data = readl(&regs->phymntnc);
Signature · 1 line
1.9.1
#3 lore raw

PATCH 1/2 lib: Add WATCHDOG_RESET to wait_bit.h

In reply to Michal Simek
Quoted 4 lines · Michal Simek

wait_for_bit() is missing reset watchdog in case watchdog is configured.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161212/28f69c3f/attachment.sig>