Commit b6bb4dfc authored by Hector Palacios's avatar Hector Palacios Committed by David S. Miller

phy/micrel: move flag handling to function for common use

The flag MICREL_PHY_50MHZ_CLK is not of exclusive use of KSZ8051
model. At least KSZ8021 and KSZ8031 models also use it.
This patch moves the handling of this and future flags to a
separate function so that the different PHY models can call it on
their init function, if needed.
Signed-off-by: default avatarHector Palacios <hector.palacios@digi.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b818d1a7
...@@ -53,6 +53,18 @@ ...@@ -53,6 +53,18 @@
#define KS8737_CTRL_INT_ACTIVE_HIGH (1 << 14) #define KS8737_CTRL_INT_ACTIVE_HIGH (1 << 14)
#define KSZ8051_RMII_50MHZ_CLK (1 << 7) #define KSZ8051_RMII_50MHZ_CLK (1 << 7)
static int ksz_config_flags(struct phy_device *phydev)
{
int regval;
if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) {
regval = phy_read(phydev, MII_KSZPHY_CTRL);
regval |= KSZ8051_RMII_50MHZ_CLK;
return phy_write(phydev, MII_KSZPHY_CTRL, regval);
}
return 0;
}
static int kszphy_ack_interrupt(struct phy_device *phydev) static int kszphy_ack_interrupt(struct phy_device *phydev)
{ {
/* bit[7..0] int status, which is a read and clear register. */ /* bit[7..0] int status, which is a read and clear register. */
...@@ -114,22 +126,19 @@ static int kszphy_config_init(struct phy_device *phydev) ...@@ -114,22 +126,19 @@ static int kszphy_config_init(struct phy_device *phydev)
static int ksz8021_config_init(struct phy_device *phydev) static int ksz8021_config_init(struct phy_device *phydev)
{ {
int rc;
const u16 val = KSZPHY_OMSO_B_CAST_OFF | KSZPHY_OMSO_RMII_OVERRIDE; const u16 val = KSZPHY_OMSO_B_CAST_OFF | KSZPHY_OMSO_RMII_OVERRIDE;
phy_write(phydev, MII_KSZPHY_OMSO, val); phy_write(phydev, MII_KSZPHY_OMSO, val);
return 0; rc = ksz_config_flags(phydev);
return rc < 0 ? rc : 0;
} }
static int ks8051_config_init(struct phy_device *phydev) static int ks8051_config_init(struct phy_device *phydev)
{ {
int regval; int rc;
if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) {
regval = phy_read(phydev, MII_KSZPHY_CTRL);
regval |= KSZ8051_RMII_50MHZ_CLK;
phy_write(phydev, MII_KSZPHY_CTRL, regval);
}
return 0; rc = ksz_config_flags(phydev);
return rc < 0 ? rc : 0;
} }
#define KSZ8873MLL_GLOBAL_CONTROL_4 0x06 #define KSZ8873MLL_GLOBAL_CONTROL_4 0x06
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment