Commit fef29982 authored by Maxime Chevallier's avatar Maxime Chevallier Committed by David S. Miller

net: altera: tse: convert to phylink

Convert the Altera Triple Speed Ethernet Controller to phylink.
This controller supports MII, GMII and RGMII with its MAC, and
SGMII + 1000BaseX through a small embedded PCS.

The PCS itself has a register set very similar to what is found in a
typical 802.3 ethernet PHY, but this register set memory-mapped instead
of lying on an mdio bus.
Signed-off-by: default avatarMaxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4a502cf4
...@@ -3,6 +3,8 @@ config ALTERA_TSE ...@@ -3,6 +3,8 @@ config ALTERA_TSE
tristate "Altera Triple-Speed Ethernet MAC support" tristate "Altera Triple-Speed Ethernet MAC support"
depends on HAS_DMA depends on HAS_DMA
select PHYLIB select PHYLIB
select PHYLINK
select PCS_ALTERA_TSE
help help
This driver supports the Altera Triple-Speed (TSE) Ethernet MAC. This driver supports the Altera Triple-Speed (TSE) Ethernet MAC.
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/phylink.h>
#define ALTERA_TSE_SW_RESET_WATCHDOG_CNTR 10000 #define ALTERA_TSE_SW_RESET_WATCHDOG_CNTR 10000
#define ALTERA_TSE_MAC_FIFO_WIDTH 4 /* TX/RX FIFO width in #define ALTERA_TSE_MAC_FIFO_WIDTH 4 /* TX/RX FIFO width in
...@@ -109,17 +110,6 @@ ...@@ -109,17 +110,6 @@
#define MAC_CMDCFG_DISABLE_READ_TIMEOUT_GET(v) GET_BIT_VALUE(v, 27) #define MAC_CMDCFG_DISABLE_READ_TIMEOUT_GET(v) GET_BIT_VALUE(v, 27)
#define MAC_CMDCFG_CNT_RESET_GET(v) GET_BIT_VALUE(v, 31) #define MAC_CMDCFG_CNT_RESET_GET(v) GET_BIT_VALUE(v, 31)
/* SGMII PCS register addresses
*/
#define SGMII_PCS_SCRATCH 0x10
#define SGMII_PCS_REV 0x11
#define SGMII_PCS_LINK_TIMER_0 0x12
#define SGMII_PCS_LINK_TIMER_1 0x13
#define SGMII_PCS_IF_MODE 0x14
#define SGMII_PCS_DIS_READ_TO 0x15
#define SGMII_PCS_READ_TO 0x16
#define SGMII_PCS_SW_RESET_TIMEOUT 100 /* usecs */
/* MDIO registers within MAC register Space /* MDIO registers within MAC register Space
*/ */
struct altera_tse_mdio { struct altera_tse_mdio {
...@@ -423,6 +413,9 @@ struct altera_tse_private { ...@@ -423,6 +413,9 @@ struct altera_tse_private {
void __iomem *tx_dma_csr; void __iomem *tx_dma_csr;
void __iomem *tx_dma_desc; void __iomem *tx_dma_desc;
/* SGMII PCS address space */
void __iomem *pcs_base;
/* Rx buffers queue */ /* Rx buffers queue */
struct tse_buffer *rx_ring; struct tse_buffer *rx_ring;
u32 rx_cons; u32 rx_cons;
...@@ -480,6 +473,10 @@ struct altera_tse_private { ...@@ -480,6 +473,10 @@ struct altera_tse_private {
u32 msg_enable; u32 msg_enable;
struct altera_dmaops *dmaops; struct altera_dmaops *dmaops;
struct phylink *phylink;
struct phylink_config phylink_config;
struct phylink_pcs *pcs;
}; };
/* Function prototypes /* Function prototypes
......
...@@ -221,6 +221,22 @@ static void tse_get_regs(struct net_device *dev, struct ethtool_regs *regs, ...@@ -221,6 +221,22 @@ static void tse_get_regs(struct net_device *dev, struct ethtool_regs *regs,
buf[i] = csrrd32(priv->mac_dev, i * 4); buf[i] = csrrd32(priv->mac_dev, i * 4);
} }
static int tse_ethtool_set_link_ksettings(struct net_device *dev,
const struct ethtool_link_ksettings *cmd)
{
struct altera_tse_private *priv = netdev_priv(dev);
return phylink_ethtool_ksettings_set(priv->phylink, cmd);
}
static int tse_ethtool_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{
struct altera_tse_private *priv = netdev_priv(dev);
return phylink_ethtool_ksettings_get(priv->phylink, cmd);
}
static const struct ethtool_ops tse_ethtool_ops = { static const struct ethtool_ops tse_ethtool_ops = {
.get_drvinfo = tse_get_drvinfo, .get_drvinfo = tse_get_drvinfo,
.get_regs_len = tse_reglen, .get_regs_len = tse_reglen,
...@@ -231,8 +247,8 @@ static const struct ethtool_ops tse_ethtool_ops = { ...@@ -231,8 +247,8 @@ static const struct ethtool_ops tse_ethtool_ops = {
.get_ethtool_stats = tse_fill_stats, .get_ethtool_stats = tse_fill_stats,
.get_msglevel = tse_get_msglevel, .get_msglevel = tse_get_msglevel,
.set_msglevel = tse_set_msglevel, .set_msglevel = tse_set_msglevel,
.get_link_ksettings = phy_ethtool_get_link_ksettings, .get_link_ksettings = tse_ethtool_get_link_ksettings,
.set_link_ksettings = phy_ethtool_set_link_ksettings, .set_link_ksettings = tse_ethtool_set_link_ksettings,
.get_ts_info = ethtool_op_get_ts_info, .get_ts_info = ethtool_op_get_ts_info,
}; };
......
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