Skip to content

Commit 293e38f

Browse files
Thangaraj Samynathankuba-moo
authored andcommitted
net: lan743x: Restore SGMII CTRL register on resume
SGMII_CTRL register, which specifies the active interface, was not properly restored when resuming from suspend. This led to incorrect interface selection after resume particularly in scenarios involving the FPGA. To fix this: - Move the SGMII_CTRL setup out of the probe function. - Initialize the register in the hardware initialization helper function, which is called during both device initialization and resume. This ensures the interface configuration is consistently restored after suspend/resume cycles. Fixes: a46d9d3 ("net: lan743x: Add support for SGMII interface") Signed-off-by: Thangaraj Samynathan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent aed031d commit 293e38f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/net/ethernet/microchip/lan743x_main.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3495,6 +3495,7 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
34953495
struct pci_dev *pdev)
34963496
{
34973497
struct lan743x_tx *tx;
3498+
u32 sgmii_ctl;
34983499
int index;
34993500
int ret;
35003501

@@ -3507,6 +3508,15 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
35073508
spin_lock_init(&adapter->eth_syslock_spinlock);
35083509
mutex_init(&adapter->sgmii_rw_lock);
35093510
pci11x1x_set_rfe_rd_fifo_threshold(adapter);
3511+
sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL);
3512+
if (adapter->is_sgmii_en) {
3513+
sgmii_ctl |= SGMII_CTL_SGMII_ENABLE_;
3514+
sgmii_ctl &= ~SGMII_CTL_SGMII_POWER_DN_;
3515+
} else {
3516+
sgmii_ctl &= ~SGMII_CTL_SGMII_ENABLE_;
3517+
sgmii_ctl |= SGMII_CTL_SGMII_POWER_DN_;
3518+
}
3519+
lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl);
35103520
} else {
35113521
adapter->max_tx_channels = LAN743X_MAX_TX_CHANNELS;
35123522
adapter->used_tx_channels = LAN743X_USED_TX_CHANNELS;
@@ -3558,7 +3568,6 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
35583568

35593569
static int lan743x_mdiobus_init(struct lan743x_adapter *adapter)
35603570
{
3561-
u32 sgmii_ctl;
35623571
int ret;
35633572

35643573
adapter->mdiobus = devm_mdiobus_alloc(&adapter->pdev->dev);
@@ -3570,10 +3579,6 @@ static int lan743x_mdiobus_init(struct lan743x_adapter *adapter)
35703579
adapter->mdiobus->priv = (void *)adapter;
35713580
if (adapter->is_pci11x1x) {
35723581
if (adapter->is_sgmii_en) {
3573-
sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL);
3574-
sgmii_ctl |= SGMII_CTL_SGMII_ENABLE_;
3575-
sgmii_ctl &= ~SGMII_CTL_SGMII_POWER_DN_;
3576-
lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl);
35773582
netif_dbg(adapter, drv, adapter->netdev,
35783583
"SGMII operation\n");
35793584
adapter->mdiobus->read = lan743x_mdiobus_read_c22;
@@ -3584,10 +3589,6 @@ static int lan743x_mdiobus_init(struct lan743x_adapter *adapter)
35843589
netif_dbg(adapter, drv, adapter->netdev,
35853590
"lan743x-mdiobus-c45\n");
35863591
} else {
3587-
sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL);
3588-
sgmii_ctl &= ~SGMII_CTL_SGMII_ENABLE_;
3589-
sgmii_ctl |= SGMII_CTL_SGMII_POWER_DN_;
3590-
lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl);
35913592
netif_dbg(adapter, drv, adapter->netdev,
35923593
"RGMII operation\n");
35933594
// Only C22 support when RGMII I/F

0 commit comments

Comments
 (0)