aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Hoffmann <jan@3e8.eu>2022-07-23 22:53:15 +0200
committerDaniel Golle <daniel@makrotopia.org>2022-07-28 14:08:43 +0200
commitb6a0d50b7fd1ed8d62cc017d9fc5b83f436d3156 (patch)
tree6e6abbdcf7991fdaec5023debd58ec3e7a77f516
parentc6a7ea9f7f49fb805af54e586941f066e0a8786d (diff)
downloadupstream-b6a0d50b7fd1ed8d62cc017d9fc5b83f436d3156.tar.gz
upstream-b6a0d50b7fd1ed8d62cc017d9fc5b83f436d3156.tar.bz2
upstream-b6a0d50b7fd1ed8d62cc017d9fc5b83f436d3156.zip
realtek: add SFP support for RTL8214FC PHY
Probe the SFP module during PHY initialization and implement insertion/removal handlers to automatically configure the media type of the respective port. Suggested-by: Birger Koblitz <git@birger-koblitz.de> Tested-by: Birger Koblitz <mail@birger-koblitz.de> Signed-off-by: Jan Hoffmann <jan@3e8.eu>
-rw-r--r--target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c b/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c
index 70b57924b9..4175b95043 100644
--- a/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c
+++ b/target/linux/realtek/files-5.10/drivers/net/phy/rtl83xx-phy.c
@@ -10,6 +10,7 @@
#include <linux/netdevice.h>
#include <linux/firmware.h>
#include <linux/crc32.h>
+#include <linux/sfp.h>
#include <asm/mach-rtl838x/mach-rtl83xx.h>
#include "rtl83xx-phy.h"
@@ -3676,6 +3677,29 @@ int rtl931x_link_sts_get(u32 sds)
return sts1;
}
+static int rtl8214fc_sfp_insert(void *upstream, const struct sfp_eeprom_id *id)
+{
+ struct phy_device *phydev = upstream;
+
+ rtl8214fc_media_set(phydev, true);
+
+ return 0;
+}
+
+static void rtl8214fc_sfp_remove(void *upstream)
+{
+ struct phy_device *phydev = upstream;
+
+ rtl8214fc_media_set(phydev, false);
+}
+
+static const struct sfp_upstream_ops rtl8214fc_sfp_ops = {
+ .attach = phy_sfp_attach,
+ .detach = phy_sfp_detach,
+ .module_insert = rtl8214fc_sfp_insert,
+ .module_remove = rtl8214fc_sfp_remove,
+};
+
static int rtl8214fc_phy_probe(struct phy_device *phydev)
{
struct device *dev = &phydev->mdio.dev;
@@ -3699,7 +3723,7 @@ static int rtl8214fc_phy_probe(struct phy_device *phydev)
return ret;
}
- return 0;
+ return phy_sfp_probe(phydev, &rtl8214fc_sfp_ops);
}
static int rtl8214c_phy_probe(struct phy_device *phydev)