Skip to content

Commit fef2998

Browse files
minimaxwelldavem330
authored andcommitted
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: Maxime Chevallier <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4a502cf commit fef2998

File tree

4 files changed

+141
-314
lines changed

4 files changed

+141
-314
lines changed

drivers/net/ethernet/altera/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ config ALTERA_TSE
33
tristate "Altera Triple-Speed Ethernet MAC support"
44
depends on HAS_DMA
55
select PHYLIB
6+
select PHYLINK
7+
select PCS_ALTERA_TSE
68
help
79
This driver supports the Altera Triple-Speed (TSE) Ethernet MAC.
810

drivers/net/ethernet/altera/altera_tse.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/list.h>
2828
#include <linux/netdevice.h>
2929
#include <linux/phy.h>
30+
#include <linux/phylink.h>
3031

3132
#define ALTERA_TSE_SW_RESET_WATCHDOG_CNTR 10000
3233
#define ALTERA_TSE_MAC_FIFO_WIDTH 4 /* TX/RX FIFO width in
@@ -109,17 +110,6 @@
109110
#define MAC_CMDCFG_DISABLE_READ_TIMEOUT_GET(v) GET_BIT_VALUE(v, 27)
110111
#define MAC_CMDCFG_CNT_RESET_GET(v) GET_BIT_VALUE(v, 31)
111112

112-
/* SGMII PCS register addresses
113-
*/
114-
#define SGMII_PCS_SCRATCH 0x10
115-
#define SGMII_PCS_REV 0x11
116-
#define SGMII_PCS_LINK_TIMER_0 0x12
117-
#define SGMII_PCS_LINK_TIMER_1 0x13
118-
#define SGMII_PCS_IF_MODE 0x14
119-
#define SGMII_PCS_DIS_READ_TO 0x15
120-
#define SGMII_PCS_READ_TO 0x16
121-
#define SGMII_PCS_SW_RESET_TIMEOUT 100 /* usecs */
122-
123113
/* MDIO registers within MAC register Space
124114
*/
125115
struct altera_tse_mdio {
@@ -423,6 +413,9 @@ struct altera_tse_private {
423413
void __iomem *tx_dma_csr;
424414
void __iomem *tx_dma_desc;
425415

416+
/* SGMII PCS address space */
417+
void __iomem *pcs_base;
418+
426419
/* Rx buffers queue */
427420
struct tse_buffer *rx_ring;
428421
u32 rx_cons;
@@ -480,6 +473,10 @@ struct altera_tse_private {
480473
u32 msg_enable;
481474

482475
struct altera_dmaops *dmaops;
476+
477+
struct phylink *phylink;
478+
struct phylink_config phylink_config;
479+
struct phylink_pcs *pcs;
483480
};
484481

485482
/* Function prototypes

drivers/net/ethernet/altera/altera_tse_ethtool.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,22 @@ static void tse_get_regs(struct net_device *dev, struct ethtool_regs *regs,
221221
buf[i] = csrrd32(priv->mac_dev, i * 4);
222222
}
223223

224+
static int tse_ethtool_set_link_ksettings(struct net_device *dev,
225+
const struct ethtool_link_ksettings *cmd)
226+
{
227+
struct altera_tse_private *priv = netdev_priv(dev);
228+
229+
return phylink_ethtool_ksettings_set(priv->phylink, cmd);
230+
}
231+
232+
static int tse_ethtool_get_link_ksettings(struct net_device *dev,
233+
struct ethtool_link_ksettings *cmd)
234+
{
235+
struct altera_tse_private *priv = netdev_priv(dev);
236+
237+
return phylink_ethtool_ksettings_get(priv->phylink, cmd);
238+
}
239+
224240
static const struct ethtool_ops tse_ethtool_ops = {
225241
.get_drvinfo = tse_get_drvinfo,
226242
.get_regs_len = tse_reglen,
@@ -231,8 +247,8 @@ static const struct ethtool_ops tse_ethtool_ops = {
231247
.get_ethtool_stats = tse_fill_stats,
232248
.get_msglevel = tse_get_msglevel,
233249
.set_msglevel = tse_set_msglevel,
234-
.get_link_ksettings = phy_ethtool_get_link_ksettings,
235-
.set_link_ksettings = phy_ethtool_set_link_ksettings,
250+
.get_link_ksettings = tse_ethtool_get_link_ksettings,
251+
.set_link_ksettings = tse_ethtool_set_link_ksettings,
236252
.get_ts_info = ethtool_op_get_ts_info,
237253
};
238254

0 commit comments

Comments
 (0)