mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 22:14:03 +02:00
Merge branch 'net-lan743x-add-rmii-support-for-pci11x1x'
Thangaraj Samynathan says: ==================== net: lan743x: add RMII support for PCI11x1x From: Thangaraj Samynathan <thangaraj.s@microchip.com> This series adds RMII interface support for the Microchip PCI11x1x Ethernet controller. The PCI11x1x device supports RMII as an alternative MAC-PHY interface, selected via the STRAP_READ software strap register. Patch 1 reads the RMII strap bits from this register and sets the is_rmii_en flag. Patch 2 uses this flag to configure the PHY interface mode, phylink supported interfaces, and enables RMII in hardware via the RMII_CTL register. ==================== Link: https://patch.msgid.link/20260723050827.694832-1-Thangaraj.S@microchip.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
commit
bc03e08039
|
|
@ -42,6 +42,7 @@ static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter)
|
|||
u32 strap;
|
||||
int ret;
|
||||
|
||||
adapter->is_rmii_en = false;
|
||||
/* Timeout = 100 (i.e. 1 sec (10 msce * 100)) */
|
||||
ret = lan743x_hs_syslock_acquire(adapter, 100);
|
||||
if (ret < 0) {
|
||||
|
|
@ -73,8 +74,15 @@ static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter)
|
|||
adapter->is_sgmii_en = false;
|
||||
}
|
||||
}
|
||||
netif_dbg(adapter, drv, adapter->netdev,
|
||||
"SGMII I/F %sable\n", adapter->is_sgmii_en ? "En" : "Dis");
|
||||
|
||||
if (!adapter->is_sgmii_en && strap & STRAP_READ_USE_RMII_EN_) {
|
||||
if (strap & STRAP_READ_RMII_EN_)
|
||||
adapter->is_rmii_en = true;
|
||||
}
|
||||
|
||||
netif_dbg(adapter, drv, adapter->netdev, "Selected I/F: %s\n",
|
||||
adapter->is_sgmii_en ? "SGMII" :
|
||||
adapter->is_rmii_en ? "RMII" : "RGMII");
|
||||
}
|
||||
|
||||
static bool is_pci11x1x_chip(struct lan743x_adapter *adapter)
|
||||
|
|
@ -1394,6 +1402,8 @@ static void lan743x_phy_interface_select(struct lan743x_adapter *adapter)
|
|||
|
||||
if (adapter->is_pci11x1x && adapter->is_sgmii_en)
|
||||
adapter->phy_interface = PHY_INTERFACE_MODE_SGMII;
|
||||
else if (adapter->is_pci11x1x && adapter->is_rmii_en)
|
||||
adapter->phy_interface = PHY_INTERFACE_MODE_RMII;
|
||||
else if (id_rev == ID_REV_ID_LAN7430_)
|
||||
adapter->phy_interface = PHY_INTERFACE_MODE_GMII;
|
||||
else if ((id_rev == ID_REV_ID_LAN7431_) && (data & MAC_CR_MII_EN_))
|
||||
|
|
@ -3182,6 +3192,12 @@ static int lan743x_phylink_create(struct lan743x_adapter *adapter)
|
|||
__set_bit(PHY_INTERFACE_MODE_MII,
|
||||
adapter->phylink_config.supported_interfaces);
|
||||
break;
|
||||
case PHY_INTERFACE_MODE_RMII:
|
||||
__set_bit(PHY_INTERFACE_MODE_RMII,
|
||||
adapter->phylink_config.supported_interfaces);
|
||||
adapter->phylink_config.lpi_capabilities = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
phy_interface_set_rgmii(adapter->phylink_config.supported_interfaces);
|
||||
}
|
||||
|
|
@ -3189,6 +3205,9 @@ static int lan743x_phylink_create(struct lan743x_adapter *adapter)
|
|||
memcpy(adapter->phylink_config.lpi_interfaces,
|
||||
adapter->phylink_config.supported_interfaces,
|
||||
sizeof(adapter->phylink_config.lpi_interfaces));
|
||||
if (adapter->phy_interface == PHY_INTERFACE_MODE_RMII)
|
||||
__clear_bit(PHY_INTERFACE_MODE_RMII,
|
||||
adapter->phylink_config.lpi_interfaces);
|
||||
|
||||
pl = phylink_create(&adapter->phylink_config, NULL,
|
||||
adapter->phy_interface, &lan743x_phylink_mac_ops);
|
||||
|
|
@ -3533,6 +3552,7 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
|
|||
{
|
||||
struct lan743x_tx *tx;
|
||||
u32 sgmii_ctl;
|
||||
u32 rmii_ctl;
|
||||
int index;
|
||||
int ret;
|
||||
|
||||
|
|
@ -3554,6 +3574,12 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
|
|||
sgmii_ctl |= SGMII_CTL_SGMII_POWER_DN_;
|
||||
}
|
||||
lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl);
|
||||
rmii_ctl = lan743x_csr_read(adapter, RMII_CTL);
|
||||
if (adapter->is_rmii_en)
|
||||
rmii_ctl |= RMII_CTL_RMII_ENABLE_;
|
||||
else
|
||||
rmii_ctl &= ~RMII_CTL_RMII_ENABLE_;
|
||||
lan743x_csr_write(adapter, RMII_CTL, rmii_ctl);
|
||||
} else {
|
||||
adapter->max_tx_channels = LAN743X_MAX_TX_CHANNELS;
|
||||
adapter->used_tx_channels = LAN743X_USED_TX_CHANNELS;
|
||||
|
|
@ -3620,8 +3646,9 @@ static int lan743x_mdiobus_init(struct lan743x_adapter *adapter)
|
|||
adapter->mdiobus->name = "lan743x-mdiobus-c45";
|
||||
dev_dbg(&adapter->pdev->dev, "lan743x-mdiobus-c45\n");
|
||||
} else {
|
||||
dev_dbg(&adapter->pdev->dev, "RGMII operation\n");
|
||||
// Only C22 support when RGMII I/F
|
||||
dev_dbg(&adapter->pdev->dev, "%s operation\n",
|
||||
adapter->is_rmii_en ? "RMII" : "RGMII");
|
||||
// Only C22 support when RGMII/RMII I/F
|
||||
adapter->mdiobus->read = lan743x_mdiobus_read_c22;
|
||||
adapter->mdiobus->write = lan743x_mdiobus_write_c22;
|
||||
adapter->mdiobus->name = "lan743x-mdiobus";
|
||||
|
|
|
|||
|
|
@ -36,7 +36,9 @@
|
|||
#define FPGA_SGMII_OP BIT(24)
|
||||
|
||||
#define STRAP_READ (0x0C)
|
||||
#define STRAP_READ_USE_RMII_EN_ BIT(23)
|
||||
#define STRAP_READ_USE_SGMII_EN_ BIT(22)
|
||||
#define STRAP_READ_RMII_EN_ BIT(7)
|
||||
#define STRAP_READ_SGMII_EN_ BIT(6)
|
||||
#define STRAP_READ_SGMII_REFCLK_ BIT(5)
|
||||
#define STRAP_READ_SGMII_2_5G_ BIT(4)
|
||||
|
|
@ -323,6 +325,9 @@
|
|||
#define MAC_WUCSR2_IPV6_TCPSYN_RCD_ BIT(5)
|
||||
#define MAC_WUCSR2_IPV4_TCPSYN_RCD_ BIT(4)
|
||||
|
||||
#define RMII_CTL (0x710)
|
||||
#define RMII_CTL_RMII_ENABLE_ BIT(0)
|
||||
|
||||
#define SGMII_ACC (0x720)
|
||||
#define SGMII_ACC_SGMII_BZY_ BIT(31)
|
||||
#define SGMII_ACC_SGMII_WR_ BIT(30)
|
||||
|
|
@ -1072,6 +1077,7 @@ struct lan743x_adapter {
|
|||
struct lan743x_rx rx[LAN743X_USED_RX_CHANNELS];
|
||||
bool is_pci11x1x;
|
||||
bool is_sgmii_en;
|
||||
bool is_rmii_en;
|
||||
/* protect ethernet syslock */
|
||||
spinlock_t eth_syslock_spinlock;
|
||||
bool eth_syslock_en;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user