* [PATCH net-next v2 1/3] dt-bindings: net: ethernet-phy: add property tx-amplitude-100base-tx-gain-milli
2025-01-20 13:50 [PATCH net-next v2 0/3] net: phy: dp83822: Add support for changing the transmit amplitude voltage Dimitri Fedrau via B4 Relay
@ 2025-01-20 13:50 ` Dimitri Fedrau via B4 Relay
2025-01-21 10:17 ` Krzysztof Kozlowski
2025-01-20 13:50 ` [PATCH net-next v2 2/3] net: phy: Add helper for getting tx amplitude gain Dimitri Fedrau via B4 Relay
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Dimitri Fedrau via B4 Relay @ 2025-01-20 13:50 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Andrew Davis, Andrew Lunn, Heiner Kallweit, Russell King,
Florian Fainelli
Cc: netdev, devicetree, linux-kernel, Dimitri Fedrau, Dimitri Fedrau
From: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
Add property tx-amplitude-100base-tx-gain-milli in the device tree bindings
for configuring the tx amplitude of 100BASE-TX PHYs. Modifying it can be
necessary to compensate losses on the PCB and connector, so the voltages
measured on the RJ45 pins are conforming.
Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
---
Documentation/devicetree/bindings/net/ethernet-phy.yaml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/ethernet-phy.yaml b/Documentation/devicetree/bindings/net/ethernet-phy.yaml
index 2c71454ae8e362e7032e44712949e12da6826070..ce65413410c2343a3525e746e72b6c6c8bb120d0 100644
--- a/Documentation/devicetree/bindings/net/ethernet-phy.yaml
+++ b/Documentation/devicetree/bindings/net/ethernet-phy.yaml
@@ -232,6 +232,14 @@ properties:
PHY's that have configurable TX internal delays. If this property is
present then the PHY applies the TX delay.
+ tx-amplitude-100base-tx-gain-milli:
+ description: |
+ Transmit amplitude gain applied (in milli units) for 100BASE-TX. When
+ omitted, the PHYs default will be left as is. If not present, default to
+ 1000 (no actual gain applied).
+ $ref: /schemas/types.yaml#/definitions/uint32
+ default: 1000
+
leds:
type: object
--
2.39.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH net-next v2 1/3] dt-bindings: net: ethernet-phy: add property tx-amplitude-100base-tx-gain-milli
2025-01-20 13:50 ` [PATCH net-next v2 1/3] dt-bindings: net: ethernet-phy: add property tx-amplitude-100base-tx-gain-milli Dimitri Fedrau via B4 Relay
@ 2025-01-21 10:17 ` Krzysztof Kozlowski
2025-01-24 6:36 ` Dimitri Fedrau
0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-21 10:17 UTC (permalink / raw)
To: Dimitri Fedrau
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Andrew Davis, Andrew Lunn, Heiner Kallweit, Russell King,
Florian Fainelli, netdev, devicetree, linux-kernel,
Dimitri Fedrau
On Mon, Jan 20, 2025 at 02:50:21PM +0100, Dimitri Fedrau wrote:
> Add property tx-amplitude-100base-tx-gain-milli in the device tree bindings
> for configuring the tx amplitude of 100BASE-TX PHYs. Modifying it can be
> necessary to compensate losses on the PCB and connector, so the voltages
> measured on the RJ45 pins are conforming.
>
> Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
> ---
> Documentation/devicetree/bindings/net/ethernet-phy.yaml | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/net/ethernet-phy.yaml b/Documentation/devicetree/bindings/net/ethernet-phy.yaml
> index 2c71454ae8e362e7032e44712949e12da6826070..ce65413410c2343a3525e746e72b6c6c8bb120d0 100644
> --- a/Documentation/devicetree/bindings/net/ethernet-phy.yaml
> +++ b/Documentation/devicetree/bindings/net/ethernet-phy.yaml
> @@ -232,6 +232,14 @@ properties:
> PHY's that have configurable TX internal delays. If this property is
> present then the PHY applies the TX delay.
>
> + tx-amplitude-100base-tx-gain-milli:
> + description: |
> + Transmit amplitude gain applied (in milli units) for 100BASE-TX. When
milli is unit prefix, not the unit. What is the unit? percentage? basis
point?
> + omitted, the PHYs default will be left as is. If not present, default to
> + 1000 (no actual gain applied).
Don't repeat constraints in free form text.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v2 1/3] dt-bindings: net: ethernet-phy: add property tx-amplitude-100base-tx-gain-milli
2025-01-21 10:17 ` Krzysztof Kozlowski
@ 2025-01-24 6:36 ` Dimitri Fedrau
0 siblings, 0 replies; 7+ messages in thread
From: Dimitri Fedrau @ 2025-01-24 6:36 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Dimitri Fedrau, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andrew Davis, Andrew Lunn, Heiner Kallweit,
Russell King, Florian Fainelli, netdev, devicetree, linux-kernel
Hi Krzysztof,
Am Tue, Jan 21, 2025 at 11:17:34AM +0100 schrieb Krzysztof Kozlowski:
> On Mon, Jan 20, 2025 at 02:50:21PM +0100, Dimitri Fedrau wrote:
> > Add property tx-amplitude-100base-tx-gain-milli in the device tree bindings
> > for configuring the tx amplitude of 100BASE-TX PHYs. Modifying it can be
> > necessary to compensate losses on the PCB and connector, so the voltages
> > measured on the RJ45 pins are conforming.
> >
> > Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
> > ---
> > Documentation/devicetree/bindings/net/ethernet-phy.yaml | 8 ++++++++
> > 1 file changed, 8 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/net/ethernet-phy.yaml b/Documentation/devicetree/bindings/net/ethernet-phy.yaml
> > index 2c71454ae8e362e7032e44712949e12da6826070..ce65413410c2343a3525e746e72b6c6c8bb120d0 100644
> > --- a/Documentation/devicetree/bindings/net/ethernet-phy.yaml
> > +++ b/Documentation/devicetree/bindings/net/ethernet-phy.yaml
> > @@ -232,6 +232,14 @@ properties:
> > PHY's that have configurable TX internal delays. If this property is
> > present then the PHY applies the TX delay.
> >
> > + tx-amplitude-100base-tx-gain-milli:
> > + description: |
> > + Transmit amplitude gain applied (in milli units) for 100BASE-TX. When
>
> milli is unit prefix, not the unit. What is the unit? percentage? basis
> point?
>
I think it would be better to switch to percentage. Resolution should be
fine. I would switch to:
tx-amplitude-100base-tx-percent
> > + omitted, the PHYs default will be left as is. If not present, default to
> > + 1000 (no actual gain applied).
>
> Don't repeat constraints in free form text.
>
Will fix this.
Best regards,
Dimitri
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next v2 2/3] net: phy: Add helper for getting tx amplitude gain
2025-01-20 13:50 [PATCH net-next v2 0/3] net: phy: dp83822: Add support for changing the transmit amplitude voltage Dimitri Fedrau via B4 Relay
2025-01-20 13:50 ` [PATCH net-next v2 1/3] dt-bindings: net: ethernet-phy: add property tx-amplitude-100base-tx-gain-milli Dimitri Fedrau via B4 Relay
@ 2025-01-20 13:50 ` Dimitri Fedrau via B4 Relay
2025-01-20 13:50 ` [PATCH net-next v2 3/3] net: phy: dp83822: Add support for changing the transmit amplitude voltage Dimitri Fedrau via B4 Relay
2025-01-21 0:34 ` [PATCH net-next v2 0/3] " Jakub Kicinski
3 siblings, 0 replies; 7+ messages in thread
From: Dimitri Fedrau via B4 Relay @ 2025-01-20 13:50 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Andrew Davis, Andrew Lunn, Heiner Kallweit, Russell King,
Florian Fainelli
Cc: netdev, devicetree, linux-kernel, Dimitri Fedrau, Dimitri Fedrau
From: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
Add helper which returns the tx amplitude gain defined in device tree.
Modifying it can be necessary to compensate losses on the PCB and
connector, so the voltages measured on the RJ45 pins are conforming.
Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
---
drivers/net/phy/phy_device.c | 20 ++++++++++++++++----
include/linux/phy.h | 3 +++
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 46713d27412b76077d2e51e29b8d84f4f8f0a86d..7bc48f9493ceda21311748a3efa0a222dc0683dc 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3096,7 +3096,7 @@ void phy_get_pause(struct phy_device *phydev, bool *tx_pause, bool *rx_pause)
EXPORT_SYMBOL(phy_get_pause);
#if IS_ENABLED(CONFIG_OF_MDIO)
-static int phy_get_int_delay_property(struct device *dev, const char *name)
+static int phy_get_u32_property(struct device *dev, const char *name)
{
s32 int_delay;
int ret;
@@ -3108,7 +3108,7 @@ static int phy_get_int_delay_property(struct device *dev, const char *name)
return int_delay;
}
#else
-static int phy_get_int_delay_property(struct device *dev, const char *name)
+static int phy_get_u32_property(struct device *dev, const char *name)
{
return -EINVAL;
}
@@ -3137,7 +3137,7 @@ s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev,
int i;
if (is_rx) {
- delay = phy_get_int_delay_property(dev, "rx-internal-delay-ps");
+ delay = phy_get_u32_property(dev, "rx-internal-delay-ps");
if (delay < 0 && size == 0) {
if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
@@ -3147,7 +3147,7 @@ s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev,
}
} else {
- delay = phy_get_int_delay_property(dev, "tx-internal-delay-ps");
+ delay = phy_get_u32_property(dev, "tx-internal-delay-ps");
if (delay < 0 && size == 0) {
if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
@@ -3193,6 +3193,18 @@ s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev,
}
EXPORT_SYMBOL(phy_get_internal_delay);
+s32 phy_get_tx_amplitude_gain(struct phy_device *phydev, struct device *dev,
+ enum ethtool_link_mode_bit_indices linkmode)
+{
+ switch (linkmode) {
+ case ETHTOOL_LINK_MODE_100baseT_Full_BIT:
+ return phy_get_u32_property(dev, "tx-amplitude-100base-tx-gain-milli");
+ default:
+ return -EINVAL;
+ }
+}
+EXPORT_SYMBOL(phy_get_tx_amplitude_gain);
+
static int phy_led_set_brightness(struct led_classdev *led_cdev,
enum led_brightness value)
{
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 19f076a71f9462cd37588a5da240a1d54df0fe0f..abdd768b7acece3db9ffb0f9de7d20cf86e72bc7 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -2114,6 +2114,9 @@ void phy_get_pause(struct phy_device *phydev, bool *tx_pause, bool *rx_pause);
s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev,
const int *delay_values, int size, bool is_rx);
+s32 phy_get_tx_amplitude_gain(struct phy_device *phydev, struct device *dev,
+ enum ethtool_link_mode_bit_indices linkmode);
+
void phy_resolve_pause(unsigned long *local_adv, unsigned long *partner_adv,
bool *tx_pause, bool *rx_pause);
--
2.39.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net-next v2 3/3] net: phy: dp83822: Add support for changing the transmit amplitude voltage
2025-01-20 13:50 [PATCH net-next v2 0/3] net: phy: dp83822: Add support for changing the transmit amplitude voltage Dimitri Fedrau via B4 Relay
2025-01-20 13:50 ` [PATCH net-next v2 1/3] dt-bindings: net: ethernet-phy: add property tx-amplitude-100base-tx-gain-milli Dimitri Fedrau via B4 Relay
2025-01-20 13:50 ` [PATCH net-next v2 2/3] net: phy: Add helper for getting tx amplitude gain Dimitri Fedrau via B4 Relay
@ 2025-01-20 13:50 ` Dimitri Fedrau via B4 Relay
2025-01-21 0:34 ` [PATCH net-next v2 0/3] " Jakub Kicinski
3 siblings, 0 replies; 7+ messages in thread
From: Dimitri Fedrau via B4 Relay @ 2025-01-20 13:50 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Andrew Davis, Andrew Lunn, Heiner Kallweit, Russell King,
Florian Fainelli
Cc: netdev, devicetree, linux-kernel, Dimitri Fedrau, Dimitri Fedrau
From: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
Add support for changing the transmit amplitude voltage in 100BASE-TX mode.
Modifying it can be necessary to compensate losses on the PCB and
connector, so the voltages measured on the RJ45 pins are conforming.
Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
---
drivers/net/phy/dp83822.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
index 6599feca1967d705331d6e354205a2485ea962f2..dd5aaf1b2c61ee31c521f83aa1dccb6d3f5aae15 100644
--- a/drivers/net/phy/dp83822.c
+++ b/drivers/net/phy/dp83822.c
@@ -31,6 +31,7 @@
#define MII_DP83822_RCSR 0x17
#define MII_DP83822_RESET_CTRL 0x1f
#define MII_DP83822_MLEDCR 0x25
+#define MII_DP83822_LDCTRL 0x403
#define MII_DP83822_LEDCFG1 0x460
#define MII_DP83822_IOCTRL1 0x462
#define MII_DP83822_IOCTRL2 0x463
@@ -123,6 +124,9 @@
#define DP83822_IOCTRL1_GPIO1_CTRL GENMASK(2, 0)
#define DP83822_IOCTRL1_GPIO1_CTRL_LED_1 BIT(0)
+/* LDCTRL bits */
+#define DP83822_100BASE_TX_LINE_DRIVER_SWING GENMASK(7, 4)
+
/* IOCTRL2 bits */
#define DP83822_IOCTRL2_GPIO2_CLK_SRC GENMASK(6, 4)
#define DP83822_IOCTRL2_GPIO2_CTRL GENMASK(2, 0)
@@ -197,6 +201,7 @@ struct dp83822_private {
bool set_gpio2_clk_out;
u32 gpio2_clk_out;
bool led_pin_enable[DP83822_MAX_LED_PINS];
+ int tx_amplitude_100base_tx_index;
};
static int dp83822_config_wol(struct phy_device *phydev,
@@ -522,6 +527,12 @@ static int dp83822_config_init(struct phy_device *phydev)
FIELD_PREP(DP83822_IOCTRL2_GPIO2_CLK_SRC,
dp83822->gpio2_clk_out));
+ if (dp83822->tx_amplitude_100base_tx_index >= 0)
+ phy_modify_mmd(phydev, MDIO_MMD_VEND2, MII_DP83822_LDCTRL,
+ DP83822_100BASE_TX_LINE_DRIVER_SWING,
+ FIELD_PREP(DP83822_100BASE_TX_LINE_DRIVER_SWING,
+ dp83822->tx_amplitude_100base_tx_index));
+
err = dp83822_config_init_leds(phydev);
if (err)
return err;
@@ -720,6 +731,11 @@ static int dp83822_phy_reset(struct phy_device *phydev)
}
#ifdef CONFIG_OF_MDIO
+static const u32 tx_amplitude_100base_tx_gain[] = {
+ 800, 816, 833, 850, 866, 1767, 883, 916,
+ 933, 950, 966, 983, 1000, 1016, 1033, 1050,
+};
+
static int dp83822_of_init_leds(struct phy_device *phydev)
{
struct device_node *node = phydev->mdio.dev.of_node;
@@ -780,6 +796,8 @@ static int dp83822_of_init(struct phy_device *phydev)
struct dp83822_private *dp83822 = phydev->priv;
struct device *dev = &phydev->mdio.dev;
const char *of_val;
+ s32 val;
+ int i;
/* Signal detection for the PHY is only enabled if the FX_EN and the
* SD_EN pins are strapped. Signal detection can only enabled if FX_EN
@@ -815,6 +833,25 @@ static int dp83822_of_init(struct phy_device *phydev)
dp83822->set_gpio2_clk_out = true;
}
+ dp83822->tx_amplitude_100base_tx_index = -1;
+ val = phy_get_tx_amplitude_gain(phydev, dev,
+ ETHTOOL_LINK_MODE_100baseT_Full_BIT);
+ if (val > 0) {
+ for (i = 0; i < ARRAY_SIZE(tx_amplitude_100base_tx_gain); i++) {
+ if (tx_amplitude_100base_tx_gain[i] == val) {
+ dp83822->tx_amplitude_100base_tx_index = i;
+ break;
+ }
+ }
+
+ if (dp83822->tx_amplitude_100base_tx_index < 0) {
+ phydev_err(phydev,
+ "Invalid value for tx-amplitude-100base-tx-gain-milli property (%u)\n",
+ val);
+ return -EINVAL;
+ }
+ }
+
return dp83822_of_init_leds(phydev);
}
--
2.39.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH net-next v2 0/3] net: phy: dp83822: Add support for changing the transmit amplitude voltage
2025-01-20 13:50 [PATCH net-next v2 0/3] net: phy: dp83822: Add support for changing the transmit amplitude voltage Dimitri Fedrau via B4 Relay
` (2 preceding siblings ...)
2025-01-20 13:50 ` [PATCH net-next v2 3/3] net: phy: dp83822: Add support for changing the transmit amplitude voltage Dimitri Fedrau via B4 Relay
@ 2025-01-21 0:34 ` Jakub Kicinski
3 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2025-01-21 0:34 UTC (permalink / raw)
To: Dimitri Fedrau via B4 Relay
Cc: dimitri.fedrau, Andrew Lunn, David S. Miller, Eric Dumazet,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Andrew Davis, Andrew Lunn, Heiner Kallweit, Russell King,
Florian Fainelli, netdev, devicetree, linux-kernel,
Dimitri Fedrau
On Mon, 20 Jan 2025 14:50:20 +0100 Dimitri Fedrau via B4 Relay wrote:
> Add support for changing the transmit amplitude voltage in 100BASE-TX mode.
> Add support for configuration via DT.
## Form letter - net-next-closed
The merge window for v6.14 has begun. Therefore net-next is closed
for new drivers, features, code refactoring and optimizations.
We are currently accepting bug fixes only.
Please repost when net-next reopens after Feb 3rd.
RFC patches sent for review only are obviously welcome at any time.
See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle
--
pw-bot: defer
pv-bot: closed
^ permalink raw reply [flat|nested] 7+ messages in thread