[OpenWrt-Devel] [PATCH 3/5] ar8216: decrease page switch wait time

Heiner Kallweit hkallweit1 at gmail.com
Thu Jan 22 16:52:02 EST 2015


Until a few years ago the page switch wait time was set to msleep(1)
what was changed to usleep_range(1000, 2000) later.

I can not imagine that a low-level operation like switching page
on register level takes so much time.
Most likely the value of 1ms was initially set to check whether
it fixes an issue and then remained w/o further checking whether
also a smaller value would be sufficient.

Now the wait time is set to 5us and I successfully tested this on
AR8327. IMHO 5us should be plenty of time for all supported chips.
However I couldn't test this due to missing hardware.

If other chips should need a longer wait time we can add the
wait time as a parameter to the ar8xxx_chip struct.

Signed-off-by: Heiner Kallweit <hkallweit1 at gmail.com>
---
 target/linux/generic/files/drivers/net/phy/ar8216.c | 6 +++---
 target/linux/generic/files/drivers/net/phy/ar8216.h | 6 ++++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c
index 130ebf7..8a40a32 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.c
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
@@ -260,7 +260,7 @@ ar8xxx_read(struct ar8xxx_priv *priv, int reg)
 	mutex_lock(&bus->mdio_lock);
 
 	bus->write(bus, 0x18, 0, page);
-	usleep_range(1000, 2000); /* wait for the page switch to propagate */
+	wait_for_page_switch();
 	val = mii_read32(priv, 0x10 | r2, r1);
 
 	mutex_unlock(&bus->mdio_lock);
@@ -279,7 +279,7 @@ ar8xxx_write(struct ar8xxx_priv *priv, int reg, u32 val)
 	mutex_lock(&bus->mdio_lock);
 
 	bus->write(bus, 0x18, 0, page);
-	usleep_range(1000, 2000); /* wait for the page switch to propagate */
+	wait_for_page_switch();
 	mii_write32(priv, 0x10 | r2, r1, val);
 
 	mutex_unlock(&bus->mdio_lock);
@@ -297,7 +297,7 @@ ar8xxx_rmw(struct ar8xxx_priv *priv, int reg, u32 mask, u32 val)
 	mutex_lock(&bus->mdio_lock);
 
 	bus->write(bus, 0x18, 0, page);
-	usleep_range(1000, 2000); /* wait for the page switch to propagate */
+	wait_for_page_switch();
 
 	ret = mii_read32(priv, 0x10 | r2, r1);
 	ret &= ~mask;
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.h b/target/linux/generic/files/drivers/net/phy/ar8216.h
index 2d025ae..77df506 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.h
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.h
@@ -555,4 +555,10 @@ ar8xxx_reg_clear(struct ar8xxx_priv *priv, int reg, u32 val)
 	ar8xxx_rmw(priv, reg, val, 0);
 }
 
+static inline void
+wait_for_page_switch(void)
+{
+	udelay(5);
+}
+
 #endif
-- 
2.2.2
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list