Commit eeef2f6b authored by Jose Abreu's avatar Jose Abreu Committed by David S. Miller

net: stmmac: Start adding phylink support

Start adding the phylink callbacks.
Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9ad372fc
...@@ -4,6 +4,7 @@ config STMMAC_ETH ...@@ -4,6 +4,7 @@ config STMMAC_ETH
depends on HAS_IOMEM && HAS_DMA depends on HAS_IOMEM && HAS_DMA
select MII select MII
select PHYLIB select PHYLIB
select PHYLINK
select CRC32 select CRC32
imply PTP_1588_CLOCK imply PTP_1588_CLOCK
select RESET_CONTROLLER select RESET_CONTROLLER
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/stmmac.h> #include <linux/stmmac.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/phylink.h>
#include <linux/pci.h> #include <linux/pci.h>
#include "common.h" #include "common.h"
#include <linux/ptp_clock_kernel.h> #include <linux/ptp_clock_kernel.h>
...@@ -155,6 +156,9 @@ struct stmmac_priv { ...@@ -155,6 +156,9 @@ struct stmmac_priv {
struct mii_bus *mii; struct mii_bus *mii;
int mii_irq[PHY_MAX_ADDR]; int mii_irq[PHY_MAX_ADDR];
struct phylink_config phylink_config;
struct phylink *phylink;
struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp; struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp;
struct stmmac_safety_stats sstats; struct stmmac_safety_stats sstats;
struct plat_stmmacenet_data *plat; struct plat_stmmacenet_data *plat;
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
#endif /* CONFIG_DEBUG_FS */ #endif /* CONFIG_DEBUG_FS */
#include <linux/net_tstamp.h> #include <linux/net_tstamp.h>
#include <linux/phylink.h>
#include <net/pkt_cls.h> #include <net/pkt_cls.h>
#include "stmmac_ptp.h" #include "stmmac_ptp.h"
#include "stmmac.h" #include "stmmac.h"
...@@ -848,6 +849,39 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex) ...@@ -848,6 +849,39 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex)
priv->pause, tx_cnt); priv->pause, tx_cnt);
} }
static void stmmac_validate(struct phylink_config *config,
unsigned long *supported,
struct phylink_link_state *state)
{
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
int tx_cnt = priv->plat->tx_queues_to_use;
int max_speed = priv->plat->max_speed;
/* Cut down 1G if asked to */
if ((max_speed > 0) && (max_speed < 1000)) {
phylink_set(mask, 1000baseT_Full);
phylink_set(mask, 1000baseX_Full);
}
/* Half-Duplex can only work with single queue */
if (tx_cnt > 1) {
phylink_set(mask, 10baseT_Half);
phylink_set(mask, 100baseT_Half);
phylink_set(mask, 1000baseT_Half);
}
bitmap_andnot(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
bitmap_andnot(state->advertising, state->advertising, mask,
__ETHTOOL_LINK_MODE_MASK_NBITS);
}
static int stmmac_mac_link_state(struct phylink_config *config,
struct phylink_link_state *state)
{
return -EOPNOTSUPP;
}
static void stmmac_mac_config(struct net_device *dev) static void stmmac_mac_config(struct net_device *dev)
{ {
struct stmmac_priv *priv = netdev_priv(dev); struct stmmac_priv *priv = netdev_priv(dev);
...@@ -900,6 +934,11 @@ static void stmmac_mac_config(struct net_device *dev) ...@@ -900,6 +934,11 @@ static void stmmac_mac_config(struct net_device *dev)
writel(ctrl, priv->ioaddr + MAC_CTRL_REG); writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
} }
static void stmmac_mac_an_restart(struct phylink_config *config)
{
/* Not Supported */
}
static void stmmac_mac_link_down(struct net_device *dev, bool autoneg) static void stmmac_mac_link_down(struct net_device *dev, bool autoneg)
{ {
struct stmmac_priv *priv = netdev_priv(dev); struct stmmac_priv *priv = netdev_priv(dev);
...@@ -914,6 +953,15 @@ static void stmmac_mac_link_up(struct net_device *dev, bool autoneg) ...@@ -914,6 +953,15 @@ static void stmmac_mac_link_up(struct net_device *dev, bool autoneg)
stmmac_mac_set(priv, priv->ioaddr, true); stmmac_mac_set(priv, priv->ioaddr, true);
} }
static const struct phylink_mac_ops __maybe_unused stmmac_phylink_mac_ops = {
.validate = stmmac_validate,
.mac_link_state = stmmac_mac_link_state,
.mac_config = NULL, /* TO BE FILLED */
.mac_an_restart = stmmac_mac_an_restart,
.mac_link_down = NULL, /* TO BE FILLED */
.mac_link_up = NULL, /* TO BE FILLED */
};
/** /**
* stmmac_adjust_link - adjusts the link parameters * stmmac_adjust_link - adjusts the link parameters
* @dev: net device structure * @dev: net device structure
......
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