Skip to content

Commit a4414dd

Browse files
Jiawen Wudavem330
authored andcommitted
net: txgbe: support switching mode to 1000BASE-X and SGMII
Disable data path before PCS VR reset while switching PCS mode, to prevent the blocking of data path. Enable AN interrupt for CL37 auto-negotiation. Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ab928c2 commit a4414dd

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

drivers/net/ethernet/wangxun/libwx/wx_type.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@
205205
#define WX_TSC_CTL 0x1D000
206206
#define WX_TSC_CTL_TX_DIS BIT(1)
207207
#define WX_TSC_CTL_TSEC_DIS BIT(0)
208+
#define WX_TSC_ST 0x1D004
209+
#define WX_TSC_ST_SECTX_RDY BIT(0)
208210
#define WX_TSC_BUF_AE 0x1D00C
209211
#define WX_TSC_BUF_AE_THR GENMASK(9, 0)
210212

drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,34 @@
1313
#include "txgbe_type.h"
1414
#include "txgbe_hw.h"
1515

16+
/**
17+
* txgbe_disable_sec_tx_path - Stops the transmit data path
18+
* @wx: pointer to hardware structure
19+
*
20+
* Stops the transmit data path and waits for the HW to internally empty
21+
* the tx security block
22+
**/
23+
int txgbe_disable_sec_tx_path(struct wx *wx)
24+
{
25+
int val;
26+
27+
wr32m(wx, WX_TSC_CTL, WX_TSC_CTL_TX_DIS, WX_TSC_CTL_TX_DIS);
28+
return read_poll_timeout(rd32, val, val & WX_TSC_ST_SECTX_RDY,
29+
1000, 20000, false, wx, WX_TSC_ST);
30+
}
31+
32+
/**
33+
* txgbe_enable_sec_tx_path - Enables the transmit data path
34+
* @wx: pointer to hardware structure
35+
*
36+
* Enables the transmit data path.
37+
**/
38+
void txgbe_enable_sec_tx_path(struct wx *wx)
39+
{
40+
wr32m(wx, WX_TSC_CTL, WX_TSC_CTL_TX_DIS, 0);
41+
WX_WRITE_FLUSH(wx);
42+
}
43+
1644
/**
1745
* txgbe_init_thermal_sensor_thresh - Inits thermal sensor thresholds
1846
* @wx: pointer to hardware structure

drivers/net/ethernet/wangxun/txgbe/txgbe_hw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#ifndef _TXGBE_HW_H_
55
#define _TXGBE_HW_H_
66

7+
int txgbe_disable_sec_tx_path(struct wx *wx);
8+
void txgbe_enable_sec_tx_path(struct wx *wx);
79
int txgbe_read_pba_string(struct wx *wx, u8 *pba_num, u32 pba_num_size);
810
int txgbe_validate_eeprom_checksum(struct wx *wx, u16 *checksum_val);
911
int txgbe_reset_hw(struct wx *wx);

drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "../libwx/wx_hw.h"
1919
#include "txgbe_type.h"
2020
#include "txgbe_phy.h"
21+
#include "txgbe_hw.h"
2122

2223
static int txgbe_swnodes_register(struct txgbe *txgbe)
2324
{
@@ -210,8 +211,32 @@ static void txgbe_mac_link_up(struct phylink_config *config,
210211
wr32(wx, WX_MAC_WDG_TIMEOUT, wdg);
211212
}
212213

214+
static int txgbe_mac_prepare(struct phylink_config *config, unsigned int mode,
215+
phy_interface_t interface)
216+
{
217+
struct wx *wx = netdev_priv(to_net_dev(config->dev));
218+
219+
wr32m(wx, WX_MAC_TX_CFG, WX_MAC_TX_CFG_TE, 0);
220+
wr32m(wx, WX_MAC_RX_CFG, WX_MAC_RX_CFG_RE, 0);
221+
222+
return txgbe_disable_sec_tx_path(wx);
223+
}
224+
225+
static int txgbe_mac_finish(struct phylink_config *config, unsigned int mode,
226+
phy_interface_t interface)
227+
{
228+
struct wx *wx = netdev_priv(to_net_dev(config->dev));
229+
230+
txgbe_enable_sec_tx_path(wx);
231+
wr32m(wx, WX_MAC_RX_CFG, WX_MAC_RX_CFG_RE, WX_MAC_RX_CFG_RE);
232+
233+
return 0;
234+
}
235+
213236
static const struct phylink_mac_ops txgbe_mac_ops = {
214237
.mac_select_pcs = txgbe_phylink_mac_select,
238+
.mac_prepare = txgbe_mac_prepare,
239+
.mac_finish = txgbe_mac_finish,
215240
.mac_config = txgbe_mac_config,
216241
.mac_link_down = txgbe_mac_link_down,
217242
.mac_link_up = txgbe_mac_link_up,
@@ -234,6 +259,8 @@ static int txgbe_phylink_init(struct txgbe *txgbe)
234259
config->mac_capabilities = MAC_10000FD | MAC_1000FD | MAC_SYM_PAUSE | MAC_ASYM_PAUSE;
235260
phy_mode = PHY_INTERFACE_MODE_10GBASER;
236261
__set_bit(PHY_INTERFACE_MODE_10GBASER, config->supported_interfaces);
262+
__set_bit(PHY_INTERFACE_MODE_1000BASEX, config->supported_interfaces);
263+
__set_bit(PHY_INTERFACE_MODE_SGMII, config->supported_interfaces);
237264
fwnode = software_node_fwnode(txgbe->nodes.group[SWNODE_PHYLINK]);
238265
phylink = phylink_create(config, fwnode, phy_mode, &txgbe_mac_ops);
239266
if (IS_ERR(phylink))
@@ -431,7 +458,8 @@ static void txgbe_irq_handler(struct irq_desc *desc)
431458

432459
chained_irq_exit(chip, desc);
433460

434-
if (eicr & (TXGBE_PX_MISC_ETH_LK | TXGBE_PX_MISC_ETH_LKDN)) {
461+
if (eicr & (TXGBE_PX_MISC_ETH_LK | TXGBE_PX_MISC_ETH_LKDN |
462+
TXGBE_PX_MISC_ETH_AN)) {
435463
u32 reg = rd32(wx, TXGBE_CFG_PORT_ST);
436464

437465
phylink_mac_change(txgbe->phylink, !!(reg & TXGBE_CFG_PORT_ST_LINK_UP));

0 commit comments

Comments
 (0)