[PATCH v4 2/5] net: lan743x: read SFP straps from PCI11x1x device
From: Thangaraj Samynathan
Date: Thu May 14 2026 - 06:52:41 EST
Reads the SFP enable bits from the strap registers to determine
if the hardware is configured for SFP usage.
Introduce CONFIG_LAN743X_SFP to guard SFP-specific code and select
the required peripheral dependencies (I2C_PCI1XXXX, GP_PCI1XXXX, SFP,
PCS_XPCS) only when SFP hardware is present. HWMON is also selected to
support thermal monitoring of SFP modules via the sfp subsystem.
- Add STRAP_SFP_USE_EN_ and STRAP_SFP_EN_ definitions to read SFP
straps.
- Store SFP status in the adapter's is_sfp_support_en flag.
- Add a validation check when SFP support is requested without SGMII_EN
strap; log the invalid combination and force is_sfp_support_en to false
so subsequent SFP/PCS paths are safely skipped.
- Add debug logging for is_sfp_support_en using str_enable_disable()
helper, consistent with the existing PCS debug log.
Signed-off-by: Thangaraj Samynathan <thangaraj.s@xxxxxxxxxxxxx>
---
drivers/net/ethernet/microchip/Kconfig | 15 ++++++++++++
drivers/net/ethernet/microchip/lan743x_main.c | 23 +++++++++++++++++++
drivers/net/ethernet/microchip/lan743x_main.h | 3 +++
3 files changed, 41 insertions(+)
diff --git a/drivers/net/ethernet/microchip/Kconfig b/drivers/net/ethernet/microchip/Kconfig
index ee046468652c..0cc55d00ab52 100644
--- a/drivers/net/ethernet/microchip/Kconfig
+++ b/drivers/net/ethernet/microchip/Kconfig
@@ -57,6 +57,21 @@ config LAN743X
To compile this driver as a module, choose M here. The module will be
called lan743x.
+config LAN743X_SFP
+ bool "SFP support for PCI11x1x"
+ depends on LAN743X
+ select HWMON if LAN743X=y
+ select I2C_PCI1XXXX
+ select GP_PCI1XXXX
+ select SFP
+ select PCS_XPCS
+ help
+ Enable SFP module support for the Microchip PCI11x1x Ethernet
+ controller. Requires the GPIO and I2C peripheral controllers on
+ the PCI11x1x device to be present and probed.
+
+ If unsure, say N.
+
source "drivers/net/ethernet/microchip/lan865x/Kconfig"
source "drivers/net/ethernet/microchip/lan966x/Kconfig"
source "drivers/net/ethernet/microchip/sparx5/Kconfig"
diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index fad4a246e06e..77a554a0432c 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -62,6 +62,14 @@ static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter)
adapter->is_pcs_en = true;
else
adapter->is_pcs_en = false;
+
+#ifdef CONFIG_LAN743X_SFP
+ if ((strap & STRAP_SFP_USE_EN_) && (strap & STRAP_SFP_EN_))
+ adapter->is_sfp_support_en = true;
+ else
+ adapter->is_sfp_support_en = false;
+#endif
+
} else {
fpga_rev = lan743x_csr_read(adapter, FPGA_REV);
if (fpga_rev) {
@@ -73,8 +81,22 @@ static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter)
adapter->is_pcs_en = false;
}
}
+
+#ifdef CONFIG_LAN743X_SFP
+ if (adapter->is_pci11x1x && !adapter->is_pcs_en &&
+ adapter->is_sfp_support_en) {
+ netif_err(adapter, drv, adapter->netdev,
+ "Invalid EEPROM configuration: SFP_EN strap specified without SGMII_EN strap\n");
+ adapter->is_sfp_support_en = false;
+ }
+#endif
+
netif_dbg(adapter, drv, adapter->netdev,
"PCS I/F %s\n", str_enable_disable(adapter->is_pcs_en));
+#ifdef CONFIG_LAN743X_SFP
+ netif_dbg(adapter, drv, adapter->netdev,
+ "SFP support %s\n", str_enable_disable(adapter->is_sfp_support_en));
+#endif
}
static bool is_pci11x1x_chip(struct lan743x_adapter *adapter)
@@ -3665,6 +3687,7 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
NETIF_MSG_LINK | NETIF_MSG_IFUP |
NETIF_MSG_IFDOWN | NETIF_MSG_TX_QUEUED;
netdev->max_mtu = LAN743X_MAX_FRAME_SIZE;
+ adapter->is_sfp_support_en = false;
of_get_mac_address(pdev->dev.of_node, adapter->mac_address);
diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h
index f0fa0580b04e..d9eb10ffac6c 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.h
+++ b/drivers/net/ethernet/microchip/lan743x_main.h
@@ -37,6 +37,8 @@
#define STRAP_READ (0x0C)
#define STRAP_READ_USE_SGMII_EN_ BIT(22)
+#define STRAP_SFP_USE_EN_ BIT(31)
+#define STRAP_SFP_EN_ BIT(15)
#define STRAP_READ_SGMII_EN_ BIT(6)
#define STRAP_READ_SGMII_REFCLK_ BIT(5)
#define STRAP_READ_SGMII_2_5G_ BIT(4)
@@ -1081,6 +1083,7 @@ struct lan743x_adapter {
u8 max_tx_channels;
u8 used_tx_channels;
u8 max_vector_count;
+ bool is_sfp_support_en;
#define LAN743X_ADAPTER_FLAG_OTP BIT(0)
u32 flags;
--
2.34.1