diff options
author | John Crispin <blogic@openwrt.org> | 2016-03-04 08:33:33 +0000 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2016-03-04 08:33:33 +0000 |
commit | 86613b6e8b1af10163da086af09c01cb19365779 (patch) | |
tree | 407b94e9156e484316a5c5df881756f8c233a4b3 /target/linux/generic/files | |
parent | a34d8da30683e4b609850c359c1955f1521d734b (diff) | |
download | master-187ad058-86613b6e8b1af10163da086af09c01cb19365779.tar.gz master-187ad058-86613b6e8b1af10163da086af09c01cb19365779.tar.bz2 master-187ad058-86613b6e8b1af10163da086af09c01cb19365779.zip |
AR8216: improve mmd register access
Combine all bus operations for one MMD access in one function.
Protecting all these bus operations with one lock also helps
to avoid potential issues due to bus operations intercepting
the register and data write.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@48914 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic/files')
-rw-r--r-- | target/linux/generic/files/drivers/net/phy/ar8216.c | 16 | ||||
-rw-r--r-- | target/linux/generic/files/drivers/net/phy/ar8216.h | 4 | ||||
-rw-r--r-- | target/linux/generic/files/drivers/net/phy/ar8327.c | 10 |
3 files changed, 17 insertions, 13 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c index 817aca57d5..fc5627258d 100644 --- a/target/linux/generic/files/drivers/net/phy/ar8216.c +++ b/target/linux/generic/files/drivers/net/phy/ar8216.c @@ -308,25 +308,33 @@ ar8xxx_phy_dbg_write(struct ar8xxx_priv *priv, int phy_addr, mutex_unlock(&bus->mdio_lock); } +static inline void +ar8xxx_phy_mmd_prep(struct mii_bus *bus, int phy_addr, u16 addr, u16 reg) +{ + bus->write(bus, phy_addr, MII_ATH_MMD_ADDR, addr); + bus->write(bus, phy_addr, MII_ATH_MMD_DATA, reg); + bus->write(bus, phy_addr, MII_ATH_MMD_ADDR, addr | 0x4000); +} + void -ar8xxx_phy_mmd_write(struct ar8xxx_priv *priv, int phy_addr, u16 addr, u16 data) +ar8xxx_phy_mmd_write(struct ar8xxx_priv *priv, int phy_addr, u16 addr, u16 reg, u16 data) { struct mii_bus *bus = priv->mii_bus; mutex_lock(&bus->mdio_lock); - bus->write(bus, phy_addr, MII_ATH_MMD_ADDR, addr); + ar8xxx_phy_mmd_prep(bus, phy_addr, addr, reg); bus->write(bus, phy_addr, MII_ATH_MMD_DATA, data); mutex_unlock(&bus->mdio_lock); } u16 -ar8xxx_phy_mmd_read(struct ar8xxx_priv *priv, int phy_addr, u16 addr) +ar8xxx_phy_mmd_read(struct ar8xxx_priv *priv, int phy_addr, u16 addr, u16 reg) { struct mii_bus *bus = priv->mii_bus; u16 data; mutex_lock(&bus->mdio_lock); - bus->write(bus, phy_addr, MII_ATH_MMD_ADDR, addr); + ar8xxx_phy_mmd_prep(bus, phy_addr, addr, reg); data = bus->read(bus, phy_addr, MII_ATH_MMD_DATA); mutex_unlock(&bus->mdio_lock); diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.h b/target/linux/generic/files/drivers/net/phy/ar8216.h index fb961ff04c..0ccfef8abd 100644 --- a/target/linux/generic/files/drivers/net/phy/ar8216.h +++ b/target/linux/generic/files/drivers/net/phy/ar8216.h @@ -478,9 +478,9 @@ void ar8xxx_phy_dbg_write(struct ar8xxx_priv *priv, int phy_addr, u16 dbg_addr, u16 dbg_data); void -ar8xxx_phy_mmd_write(struct ar8xxx_priv *priv, int phy_addr, u16 addr, u16 data); +ar8xxx_phy_mmd_write(struct ar8xxx_priv *priv, int phy_addr, u16 addr, u16 reg, u16 data); u16 -ar8xxx_phy_mmd_read(struct ar8xxx_priv *priv, int phy_addr, u16 addr); +ar8xxx_phy_mmd_read(struct ar8xxx_priv *priv, int phy_addr, u16 addr, u16 reg); void ar8xxx_phy_init(struct ar8xxx_priv *priv); int diff --git a/target/linux/generic/files/drivers/net/phy/ar8327.c b/target/linux/generic/files/drivers/net/phy/ar8327.c index 9c232382b5..d8797820f2 100644 --- a/target/linux/generic/files/drivers/net/phy/ar8327.c +++ b/target/linux/generic/files/drivers/net/phy/ar8327.c @@ -139,13 +139,10 @@ ar8327_phy_fixup(struct ar8xxx_priv *priv, int phy) break; case 2: - ar8xxx_phy_mmd_write(priv, phy, 0x7, 0x3c); - ar8xxx_phy_mmd_write(priv, phy, 0x4007, 0x0); + ar8xxx_phy_mmd_write(priv, phy, 0x7, 0x3c, 0x0); /* fallthrough */ case 4: - ar8xxx_phy_mmd_write(priv, phy, 0x3, 0x800d); - ar8xxx_phy_mmd_write(priv, phy, 0x4003, 0x803f); - + ar8xxx_phy_mmd_write(priv, phy, 0x3, 0x800d, 0x803f); ar8xxx_phy_dbg_write(priv, phy, 0x3d, 0x6860); ar8xxx_phy_dbg_write(priv, phy, 0x5, 0x2c46); ar8xxx_phy_dbg_write(priv, phy, 0x3c, 0x6000); @@ -744,8 +741,7 @@ ar8327_read_port_eee_status(struct ar8xxx_priv *priv, int port) phy = port - 1; /* EEE Ability Auto-negotiation Result */ - ar8xxx_phy_mmd_write(priv, phy, 0x7, 0x8000); - t = ar8xxx_phy_mmd_read(priv, phy, 0x4007); + t = ar8xxx_phy_mmd_read(priv, phy, 0x7, 0x8000); return mmd_eee_adv_to_ethtool_adv_t(t); } |