From: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
To: <netdev@vger.kernel.org>
Cc: <davem@davemloft.net>, <kuba@kernel.org>,
<Bryan.Whitehead@microchip.com>, <linux-kernel@vger.kernel.org>,
<andrew@lunn.ch>, <linux@armlinux.org.uk>,
<UNGLinuxDriver@microchip.com>
Subject: [PATCH net-next V1 3/7] net: lan743x: Add SFP support check flag
Date: Tue, 17 Oct 2023 15:12:04 +0530 [thread overview]
Message-ID: <20231017094208.4956-4-Raju.Lakkaraju@microchip.com> (raw)
In-Reply-To: <20231017094208.4956-1-Raju.Lakkaraju@microchip.com>
PCI11x1x chip support the Pluggable module (SFP) depend on Board requirement.
sfp support information programmed in eeprom.
Flag "is_sfp_support_en" update on "STRAP" register.
Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
---
drivers/net/ethernet/microchip/lan743x_main.c | 27 ++++++++++++++++---
drivers/net/ethernet/microchip/lan743x_main.h | 3 +++
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index e47f0ae1770d..eee3fe7e0c66 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -25,7 +25,7 @@
#define PCS_POWER_STATE_DOWN 0x6
#define PCS_POWER_STATE_UP 0x4
-static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter)
+static int pci11x1x_strap_get_status(struct lan743x_adapter *adapter)
{
u32 chip_rev;
u32 cfg_load;
@@ -38,7 +38,7 @@ static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter)
if (ret < 0) {
netif_err(adapter, drv, adapter->netdev,
"Sys Lock acquire failed ret:%d\n", ret);
- return;
+ return ret;
}
cfg_load = lan743x_csr_read(adapter, ETH_SYS_CONFIG_LOAD_STARTED_REG);
@@ -52,6 +52,11 @@ static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter)
adapter->is_sgmii_en = true;
else
adapter->is_sgmii_en = false;
+
+ if ((strap & STRAP_SFP_USE_EN_) && (strap & STRAP_SFP_EN_))
+ adapter->is_sfp_support_en = true;
+ else
+ adapter->is_sfp_support_en = false;
} else {
chip_rev = lan743x_csr_read(adapter, FPGA_REV);
if (chip_rev) {
@@ -63,8 +68,21 @@ static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter)
adapter->is_sgmii_en = false;
}
}
+
+ if (adapter->is_pci11x1x && !adapter->is_sgmii_en &&
+ adapter->is_sfp_support_en) {
+ netif_err(adapter, drv, adapter->netdev,
+ "Invalid eeprom sgmii support configuration\n");
+ return -EINVAL;
+ }
+
netif_dbg(adapter, drv, adapter->netdev,
"SGMII I/F %sable\n", adapter->is_sgmii_en ? "En" : "Dis");
+ netif_dbg(adapter, drv, adapter->netdev,
+ "SFP support %sable\n", adapter->is_sfp_support_en ?
+ "En" : "Dis");
+
+ return 0;
}
static bool is_pci11x1x_chip(struct lan743x_adapter *adapter)
@@ -3259,7 +3277,9 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
adapter->max_tx_channels = PCI11X1X_MAX_TX_CHANNELS;
adapter->used_tx_channels = PCI11X1X_USED_TX_CHANNELS;
adapter->max_vector_count = PCI11X1X_MAX_VECTOR_COUNT;
- pci11x1x_strap_get_status(adapter);
+ ret = pci11x1x_strap_get_status(adapter);
+ if (ret < 0)
+ return ret;
spin_lock_init(&adapter->eth_syslock_spinlock);
mutex_init(&adapter->sgmii_rw_lock);
} else {
@@ -3414,6 +3434,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 52609fc13ad9..6a3a45b98140 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.h
+++ b/drivers/net/ethernet/microchip/lan743x_main.h
@@ -34,6 +34,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)
@@ -1038,6 +1040,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
next prev parent reply other threads:[~2023-10-17 9:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-17 9:42 [PATCH net-next V1 0/7] Add support to PHYLINK and SFP for PCI11x1x chips Raju Lakkaraju
2023-10-17 9:42 ` [PATCH net-next V1 1/7] net: lan743x: Create separate PCS power reset function Raju Lakkaraju
2023-10-17 9:42 ` [PATCH net-next V1 2/7] net: lan743x: Create separate Link Speed Duplex state function Raju Lakkaraju
2023-10-17 9:42 ` Raju Lakkaraju [this message]
2023-10-17 9:42 ` [PATCH net-next V1 4/7] net: lan743x: Add support to software-nodes for sfp and phylink Raju Lakkaraju
2023-10-17 9:42 ` [PATCH net-next V1 5/7] net: lan743x: Register the platform device for sfp pluggable module Raju Lakkaraju
2023-10-17 9:42 ` [PATCH net-next V1 6/7] net: lan743x: Add support to the phylink framework Raju Lakkaraju
2023-10-17 10:46 ` Russell King (Oracle)
2023-10-17 9:42 ` [PATCH net-next V1 7/7] net: lan743x: Add support to ethtool phylink get and set settings Raju Lakkaraju
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231017094208.4956-4-Raju.Lakkaraju@microchip.com \
--to=raju.lakkaraju@microchip.com \
--cc=Bryan.Whitehead@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).