]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: phy: Add Airoha phy library for shared code
authorLouis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
Tue, 26 May 2026 14:58:07 +0000 (16:58 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 28 May 2026 01:39:24 +0000 (18:39 -0700)
In preparation of Airoha AN8801R PHY support, split out the interface
functions that will be common between the already present air_en8811h
driver and the new one, and put them into a new library named
air_phy_lib.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
Link: https://patch.msgid.link/20260526-add-airoha-an8801-support-v5-2-01aea8dee69b@collabora.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/Kconfig
drivers/net/phy/Makefile
drivers/net/phy/air_en8811h.c
drivers/net/phy/air_phy_lib.c [new file with mode: 0644]
drivers/net/phy/air_phy_lib.h [new file with mode: 0644]

index 8b51bdc2e945ea327711cc3484ace11e2c0f4258..d969a792beb51a1f1937181e635532b322d34a23 100644 (file)
@@ -92,10 +92,16 @@ config AS21XXX_PHY
 
 config AIR_EN8811H_PHY
        tristate "Airoha EN8811H 2.5 Gigabit PHY"
+       select AIR_NET_PHYLIB
        select PHY_COMMON_PROPS
        help
          Currently supports the Airoha EN8811H PHY.
 
+config AIR_NET_PHYLIB
+       tristate
+       help
+         Airoha Ethernet PHY common library
+
 config AMD_PHY
        tristate "AMD and Altima PHYs"
        help
index 05e4878af27abeae3dfd9ab18fd29f8bf788b2a4..7cf1fa9e12cb6073a9e68c0ffa6284b361b80487 100644 (file)
@@ -30,6 +30,7 @@ obj-y                         += $(sfp-obj-y) $(sfp-obj-m)
 obj-$(CONFIG_ADIN_PHY)         += adin.o
 obj-$(CONFIG_ADIN1100_PHY)     += adin1100.o
 obj-$(CONFIG_AIR_EN8811H_PHY)   += air_en8811h.o
+obj-$(CONFIG_AIR_NET_PHYLIB)   += air_phy_lib.o
 obj-$(CONFIG_AMD_PHY)          += amd.o
 obj-$(CONFIG_AMCC_QT2025_PHY)  += qt2025.o
 obj-$(CONFIG_AQUANTIA_PHY)     += aquantia/
index 29ae73e65caaa9cdebe2253b5349aa6c7478dc85..be7c3426182a26fe3799b875827750e7772caadd 100644 (file)
@@ -21,6 +21,8 @@
 #include <linux/wordpart.h>
 #include <linux/unaligned.h>
 
+#include "air_phy_lib.h"
+
 #define EN8811H_PHY_ID         0x03a2a411
 #define AN8811HB_PHY_ID                0xc0ff04a0
 
@@ -40,7 +42,6 @@
 #define   AIR_AUX_CTRL_STATUS_SPEED_1000       0x8
 #define   AIR_AUX_CTRL_STATUS_SPEED_2500       0xc
 
-#define AIR_EXT_PAGE_ACCESS            0x1f
 #define   AIR_PHY_PAGE_STANDARD                        0x0000
 #define   AIR_PHY_PAGE_EXTENDED_4              0x0004
 
@@ -244,16 +245,6 @@ static const unsigned long en8811h_led_trig = BIT(TRIGGER_NETDEV_FULL_DUPLEX) |
                                              BIT(TRIGGER_NETDEV_RX)          |
                                              BIT(TRIGGER_NETDEV_TX);
 
-static int air_phy_read_page(struct phy_device *phydev)
-{
-       return __phy_read(phydev, AIR_EXT_PAGE_ACCESS);
-}
-
-static int air_phy_write_page(struct phy_device *phydev, int page)
-{
-       return __phy_write(phydev, AIR_EXT_PAGE_ACCESS, page);
-}
-
 static int __air_buckpbus_reg_write(struct phy_device *phydev,
                                    u32 pbus_address, u32 pbus_data)
 {
diff --git a/drivers/net/phy/air_phy_lib.c b/drivers/net/phy/air_phy_lib.c
new file mode 100644 (file)
index 0000000..8ef5af4
--- /dev/null
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Airoha Ethernet PHY common library
+ *
+ * Copyright (C) 2026 Airoha Technology Corp.
+ * Copyright (C) 2026 Collabora Ltd.
+ *                    Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
+ */
+
+#include <linux/export.h>
+#include <linux/module.h>
+#include <linux/phy.h>
+
+#include "air_phy_lib.h"
+
+#define AIR_EXT_PAGE_ACCESS            0x1f
+
+int air_phy_read_page(struct phy_device *phydev)
+{
+       return __phy_read(phydev, AIR_EXT_PAGE_ACCESS);
+}
+EXPORT_SYMBOL_GPL(air_phy_read_page);
+
+int air_phy_write_page(struct phy_device *phydev, int page)
+{
+       return __phy_write(phydev, AIR_EXT_PAGE_ACCESS, page);
+}
+EXPORT_SYMBOL_GPL(air_phy_write_page);
+
+MODULE_DESCRIPTION("Airoha PHY Library");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Louis-Alexis Eyraud");
diff --git a/drivers/net/phy/air_phy_lib.h b/drivers/net/phy/air_phy_lib.h
new file mode 100644 (file)
index 0000000..79367e8
--- /dev/null
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2026 Airoha Technology Corp.
+ * Copyright (C) 2026 Collabora Ltd.
+ *                    Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
+ */
+
+#ifndef __AIR_PHY_LIB_H
+#define __AIR_PHY_LIB_H
+
+#include <linux/phy.h>
+
+int air_phy_read_page(struct phy_device *phydev);
+int air_phy_write_page(struct phy_device *phydev, int page);
+
+#endif /* __AIR_PHY_LIB_H */