ipq40xx: qca807x: adapt for 6.1
[openwrt/staging/jow.git] / target / linux / ipq40xx / files / drivers / net / phy / qca807x.c
index 94d5b83a7c908c3da6a5a21968707e80918303c1..abfc11e121c1bf7ac5099c1427f46d12f2b2ff8a 100644 (file)
@@ -12,9 +12,7 @@
 #include <linux/of.h>
 #include <linux/phy.h>
 #include <linux/bitfield.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)
 #include <linux/ethtool_netlink.h>
-#endif
 #include <linux/gpio.h>
 #include <linux/sfp.h>
 
@@ -191,7 +189,6 @@ static int qca807x_set_tunable(struct phy_device *phydev,
        }
 }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)
 static bool qca807x_distance_valid(int result)
 {
        switch (result) {
@@ -324,16 +321,11 @@ static int qca807x_cable_test_start(struct phy_device *phydev)
 
        return ret;
 }
-#endif
 
 #ifdef CONFIG_GPIOLIB
 static int qca807x_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,5,0)
        return GPIO_LINE_DIRECTION_OUT;
-#else
-       return GPIOF_DIR_OUT;
-#endif
 }
 
 static int qca807x_gpio_get_reg(unsigned int offset)
@@ -584,16 +576,6 @@ static int qca807x_config_intr(struct phy_device *phydev)
        return ret;
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5,12,0)
-static int qca807x_ack_intr(struct phy_device *phydev)
-{
-       int ret;
-
-       ret = phy_read(phydev, QCA807X_INTR_STATUS);
-
-       return (ret < 0) ? ret : 0;
-}
-#else
 static irqreturn_t qca807x_handle_interrupt(struct phy_device *phydev)
 {
        int irq_status, int_enabled;
@@ -619,7 +601,6 @@ static irqreturn_t qca807x_handle_interrupt(struct phy_device *phydev)
 
        return IRQ_HANDLED;
 }
-#endif
 
 static int qca807x_led_config(struct phy_device *phydev)
 {
@@ -663,8 +644,13 @@ static int qca807x_sfp_insert(void *upstream, const struct sfp_eeprom_id *id)
        __ETHTOOL_DECLARE_LINK_MODE_MASK(support) = { 0, };
        phy_interface_t iface;
        int ret;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0)
+       DECLARE_PHY_INTERFACE_MASK(interfaces);
 
+       sfp_parse_support(phydev->sfp_bus, id, support, interfaces);
+#else
        sfp_parse_support(phydev->sfp_bus, id, support);
+#endif
        iface = sfp_select_interface(phydev->sfp_bus, support);
 
        dev_info(&phydev->mdio.dev, "%s SFP module inserted\n", phy_modes(iface));
@@ -804,54 +790,38 @@ static struct phy_driver qca807x_drivers[] = {
        {
                PHY_ID_MATCH_EXACT(PHY_ID_QCA8072),
                .name           = "Qualcomm QCA8072",
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)
                .flags          = PHY_POLL_CABLE_TEST,
-#endif
                /* PHY_GBIT_FEATURES */
                .probe          = qca807x_probe,
                .config_init    = qca807x_config,
                .read_status    = qca807x_read_status,
                .config_intr    = qca807x_config_intr,
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5,12,0)
-               .ack_interrupt  = qca807x_ack_intr,
-#else
                .handle_interrupt = qca807x_handle_interrupt,
-#endif
                .soft_reset     = genphy_soft_reset,
                .get_tunable    = qca807x_get_tunable,
                .set_tunable    = qca807x_set_tunable,
                .resume         = genphy_resume,
                .suspend        = genphy_suspend,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)
                .cable_test_start       = qca807x_cable_test_start,
                .cable_test_get_status  = qca807x_cable_test_get_status,
-#endif
        },
        {
                PHY_ID_MATCH_EXACT(PHY_ID_QCA8075),
                .name           = "Qualcomm QCA8075",
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)
                .flags          = PHY_POLL_CABLE_TEST,
-#endif
                /* PHY_GBIT_FEATURES */
                .probe          = qca807x_probe,
                .config_init    = qca807x_config,
                .read_status    = qca807x_read_status,
                .config_intr    = qca807x_config_intr,
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5,12,0)
-               .ack_interrupt  = qca807x_ack_intr,
-#else
                .handle_interrupt = qca807x_handle_interrupt,
-#endif
                .soft_reset     = genphy_soft_reset,
                .get_tunable    = qca807x_get_tunable,
                .set_tunable    = qca807x_set_tunable,
                .resume         = genphy_resume,
                .suspend        = genphy_suspend,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)
                .cable_test_start       = qca807x_cable_test_start,
                .cable_test_get_status  = qca807x_cable_test_get_status,
-#endif
        },
        {
                PHY_ID_MATCH_EXACT(PHY_ID_QCA807X_PSGMII),