net: phy: Add Airoha phy library for shared code

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>
This commit is contained in:
Louis-Alexis Eyraud
2026-05-26 16:58:07 +02:00
committed by Jakub Kicinski
parent ed28bd094d
commit dddfadd751
5 changed files with 57 additions and 11 deletions
+6
View 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
+1
View 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/
+2 -11
View 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)
{
+32
View File
@@ -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");
+16
View File
@@ -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 */