Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'net-phy-support-master-slave-config-via-device-tree'

Oleksij Rempel says:

====================
net: phy: Support master-slave config via device tree

This patch series adds support for configuring the master/slave role of
PHYs via the device tree. A new `master-slave` property is introduced in
the device tree bindings, allowing PHYs to be forced into either master
or slave mode. This is particularly necessary for Single Pair Ethernet
(SPE) PHYs (1000/100/10Base-T1), where hardware strap pins may not be
available or correctly configured, but it is applicable to all PHY
types.

changes v5:
- sync DT options with ethtool nameing.

changes v4:
- add Reviewed-by
- rebase against latest net-next

changes v3:
- rename master-slave to timing-role
- add prefer-master/slave support
====================

Link: https://patch.msgid.link/20241004090100.1654353-1-o.rempel@pengutronix.de
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

+58
+21
Documentation/devicetree/bindings/net/ethernet-phy.yaml
··· 158 158 Mark the corresponding energy efficient ethernet mode as 159 159 broken and request the ethernet to stop advertising it. 160 160 161 + timing-role: 162 + $ref: /schemas/types.yaml#/definitions/string 163 + enum: 164 + - forced-master 165 + - forced-slave 166 + - preferred-master 167 + - preferred-slave 168 + description: | 169 + Specifies the timing role of the PHY in the network link. This property is 170 + required for setups where the role must be explicitly assigned via the 171 + device tree due to limitations in hardware strapping or incorrect strap 172 + configurations. 173 + It is applicable to Single Pair Ethernet (1000/100/10Base-T1) and other 174 + PHY types, including 1000Base-T, where it controls whether the PHY should 175 + be a master (clock source) or a slave (clock receiver). 176 + 177 + - 'forced-master': The PHY is forced to operate as a master. 178 + - 'forced-slave': The PHY is forced to operate as a slave. 179 + - 'preferred-master': Prefer the PHY to be master but allow negotiation. 180 + - 'preferred-slave': Prefer the PHY to be slave but allow negotiation. 181 + 161 182 pses: 162 183 $ref: /schemas/types.yaml#/definitions/phandle-array 163 184 maxItems: 1
+33
drivers/net/phy/phy-core.c
··· 413 413 } 414 414 415 415 /** 416 + * of_set_phy_timing_role - Set the master/slave mode of the PHY 417 + * 418 + * @phydev: The phy_device struct 419 + * 420 + * Set master/slave configuration of the PHY based on the device tree. 421 + */ 422 + void of_set_phy_timing_role(struct phy_device *phydev) 423 + { 424 + struct device_node *node = phydev->mdio.dev.of_node; 425 + const char *master; 426 + 427 + if (!IS_ENABLED(CONFIG_OF_MDIO)) 428 + return; 429 + 430 + if (!node) 431 + return; 432 + 433 + if (of_property_read_string(node, "timing-role", &master)) 434 + return; 435 + 436 + if (strcmp(master, "forced-master") == 0) 437 + phydev->master_slave_set = MASTER_SLAVE_CFG_MASTER_FORCE; 438 + else if (strcmp(master, "forced-slave") == 0) 439 + phydev->master_slave_set = MASTER_SLAVE_CFG_SLAVE_FORCE; 440 + else if (strcmp(master, "preferred-master") == 0) 441 + phydev->master_slave_set = MASTER_SLAVE_CFG_MASTER_PREFERRED; 442 + else if (strcmp(master, "preferred-slave") == 0) 443 + phydev->master_slave_set = MASTER_SLAVE_CFG_SLAVE_PREFERRED; 444 + else 445 + phydev_warn(phydev, "Unknown master-slave mode %s\n", master); 446 + } 447 + 448 + /** 416 449 * phy_resolve_aneg_pause - Determine pause autoneg results 417 450 * 418 451 * @phydev: The phy_device struct
+3
drivers/net/phy/phy_device.c
··· 3608 3608 */ 3609 3609 of_set_phy_eee_broken(phydev); 3610 3610 3611 + /* Get master/slave strap overrides */ 3612 + of_set_phy_timing_role(phydev); 3613 + 3611 3614 /* The Pause Frame bits indicate that the PHY can support passing 3612 3615 * pause frames. During autonegotiation, the PHYs will determine if 3613 3616 * they should allow pause frames to pass. The MAC driver should then
+1
include/linux/phy.h
··· 1260 1260 unsigned long *mask); 1261 1261 void of_set_phy_supported(struct phy_device *phydev); 1262 1262 void of_set_phy_eee_broken(struct phy_device *phydev); 1263 + void of_set_phy_timing_role(struct phy_device *phydev); 1263 1264 int phy_speed_down_core(struct phy_device *phydev); 1264 1265 1265 1266 /**