Skip to content

Commit

Permalink
net:phy:motorcomm: support yt8521 inverted
Browse files Browse the repository at this point in the history
jh7110B need yt8521 inverted.

Signed-off-by: Samin Guo <[email protected]>
  • Loading branch information
SaminGuo authored and MichaIng committed Mar 13, 2023
1 parent b003093 commit 3c9ef2d
Showing 1 changed file with 36 additions and 26 deletions.
62 changes: 36 additions & 26 deletions drivers/net/phy/motorcomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,36 @@ static struct device_node *ytphy_get_of_node(struct phy_device *phydev)
return of_node->child;
}

static int ytphy_inverted(struct phy_device *phydev)
{
u32 val;
struct ytphy_priv_t *ytphy_priv = phydev->priv;

val = ytphy_read_ext(phydev, YTPHY_EXTREG_RGMII_CONFIG1);
switch (phydev->speed) {
case SPEED_1000:
val = bitfield_replace(val, ytphy_txinver_grp[0].off,
ytphy_txinver_grp[0].size,
ytphy_priv->tx_inverted_1000);
break;
case SPEED_100:
val = bitfield_replace(val, ytphy_txinver_grp[1].off,
ytphy_txinver_grp[1].size,
ytphy_priv->tx_inverted_100);
break;
case SPEED_10:
val = bitfield_replace(val, ytphy_txinver_grp[2].off,
ytphy_txinver_grp[2].size,
ytphy_priv->tx_inverted_10);
break;
default:
break;
}

return ytphy_write_ext(phydev, YTPHY_EXTREG_RGMII_CONFIG1, val);
}


static int ytphy_of_config(struct phy_device *phydev)
{
const struct device_node *of_node;
Expand Down Expand Up @@ -958,6 +988,8 @@ static int yt8521_adjust_status(struct phy_device *phydev, int val, int is_utp)
phydev->speed = speed;
phydev->duplex = duplex;

ytphy_inverted(phydev);

return 0;
}

Expand Down Expand Up @@ -1154,38 +1186,15 @@ static int yt8531S_config_init(struct phy_device *phydev)
static int yt8531_read_status(struct phy_device *phydev)
{
int ret;
u32 val;
struct ytphy_priv_t *ytphy_priv = phydev->priv;

val = ytphy_read_ext(phydev, YTPHY_EXTREG_RGMII_CONFIG1);
ret = genphy_read_status(phydev);
if (ret)
return ret;

switch (phydev->speed) {
case SPEED_1000:
val = bitfield_replace(val, ytphy_txinver_grp[0].off,
ytphy_txinver_grp[0].size,
ytphy_priv->tx_inverted_1000);
break;
case SPEED_100:
val = bitfield_replace(val, ytphy_txinver_grp[1].off,
ytphy_txinver_grp[1].size,
ytphy_priv->tx_inverted_100);
break;
case SPEED_10:
val = bitfield_replace(val, ytphy_txinver_grp[2].off,
ytphy_txinver_grp[2].size,
ytphy_priv->tx_inverted_10);
break;
default:
break;
}
ret = ytphy_write_ext(phydev, YTPHY_EXTREG_RGMII_CONFIG1, val);
return ret;
return ytphy_inverted(phydev);
}

static int yt8531_probe(struct phy_device *phydev)
static int ytphy_probe(struct phy_device *phydev)
{
struct device *dev = &phydev->mdio.dev;
struct ytphy_priv_t *priv;
Expand Down Expand Up @@ -2152,6 +2161,7 @@ static struct phy_driver ytphy_drvs[] = {
.phy_id_mask = MOTORCOMM_PHY_ID_MASK,
.features = PHY_GBIT_FEATURES,
.flags = PHY_POLL,
.probe = ytphy_probe,
.soft_reset = yt8521_soft_reset,
.config_aneg = genphy_config_aneg,
.aneg_done = yt8521_aneg_done,
Expand Down Expand Up @@ -2188,7 +2198,7 @@ static struct phy_driver ytphy_drvs[] = {
.phy_id_mask = MOTORCOMM_PHY_ID_MASK,
.features = PHY_GBIT_FEATURES,
.flags = PHY_POLL,
.probe = yt8531_probe,
.probe = ytphy_probe,
.config_aneg = genphy_config_aneg,
.config_init = yt8531_config_init,
.read_status = yt8531_read_status,
Expand Down

0 comments on commit 3c9ef2d

Please sign in to comment.