Skip to content

Commit 21a2802

Browse files
Ansueldavem330
authored andcommitted
net: phy: at803x: move at8035 specific DT parse to dedicated probe
Move at8035 specific DT parse for clock out frequency to dedicated probe to make at803x probe function more generic. This is to tidy code and no behaviour change are intended. Detection logic is changed, we check if the clk 25m mask is set and if it's not zero, we assume the qca,clk-out-frequency property is set. The property is checked in the generic at803x_parse_dt called by at803x_probe. Signed-off-by: Christian Marangi <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f932a6d commit 21a2802

File tree

1 file changed

+41
-19
lines changed

1 file changed

+41
-19
lines changed

drivers/net/phy/at803x.c

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -638,23 +638,6 @@ static int at803x_parse_dt(struct phy_device *phydev)
638638

639639
priv->clk_25m_reg |= FIELD_PREP(AT803X_CLK_OUT_MASK, sel);
640640
priv->clk_25m_mask |= AT803X_CLK_OUT_MASK;
641-
642-
/* Fixup for the AR8030/AR8035. This chip has another mask and
643-
* doesn't support the DSP reference. Eg. the lowest bit of the
644-
* mask. The upper two bits select the same frequencies. Mask
645-
* the lowest bit here.
646-
*
647-
* Warning:
648-
* There was no datasheet for the AR8030 available so this is
649-
* just a guess. But the AR8035 is listed as pin compatible
650-
* to the AR8030 so there might be a good chance it works on
651-
* the AR8030 too.
652-
*/
653-
if (phydev->drv->phy_id == ATH8030_PHY_ID ||
654-
phydev->drv->phy_id == ATH8035_PHY_ID) {
655-
priv->clk_25m_reg &= AT8035_CLK_OUT_MASK;
656-
priv->clk_25m_mask &= AT8035_CLK_OUT_MASK;
657-
}
658641
}
659642

660643
ret = of_property_read_u32(node, "qca,clk-out-strength", &strength);
@@ -1635,6 +1618,45 @@ static int at8031_config_intr(struct phy_device *phydev)
16351618
return at803x_config_intr(phydev);
16361619
}
16371620

1621+
static int at8035_parse_dt(struct phy_device *phydev)
1622+
{
1623+
struct at803x_priv *priv = phydev->priv;
1624+
1625+
/* Mask is set by the generic at803x_parse_dt
1626+
* if property is set. Assume property is set
1627+
* with the mask not zero.
1628+
*/
1629+
if (priv->clk_25m_mask) {
1630+
/* Fixup for the AR8030/AR8035. This chip has another mask and
1631+
* doesn't support the DSP reference. Eg. the lowest bit of the
1632+
* mask. The upper two bits select the same frequencies. Mask
1633+
* the lowest bit here.
1634+
*
1635+
* Warning:
1636+
* There was no datasheet for the AR8030 available so this is
1637+
* just a guess. But the AR8035 is listed as pin compatible
1638+
* to the AR8030 so there might be a good chance it works on
1639+
* the AR8030 too.
1640+
*/
1641+
priv->clk_25m_reg &= AT8035_CLK_OUT_MASK;
1642+
priv->clk_25m_mask &= AT8035_CLK_OUT_MASK;
1643+
}
1644+
1645+
return 0;
1646+
}
1647+
1648+
/* AR8030 and AR8035 shared the same special mask for clk_25m */
1649+
static int at8035_probe(struct phy_device *phydev)
1650+
{
1651+
int ret;
1652+
1653+
ret = at803x_probe(phydev);
1654+
if (ret)
1655+
return ret;
1656+
1657+
return at8035_parse_dt(phydev);
1658+
}
1659+
16381660
static int qca83xx_config_init(struct phy_device *phydev)
16391661
{
16401662
u8 switch_revision;
@@ -2107,7 +2129,7 @@ static struct phy_driver at803x_driver[] = {
21072129
PHY_ID_MATCH_EXACT(ATH8035_PHY_ID),
21082130
.name = "Qualcomm Atheros AR8035",
21092131
.flags = PHY_POLL_CABLE_TEST,
2110-
.probe = at803x_probe,
2132+
.probe = at8035_probe,
21112133
.config_aneg = at803x_config_aneg,
21122134
.config_init = at803x_config_init,
21132135
.soft_reset = genphy_soft_reset,
@@ -2128,7 +2150,7 @@ static struct phy_driver at803x_driver[] = {
21282150
.phy_id = ATH8030_PHY_ID,
21292151
.name = "Qualcomm Atheros AR8030",
21302152
.phy_id_mask = AT8030_PHY_ID_MASK,
2131-
.probe = at803x_probe,
2153+
.probe = at8035_probe,
21322154
.config_init = at803x_config_init,
21332155
.link_change_notify = at803x_link_change_notify,
21342156
.set_wol = at803x_set_wol,

0 commit comments

Comments
 (0)