* [PATCH net-next v4 0/2] net: phy: Support master-slave config via device tree
@ 2024-10-01 7:37 Oleksij Rempel
2024-10-01 7:37 ` [PATCH net-next v4 1/2] dt-bindings: net: ethernet-phy: Add timing-role role property for ethernet PHYs Oleksij Rempel
2024-10-01 7:37 ` [PATCH net-next v4 2/2] net: phy: Add support for PHY timing-role configuration via device tree Oleksij Rempel
0 siblings, 2 replies; 12+ messages in thread
From: Oleksij Rempel @ 2024-10-01 7:37 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Florian Fainelli
Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Russell King,
devicetree
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 v4:
- add Reviewed-by
- rebase against latest net-next
changes v3:
- rename master-slave to timing-role
- add prefer-master/slave support
Oleksij Rempel (2):
dt-bindings: net: ethernet-phy: Add timing-role role property for
ethernet PHYs
net: phy: Add support for PHY timing-role configuration via device
tree
.../devicetree/bindings/net/ethernet-phy.yaml | 21 ++++++++++++
drivers/net/phy/phy-core.c | 33 +++++++++++++++++++
drivers/net/phy/phy_device.c | 3 ++
include/linux/phy.h | 1 +
4 files changed, 58 insertions(+)
--
2.39.5
^ permalink raw reply [flat|nested] 12+ messages in thread* [PATCH net-next v4 1/2] dt-bindings: net: ethernet-phy: Add timing-role role property for ethernet PHYs 2024-10-01 7:37 [PATCH net-next v4 0/2] net: phy: Support master-slave config via device tree Oleksij Rempel @ 2024-10-01 7:37 ` Oleksij Rempel 2024-10-02 4:29 ` Florian Fainelli 2024-10-03 10:49 ` Divya.Koppera 2024-10-01 7:37 ` [PATCH net-next v4 2/2] net: phy: Add support for PHY timing-role configuration via device tree Oleksij Rempel 1 sibling, 2 replies; 12+ messages in thread From: Oleksij Rempel @ 2024-10-01 7:37 UTC (permalink / raw) To: Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Florian Fainelli Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Russell King, devicetree This patch introduces a new `timing-role` property in the device tree bindings for configuring the master/slave role of PHYs. This is essential for scenarios where hardware strap pins are unavailable or incorrectly configured. The `timing-role` property supports the following values: - `force-master`: Forces the PHY to operate as a master (clock source). - `force-slave`: Forces the PHY to operate as a slave (clock receiver). - `prefer-master`: Prefers the PHY to be master but allows negotiation. - `prefer-slave`: Prefers the PHY to be slave but allows negotiation. The terms "master" and "slave" are retained in this context to align with the IEEE 802.3 standards, where they are used to describe the roles of PHY devices in managing clock signals for data transmission. In particular, the terms are used in specifications for 1000Base-T and MultiGBASE-T PHYs, among others. Although there is an effort to adopt more inclusive terminology, replacing these terms could create discrepancies between the Linux kernel and the established standards, documentation, and existing hardware interfaces. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Reviewed-by: Rob Herring (Arm) <robh@kernel.org> --- changes v4: - add "Reviewed-by: Rob Herring (Arm) <robh@kernel.org>" changes v3: - rename "master-slave" to "timing-role" changes v2: - use string property instead of multiple flags --- .../devicetree/bindings/net/ethernet-phy.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ethernet-phy.yaml b/Documentation/devicetree/bindings/net/ethernet-phy.yaml index d9b62741a2259..da9eaa811d70f 100644 --- a/Documentation/devicetree/bindings/net/ethernet-phy.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-phy.yaml @@ -158,6 +158,27 @@ properties: Mark the corresponding energy efficient ethernet mode as broken and request the ethernet to stop advertising it. + timing-role: + $ref: /schemas/types.yaml#/definitions/string + enum: + - force-master + - force-slave + - prefer-master + - prefer-slave + description: | + Specifies the timing role of the PHY in the network link. This property is + required for setups where the role must be explicitly assigned via the + device tree due to limitations in hardware strapping or incorrect strap + configurations. + It is applicable to Single Pair Ethernet (1000/100/10Base-T1) and other + PHY types, including 1000Base-T, where it controls whether the PHY should + be a master (clock source) or a slave (clock receiver). + + - 'force-master': The PHY is forced to operate as a master. + - 'force-slave': The PHY is forced to operate as a slave. + - 'prefer-master': Prefer the PHY to be master but allow negotiation. + - 'prefer-slave': Prefer the PHY to be slave but allow negotiation. + pses: $ref: /schemas/types.yaml#/definitions/phandle-array maxItems: 1 -- 2.39.5 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 1/2] dt-bindings: net: ethernet-phy: Add timing-role role property for ethernet PHYs 2024-10-01 7:37 ` [PATCH net-next v4 1/2] dt-bindings: net: ethernet-phy: Add timing-role role property for ethernet PHYs Oleksij Rempel @ 2024-10-02 4:29 ` Florian Fainelli 2024-10-03 10:49 ` Divya.Koppera 1 sibling, 0 replies; 12+ messages in thread From: Florian Fainelli @ 2024-10-02 4:29 UTC (permalink / raw) To: Oleksij Rempel, Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: kernel, linux-kernel, netdev, Russell King, devicetree On 10/1/2024 12:37 AM, Oleksij Rempel wrote: > This patch introduces a new `timing-role` property in the device tree > bindings for configuring the master/slave role of PHYs. This is > essential for scenarios where hardware strap pins are unavailable or > incorrectly configured. > > The `timing-role` property supports the following values: > - `force-master`: Forces the PHY to operate as a master (clock source). > - `force-slave`: Forces the PHY to operate as a slave (clock receiver). > - `prefer-master`: Prefers the PHY to be master but allows negotiation. > - `prefer-slave`: Prefers the PHY to be slave but allows negotiation. > > The terms "master" and "slave" are retained in this context to align > with the IEEE 802.3 standards, where they are used to describe the roles > of PHY devices in managing clock signals for data transmission. In > particular, the terms are used in specifications for 1000Base-T and > MultiGBASE-T PHYs, among others. Although there is an effort to adopt > more inclusive terminology, replacing these terms could create > discrepancies between the Linux kernel and the established standards, > documentation, and existing hardware interfaces. > > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> > Reviewed-by: Rob Herring (Arm) <robh@kernel.org> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> -- Florian ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH net-next v4 1/2] dt-bindings: net: ethernet-phy: Add timing-role role property for ethernet PHYs 2024-10-01 7:37 ` [PATCH net-next v4 1/2] dt-bindings: net: ethernet-phy: Add timing-role role property for ethernet PHYs Oleksij Rempel 2024-10-02 4:29 ` Florian Fainelli @ 2024-10-03 10:49 ` Divya.Koppera 2024-10-03 12:08 ` Andrew Lunn 1 sibling, 1 reply; 12+ messages in thread From: Divya.Koppera @ 2024-10-03 10:49 UTC (permalink / raw) To: o.rempel, andrew, hkallweit1, davem, edumazet, kuba, pabeni, robh, krzk+dt, conor+dt, f.fainelli Cc: kernel, linux-kernel, netdev, linux, devicetree > -----Original Message----- > From: Oleksij Rempel <o.rempel@pengutronix.de> > Sent: Tuesday, October 1, 2024 1:07 PM > To: Andrew Lunn <andrew@lunn.ch>; Heiner Kallweit > <hkallweit1@gmail.com>; David S. Miller <davem@davemloft.net>; Eric > Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo > Abeni <pabeni@redhat.com>; Rob Herring <robh@kernel.org>; Krzysztof > Kozlowski <krzk+dt@kernel.org>; Conor Dooley <conor+dt@kernel.org>; > Florian Fainelli <f.fainelli@gmail.com> > Cc: Oleksij Rempel <o.rempel@pengutronix.de>; kernel@pengutronix.de; > linux-kernel@vger.kernel.org; netdev@vger.kernel.org; Russell King > <linux@armlinux.org.uk>; devicetree@vger.kernel.org > Subject: [PATCH net-next v4 1/2] dt-bindings: net: ethernet-phy: Add timing- > role role property for ethernet PHYs > > EXTERNAL EMAIL: Do not click links or open attachments unless you know the > content is safe > > This patch introduces a new `timing-role` property in the device tree bindings > for configuring the master/slave role of PHYs. This is essential for scenarios > where hardware strap pins are unavailable or incorrectly configured. > > The `timing-role` property supports the following values: > - `force-master`: Forces the PHY to operate as a master (clock source). > - `force-slave`: Forces the PHY to operate as a slave (clock receiver). > - `prefer-master`: Prefers the PHY to be master but allows negotiation. > - `prefer-slave`: Prefers the PHY to be slave but allows negotiation. > > The terms "master" and "slave" are retained in this context to align with the > IEEE 802.3 standards, where they are used to describe the roles of PHY > devices in managing clock signals for data transmission. In particular, the > terms are used in specifications for 1000Base-T and MultiGBASE-T PHYs, > among others. Although there is an effort to adopt more inclusive > terminology, replacing these terms could create discrepancies between the > Linux kernel and the established standards, documentation, and existing > hardware interfaces. > > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> > Reviewed-by: Rob Herring (Arm) <robh@kernel.org> > --- > changes v4: > - add "Reviewed-by: Rob Herring (Arm) <robh@kernel.org>" > changes v3: > - rename "master-slave" to "timing-role" > changes v2: > - use string property instead of multiple flags > --- > .../devicetree/bindings/net/ethernet-phy.yaml | 21 +++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/Documentation/devicetree/bindings/net/ethernet-phy.yaml > b/Documentation/devicetree/bindings/net/ethernet-phy.yaml > index d9b62741a2259..da9eaa811d70f 100644 > --- a/Documentation/devicetree/bindings/net/ethernet-phy.yaml > +++ b/Documentation/devicetree/bindings/net/ethernet-phy.yaml > @@ -158,6 +158,27 @@ properties: > Mark the corresponding energy efficient ethernet mode as > broken and request the ethernet to stop advertising it. > > + timing-role: > + $ref: /schemas/types.yaml#/definitions/string > + enum: > + - force-master > + - force-slave > + - prefer-master > + - prefer-slave > + description: | > + Specifies the timing role of the PHY in the network link. This property is > + required for setups where the role must be explicitly assigned via the > + device tree due to limitations in hardware strapping or incorrect strap > + configurations. > + It is applicable to Single Pair Ethernet (1000/100/10Base-T1) and other > + PHY types, including 1000Base-T, where it controls whether the PHY > should > + be a master (clock source) or a slave (clock receiver). > + > + - 'force-master': The PHY is forced to operate as a master. > + - 'force-slave': The PHY is forced to operate as a slave. > + - 'prefer-master': Prefer the PHY to be master but allow negotiation. > + - 'prefer-slave': Prefer the PHY to be slave but allow negotiation. > + I would suggest to use "preferred" instead of "prefer" to be in sync with existing phy library macros. > pses: > $ref: /schemas/types.yaml#/definitions/phandle-array > maxItems: 1 > -- > 2.39.5 > Reviewed-by: Divya Koppera <divya.koppera@microchip.com> ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 1/2] dt-bindings: net: ethernet-phy: Add timing-role role property for ethernet PHYs 2024-10-03 10:49 ` Divya.Koppera @ 2024-10-03 12:08 ` Andrew Lunn 2024-10-03 13:08 ` Oleksij Rempel 0 siblings, 1 reply; 12+ messages in thread From: Andrew Lunn @ 2024-10-03 12:08 UTC (permalink / raw) To: Divya.Koppera Cc: o.rempel, hkallweit1, davem, edumazet, kuba, pabeni, robh, krzk+dt, conor+dt, f.fainelli, kernel, linux-kernel, netdev, linux, devicetree > > + - 'force-master': The PHY is forced to operate as a master. > > + - 'force-slave': The PHY is forced to operate as a slave. > > + - 'prefer-master': Prefer the PHY to be master but allow negotiation. > > + - 'prefer-slave': Prefer the PHY to be slave but allow negotiation. > > + > > I would suggest to use "preferred" instead of "prefer" to be in sync with existing phy library macros. How does 802.3 name it? Andrew ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 1/2] dt-bindings: net: ethernet-phy: Add timing-role role property for ethernet PHYs 2024-10-03 12:08 ` Andrew Lunn @ 2024-10-03 13:08 ` Oleksij Rempel 2024-10-03 17:05 ` Andrew Lunn 0 siblings, 1 reply; 12+ messages in thread From: Oleksij Rempel @ 2024-10-03 13:08 UTC (permalink / raw) To: Andrew Lunn Cc: Divya.Koppera, hkallweit1, davem, edumazet, kuba, pabeni, robh, krzk+dt, conor+dt, f.fainelli, kernel, linux-kernel, netdev, linux, devicetree On Thu, Oct 03, 2024 at 02:08:00PM +0200, Andrew Lunn wrote: > > > + - 'force-master': The PHY is forced to operate as a master. > > > + - 'force-slave': The PHY is forced to operate as a slave. > > > + - 'prefer-master': Prefer the PHY to be master but allow negotiation. > > > + - 'prefer-slave': Prefer the PHY to be slave but allow negotiation. > > > + > > > > I would suggest to use "preferred" instead of "prefer" to be in sync with existing phy library macros. > > How does 802.3 name it? 802.3 use "Multiport device" for "preferred master" and "single-port device" for "preferred slave". We decided to use other wording back in the past to avoid confusing and align it with forced master/slave configurations. -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 1/2] dt-bindings: net: ethernet-phy: Add timing-role role property for ethernet PHYs 2024-10-03 13:08 ` Oleksij Rempel @ 2024-10-03 17:05 ` Andrew Lunn 2024-10-04 16:51 ` Jakub Kicinski 0 siblings, 1 reply; 12+ messages in thread From: Andrew Lunn @ 2024-10-03 17:05 UTC (permalink / raw) To: Oleksij Rempel Cc: Divya.Koppera, hkallweit1, davem, edumazet, kuba, pabeni, robh, krzk+dt, conor+dt, f.fainelli, kernel, linux-kernel, netdev, linux, devicetree On Thu, Oct 03, 2024 at 03:08:09PM +0200, Oleksij Rempel wrote: > On Thu, Oct 03, 2024 at 02:08:00PM +0200, Andrew Lunn wrote: > > > > + - 'force-master': The PHY is forced to operate as a master. > > > > + - 'force-slave': The PHY is forced to operate as a slave. > > > > + - 'prefer-master': Prefer the PHY to be master but allow negotiation. > > > > + - 'prefer-slave': Prefer the PHY to be slave but allow negotiation. > > > > + > > > > > > I would suggest to use "preferred" instead of "prefer" to be in sync with existing phy library macros. > > > > How does 802.3 name it? > > 802.3 use "Multiport device" for "preferred master" and "single-port device" > for "preferred slave". We decided to use other wording back in the past > to avoid confusing and align it with forced master/slave configurations. ethtool is preferred, so it would be more consistent with preferred [Shrug] Andrew ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 1/2] dt-bindings: net: ethernet-phy: Add timing-role role property for ethernet PHYs 2024-10-03 17:05 ` Andrew Lunn @ 2024-10-04 16:51 ` Jakub Kicinski 2024-10-07 5:15 ` Oleksij Rempel 0 siblings, 1 reply; 12+ messages in thread From: Jakub Kicinski @ 2024-10-04 16:51 UTC (permalink / raw) To: Andrew Lunn Cc: Oleksij Rempel, Divya.Koppera, hkallweit1, davem, edumazet, pabeni, robh, krzk+dt, conor+dt, f.fainelli, kernel, linux-kernel, netdev, linux, devicetree On Thu, 3 Oct 2024 19:05:58 +0200 Andrew Lunn wrote: > > 802.3 use "Multiport device" for "preferred master" and "single-port device" > > for "preferred slave". We decided to use other wording back in the past > > to avoid confusing and align it with forced master/slave configurations. > > ethtool is preferred, so it would be more consistent with preferred > > [Shrug] IIUC we have two weak preferences for "preferred"? LMK if I misunderstood. -- pw-bot: cr ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 1/2] dt-bindings: net: ethernet-phy: Add timing-role role property for ethernet PHYs 2024-10-04 16:51 ` Jakub Kicinski @ 2024-10-07 5:15 ` Oleksij Rempel 0 siblings, 0 replies; 12+ messages in thread From: Oleksij Rempel @ 2024-10-07 5:15 UTC (permalink / raw) To: Jakub Kicinski Cc: Andrew Lunn, Divya.Koppera, hkallweit1, davem, edumazet, pabeni, robh, krzk+dt, conor+dt, f.fainelli, kernel, linux-kernel, netdev, linux, devicetree On Fri, Oct 04, 2024 at 09:51:54AM -0700, Jakub Kicinski wrote: > On Thu, 3 Oct 2024 19:05:58 +0200 Andrew Lunn wrote: > > > 802.3 use "Multiport device" for "preferred master" and "single-port device" > > > for "preferred slave". We decided to use other wording back in the past > > > to avoid confusing and align it with forced master/slave configurations. > > > > ethtool is preferred, so it would be more consistent with preferred > > > > [Shrug] > > IIUC we have two weak preferences for "preferred"? > LMK if I misunderstood. Ahm... yes :) -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next v4 2/2] net: phy: Add support for PHY timing-role configuration via device tree 2024-10-01 7:37 [PATCH net-next v4 0/2] net: phy: Support master-slave config via device tree Oleksij Rempel 2024-10-01 7:37 ` [PATCH net-next v4 1/2] dt-bindings: net: ethernet-phy: Add timing-role role property for ethernet PHYs Oleksij Rempel @ 2024-10-01 7:37 ` Oleksij Rempel 2024-10-02 4:29 ` Florian Fainelli 2024-10-03 10:45 ` Divya.Koppera 1 sibling, 2 replies; 12+ messages in thread From: Oleksij Rempel @ 2024-10-01 7:37 UTC (permalink / raw) To: Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Florian Fainelli Cc: Oleksij Rempel, Russell King, kernel, linux-kernel, netdev, Russell King, devicetree Introduce support for configuring the master/slave role of PHYs based on the `timing-role` property in the device tree. While this functionality is necessary for Single Pair Ethernet (SPE) PHYs (1000/100/10Base-T1) where hardware strap pins may be unavailable or incorrectly set, it works for any PHY type. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> --- changes v4: - add "Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>" changes v3: - rename master-slave to timing-role --- drivers/net/phy/phy-core.c | 33 +++++++++++++++++++++++++++++++++ drivers/net/phy/phy_device.c | 3 +++ include/linux/phy.h | 1 + 3 files changed, 37 insertions(+) diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c index 1f98b6a96c153..97ff10e226180 100644 --- a/drivers/net/phy/phy-core.c +++ b/drivers/net/phy/phy-core.c @@ -412,6 +412,39 @@ void of_set_phy_eee_broken(struct phy_device *phydev) phydev->eee_broken_modes = broken; } +/** + * of_set_phy_timing_role - Set the master/slave mode of the PHY + * + * @phydev: The phy_device struct + * + * Set master/slave configuration of the PHY based on the device tree. + */ +void of_set_phy_timing_role(struct phy_device *phydev) +{ + struct device_node *node = phydev->mdio.dev.of_node; + const char *master; + + if (!IS_ENABLED(CONFIG_OF_MDIO)) + return; + + if (!node) + return; + + if (of_property_read_string(node, "timing-role", &master)) + return; + + if (strcmp(master, "force-master") == 0) + phydev->master_slave_set = MASTER_SLAVE_CFG_MASTER_FORCE; + else if (strcmp(master, "force-slave") == 0) + phydev->master_slave_set = MASTER_SLAVE_CFG_SLAVE_FORCE; + else if (strcmp(master, "prefer-master") == 0) + phydev->master_slave_set = MASTER_SLAVE_CFG_MASTER_PREFERRED; + else if (strcmp(master, "prefer-slave") == 0) + phydev->master_slave_set = MASTER_SLAVE_CFG_SLAVE_PREFERRED; + else + phydev_warn(phydev, "Unknown master-slave mode %s\n", master); +} + /** * phy_resolve_aneg_pause - Determine pause autoneg results * diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 560e338b307a4..4ccf504a8b2c2 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3608,6 +3608,9 @@ static int phy_probe(struct device *dev) */ of_set_phy_eee_broken(phydev); + /* Get master/slave strap overrides */ + of_set_phy_timing_role(phydev); + /* The Pause Frame bits indicate that the PHY can support passing * pause frames. During autonegotiation, the PHYs will determine if * they should allow pause frames to pass. The MAC driver should then diff --git a/include/linux/phy.h b/include/linux/phy.h index a98bc91a0cde9..ff762a3d8270a 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1260,6 +1260,7 @@ size_t phy_speeds(unsigned int *speeds, size_t size, unsigned long *mask); void of_set_phy_supported(struct phy_device *phydev); void of_set_phy_eee_broken(struct phy_device *phydev); +void of_set_phy_timing_role(struct phy_device *phydev); int phy_speed_down_core(struct phy_device *phydev); /** -- 2.39.5 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v4 2/2] net: phy: Add support for PHY timing-role configuration via device tree 2024-10-01 7:37 ` [PATCH net-next v4 2/2] net: phy: Add support for PHY timing-role configuration via device tree Oleksij Rempel @ 2024-10-02 4:29 ` Florian Fainelli 2024-10-03 10:45 ` Divya.Koppera 1 sibling, 0 replies; 12+ messages in thread From: Florian Fainelli @ 2024-10-02 4:29 UTC (permalink / raw) To: Oleksij Rempel, Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: Russell King, kernel, linux-kernel, netdev, Russell King, devicetree On 10/1/2024 12:37 AM, Oleksij Rempel wrote: > Introduce support for configuring the master/slave role of PHYs based on > the `timing-role` property in the device tree. While this functionality > is necessary for Single Pair Ethernet (SPE) PHYs (1000/100/10Base-T1) > where hardware strap pins may be unavailable or incorrectly set, it > works for any PHY type. > > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> > Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> -- Florian ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH net-next v4 2/2] net: phy: Add support for PHY timing-role configuration via device tree 2024-10-01 7:37 ` [PATCH net-next v4 2/2] net: phy: Add support for PHY timing-role configuration via device tree Oleksij Rempel 2024-10-02 4:29 ` Florian Fainelli @ 2024-10-03 10:45 ` Divya.Koppera 1 sibling, 0 replies; 12+ messages in thread From: Divya.Koppera @ 2024-10-03 10:45 UTC (permalink / raw) To: o.rempel, andrew, hkallweit1, davem, edumazet, kuba, pabeni, robh, krzk+dt, conor+dt, f.fainelli Cc: rmk+kernel, kernel, linux-kernel, netdev, linux, devicetree Hi @Oleksij Rempel > -----Original Message----- > From: Oleksij Rempel <o.rempel@pengutronix.de> > Sent: Tuesday, October 1, 2024 1:07 PM > To: Andrew Lunn <andrew@lunn.ch>; Heiner Kallweit > <hkallweit1@gmail.com>; David S. Miller <davem@davemloft.net>; Eric > Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo > Abeni <pabeni@redhat.com>; Rob Herring <robh@kernel.org>; Krzysztof > Kozlowski <krzk+dt@kernel.org>; Conor Dooley <conor+dt@kernel.org>; > Florian Fainelli <f.fainelli@gmail.com> > Cc: Oleksij Rempel <o.rempel@pengutronix.de>; Russell King > <rmk+kernel@armlinux.org.uk>; kernel@pengutronix.de; linux- > kernel@vger.kernel.org; netdev@vger.kernel.org; Russell King > <linux@armlinux.org.uk>; devicetree@vger.kernel.org > Subject: [PATCH net-next v4 2/2] net: phy: Add support for PHY timing-role > configuration via device tree > > EXTERNAL EMAIL: Do not click links or open attachments unless you know the > content is safe > > Introduce support for configuring the master/slave role of PHYs based on the > `timing-role` property in the device tree. While this functionality is necessary > for Single Pair Ethernet (SPE) PHYs (1000/100/10Base-T1) where hardware > strap pins may be unavailable or incorrectly set, it works for any PHY type. > > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> > Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> > --- > changes v4: > - add "Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>" > changes v3: > - rename master-slave to timing-role > --- > drivers/net/phy/phy-core.c | 33 +++++++++++++++++++++++++++++++++ > drivers/net/phy/phy_device.c | 3 +++ > include/linux/phy.h | 1 + > 3 files changed, 37 insertions(+) > > diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c index > 1f98b6a96c153..97ff10e226180 100644 > --- a/drivers/net/phy/phy-core.c > +++ b/drivers/net/phy/phy-core.c > @@ -412,6 +412,39 @@ void of_set_phy_eee_broken(struct phy_device > *phydev) > phydev->eee_broken_modes = broken; } > > +/** > + * of_set_phy_timing_role - Set the master/slave mode of the PHY > + * > + * @phydev: The phy_device struct > + * > + * Set master/slave configuration of the PHY based on the device tree. > + */ > +void of_set_phy_timing_role(struct phy_device *phydev) { > + struct device_node *node = phydev->mdio.dev.of_node; > + const char *master; > + > + if (!IS_ENABLED(CONFIG_OF_MDIO)) > + return; > + > + if (!node) > + return; > + > + if (of_property_read_string(node, "timing-role", &master)) > + return; > + > + if (strcmp(master, "force-master") == 0) > + phydev->master_slave_set = MASTER_SLAVE_CFG_MASTER_FORCE; > + else if (strcmp(master, "force-slave") == 0) > + phydev->master_slave_set = MASTER_SLAVE_CFG_SLAVE_FORCE; > + else if (strcmp(master, "prefer-master") == 0) > + phydev->master_slave_set = > MASTER_SLAVE_CFG_MASTER_PREFERRED; > + else if (strcmp(master, "prefer-slave") == 0) I would suggest to use "preferred" instead of "prefer" to be in sync with existing macros. > + phydev->master_slave_set = > MASTER_SLAVE_CFG_SLAVE_PREFERRED; > + else > + phydev_warn(phydev, "Unknown master-slave mode %s\n", > +master); } > + > /** > * phy_resolve_aneg_pause - Determine pause autoneg results > * > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c > index 560e338b307a4..4ccf504a8b2c2 100644 > --- a/drivers/net/phy/phy_device.c > +++ b/drivers/net/phy/phy_device.c > @@ -3608,6 +3608,9 @@ static int phy_probe(struct device *dev) > */ > of_set_phy_eee_broken(phydev); > > + /* Get master/slave strap overrides */ > + of_set_phy_timing_role(phydev); > + > /* The Pause Frame bits indicate that the PHY can support passing > * pause frames. During autonegotiation, the PHYs will determine if > * they should allow pause frames to pass. The MAC driver should then > diff --git a/include/linux/phy.h b/include/linux/phy.h index > a98bc91a0cde9..ff762a3d8270a 100644 > --- a/include/linux/phy.h > +++ b/include/linux/phy.h > @@ -1260,6 +1260,7 @@ size_t phy_speeds(unsigned int *speeds, size_t size, > unsigned long *mask); > void of_set_phy_supported(struct phy_device *phydev); void > of_set_phy_eee_broken(struct phy_device *phydev); > +void of_set_phy_timing_role(struct phy_device *phydev); > int phy_speed_down_core(struct phy_device *phydev); > > /** > -- > 2.39.5 > LGTM. Reviewed-by: Divya Koppera <divya.koppera@microchip.com> ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-10-07 5:15 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-10-01 7:37 [PATCH net-next v4 0/2] net: phy: Support master-slave config via device tree Oleksij Rempel 2024-10-01 7:37 ` [PATCH net-next v4 1/2] dt-bindings: net: ethernet-phy: Add timing-role role property for ethernet PHYs Oleksij Rempel 2024-10-02 4:29 ` Florian Fainelli 2024-10-03 10:49 ` Divya.Koppera 2024-10-03 12:08 ` Andrew Lunn 2024-10-03 13:08 ` Oleksij Rempel 2024-10-03 17:05 ` Andrew Lunn 2024-10-04 16:51 ` Jakub Kicinski 2024-10-07 5:15 ` Oleksij Rempel 2024-10-01 7:37 ` [PATCH net-next v4 2/2] net: phy: Add support for PHY timing-role configuration via device tree Oleksij Rempel 2024-10-02 4:29 ` Florian Fainelli 2024-10-03 10:45 ` Divya.Koppera
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).