forked from Minki/linux
net: stmmac: Support WOL with phy
Currently, the stmmac driver WOL implementation relies on MAC's PMT feature. We have a case: the MAC HW doesn't enable PMT, instead, we rely on the phy to support WOL. Implement the support for this case. Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e8377e7a29
commit
1d8e5b0f3f
@ -600,6 +600,9 @@ static void stmmac_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
|
|||||||
{
|
{
|
||||||
struct stmmac_priv *priv = netdev_priv(dev);
|
struct stmmac_priv *priv = netdev_priv(dev);
|
||||||
|
|
||||||
|
if (!priv->plat->pmt)
|
||||||
|
return phylink_ethtool_get_wol(priv->phylink, wol);
|
||||||
|
|
||||||
mutex_lock(&priv->lock);
|
mutex_lock(&priv->lock);
|
||||||
if (device_can_wakeup(priv->device)) {
|
if (device_can_wakeup(priv->device)) {
|
||||||
wol->supported = WAKE_MAGIC | WAKE_UCAST;
|
wol->supported = WAKE_MAGIC | WAKE_UCAST;
|
||||||
@ -618,6 +621,14 @@ static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
|
|||||||
if (!device_can_wakeup(priv->device))
|
if (!device_can_wakeup(priv->device))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
if (!priv->plat->pmt) {
|
||||||
|
int ret = phylink_ethtool_set_wol(priv->phylink, wol);
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
|
device_set_wakeup_enable(&dev->dev, !!wol->wolopts);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* By default almost all GMAC devices support the WoL via
|
/* By default almost all GMAC devices support the WoL via
|
||||||
* magic frame but we can disable it if the HW capability
|
* magic frame but we can disable it if the HW capability
|
||||||
* register shows no support for pmt_magic_frame. */
|
* register shows no support for pmt_magic_frame. */
|
||||||
|
@ -1075,6 +1075,7 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
|
|||||||
*/
|
*/
|
||||||
static int stmmac_init_phy(struct net_device *dev)
|
static int stmmac_init_phy(struct net_device *dev)
|
||||||
{
|
{
|
||||||
|
struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
|
||||||
struct stmmac_priv *priv = netdev_priv(dev);
|
struct stmmac_priv *priv = netdev_priv(dev);
|
||||||
struct device_node *node;
|
struct device_node *node;
|
||||||
int ret;
|
int ret;
|
||||||
@ -1100,6 +1101,9 @@ static int stmmac_init_phy(struct net_device *dev)
|
|||||||
ret = phylink_connect_phy(priv->phylink, phydev);
|
ret = phylink_connect_phy(priv->phylink, phydev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
phylink_ethtool_get_wol(priv->phylink, &wol);
|
||||||
|
device_set_wakeup_capable(priv->device, !!wol.supported);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user