Commit d90db36a authored by Joakim Zhang's avatar Joakim Zhang Committed by David S. Miller

net: phy: realtek: add dt property to enable ALDPS mode

If enable Advance Link Down Power Saving (ALDPS) mode, it will change
crystal/clock behavior, which cause RXC clock stop for dozens to hundreds
of miliseconds. This is comfirmed by Realtek engineer. For some MACs, it
needs RXC clock to support RX logic, after this patch, PHY can generate
continuous RXC clock during auto-negotiation.

ALDPS default is disabled after hardware reset, it's more reasonable to
add a property to enable this feature, since ALDPS would introduce side effect.
This patch adds dt property "realtek,aldps-enable" to enable ALDPS mode
per users' requirement.

Jisheng Zhang enables this feature, changes the default behavior. Since
mine patch breaks the rule that new implementation should not break
existing design, so Cc'ed let him know to see if it can be accepted.

Cc: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Signed-off-by: default avatarJoakim Zhang <qiangqing.zhang@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0a4355c2
...@@ -76,6 +76,7 @@ MODULE_AUTHOR("Johnson Leung"); ...@@ -76,6 +76,7 @@ MODULE_AUTHOR("Johnson Leung");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
struct rtl821x_priv { struct rtl821x_priv {
u16 phycr1;
u16 phycr2; u16 phycr2;
}; };
...@@ -98,6 +99,14 @@ static int rtl821x_probe(struct phy_device *phydev) ...@@ -98,6 +99,14 @@ static int rtl821x_probe(struct phy_device *phydev)
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
priv->phycr1 = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR1);
if (priv->phycr1 < 0)
return priv->phycr1;
priv->phycr1 &= (RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF);
if (of_property_read_bool(dev->of_node, "realtek,aldps-enable"))
priv->phycr1 |= RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF;
priv->phycr2 = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR2); priv->phycr2 = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR2);
if (priv->phycr2 < 0) if (priv->phycr2 < 0)
return priv->phycr2; return priv->phycr2;
...@@ -324,11 +333,16 @@ static int rtl8211f_config_init(struct phy_device *phydev) ...@@ -324,11 +333,16 @@ static int rtl8211f_config_init(struct phy_device *phydev)
struct rtl821x_priv *priv = phydev->priv; struct rtl821x_priv *priv = phydev->priv;
struct device *dev = &phydev->mdio.dev; struct device *dev = &phydev->mdio.dev;
u16 val_txdly, val_rxdly; u16 val_txdly, val_rxdly;
u16 val;
int ret; int ret;
val = RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_XTAL_OFF; ret = phy_modify_paged_changed(phydev, 0xa43, RTL8211F_PHYCR1,
phy_modify_paged_changed(phydev, 0xa43, RTL8211F_PHYCR1, val, val); RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF,
priv->phycr1);
if (ret < 0) {
dev_err(dev, "aldps mode configuration failed: %pe\n",
ERR_PTR(ret));
return ret;
}
switch (phydev->interface) { switch (phydev->interface) {
case PHY_INTERFACE_MODE_RGMII: case PHY_INTERFACE_MODE_RGMII:
......
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