net: phy: Add support for new Aeonsemi PHYs
Subsystems (7)
Christian Marangi
maintainerv3 cover net: phy: Add support for new Aeonsemi PHYs
Add support for new Aeonsemi 10G C45 PHYs. These PHYs intergate an IPC to setup some configuration and require special handling to sync with the parity bit. The parity bit is a way the IPC use to follow correct order of command sent.
Supported PHYs AS21011JB1, AS21011PB1, AS21010JB1, AS21010PB1, AS21511JB1, AS21511PB1, AS21510JB1, AS21510PB1, AS21210JB1, AS21210PB1 that all register with the PHY ID 0x7500 0x7500 before the firmware is loaded.
The big special thing about this PHY is that it does provide a generic PHY ID in C45 register that change to the correct one one the firmware is loaded.
In practice:
- MMD 0x7 ID 0x7500 0x9410 -> FW LOAD -> ID 0x7500 0x9422
To handle this, we operate on .match_phy_device where we check the PHY ID, if the ID match the generic one, we load the firmware and we return 0 (PHY driver doesn't match). Then PHY core will try the next PHY driver in the list and this time the PHY is correctly filled in and we register for it.
To help in the matching and not modify part of the PHY device struct, .match_phy_device is extended to provide also the current phy_driver is trying to match for. This add the extra benefits that some other PHY can simplify their .match_phy_device OP.
Changes v3:
- Correct typo intergate->intergate
- Try to reduce to 80 column (where possible... define become unreasable if split)
- Rework to new .match_phy_device implementation
- Init active_low_led and fix other minor smatch war
- Drop inline tag (kbot doesn't like it but not reported by checkpatch???) Changes v2:
- Move to RFC as net-next closed :(
- Add lock for IPC command
- Better check size values from IPC
- Add PHY ID for all supported PHYs
- Drop .get_feature (correct values are exported by standard regs)
- Rework LED event to enum
- Update .yaml with changes requested (firmware-name required for generic PHY ID)
- Better document C22 in C45
- Document PHY name logic
- Introduce patch to load PHY 2 times
Christian Marangi (4):
net: phy: pass PHY driver to .match_phy_device OP
net: phy: bcm87xx: simplify .match_phy_device OP
net: phy: Add support for Aeonsemi AS21xxx PHYs
dt-bindings: net: Document support for Aeonsemi PHYs
.../bindings/net/aeonsemi,as21xxx.yaml | 122 ++ MAINTAINERS | 7 + drivers/net/phy/Kconfig | 12 + drivers/net/phy/Makefile | 1 + drivers/net/phy/as21xxx.c | 1048 +++++++++++++++++ drivers/net/phy/bcm87xx.c | 14 +- drivers/net/phy/icplus.c | 6 +- drivers/net/phy/marvell10g.c | 12 +- drivers/net/phy/micrel.c | 6 +- drivers/net/phy/nxp-tja11xx.c | 6 +- drivers/net/phy/phy_device.c | 2 +- drivers/net/phy/realtek/realtek_main.c | 27 +- drivers/net/phy/teranetics.c | 3 +- include/linux/phy.h | 3 +- 14 files changed, 1238 insertions(+), 31 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/aeonsemi,as21xxx.yaml create mode 100644 drivers/net/phy/as21xxx.c
Signature · 1 line
2.48.1
Christian Marangi
maintainerRFC PATCH v3 1/4 net: phy: pass PHY driver to .match_phy_device OP
Pass PHY driver pointer to .match_phy_device OP in addition to phydev. Having access to the PHY driver struct might be useful to check the PHY ID of the driver is being matched for in case the PHY ID scanned in the phydev is not consistent.
A scenario for this is a PHY that change PHY ID after a firmware is loaded, in such case, the PHY ID stored in PHY device struct is not valid anymore and PHY will manually scan the ID in the match_phy_device function.
Having the PHY driver info is also useful for those PHY driver that implement multiple simple .match_phy_device OP to match specific MMD PHY ID. With this extra info if the parsing logic is the same, the matching function can be generalized by using the phy_id in the PHY driver instead of hardcoding.
--- drivers/net/phy/bcm87xx.c | 6 ++++-- drivers/net/phy/icplus.c | 6 ++++-- drivers/net/phy/marvell10g.c | 12 ++++++++---- drivers/net/phy/micrel.c | 6 ++++-- drivers/net/phy/nxp-tja11xx.c | 6 ++++-- drivers/net/phy/phy_device.c | 2 +- drivers/net/phy/realtek/realtek_main.c | 27 +++++++++++++++++--------- drivers/net/phy/teranetics.c | 3 ++- include/linux/phy.h | 3 ++- 9 files changed, 47 insertions(+), 24 deletions(-)
drivers/net/phy/bcm87xx.c +4 -2
@@ -185,12 +185,14 @@ static irqreturn_t bcm87xx_handle_interrupt(struct phy_device *phydev)return IRQ_HANDLED ; } -static int bcm8706_match_phy_device (struct phy_device *phydev) +static int bcm8706_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return phydev->c45_ids.device_ids[4 ] ==PHY_ID_BCM8706 ; } -static int bcm8727_match_phy_device (struct phy_device *phydev) +static int bcm8727_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return phydev->c45_ids.device_ids[4 ] ==PHY_ID_BCM8727 ; }
drivers/net/phy/icplus.c +4 -2
@@ -520,12 +520,14 @@ static int ip101a_g_match_phy_device(struct phy_device *phydev, bool ip101a)return ip101a == !ret; } -static int ip101a_match_phy_device (struct phy_device *phydev) +static int ip101a_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return ip101a_g_match_phy_device (phydev, true); } -static int ip101g_match_phy_device (struct phy_device *phydev) +static int ip101g_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return ip101a_g_match_phy_device (phydev, false); }
drivers/net/phy/marvell10g.c +8 -4
@@ -1284,7 +1284,8 @@ static int mv3310_get_number_of_ports(struct phy_device *phydev)return ret +1 ; } -static int mv3310_match_phy_device (struct phy_device *phydev) +static int mv3310_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {if ((phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD ] &MARVELL_PHY_ID_MASK ) !=MARVELL_PHY_ID_88X3310 )
@@ -1293,7 +1294,8 @@ static int mv3310_match_phy_device(struct phy_device *phydev)return mv3310_get_number_of_ports (phydev) ==1 ; } -static int mv3340_match_phy_device (struct phy_device *phydev) +static int mv3340_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {if ((phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD ] &MARVELL_PHY_ID_MASK ) !=MARVELL_PHY_ID_88X3310 )
@@ -1317,12 +1319,14 @@ static int mv211x_match_phy_device(struct phy_device *phydev, bool has_5g)return !!(val &MDIO_PCS_SPEED_5G ) == has_5g; } -static int mv2110_match_phy_device (struct phy_device *phydev) +static int mv2110_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return mv211x_match_phy_device (phydev, true); } -static int mv2111_match_phy_device (struct phy_device *phydev) +static int mv2111_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return mv211x_match_phy_device (phydev, false); }
drivers/net/phy/micrel.c +4 -2
@@ -766,7 +766,8 @@ static int ksz8051_ksz8795_match_phy_device(struct phy_device *phydev,return !ret; } -static int ksz8051_match_phy_device (struct phy_device *phydev) +static int ksz8051_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return ksz8051_ksz8795_match_phy_device (phydev, true); }
@@ -886,7 +887,8 @@ static int ksz8061_config_init(struct phy_device *phydev)return kszphy_config_init (phydev); } -static int ksz8795_match_phy_device (struct phy_device *phydev) +static int ksz8795_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return ksz8051_ksz8795_match_phy_device (phydev, false); }
drivers/net/phy/nxp-tja11xx.c +4 -2
@@ -646,12 +646,14 @@ static int tja1102_match_phy_device(struct phy_device *phydev, bool port0)return !ret; } -static int tja1102_p0_match_phy_device (struct phy_device *phydev) +static int tja1102_p0_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return tja1102_match_phy_device (phydev, true); } -static int tja1102_p1_match_phy_device (struct phy_device *phydev) +static int tja1102_p1_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return tja1102_match_phy_device (phydev, false); }
drivers/net/phy/phy_device.c +1 -1
@@ -511,7 +511,7 @@ static int phy_bus_match(struct device *dev, const struct device_driver *drv)return 0 ;if (phydrv->match_phy_device) -return phydrv->match_phy_device (phydev); +return phydrv->match_phy_device (phydev, phydrv);if (phydev->is_c45) {for (i =1 ; i < num_ids; i++) {
drivers/net/phy/realtek/realtek_main.c +18 -9
@@ -1114,13 +1114,15 @@ static bool rtlgen_supports_mmd(struct phy_device *phydev)return val >0 ; } -static int rtlgen_match_phy_device (struct phy_device *phydev) +static int rtlgen_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return phydev->phy_id ==RTL_GENERIC_PHYID && !rtlgen_supports_2_5gbps (phydev); } -static int rtl8226_match_phy_device (struct phy_device *phydev) +static int rtl8226_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return phydev->phy_id ==RTL_GENERIC_PHYID && rtlgen_supports_2_5gbps(phydev) &&
@@ -1136,32 +1138,38 @@ static int rtlgen_is_c45_match(struct phy_device *phydev, unsigned int id,return !is_c45 && (id == phydev->phy_id); } -static int rtl8221b_match_phy_device (struct phy_device *phydev) +static int rtl8221b_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return phydev->phy_id ==RTL_8221B &&rtlgen_supports_mmd (phydev); } -static int rtl8221b_vb_cg_c22_match_phy_device (struct phy_device *phydev) +static int rtl8221b_vb_cg_c22_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return rtlgen_is_c45_match (phydev,RTL_8221B_VB_CG , false); } -static int rtl8221b_vb_cg_c45_match_phy_device (struct phy_device *phydev) +static int rtl8221b_vb_cg_c45_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return rtlgen_is_c45_match (phydev,RTL_8221B_VB_CG , true); } -static int rtl8221b_vn_cg_c22_match_phy_device (struct phy_device *phydev) +static int rtl8221b_vn_cg_c22_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return rtlgen_is_c45_match (phydev,RTL_8221B_VN_CG , false); } -static int rtl8221b_vn_cg_c45_match_phy_device (struct phy_device *phydev) +static int rtl8221b_vn_cg_c45_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return rtlgen_is_c45_match (phydev,RTL_8221B_VN_CG , true); } -static int rtl_internal_nbaset_match_phy_device (struct phy_device *phydev) +static int rtl_internal_nbaset_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {if (phydev->is_c45)return false;
@@ -1179,7 +1187,8 @@ static int rtl_internal_nbaset_match_phy_device(struct phy_device *phydev)return rtlgen_supports_2_5gbps (phydev) && !rtlgen_supports_mmd (phydev); } -static int rtl8251b_c45_match_phy_device (struct phy_device *phydev) +static int rtl8251b_c45_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return rtlgen_is_c45_match (phydev,RTL_8251B , true); }
drivers/net/phy/teranetics.c +2 -1
@@ -67,7 +67,8 @@ static int teranetics_read_status(struct phy_device *phydev)return 0 ; } -static int teranetics_match_phy_device (struct phy_device *phydev) +static int teranetics_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) {return phydev->c45_ids.device_ids[3 ] ==PHY_ID_TN2020 ; }
include/linux/phy.h +2 -1
@@ -1042,7 +1042,8 @@ struct phy_driver {* driver for the given phydev. If NULL, matching is based on * phy_id and phy_id_mask. */ -int (*match_phy_device)(struct phy_device *phydev); +int (*match_phy_device)(struct phy_device *phydev, +const struct phy_driver *phydrv);/** * @set_wol: Some devices (e.g. qnap TS-119P II) require PHY
Signature · 1 line
2.48.1
Christian Marangi
maintainerRFC PATCH v3 2/4 net: phy: bcm87xx: simplify .match_phy_device OP
In reply to Christian MarangiSimplify .match_phy_device OP by using a generic function and using the new phy_id PHY driver info instead of hardcoding the matching PHY ID.
--- drivers/net/phy/bcm87xx.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/net/phy/bcm87xx.c +4 -10
@@ -185,16 +185,10 @@ static irqreturn_t bcm87xx_handle_interrupt(struct phy_device *phydev)return IRQ_HANDLED ; } -static int bcm8706_match_phy_device (struct phy_device *phydev, +static int bcm87xx_match_phy_device (struct phy_device *phydev,const struct phy_driver *phydrv) { -return phydev->c45_ids.device_ids[4 ] ==PHY_ID_BCM8706 ; -} - -static int bcm8727_match_phy_device (struct phy_device *phydev, -const struct phy_driver *phydrv) -{ -return phydev->c45_ids.device_ids[4 ] ==PHY_ID_BCM8727 ; +return phydev->c45_ids.device_ids[4 ] == phydrv->phy_id; }static struct phy_driver bcm87xx_driver[] = {
@@ -208,7 +202,7 @@ static struct phy_driver bcm87xx_driver[] = { .read_status = bcm87xx_read_status, .config_intr = bcm87xx_config_intr, .handle_interrupt = bcm87xx_handle_interrupt, - .match_phy_device = bcm8706_match_phy_device, + .match_phy_device = bcm87xx_match_phy_device, }, { .phy_id = PHY_ID_BCM8727, .phy_id_mask = 0xffffffff,
@@ -219,7 +213,7 @@ static struct phy_driver bcm87xx_driver[] = { .read_status = bcm87xx_read_status, .config_intr = bcm87xx_config_intr, .handle_interrupt = bcm87xx_handle_interrupt, - .match_phy_device = bcm8727_match_phy_device, + .match_phy_device = bcm87xx_match_phy_device, } };module_phy_driver (bcm87xx_driver);
Signature · 1 line
2.48.1
Christian Marangi
maintainerRFC PATCH v3 3/4 net: phy: Add support for Aeonsemi AS21xxx PHYs
In reply to Christian MarangiAdd support for Aeonsemi AS21xxx 10G C45 PHYs. These PHYs integrate an IPC to setup some configuration and require special handling to sync with the parity bit. The parity bit is a way the IPC use to follow correct order of command sent.
Supported PHYs AS21011JB1, AS21011PB1, AS21010JB1, AS21010PB1, AS21511JB1, AS21511PB1, AS21510JB1, AS21510PB1, AS21210JB1, AS21210PB1 that all register with the PHY ID 0x7500 0x7510 before the firmware is loaded.
They all support up to 5 LEDs with various HW mode supported.
While implementing it was found some strange coincidence with using the same logic for implementing C22 in MMD regs in Broadcom PHYs.
For reference here the AS21xxx PHY name logic:
AS21x1xxB1
^ ^^
| |J: Supports SyncE/PTP
| |P: No SyncE/PTP support
| 1: Supports 2nd Serdes
| 2: Not 2nd Serdes support
0: 10G, 5G, 2.5G
5: 5G, 2.5G
2: 2.5G
--- MAINTAINERS | 6 + drivers/net/phy/Kconfig | 12 + drivers/net/phy/Makefile | 1 + drivers/net/phy/as21xxx.c | 1048 +++++++++++++++++++++++++++++++++++++ 4 files changed, 1067 insertions(+) create mode 100644 drivers/net/phy/as21xxx.c
MAINTAINERS +6 -0
@@ -645,6 +645,12 @@ F: drivers/iio/accel/adxl380.h F: drivers/iio/accel/adxl380_i2c.c F: drivers/iio/accel/adxl380_spi.c +AEONSEMI PHY DRIVER +M: Christian Marangi <[email protected]> +L: [email protected] +S: Maintained +F: drivers/net/phy/as21xxx.c + AF8133J THREE-AXIS MAGNETOMETER DRIVER M: Ondřej Jirman <[email protected]> S: Maintained
drivers/net/phy/Kconfig +12 -0
@@ -119,6 +119,18 @@ config AMCC_QT2025_PHY help Adds support for the Applied Micro Circuits Corporation QT2025 PHY. +config AS21XXX_PHY + tristate "Aeonsemi AS21xxx PHYs" + help + Currently supports the Aeonsemi AS21xxx PHY. + + These are C45 PHYs 10G that require all a generic firmware. + + Supported PHYs AS21011JB1, AS21011PB1, AS21010JB1, AS21010PB1, + AS21511JB1, AS21511PB1, AS21510JB1, AS21510PB1, AS21210JB1, + AS21210PB1 that all register with the PHY ID 0x7500 0x7500 + before the firmware is loaded. + source "drivers/net/phy/aquantia/Kconfig" config AX88796B_PHY
drivers/net/phy/Makefile +1 -0
@@ -39,6 +39,7 @@ obj-$(CONFIG_AIR_EN8811H_PHY) += air_en8811h.o obj-$(CONFIG_AMD_PHY) += amd.o obj-$(CONFIG_AMCC_QT2025_PHY) += qt2025.o obj-$(CONFIG_AQUANTIA_PHY) += aquantia/ +obj-$(CONFIG_AS21XXX_PHY) += as21xxx.o ifdef CONFIG_AX88796B_RUST_PHY obj-$(CONFIG_AX88796B_PHY) += ax88796b_rust.o else
drivers/net/phy/as21xxx.c new file +1048 -0
1,048 lines not on this page · raw message
Signature · 1 line
2.48.1
Christian Marangi
maintainerRFC PATCH v3 4/4 dt-bindings: net: Document support for Aeonsemi PHYs
In reply to Christian MarangiDocument support for Aeonsemi PHYs and the requirement of a firmware to correctly work. Also document the max number of LEDs supported and what PHY ID expose when no firmware is loaded.
Supported PHYs AS21011JB1, AS21011PB1, AS21010JB1, AS21010PB1, AS21511JB1, AS21511PB1, AS21510JB1, AS21510PB1, AS21210JB1, AS21210PB1 that all register with the PHY ID 0x7500 0x9410 on C45 registers before the firmware is loaded.
--- .../bindings/net/aeonsemi,as21xxx.yaml | 122 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 123 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/aeonsemi,as21xxx.yaml
Documentation/devicetree/bindings/net/aeonsemi,as21xxx.yaml new file +122 -0
@@ -0,0 +1,122 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/aeonsemi,as21xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Aeonsemi AS21XXX Ethernet PHY + +maintainers: + - Christian Marangi <[email protected]> + +description: | + Aeonsemi AS21xxx Ethernet PHYs requires a firmware to be loaded to actually + work. The same firmware is compatible with various PHYs of the same family. + + A PHY with not firmware loaded will be exposed on the MDIO bus with ID + 0x7500 0x7500 or 0x7500 0x9410 on C45 registers. + + This can be done and is implemented by OEM in 2 different way: + - Attached SPI flash directly to the PHY with the firmware. The PHY + will self load the firmware in the presence of this configuration. + - Manually provided firmware loaded from a file in the filesystem. + + Each PHY can support up to 5 LEDs. + + AS2xxx PHY Name logic: + + AS21x1xxB1 + ^ ^^ + | |J: Supports SyncE/PTP + | |P: No SyncE/PTP support + | 1: Supports 2nd Serdes + | 2: Not 2nd Serdes support + 0: 10G, 5G, 2.5G + 5: 5G, 2.5G + 2: 2.5G + +allOf: + - $ref: ethernet-phy.yaml# + +select: + properties: + compatible: + contains: + enum: + - ethernet-phy-id7500.9410 + - ethernet-phy-id7500.9402 + - ethernet-phy-id7500.9412 + - ethernet-phy-id7500.9422 + - ethernet-phy-id7500.9432 + - ethernet-phy-id7500.9442 + - ethernet-phy-id7500.9452 + - ethernet-phy-id7500.9462 + - ethernet-phy-id7500.9472 + - ethernet-phy-id7500.9482 + - ethernet-phy-id7500.9492 + required: + - compatible + +properties: + reg: + maxItems: 1 + + firmware-name: + description: specify the name of PHY firmware to load + maxItems: 1 + +required: + - compatible + - reg + +if: + properties: + compatible: + contains: + const: ethernet-phy-id7500.9410 +then: + required: + - firmware-name +else: + properties: + firmware-name: false + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/leds/common.h> + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + ethernet-phy@1f { + compatible = "ethernet-phy-id7500.9410", + "ethernet-phy-ieee802.3-c45"; + + reg = <31>; + firmware-name = "as21x1x_fw.bin"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_GREEN>; + function = LED_FUNCTION_LAN; + function-enumerator = <0>; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = <LED_COLOR_ID_GREEN>; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + default-state = "keep"; + }; + }; + }; + };
MAINTAINERS +1 -0
@@ -649,6 +649,7 @@ AEONSEMI PHY DRIVER M: Christian Marangi <[email protected]> L: [email protected] S: Maintained +F: Documentation/devicetree/bindings/net/aeonsemi,as21xxx.yaml F: drivers/net/phy/as21xxx.c AF8133J THREE-AXIS MAGNETOMETER DRIVER
Signature · 1 line
2.48.1
kernel test robot
build botRe: [net-next RFC PATCH v3 1/4] net: phy: pass PHY driver to .match_phy_device OP
In reply to Christian Marangikernel test robot noticed the following build errors:
Hi Christian,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-phy-pass-PHY-driver-to-match_phy_device-OP/20250327-073812 base: net-next/main patch link: https://lore.kernel.org/r/20250326233512.17153-2-ansuelsmth%40gmail.com patch subject: [net-next RFC PATCH v3 1/4] net: phy: pass PHY driver to .match_phy_device OP config: um-randconfig-002-20250327 (https://download.01.org/0day-ci/archive/20250327/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250327/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/net/phy/nxp-c45-tja11xx.c:2089:43: error: initialization of 'int (*)(struct phy_device *, const struct phy_driver *)' from incompatible pointer type 'int (*)(struct phy_device *)' [-Werror=incompatible-pointer-types]
2089 | .match_phy_device = tja1103_match_phy_device,
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/phy/nxp-c45-tja11xx.c:2089:43: note: (near initialization for 'nxp_c45_driver[0].match_phy_device')
drivers/net/phy/nxp-c45-tja11xx.c:2113:43: error: initialization of 'int (*)(struct phy_device *, const struct phy_driver *)' from incompatible pointer type 'int (*)(struct phy_device *)' [-Werror=incompatible-pointer-types]
2113 | .match_phy_device = tja1104_match_phy_device,
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/phy/nxp-c45-tja11xx.c:2113:43: note: (near initialization for 'nxp_c45_driver[1].match_phy_device')
drivers/net/phy/nxp-c45-tja11xx.c:2138:43: error: initialization of 'int (*)(struct phy_device *, const struct phy_driver *)' from incompatible pointer type 'int (*)(struct phy_device *)' [-Werror=incompatible-pointer-types]
2138 | .match_phy_device = tja1120_match_phy_device,
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/phy/nxp-c45-tja11xx.c:2138:43: note: (near initialization for 'nxp_c45_driver[2].match_phy_device')
drivers/net/phy/nxp-c45-tja11xx.c:2163:43: error: initialization of 'int (*)(struct phy_device *, const struct phy_driver *)' from incompatible pointer type 'int (*)(struct phy_device *)' [-Werror=incompatible-pointer-types]
2163 | .match_phy_device = tja1121_match_phy_device,
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/phy/nxp-c45-tja11xx.c:2163:43: note: (near initialization for 'nxp_c45_driver[3].match_phy_device')
cc1: some warnings being treated as errors
vim +2089 drivers/net/phy/nxp-c45-tja11xx.c
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2065)
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2066) static struct phy_driver nxp_c45_driver[] = {
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2067) {
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2068) .name = "NXP C45 TJA1103",
369da333569eb8 Radu Pirea (NXP OSS 2023-07-31 2069) .get_features = nxp_c45_get_features,
6c0c85da044e92 Radu Pirea (NXP OSS 2023-07-31 2070) .driver_data = &tja1103_phy_data,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2071) .probe = nxp_c45_probe,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2072) .soft_reset = nxp_c45_soft_reset,
ac0687e821cffa Radu Pirea (NXP OSS 2023-07-31 2073) .config_aneg = genphy_c45_config_aneg,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2074) .config_init = nxp_c45_config_init,
425c8348df7b86 Radu Pirea (NXP OSS 2023-07-31 2075) .config_intr = tja1103_config_intr,
b2f0ca00e6b34b Radu Pirea (NXP OSS 2021-04-23 2076) .handle_interrupt = nxp_c45_handle_interrupt,
ac0687e821cffa Radu Pirea (NXP OSS 2023-07-31 2077) .read_status = genphy_c45_read_status,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2078) .suspend = genphy_c45_pma_suspend,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2079) .resume = genphy_c45_pma_resume,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2080) .get_sset_count = nxp_c45_get_sset_count,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2081) .get_strings = nxp_c45_get_strings,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2082) .get_stats = nxp_c45_get_stats,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2083) .cable_test_start = nxp_c45_cable_test_start,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2084) .cable_test_get_status = nxp_c45_cable_test_get_status,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2085) .set_loopback = genphy_c45_loopback,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2086) .get_sqi = nxp_c45_get_sqi,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2087) .get_sqi_max = nxp_c45_get_sqi_max,
a4506722dc39ca Radu Pirea (OSS 2023-04-06 2088) .remove = nxp_c45_remove,
a06a868a0cd96b Andrei Botila 2025-02-28 @2089 .match_phy_device = tja1103_match_phy_device,
a06a868a0cd96b Andrei Botila 2025-02-28 2090 },
a06a868a0cd96b Andrei Botila 2025-02-28 2091 {
a06a868a0cd96b Andrei Botila 2025-02-28 2092 .name = "NXP C45 TJA1104",
a06a868a0cd96b Andrei Botila 2025-02-28 2093 .get_features = nxp_c45_get_features,
a06a868a0cd96b Andrei Botila 2025-02-28 2094 .driver_data = &tja1103_phy_data,
a06a868a0cd96b Andrei Botila 2025-02-28 2095 .probe = nxp_c45_probe,
a06a868a0cd96b Andrei Botila 2025-02-28 2096 .soft_reset = nxp_c45_soft_reset,
a06a868a0cd96b Andrei Botila 2025-02-28 2097 .config_aneg = genphy_c45_config_aneg,
a06a868a0cd96b Andrei Botila 2025-02-28 2098 .config_init = nxp_c45_config_init,
a06a868a0cd96b Andrei Botila 2025-02-28 2099 .config_intr = tja1103_config_intr,
a06a868a0cd96b Andrei Botila 2025-02-28 2100 .handle_interrupt = nxp_c45_handle_interrupt,
a06a868a0cd96b Andrei Botila 2025-02-28 2101 .read_status = genphy_c45_read_status,
a06a868a0cd96b Andrei Botila 2025-02-28 2102 .suspend = genphy_c45_pma_suspend,
a06a868a0cd96b Andrei Botila 2025-02-28 2103 .resume = genphy_c45_pma_resume,
a06a868a0cd96b Andrei Botila 2025-02-28 2104 .get_sset_count = nxp_c45_get_sset_count,
a06a868a0cd96b Andrei Botila 2025-02-28 2105 .get_strings = nxp_c45_get_strings,
a06a868a0cd96b Andrei Botila 2025-02-28 2106 .get_stats = nxp_c45_get_stats,
a06a868a0cd96b Andrei Botila 2025-02-28 2107 .cable_test_start = nxp_c45_cable_test_start,
a06a868a0cd96b Andrei Botila 2025-02-28 2108 .cable_test_get_status = nxp_c45_cable_test_get_status,
a06a868a0cd96b Andrei Botila 2025-02-28 2109 .set_loopback = genphy_c45_loopback,
a06a868a0cd96b Andrei Botila 2025-02-28 2110 .get_sqi = nxp_c45_get_sqi,
a06a868a0cd96b Andrei Botila 2025-02-28 2111 .get_sqi_max = nxp_c45_get_sqi_max,
a06a868a0cd96b Andrei Botila 2025-02-28 2112 .remove = nxp_c45_remove,
a06a868a0cd96b Andrei Botila 2025-02-28 2113 .match_phy_device = tja1104_match_phy_device,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2114) },
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2115) {
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2116) .name = "NXP C45 TJA1120",
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2117) .get_features = nxp_c45_get_features,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2118) .driver_data = &tja1120_phy_data,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2119) .probe = nxp_c45_probe,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2120) .soft_reset = nxp_c45_soft_reset,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2121) .config_aneg = genphy_c45_config_aneg,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2122) .config_init = nxp_c45_config_init,
425c8348df7b86 Radu Pirea (NXP OSS 2023-07-31 2123) .config_intr = tja1120_config_intr,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2124) .handle_interrupt = nxp_c45_handle_interrupt,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2125) .read_status = genphy_c45_read_status,
68c6af72047ca7 Radu Pirea (NXP OSS 2023-07-31 2126) .link_change_notify = tja1120_link_change_notify,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2127) .suspend = genphy_c45_pma_suspend,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2128) .resume = genphy_c45_pma_resume,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2129) .get_sset_count = nxp_c45_get_sset_count,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2130) .get_strings = nxp_c45_get_strings,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2131) .get_stats = nxp_c45_get_stats,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2132) .cable_test_start = nxp_c45_cable_test_start,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2133) .cable_test_get_status = nxp_c45_cable_test_get_status,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2134) .set_loopback = genphy_c45_loopback,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2135) .get_sqi = nxp_c45_get_sqi,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2136) .get_sqi_max = nxp_c45_get_sqi_max,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2137) .remove = nxp_c45_remove,
7215e9375694db Andrei Botila 2025-02-28 2138 .match_phy_device = tja1120_match_phy_device,
7215e9375694db Andrei Botila 2025-02-28 2139 },
7215e9375694db Andrei Botila 2025-02-28 2140 {
7215e9375694db Andrei Botila 2025-02-28 2141 .name = "NXP C45 TJA1121",
7215e9375694db Andrei Botila 2025-02-28 2142 .get_features = nxp_c45_get_features,
7215e9375694db Andrei Botila 2025-02-28 2143 .driver_data = &tja1120_phy_data,
7215e9375694db Andrei Botila 2025-02-28 2144 .probe = nxp_c45_probe,
7215e9375694db Andrei Botila 2025-02-28 2145 .soft_reset = nxp_c45_soft_reset,
7215e9375694db Andrei Botila 2025-02-28 2146 .config_aneg = genphy_c45_config_aneg,
7215e9375694db Andrei Botila 2025-02-28 2147 .config_init = nxp_c45_config_init,
7215e9375694db Andrei Botila 2025-02-28 2148 .config_intr = tja1120_config_intr,
7215e9375694db Andrei Botila 2025-02-28 2149 .handle_interrupt = nxp_c45_handle_interrupt,
7215e9375694db Andrei Botila 2025-02-28 2150 .read_status = genphy_c45_read_status,
7215e9375694db Andrei Botila 2025-02-28 2151 .link_change_notify = tja1120_link_change_notify,
7215e9375694db Andrei Botila 2025-02-28 2152 .suspend = genphy_c45_pma_suspend,
7215e9375694db Andrei Botila 2025-02-28 2153 .resume = genphy_c45_pma_resume,
7215e9375694db Andrei Botila 2025-02-28 2154 .get_sset_count = nxp_c45_get_sset_count,
7215e9375694db Andrei Botila 2025-02-28 2155 .get_strings = nxp_c45_get_strings,
7215e9375694db Andrei Botila 2025-02-28 2156 .get_stats = nxp_c45_get_stats,
7215e9375694db Andrei Botila 2025-02-28 2157 .cable_test_start = nxp_c45_cable_test_start,
7215e9375694db Andrei Botila 2025-02-28 2158 .cable_test_get_status = nxp_c45_cable_test_get_status,
7215e9375694db Andrei Botila 2025-02-28 2159 .set_loopback = genphy_c45_loopback,
7215e9375694db Andrei Botila 2025-02-28 2160 .get_sqi = nxp_c45_get_sqi,
7215e9375694db Andrei Botila 2025-02-28 2161 .get_sqi_max = nxp_c45_get_sqi_max,
7215e9375694db Andrei Botila 2025-02-28 2162 .remove = nxp_c45_remove,
7215e9375694db Andrei Botila 2025-02-28 2163 .match_phy_device = tja1121_match_phy_device,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2164) },
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2165) };
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2166) Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [net-next RFC PATCH v3 1/4] net: phy: pass PHY driver to .match_phy_device OP
In reply to Christian Marangikernel test robot noticed the following build errors:
Hi Christian,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-phy-pass-PHY-driver-to-match_phy_device-OP/20250327-073812 base: net-next/main patch link: https://lore.kernel.org/r/20250326233512.17153-2-ansuelsmth%40gmail.com patch subject: [net-next RFC PATCH v3 1/4] net: phy: pass PHY driver to .match_phy_device OP config: arm-randconfig-003-20250327 (https://download.01.org/0day-ci/archive/20250327/[email protected]/config) compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project c2692afc0a92cd5da140dfcdfff7818a5b8ce997) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250327/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/net/phy/nxp-c45-tja11xx.c:2089:23: error: incompatible function pointer types initializing 'int (*)(struct phy_device *, const struct phy_driver *)' with an expression of type 'int (struct phy_device *)' [-Wincompatible-function-pointer-types]
2089 | .match_phy_device = tja1103_match_phy_device,
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/phy/nxp-c45-tja11xx.c:2113:23: error: incompatible function pointer types initializing 'int (*)(struct phy_device *, const struct phy_driver *)' with an expression of type 'int (struct phy_device *)' [-Wincompatible-function-pointer-types]
2113 | .match_phy_device = tja1104_match_phy_device,
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/phy/nxp-c45-tja11xx.c:2138:23: error: incompatible function pointer types initializing 'int (*)(struct phy_device *, const struct phy_driver *)' with an expression of type 'int (struct phy_device *)' [-Wincompatible-function-pointer-types]
2138 | .match_phy_device = tja1120_match_phy_device,
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/phy/nxp-c45-tja11xx.c:2163:23: error: incompatible function pointer types initializing 'int (*)(struct phy_device *, const struct phy_driver *)' with an expression of type 'int (struct phy_device *)' [-Wincompatible-function-pointer-types]
2163 | .match_phy_device = tja1121_match_phy_device,
| ^~~~~~~~~~~~~~~~~~~~~~~~
4 errors generated.
vim +2089 drivers/net/phy/nxp-c45-tja11xx.c
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2065)
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2066) static struct phy_driver nxp_c45_driver[] = {
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2067) {
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2068) .name = "NXP C45 TJA1103",
369da333569eb8 Radu Pirea (NXP OSS 2023-07-31 2069) .get_features = nxp_c45_get_features,
6c0c85da044e92 Radu Pirea (NXP OSS 2023-07-31 2070) .driver_data = &tja1103_phy_data,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2071) .probe = nxp_c45_probe,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2072) .soft_reset = nxp_c45_soft_reset,
ac0687e821cffa Radu Pirea (NXP OSS 2023-07-31 2073) .config_aneg = genphy_c45_config_aneg,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2074) .config_init = nxp_c45_config_init,
425c8348df7b86 Radu Pirea (NXP OSS 2023-07-31 2075) .config_intr = tja1103_config_intr,
b2f0ca00e6b34b Radu Pirea (NXP OSS 2021-04-23 2076) .handle_interrupt = nxp_c45_handle_interrupt,
ac0687e821cffa Radu Pirea (NXP OSS 2023-07-31 2077) .read_status = genphy_c45_read_status,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2078) .suspend = genphy_c45_pma_suspend,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2079) .resume = genphy_c45_pma_resume,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2080) .get_sset_count = nxp_c45_get_sset_count,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2081) .get_strings = nxp_c45_get_strings,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2082) .get_stats = nxp_c45_get_stats,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2083) .cable_test_start = nxp_c45_cable_test_start,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2084) .cable_test_get_status = nxp_c45_cable_test_get_status,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2085) .set_loopback = genphy_c45_loopback,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2086) .get_sqi = nxp_c45_get_sqi,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2087) .get_sqi_max = nxp_c45_get_sqi_max,
a4506722dc39ca Radu Pirea (OSS 2023-04-06 2088) .remove = nxp_c45_remove,
a06a868a0cd96b Andrei Botila 2025-02-28 @2089 .match_phy_device = tja1103_match_phy_device,
a06a868a0cd96b Andrei Botila 2025-02-28 2090 },
a06a868a0cd96b Andrei Botila 2025-02-28 2091 {
a06a868a0cd96b Andrei Botila 2025-02-28 2092 .name = "NXP C45 TJA1104",
a06a868a0cd96b Andrei Botila 2025-02-28 2093 .get_features = nxp_c45_get_features,
a06a868a0cd96b Andrei Botila 2025-02-28 2094 .driver_data = &tja1103_phy_data,
a06a868a0cd96b Andrei Botila 2025-02-28 2095 .probe = nxp_c45_probe,
a06a868a0cd96b Andrei Botila 2025-02-28 2096 .soft_reset = nxp_c45_soft_reset,
a06a868a0cd96b Andrei Botila 2025-02-28 2097 .config_aneg = genphy_c45_config_aneg,
a06a868a0cd96b Andrei Botila 2025-02-28 2098 .config_init = nxp_c45_config_init,
a06a868a0cd96b Andrei Botila 2025-02-28 2099 .config_intr = tja1103_config_intr,
a06a868a0cd96b Andrei Botila 2025-02-28 2100 .handle_interrupt = nxp_c45_handle_interrupt,
a06a868a0cd96b Andrei Botila 2025-02-28 2101 .read_status = genphy_c45_read_status,
a06a868a0cd96b Andrei Botila 2025-02-28 2102 .suspend = genphy_c45_pma_suspend,
a06a868a0cd96b Andrei Botila 2025-02-28 2103 .resume = genphy_c45_pma_resume,
a06a868a0cd96b Andrei Botila 2025-02-28 2104 .get_sset_count = nxp_c45_get_sset_count,
a06a868a0cd96b Andrei Botila 2025-02-28 2105 .get_strings = nxp_c45_get_strings,
a06a868a0cd96b Andrei Botila 2025-02-28 2106 .get_stats = nxp_c45_get_stats,
a06a868a0cd96b Andrei Botila 2025-02-28 2107 .cable_test_start = nxp_c45_cable_test_start,
a06a868a0cd96b Andrei Botila 2025-02-28 2108 .cable_test_get_status = nxp_c45_cable_test_get_status,
a06a868a0cd96b Andrei Botila 2025-02-28 2109 .set_loopback = genphy_c45_loopback,
a06a868a0cd96b Andrei Botila 2025-02-28 2110 .get_sqi = nxp_c45_get_sqi,
a06a868a0cd96b Andrei Botila 2025-02-28 2111 .get_sqi_max = nxp_c45_get_sqi_max,
a06a868a0cd96b Andrei Botila 2025-02-28 2112 .remove = nxp_c45_remove,
a06a868a0cd96b Andrei Botila 2025-02-28 2113 .match_phy_device = tja1104_match_phy_device,
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2114) },
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2115) {
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2116) .name = "NXP C45 TJA1120",
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2117) .get_features = nxp_c45_get_features,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2118) .driver_data = &tja1120_phy_data,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2119) .probe = nxp_c45_probe,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2120) .soft_reset = nxp_c45_soft_reset,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2121) .config_aneg = genphy_c45_config_aneg,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2122) .config_init = nxp_c45_config_init,
425c8348df7b86 Radu Pirea (NXP OSS 2023-07-31 2123) .config_intr = tja1120_config_intr,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2124) .handle_interrupt = nxp_c45_handle_interrupt,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2125) .read_status = genphy_c45_read_status,
68c6af72047ca7 Radu Pirea (NXP OSS 2023-07-31 2126) .link_change_notify = tja1120_link_change_notify,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2127) .suspend = genphy_c45_pma_suspend,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2128) .resume = genphy_c45_pma_resume,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2129) .get_sset_count = nxp_c45_get_sset_count,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2130) .get_strings = nxp_c45_get_strings,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2131) .get_stats = nxp_c45_get_stats,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2132) .cable_test_start = nxp_c45_cable_test_start,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2133) .cable_test_get_status = nxp_c45_cable_test_get_status,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2134) .set_loopback = genphy_c45_loopback,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2135) .get_sqi = nxp_c45_get_sqi,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2136) .get_sqi_max = nxp_c45_get_sqi_max,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2137) .remove = nxp_c45_remove,
7215e9375694db Andrei Botila 2025-02-28 2138 .match_phy_device = tja1120_match_phy_device,
7215e9375694db Andrei Botila 2025-02-28 2139 },
7215e9375694db Andrei Botila 2025-02-28 2140 {
7215e9375694db Andrei Botila 2025-02-28 2141 .name = "NXP C45 TJA1121",
7215e9375694db Andrei Botila 2025-02-28 2142 .get_features = nxp_c45_get_features,
7215e9375694db Andrei Botila 2025-02-28 2143 .driver_data = &tja1120_phy_data,
7215e9375694db Andrei Botila 2025-02-28 2144 .probe = nxp_c45_probe,
7215e9375694db Andrei Botila 2025-02-28 2145 .soft_reset = nxp_c45_soft_reset,
7215e9375694db Andrei Botila 2025-02-28 2146 .config_aneg = genphy_c45_config_aneg,
7215e9375694db Andrei Botila 2025-02-28 2147 .config_init = nxp_c45_config_init,
7215e9375694db Andrei Botila 2025-02-28 2148 .config_intr = tja1120_config_intr,
7215e9375694db Andrei Botila 2025-02-28 2149 .handle_interrupt = nxp_c45_handle_interrupt,
7215e9375694db Andrei Botila 2025-02-28 2150 .read_status = genphy_c45_read_status,
7215e9375694db Andrei Botila 2025-02-28 2151 .link_change_notify = tja1120_link_change_notify,
7215e9375694db Andrei Botila 2025-02-28 2152 .suspend = genphy_c45_pma_suspend,
7215e9375694db Andrei Botila 2025-02-28 2153 .resume = genphy_c45_pma_resume,
7215e9375694db Andrei Botila 2025-02-28 2154 .get_sset_count = nxp_c45_get_sset_count,
7215e9375694db Andrei Botila 2025-02-28 2155 .get_strings = nxp_c45_get_strings,
7215e9375694db Andrei Botila 2025-02-28 2156 .get_stats = nxp_c45_get_stats,
7215e9375694db Andrei Botila 2025-02-28 2157 .cable_test_start = nxp_c45_cable_test_start,
7215e9375694db Andrei Botila 2025-02-28 2158 .cable_test_get_status = nxp_c45_cable_test_get_status,
7215e9375694db Andrei Botila 2025-02-28 2159 .set_loopback = genphy_c45_loopback,
7215e9375694db Andrei Botila 2025-02-28 2160 .get_sqi = nxp_c45_get_sqi,
7215e9375694db Andrei Botila 2025-02-28 2161 .get_sqi_max = nxp_c45_get_sqi_max,
7215e9375694db Andrei Botila 2025-02-28 2162 .remove = nxp_c45_remove,
7215e9375694db Andrei Botila 2025-02-28 2163 .match_phy_device = tja1121_match_phy_device,
f1fe5dff2b8aa8 Radu Pirea (NXP OSS 2023-07-31 2164) },
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2165) };
b050f2f15e04f0 Radu Pirea (NXP OSS 2021-04-19 2166) Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [net-next RFC PATCH v3 3/4] net: phy: Add support for Aeonsemi AS21xxx PHYs
In reply to Christian MarangiHi Christian,
Quoted 27 lines · On Thu, 27 Mar 2025 00:35:03 +0100 Christian Marangi <[email protected]>…
Add support for Aeonsemi AS21xxx 10G C45 PHYs. These PHYs integrate an IPC to setup some configuration and require special handling to sync with the parity bit. The parity bit is a way the IPC use to follow correct order of command sent.
Supported PHYs AS21011JB1, AS21011PB1, AS21010JB1, AS21010PB1, AS21511JB1, AS21511PB1, AS21510JB1, AS21510PB1, AS21210JB1, AS21210PB1 that all register with the PHY ID
0x75000x7510before the firmware is loaded.They all support up to 5 LEDs with various HW mode supported.
While implementing it was found some strange coincidence with using the same logic for implementing C22 in MMD regs in Broadcom PHYs.
For reference here the AS21xxx PHY name logic:
AS21x1xxB1
^ ^^
| |J: Supports SyncE/PTP
| |P: No SyncE/PTP support
| 1: Supports 2nd Serdes
| 2: Not 2nd Serdes support
0: 10G, 5G, 2.5G
5: 5G, 2.5G
2: 2.5G
Quoted 1 line
Signed-off-by Christian Marangi <[email protected]>
[...]
I know this is only RFC, but I have some questions
Quoted 28 lines
drivers/net/phy/as21xxx.c new file +28
-0+static int as21xxx_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) +{ +struct as21xxx_priv *priv; +u32 phy_id; +int ret; + +/* Skip PHY that are not AS21xxx or already have firmware loaded */ +if (phydev->c45_ids.device_ids[MDIO_MMD_PCS ] !=PHY_ID_AS21XXX ) +return phydev->phy_id == phydrv->phy_id; + +/* Read PHY ID to handle firmware just loaded */ + ret =phy_read_mmd (phydev,MDIO_MMD_PCS ,MII_PHYSID1 ); +if (ret <0 ) +return ret; + phy_id = ret <<16 ; + + ret =phy_read_mmd (phydev,MDIO_MMD_PCS ,MII_PHYSID2 ); +if (ret <0 ) +return ret; + phy_id |= ret; + +/* With PHY ID not the generic AS21xxx one assume +* the firmware just loaded +*/ +if (phy_id !=PHY_ID_AS21XXX ) +return phy_id == phydrv->phy_id; +
drivers/net/phy/as21xxx.c line 883
Quoted 10 lines
drivers/net/phy/as21xxx.c new file +10
-0+/* Allocate temp priv and load the firmware */ + priv =kzalloc (sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + +mutex_init (&priv->ipc_lock); + + ret =aeon_firmware_load (phydev); +if (ret) +return ret;
Here, and below, you leak priv by returning early.
Quoted 4 lines
drivers/net/phy/as21xxx.c new file +4
-0+ + ret =aeon_ipc_sync_parity (phydev, priv); +if (ret) +return ret;
drivers/net/phy/as21xxx.c line 897
Quoted 10 lines
drivers/net/phy/as21xxx.c new file +10
-0+ +/* Enable PTP clk if not already Enabled */ + ret =phy_set_bits_mmd (phydev,MDIO_MMD_VEND1 ,VEND1_PTP_CLK , +VEND1_PTP_CLK_EN ); +if (ret) +return ret; + + ret =aeon_dpc_ra_enable (phydev, priv); +if (ret) +return ret;
Does all of the above with sync_parity, PTP clock cfg and so on needs to be done in this first pass of the matching process for this PHY ?
From what I got from the discussions, the only important bit is to load the FW to get the correct PHY id ?
drivers/net/phy/as21xxx.c line 906
Quoted 8 lines
drivers/net/phy/as21xxx.c new file +8
-0+mutex_destroy (&priv->ipc_lock); +kfree (priv); + +/* Return not maching anyway as PHY ID will change after +* firmware is loaded. +*/ +return 0 ; +}
Maxime
Re: [net-next RFC PATCH v3 1/4] net: phy: pass PHY driver to .match_phy_device OP
In reply to Christian MarangiQuoted 10 lines · Christian Marangi
Pass PHY driver pointer to .match_phy_device OP in addition to phydev. Having access to the PHY driver struct might be useful to check the PHY ID of the driver is being matched for in case the PHY ID scanned in the phydev is not consistent.
A scenario for this is a PHY that change PHY ID after a firmware is loaded, in such case, the PHY ID stored in PHY device struct is not valid anymore and PHY will manually scan the ID in the
match_phy_devicefunction.
Quoted 7 lines
Having the PHY driver info is also useful for those PHY driver that implement multiple simple .match_phy_device OP to match specific MMD PHY ID. With this extra info if the parsing logic is the same, the matching function can be generalized by using the
phy_idin the PHY driver instead of hardcoding.Suggested-by Russell King (Oracle) <[email protected]>
Please also update the email address in the suggested-by to match the one in my reviewed-by for the next resend.
Thanks!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [net-next RFC PATCH v3 2/4] net: phy: bcm87xx: simplify .match_phy_device OP
In reply to Christian MarangiQuoted 7 lines · Christian Marangi
Simplify .match_phy_device OP by using a generic function and using the new
phy_idPHY driver info instead of hardcoding the matching PHY ID.Signed-off-by Christian Marangi <[email protected]>--- drivers/net/phy/bcm87xx.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
Great! Less code! :)
Thanks!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Russell King (Oracle)
maintainerRe: [net-next RFC PATCH v3 3/4] net: phy: Add support for Aeonsemi AS21xxx PHYs
In reply to Christian Marangidrivers/net/phy/as21xxx.c line 855
Quoted 10 lines · Christian Marangi
drivers/net/phy/as21xxx.c new file +10
-0+static int as21xxx_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) +{ +struct as21xxx_priv *priv; +u32 phy_id; +int ret; + +/* Skip PHY that are not AS21xxx or already have firmware loaded */ +if (phydev->c45_ids.device_ids[MDIO_MMD_PCS ] !=PHY_ID_AS21XXX ) +return phydev->phy_id == phydrv->phy_id;
Isn't phydev->phy_id zero here for a clause 45 PHY? If the firmware has been loaded, I believ eyou said that PHY_ID_AS21XXX won't be used, so the if() will be true, and because we've read clause 45 IDs, phydev->phy_id will be zero meaning this will never match. So a PHY with firmware loaded won't ever match any of these drivers. This is probably not what you want.
I'd suggest converting the tail of phy_bus_match() so that you can call that to do the standard matching using either C22 or C45 IDs as appropriate without duplicating that code.
Quoted 38 lines
drivers/net/phy/as21xxx.c new file +38
-0+ +/* Read PHY ID to handle firmware just loaded */ + ret =phy_read_mmd (phydev,MDIO_MMD_PCS ,MII_PHYSID1 ); +if (ret <0 ) +return ret; + phy_id = ret <<16 ; + + ret =phy_read_mmd (phydev,MDIO_MMD_PCS ,MII_PHYSID2 ); +if (ret <0 ) +return ret; + phy_id |= ret; + +/* With PHY ID not the generic AS21xxx one assume +* the firmware just loaded +*/ +if (phy_id !=PHY_ID_AS21XXX ) +return phy_id == phydrv->phy_id; + +/* Allocate temp priv and load the firmware */ + priv =kzalloc (sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + +mutex_init (&priv->ipc_lock); + + ret =aeon_firmware_load (phydev); +if (ret) +return ret; + + ret =aeon_ipc_sync_parity (phydev, priv); +if (ret) +return ret; + +/* Enable PTP clk if not already Enabled */ + ret =phy_set_bits_mmd (phydev,MDIO_MMD_VEND1 ,VEND1_PTP_CLK , +VEND1_PTP_CLK_EN ); +if (ret) +return ret;
drivers/net/phy/as21xxx.c line 903
Quoted 10 lines
drivers/net/phy/as21xxx.c new file +10
-0+ + ret =aeon_dpc_ra_enable (phydev, priv); +if (ret) +return ret; + +mutex_destroy (&priv->ipc_lock); +kfree (priv); + +/* Return not maching anyway as PHY ID will change after +* firmware is loaded.
Also "This relies on the driver probe order."
drivers/net/phy/as21xxx.c line 911
Quoted 8 lines
drivers/net/phy/as21xxx.c new file +8
-0+*/ +return 0 ; +} + +static struct phy_driver as21xxx_drivers[] = { + { +/* PHY expose in C45 as 0x7500 0x9410 +* before firmware is loaded.
Also "This driver entry must be attempted first to load the firmware and thus update the ID registers."
Quoted 6 lines
drivers/net/phy/as21xxx.c new file +6
-0+*/ +PHY_ID_MATCH_EXACT (PHY_ID_AS21XXX ), + .name = "Aeonsemi AS21xxx", + .match_phy_device = as21xxx_match_phy_device, + }, + {
drivers/net/phy/as21xxx.c line 927
Quoted 10 lines
drivers/net/phy/as21xxx.c new file +10
-0+PHY_ID_MATCH_EXACT (PHY_ID_AS21011JB1 ), + .name = "Aeonsemi AS21011JB1", + .probe = as21xxx_probe, + .match_phy_device = as21xxx_match_phy_device, + .read_status = as21xxx_read_status, + .led_brightness_set = as21xxx_led_brightness_set, + .led_hw_is_supported = as21xxx_led_hw_is_supported, + .led_hw_control_set = as21xxx_led_hw_control_set, + .led_hw_control_get = as21xxx_led_hw_control_get, + .led_polarity_set = as21xxx_led_polarity_set,
If I'm reading these driver entries correctly, the only reason for having separate entries is to be able to have a unique name printed for each - the methods themselves are all identical.
My feeling is that is not a sufficient reason to duplicate the driver entries, which adds bloat (not only in terms of static data, but also the data structures necessary to support each entry in sysfs.) However, lets see what Andrew says.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Christian Marangi
maintainerRe: [net-next RFC PATCH v3 3/4] net: phy: Add support for Aeonsemi AS21xxx PHYs
In reply to Maxime ChevallierQuoted 70 lines · Maxime Chevallier
Hi Christian,
Quoted 27 lines · On Thu, 27 Mar 2025 00:35:03 +0100 Christian Marangi <[email protected]>…
Add support for Aeonsemi AS21xxx 10G C45 PHYs. These PHYs integrate an IPC to setup some configuration and require special handling to sync with the parity bit. The parity bit is a way the IPC use to follow correct order of command sent.
Supported PHYs AS21011JB1, AS21011PB1, AS21010JB1, AS21010PB1, AS21511JB1, AS21511PB1, AS21510JB1, AS21510PB1, AS21210JB1, AS21210PB1 that all register with the PHY ID
0x75000x7510before the firmware is loaded.They all support up to 5 LEDs with various HW mode supported.
While implementing it was found some strange coincidence with using the same logic for implementing C22 in MMD regs in Broadcom PHYs.
For reference here the AS21xxx PHY name logic:
AS21x1xxB1
^ ^^
| |J: Supports SyncE/PTP
| |P: No SyncE/PTP support
| 1: Supports 2nd Serdes
| 2: Not 2nd Serdes support
0: 10G, 5G, 2.5G
5: 5G, 2.5G
2: 2.5GQuoted 1 line
Signed-off-by Christian Marangi <[email protected]>[...]
I know this is only RFC, but I have some questions
Quoted 32 lines
drivers/net/phy/as21xxx.c new file +32
-0+static int as21xxx_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) +{ +struct as21xxx_priv *priv; +u32 phy_id; +int ret; + +/* Skip PHY that are not AS21xxx or already have firmware loaded */ +if (phydev->c45_ids.device_ids[MDIO_MMD_PCS ] !=PHY_ID_AS21XXX ) +return phydev->phy_id == phydrv->phy_id; + +/* Read PHY ID to handle firmware just loaded */ + ret =phy_read_mmd (phydev,MDIO_MMD_PCS ,MII_PHYSID1 ); +if (ret <0 ) +return ret; + phy_id = ret <<16 ; + + ret =phy_read_mmd (phydev,MDIO_MMD_PCS ,MII_PHYSID2 ); +if (ret <0 ) +return ret; + phy_id |= ret; + +/* With PHY ID not the generic AS21xxx one assume +* the firmware just loaded +*/ +if (phy_id !=PHY_ID_AS21XXX ) +return phy_id == phydrv->phy_id; + +/* Allocate temp priv and load the firmware */ + priv =kzalloc (sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ;
Quoted 9 lines
drivers/net/phy/as21xxx.c line 883
Quoted 6 lines
drivers/net/phy/as21xxx.c new file +6
-0+ +mutex_init (&priv->ipc_lock); + + ret =aeon_firmware_load (phydev); +if (ret) +return ret;Here, and below, you leak priv by returning early.
Yes copy paste error with migrating from devm to non-devmem.
Quoted 18 lines
Quoted 4 lines
drivers/net/phy/as21xxx.c new file +4
-0+ + ret =aeon_ipc_sync_parity (phydev, priv); +if (ret) +return ret;drivers/net/phy/as21xxx.c line 897
Quoted 10 lines
drivers/net/phy/as21xxx.c new file +10
-0+ +/* Enable PTP clk if not already Enabled */ + ret =phy_set_bits_mmd (phydev,MDIO_MMD_VEND1 ,VEND1_PTP_CLK , +VEND1_PTP_CLK_EN ); +if (ret) +return ret; + + ret =aeon_dpc_ra_enable (phydev, priv); +if (ret) +return ret;Does all of the above with
sync_parity, PTP clock cfg and so on needs to be done in this first pass of the matching process for this PHY ?
Quoted 3 lines
From what I got from the discussions, the only important bit is to load the FW to get the correct PHY id ?
I will do further check on this. Waiting for the sync parity have the side effect of waiting for the firmware to finish loading.
Quoted 10 lines
drivers/net/phy/as21xxx.c line 906
Quoted 8 lines
drivers/net/phy/as21xxx.c new file +8
-0+mutex_destroy (&priv->ipc_lock); +kfree (priv); + +/* Return not maching anyway as PHY ID will change after +* firmware is loaded. +*/ +return 0 ; +}Maxime
Signature · 1 line
Ansuel
Russell King (Oracle)
maintainerRe: [net-next RFC PATCH v3 3/4] net: phy: Add support for Aeonsemi AS21xxx PHYs
In reply to Russell King (Oracle)Quoted 8 lines · Russell King (Oracle)
If I'm reading these driver entries correctly, the only reason for having separate entries is to be able to have a unique name printed for each - the methods themselves are all identical.
My feeling is that is not a sufficient reason to duplicate the driver entries, which adds bloat (not only in terms of static data, but also the data structures necessary to support each entry in sysfs.) However, lets see what Andrew says.
I did have this patch from a previous discussion which adds support for a single phy_driver struct to have multiple matching IDs. I haven't rebased it on current net-next, so may no longer apply:
drivers/net/phy/phy_device.c | 64 +++++++++++++++++++++++++++++++++----------- include/linux/phy.h | 16 ++++++++++- 2 files changed, 63 insertions(+), 17 deletions(-)
drivers/net/phy/phy_device.c +48 -16
@@ -522,12 +522,51 @@ static int phy_scan_fixups(struct phy_device *phydev)return 0 ; } +static const struct mdio_device_id * +phy_driver_match_id (struct phy_driver *phydrv,u32 id) +{ +const struct mdio_device_id *ids = phydrv->ids; + +if (ids) { +while (ids->phy_id) { +if (phy_id_compare (id, ids->phy_id, ids->phy_id_mask)) +return ids; + ids++; + } + } + +if (phy_id_compare (id, phydrv->id.phy_id, phydrv->id.phy_id_mask)) +return &phydrv->id; + +return NULL ; +} + +static const struct mdio_device_id * +phy_driver_match (struct phy_driver *phydrv,struct phy_device *phydev) +{ +const int num_ids =ARRAY_SIZE (phydev->c45_ids.device_ids); +const struct mdio_device_id *id; +int i; + +if (!phydev->is_c45) +return phy_driver_match_id (phydrv, phydev->phy_id); + +for (i =1 ; i < num_ids; i++) { +if (phydev->c45_ids.device_ids[i] ==0xffffffff ) +continue ; + + id =phy_driver_match_id (phydrv, phydev->c45_ids.device_ids[i]); +if (id) +return id; + } + +return NULL ; +} +static int phy_bus_match (struct device *dev,struct device_driver *drv) {struct phy_device *phydev =to_phy_device (dev);struct phy_driver *phydrv =to_phy_driver (drv); -const int num_ids =ARRAY_SIZE (phydev->c45_ids.device_ids); -int i;if (!(phydrv->mdiodrv.flags &MDIO_DEVICE_IS_PHY ))return 0 ;
@@ -535,20 +574,7 @@ static int phy_bus_match(struct device *dev, struct device_driver *drv)if (phydrv->match_phy_device)return phydrv->match_phy_device (phydev); -if (phydev->is_c45) { -for (i =1 ; i < num_ids; i++) { -if (phydev->c45_ids.device_ids[i] ==0xffffffff ) -continue ; - -if (phy_id_compare (phydev->c45_ids.device_ids[i], - phydrv->phy_id, phydrv->phy_id_mask)) -return 1 ; - } -return 0 ; - }else { -return phy_id_compare (phydev->phy_id, phydrv->phy_id, - phydrv->phy_id_mask); - } +return !!phy_driver_match (phydrv, phydev); } static ssize_t
@@ -3311,6 +3337,7 @@ static int phy_probe(struct device *dev)int err =0 ; phydev->drv = phydrv; + phydev->drv_id =phy_driver_match (phydrv, phydev);/* Disable the interrupt if the PHY doesn't support it * but the interrupt is still a valid one
@@ -3485,6 +3512,11 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner) new_driver->mdiodrv.driver.owner = owner; new_driver->mdiodrv.driver.probe_type =PROBE_FORCE_SYNCHRONOUS ; +if (!new_driver->id.phy_id) { + new_driver->id.phy_id = new_driver->phy_id; + new_driver->id.phy_id_mask = new_driver->phy_id_mask; + } + retval =driver_register (&new_driver->mdiodrv.driver);if (retval) { pr_err("%s: Error %d in registering driver\n",
include/linux/phy.h +15 -1
@@ -542,6 +542,7 @@ struct macsec_ops;* * @mdio: MDIO bus this PHY is on * @drv: Pointer to the driver for this PHY instance +* @drv_id: The matched driver ID for this PHY instance * @devlink: Create a link between phy dev and mac dev, if the external phy * used by current mac interface is managed by another mac interface. * @phy_id: UID for this device found during discovery
@@ -639,6 +640,7 @@ struct phy_device {/* Information about the PHY type */ /* And management functions */ const struct phy_driver *drv; +const struct mdio_device_id *drv_id;struct device_link *devlink;
@@ -882,6 +884,9 @@ struct phy_led {* struct phy_driver - Driver structure for a particular PHY type * * @mdiodrv: Data common to all MDIO devices +* @ids: array of mdio device IDs to match this driver (terminated with +* zero phy_id) +* @id: mdio device ID to match * @phy_id: The result of reading the UID registers of this PHY * type, and ANDing them with the phy_id_mask. This driver * only works for PHYs with IDs which match this field
@@ -903,6 +908,8 @@ struct phy_led {*/ struct phy_driver {struct mdio_driver_common mdiodrv; +const struct mdio_device_id *ids; +struct mdio_device_id id;u32 phy_id;char *name;u32 phy_id_mask;
@@ -1203,7 +1210,14 @@ static inline bool phy_id_compare(u32 id1, u32 id2, u32 mask)*/ static inline bool phydev_id_compare (struct phy_device *phydev,u32 id) { -return phy_id_compare (id, phydev->phy_id, phydev->drv->phy_id_mask); +u32 mask; + +if (phydev->drv_id) + mask = phydev->drv_id->phy_id_mask; +else + mask = phydev->drv->phy_id_mask; + +return phy_id_compare (id, phydev->phy_id, mask); }/* A Structure for boards to register fixups with the PHY Lib */
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Christian Marangi
maintainerRe: [net-next RFC PATCH v3 3/4] net: phy: Add support for Aeonsemi AS21xxx PHYs
In reply to Russell King (Oracle)Quoted 10 lines · Russell King (Oracle)
Quoted 9 lines · Christian Marangi
drivers/net/phy/as21xxx.c new file +9
-0+static int as21xxx_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) +{ +struct as21xxx_priv *priv; +u32 phy_id; +int ret; + +/* Skip PHY that are not AS21xxx or already have firmware loaded */ +if (phydev->c45_ids.device_ids[MDIO_MMD_PCS ] !=PHY_ID_AS21XXX )
Quoted 8 lines
drivers/net/phy/as21xxx.c line 855
Quoted 1 line
drivers/net/phy/as21xxx.c new file +1
-0+return phydev->phy_id == phydrv->phy_id;Isn't
phydev->phy_idzero here for a clause 45 PHY? If the firmware has been loaded, I believ eyou said thatPHY_ID_AS21XXXwon't be used, so theif()will be true, and because we've read clause 45 IDs,phydev->phy_idwill be zero meaning this will never match. So a PHY with firmware loaded won't ever match any of these drivers. This is probably not what you want.
You are right. I will generalize the function to skip having to redo the logic. With FW loaded either c45 and c22 ID are filled in.
Quoted 89 lines
I'd suggest converting the tail of
phy_bus_match()so that you can call that to do the standard matching using either C22 or C45 IDs as appropriate without duplicating that code.Quoted 38 lines
drivers/net/phy/as21xxx.c new file +38
-0+ +/* Read PHY ID to handle firmware just loaded */ + ret =phy_read_mmd (phydev,MDIO_MMD_PCS ,MII_PHYSID1 ); +if (ret <0 ) +return ret; + phy_id = ret <<16 ; + + ret =phy_read_mmd (phydev,MDIO_MMD_PCS ,MII_PHYSID2 ); +if (ret <0 ) +return ret; + phy_id |= ret; + +/* With PHY ID not the generic AS21xxx one assume +* the firmware just loaded +*/ +if (phy_id !=PHY_ID_AS21XXX ) +return phy_id == phydrv->phy_id; + +/* Allocate temp priv and load the firmware */ + priv =kzalloc (sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + +mutex_init (&priv->ipc_lock); + + ret =aeon_firmware_load (phydev); +if (ret) +return ret; + + ret =aeon_ipc_sync_parity (phydev, priv); +if (ret) +return ret; + +/* Enable PTP clk if not already Enabled */ + ret =phy_set_bits_mmd (phydev,MDIO_MMD_VEND1 ,VEND1_PTP_CLK , +VEND1_PTP_CLK_EN ); +if (ret) +return ret;drivers/net/phy/as21xxx.c line 903
Quoted 10 lines
drivers/net/phy/as21xxx.c new file +10
-0+ + ret =aeon_dpc_ra_enable (phydev, priv); +if (ret) +return ret; + +mutex_destroy (&priv->ipc_lock); +kfree (priv); + +/* Return not maching anyway as PHY ID will change after +* firmware is loaded. Also "This relies on the driver probe order."
drivers/net/phy/as21xxx.c line 911
Quoted 8 lines
drivers/net/phy/as21xxx.c new file +8
-0+*/ +return 0 ; +} + +static struct phy_driver as21xxx_drivers[] = { + { +/* PHY expose in C45 as 0x7500 0x9410 +* before firmware is loaded. Also "This driver entry must be attempted first to load the firmware and thus update the ID registers."
Quoted 6 lines
drivers/net/phy/as21xxx.c new file +6
-0+*/ +PHY_ID_MATCH_EXACT (PHY_ID_AS21XXX ), + .name = "Aeonsemi AS21xxx", + .match_phy_device = as21xxx_match_phy_device, + }, + {drivers/net/phy/as21xxx.c line 927
Quoted 10 lines
drivers/net/phy/as21xxx.c new file +10
-0+PHY_ID_MATCH_EXACT (PHY_ID_AS21011JB1 ), + .name = "Aeonsemi AS21011JB1", + .probe = as21xxx_probe, + .match_phy_device = as21xxx_match_phy_device, + .read_status = as21xxx_read_status, + .led_brightness_set = as21xxx_led_brightness_set, + .led_hw_is_supported = as21xxx_led_hw_is_supported, + .led_hw_control_set = as21xxx_led_hw_control_set, + .led_hw_control_get = as21xxx_led_hw_control_get, + .led_polarity_set = as21xxx_led_polarity_set,If I'm reading these driver entries correctly, the only reason for having separate entries is to be able to have a unique name printed for each - the methods themselves are all identical.
Quoted 5 lines
My feeling is that is not a sufficient reason to duplicate the driver entries, which adds bloat (not only in terms of static data, but also the data structures necessary to support each entry in sysfs.) However, lets see what Andrew says.
If you remember that was one of my crazy project in trying to reduce the array but I remember it did end up bad or abbandoned with the problem of having to reinvent each PHY. Probably my changes caused too much patch delta.
The proposal was exactly to pack all the struct that have similar OPs with introducing an array of PHY ID for each driver.
Signature · 1 line
Ansuel
Christian Marangi
maintainerRe: [net-next RFC PATCH v3 3/4] net: phy: Add support for Aeonsemi AS21xxx PHYs
Quoted 118 lines · Christian Marangi
Quoted 10 lines · Russell King (Oracle)
Quoted 9 lines · Christian Marangi
drivers/net/phy/as21xxx.c new file +9
-0+static int as21xxx_match_phy_device (struct phy_device *phydev, +const struct phy_driver *phydrv) +{ +struct as21xxx_priv *priv; +u32 phy_id; +int ret; + +/* Skip PHY that are not AS21xxx or already have firmware loaded */ +if (phydev->c45_ids.device_ids[MDIO_MMD_PCS ] !=PHY_ID_AS21XXX )Quoted 8 lines
drivers/net/phy/as21xxx.c line 855
Quoted 1 line
drivers/net/phy/as21xxx.c new file +1
-0+return phydev->phy_id == phydrv->phy_id;Isn't
phydev->phy_idzero here for a clause 45 PHY? If the firmware has been loaded, I believ eyou said thatPHY_ID_AS21XXXwon't be used, so theif()will be true, and because we've read clause 45 IDs,phydev->phy_idwill be zero meaning this will never match. So a PHY with firmware loaded won't ever match any of these drivers. This is probably not what you want.You are right. I will generalize the function to skip having to redo the logic. With FW loaded either c45 and c22 ID are filled in.
Quoted 89 lines
I'd suggest converting the tail of
phy_bus_match()so that you can call that to do the standard matching using either C22 or C45 IDs as appropriate without duplicating that code.Quoted 38 lines
drivers/net/phy/as21xxx.c new file +38
-0+ +/* Read PHY ID to handle firmware just loaded */ + ret =phy_read_mmd (phydev,MDIO_MMD_PCS ,MII_PHYSID1 ); +if (ret <0 ) +return ret; + phy_id = ret <<16 ; + + ret =phy_read_mmd (phydev,MDIO_MMD_PCS ,MII_PHYSID2 ); +if (ret <0 ) +return ret; + phy_id |= ret; + +/* With PHY ID not the generic AS21xxx one assume +* the firmware just loaded +*/ +if (phy_id !=PHY_ID_AS21XXX ) +return phy_id == phydrv->phy_id; + +/* Allocate temp priv and load the firmware */ + priv =kzalloc (sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + +mutex_init (&priv->ipc_lock); + + ret =aeon_firmware_load (phydev); +if (ret) +return ret; + + ret =aeon_ipc_sync_parity (phydev, priv); +if (ret) +return ret; + +/* Enable PTP clk if not already Enabled */ + ret =phy_set_bits_mmd (phydev,MDIO_MMD_VEND1 ,VEND1_PTP_CLK , +VEND1_PTP_CLK_EN ); +if (ret) +return ret;drivers/net/phy/as21xxx.c line 903
Quoted 10 lines
drivers/net/phy/as21xxx.c new file +10
-0+ + ret =aeon_dpc_ra_enable (phydev, priv); +if (ret) +return ret; + +mutex_destroy (&priv->ipc_lock); +kfree (priv); + +/* Return not maching anyway as PHY ID will change after +* firmware is loaded. Also "This relies on the driver probe order."
drivers/net/phy/as21xxx.c line 911
Quoted 8 lines
drivers/net/phy/as21xxx.c new file +8
-0+*/ +return 0 ; +} + +static struct phy_driver as21xxx_drivers[] = { + { +/* PHY expose in C45 as 0x7500 0x9410 +* before firmware is loaded. Also "This driver entry must be attempted first to load the firmware and thus update the ID registers."
Quoted 6 lines
drivers/net/phy/as21xxx.c new file +6
-0+*/ +PHY_ID_MATCH_EXACT (PHY_ID_AS21XXX ), + .name = "Aeonsemi AS21xxx", + .match_phy_device = as21xxx_match_phy_device, + }, + {drivers/net/phy/as21xxx.c line 927
Quoted 10 lines
drivers/net/phy/as21xxx.c new file +10
-0+PHY_ID_MATCH_EXACT (PHY_ID_AS21011JB1 ), + .name = "Aeonsemi AS21011JB1", + .probe = as21xxx_probe, + .match_phy_device = as21xxx_match_phy_device, + .read_status = as21xxx_read_status, + .led_brightness_set = as21xxx_led_brightness_set, + .led_hw_is_supported = as21xxx_led_hw_is_supported, + .led_hw_control_set = as21xxx_led_hw_control_set, + .led_hw_control_get = as21xxx_led_hw_control_get, + .led_polarity_set = as21xxx_led_polarity_set,If I'm reading these driver entries correctly, the only reason for having separate entries is to be able to have a unique name printed for each - the methods themselves are all identical.
Quoted 5 lines
My feeling is that is not a sufficient reason to duplicate the driver entries, which adds bloat (not only in terms of static data, but also the data structures necessary to support each entry in sysfs.) However, lets see what Andrew says.
Quoted 8 lines
If you remember that was one of my crazy project in trying to reduce the array but I remember it did end up bad or abbandoned with the problem of having to reinvent each PHY. Probably my changes caused too much patch delta.
The proposal was exactly to pack all the struct that have similar OPs with introducing an array of PHY ID for each driver.
Found the old series. [1]
[1] https://lore.kernel.org/all/[email protected]/
Signature · 1 line
Ansuel
Christian Marangi
maintainerRe: [net-next RFC PATCH v3 1/4] net: phy: pass PHY driver to .match_phy_device OP
In reply to Russell King (Oracle)Quoted 17 lines · Russell King (Oracle)
Quoted 16 lines · Christian Marangi
Pass PHY driver pointer to .match_phy_device OP in addition to phydev. Having access to the PHY driver struct might be useful to check the PHY ID of the driver is being matched for in case the PHY ID scanned in the phydev is not consistent.
A scenario for this is a PHY that change PHY ID after a firmware is loaded, in such case, the PHY ID stored in PHY device struct is not valid anymore and PHY will manually scan the ID in the
match_phy_devicefunction.Having the PHY driver info is also useful for those PHY driver that implement multiple simple .match_phy_device OP to match specific MMD PHY ID. With this extra info if the parsing logic is the same, the matching function can be generalized by using the
phy_idin the PHY driver instead of hardcoding.
Quoted 9 lines
Quoted 1 line
Suggested-by Russell King (Oracle) <[email protected]>Reviewed-by Russell King (Oracle) <[email protected]>Please also update the email address in the suggested-by to match the one in my reviewed-by for the next resend.
Thanks!
kernel test robot made me aware that this cause error with nxp-c45-tja11xx. I was on an old net-next branch and didn't notice the ""recent"" changes to macsec support. I'm updating this and keeping the reviewed-by tag, hope it's OK.
Also adding the simplify commit as suggested that recive the match_phy_device.
Signature · 1 line
Ansuel