[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231017094208.4956-6-Raju.Lakkaraju@microchip.com>
Date: Tue, 17 Oct 2023 15:12:06 +0530
From: Raju Lakkaraju <Raju.Lakkaraju@...rochip.com>
To: <netdev@...r.kernel.org>
CC: <davem@...emloft.net>, <kuba@...nel.org>,
<Bryan.Whitehead@...rochip.com>, <linux-kernel@...r.kernel.org>,
<andrew@...n.ch>, <linux@...linux.org.uk>,
<UNGLinuxDriver@...rochip.com>
Subject: [PATCH net-next V1 5/7] net: lan743x: Register the platform device for sfp pluggable module
Add support for sfp pluggable module as platform device handle the gpio
input and output signals and i2c bus access the sfp eeprom data.
Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@...rochip.com>
---
drivers/net/ethernet/microchip/Kconfig | 2 +-
drivers/net/ethernet/microchip/lan743x_main.c | 41 +++++++++++++++++++
drivers/net/ethernet/microchip/lan743x_main.h | 1 +
3 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/microchip/Kconfig b/drivers/net/ethernet/microchip/Kconfig
index c50970705e88..f26368b7b834 100644
--- a/drivers/net/ethernet/microchip/Kconfig
+++ b/drivers/net/ethernet/microchip/Kconfig
@@ -46,12 +46,12 @@ config LAN743X
tristate "LAN743x support"
depends on PCI
depends on PTP_1588_CLOCK_OPTIONAL
- select PHYLIB
select FIXED_PHY
select CRC16
select CRC32
select I2C_PCI1XXXX
select GP_PCI1XXXX
+ select SFP
help
Support for the Microchip LAN743x and PCI11x1x families of PCI
Express Ethernet devices
diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index 71cce7722a21..a4baa00273f7 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -18,6 +18,7 @@
#include <linux/i2c.h>
#include <linux/gpio/machine.h>
#include <linux/auxiliary_bus.h>
+#include <linux/platform_device.h>
#include "lan743x_main.h"
#include "lan743x_ethtool.h"
@@ -3257,6 +3258,31 @@ static int lan743x_swnodes_register(struct lan743x_adapter *adapter)
return software_node_register_node_group(nodes->group);
}
+static int lan743x_sfp_register(struct lan743x_adapter *adapter)
+{
+ struct pci_dev *pdev = adapter->pdev;
+ struct platform_device_info sfp_info;
+ struct platform_device *sfp_dev;
+
+ memset(&sfp_info, 0, sizeof(sfp_info));
+ sfp_info.parent = &adapter->pdev->dev;
+ sfp_info.fwnode = software_node_fwnode(adapter->nodes->group[SWNODE_SFP]);
+ sfp_info.name = "sfp";
+ sfp_info.id = (pdev->bus->number << 8) | pdev->devfn;
+ sfp_dev = platform_device_register_full(&sfp_info);
+ if (IS_ERR(sfp_dev)) {
+ netif_err(adapter, drv, adapter->netdev,
+ "Failed to register SFP device\n");
+ return PTR_ERR(sfp_dev);
+ }
+
+ adapter->sfp_dev = sfp_dev;
+ netif_dbg(adapter, drv, adapter->netdev,
+ "SFP platform device registered");
+
+ return 0;
+}
+
static int lan743x_netdev_close(struct net_device *netdev)
{
struct lan743x_adapter *adapter = netdev_priv(netdev);
@@ -3472,6 +3498,9 @@ static void lan743x_full_cleanup(struct lan743x_adapter *adapter)
{
unregister_netdev(adapter->netdev);
+ if (adapter->sfp_dev)
+ platform_device_unregister(adapter->sfp_dev);
+
if (adapter->i2c_adap)
adapter->i2c_adap = NULL;
@@ -3689,6 +3718,18 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
NETIF_F_HW_CSUM | NETIF_F_RXCSUM;
adapter->netdev->hw_features = adapter->netdev->features;
+ if (adapter->is_sfp_support_en) {
+ adapter->i2c_adap->dev.fwnode =
+ software_node_fwnode(adapter->nodes->group[SWNODE_I2C]);
+
+ ret = lan743x_sfp_register(adapter);
+ if (ret < 0) {
+ netif_err(adapter, probe, netdev,
+ "failed to sfp register (%d)\n", ret);
+ goto cleanup_hardware;
+ }
+ }
+
/* carrier off reporting is important to ethtool even BEFORE open */
netif_carrier_off(netdev);
diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h
index 450d8984cdb5..9746e36baaac 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.h
+++ b/drivers/net/ethernet/microchip/lan743x_main.h
@@ -1082,6 +1082,7 @@ struct lan743x_adapter {
phy_interface_t phy_interface;
struct lan743x_sw_nodes *nodes;
struct i2c_adapter *i2c_adap;
+ struct platform_device *sfp_dev;
};
#define LAN743X_COMPONENT_FLAG_RX(channel) BIT(20 + (channel))
--
2.34.1
Powered by blists - more mailing lists