From patchwork Mon Jan 20 13:50:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri Fedrau via B4 Relay X-Patchwork-Id: 13945137 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE26E1E22FC; Mon, 20 Jan 2025 13:50:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737381030; cv=none; b=MGu010LXLVVToR/rAY8DoBG0BI9QS72q0/yiIOTrwsSLMLtFDJi6FBmXA/NCwAY2/7m0eQGZGHWtvejFff9VlA3rqJEUqeWdhEoRM4lgKhHEckcLCXhUkD0jiXfXGbV1HjhrNDB5QmKT115ATMsqg4/TEiMzuCbjoSdfQltdeXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737381030; c=relaxed/simple; bh=1ximHPbMmEHEBuLgHpQFBwbcsdYKRx5fYUW+fBDJ4NI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p+g2jiHX9LROvkt6A2/DsiE7sR4uz+ElEEsi+Y8A/bJKLOAArUFYFiFPhObQ7BnZAkecrC28lrxy4eN6ksgj1hpXKKRRo/2cJ3iLLU/VLbqwVuI6As/BUC8ic0fCxcVCb0DqWGLh5iX1zZZbUACbN23ajAcJc1oqk2BtvLYJX1M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Oa/M5wTF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Oa/M5wTF" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1ADBFC4CEE5; Mon, 20 Jan 2025 13:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737381030; bh=1ximHPbMmEHEBuLgHpQFBwbcsdYKRx5fYUW+fBDJ4NI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Oa/M5wTFtX1O5DURgESD8reMP52NQxnwuU7vQoh1MHLuOIyW59dlIvYZcRInzT+kx OmOypZuCEfe9SloL/4NjdH4/hVWWviqxNZRP5TiZXzMgXbu5wsCtnAi66e7ZAUb/h/ ctc6LeBGbXXZLCWxvJRY9JqEM3d3RSPzTYZVQEEjj78rz2UPQ+glN/aSD9ATXmclrg 6MP4jMuMhPSQ4/SoMCkKiewFlHdE8fLwCmwNlZf775XXqHUWrRfzvhfaDt8o1vxggh 561hCTyDrFACkW6qwatot5YtxAZMMdl9Wye+3HKNGKDS7NFouQUKnik/k2xf1WWXYQ NK4aU5wi7HcQA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0928AC02185; Mon, 20 Jan 2025 13:50:30 +0000 (UTC) From: Dimitri Fedrau via B4 Relay Date: Mon, 20 Jan 2025 14:50:21 +0100 Subject: [PATCH net-next v2 1/3] dt-bindings: net: ethernet-phy: add property tx-amplitude-100base-tx-gain-milli Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250120-dp83822-tx-swing-v2-1-07c99dc42627@liebherr.com> References: <20250120-dp83822-tx-swing-v2-0-07c99dc42627@liebherr.com> In-Reply-To: <20250120-dp83822-tx-swing-v2-0-07c99dc42627@liebherr.com> 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@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Dimitri Fedrau , Dimitri Fedrau X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737381028; l=1340; i=dimitri.fedrau@liebherr.com; s=20241202; h=from:subject:message-id; bh=o9/uYCQMqtj7aA5WdqSP5I74ZoABiwwXrCBqYSBeaRI=; b=HzyehliKyx0cDcSOOj1zdjTN00xtHbx8p1oWQhEu6VA+ZEHW4tacLpYoWV+UINcjc+I4h7prx Qi9d8HHyTAmD0s4KUAnN6oAkRgRiacX5MoX82SV9n0eucRtIOeerheh X-Developer-Key: i=dimitri.fedrau@liebherr.com; a=ed25519; pk=rT653x09JSQvotxIqQl4/XiI4AOiBZrdOGvxDUbb5m8= X-Endpoint-Received: by B4 Relay for dimitri.fedrau@liebherr.com/20241202 with auth_id=290 X-Original-From: Dimitri Fedrau Reply-To: dimitri.fedrau@liebherr.com X-Patchwork-Delegate: kuba@kernel.org From: Dimitri Fedrau 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 --- 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 From patchwork Mon Jan 20 13:50:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri Fedrau via B4 Relay X-Patchwork-Id: 13945138 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC3071E25E4; Mon, 20 Jan 2025 13:50:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737381030; cv=none; b=OvSa+73vPq9Zy9UPeTtoaChrs+T99RJvWwry9KycTNQof67bJkGCUhTlvtwCcbqAC5up5HMLFAKoYDnGbnmpLvMKXnb/mXrLqkuU2Grygs50+seZQ1bjJTgQxl22Li7os7Lt90aKp17VWbpageq3ZkDS5ZWp0xDyNrDIobmSmY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737381030; c=relaxed/simple; bh=5QUzy70Aht17qVvxw78UZoTUeK4o09d7iHlDFj0Xk4Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ah+3zp0FdSQDBmaHCnGu9NHo3VU7xeuPlbrPCqOOWUU191efMY9dncggQLkVRzTIIMtz9psxGCnEfmcHCh8Z5nbtWW+M72FifZKKJukNYlJiVzC2f83999Epcaue9WekpgDEafpEHRlrUMbQ1Wi1UwXVqLmYR9ErXveuGV0qDGs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Bna1RtY8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Bna1RtY8" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2D0E8C4CEE1; Mon, 20 Jan 2025 13:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737381030; bh=5QUzy70Aht17qVvxw78UZoTUeK4o09d7iHlDFj0Xk4Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Bna1RtY8XugYTApM+IpYh8J6Ss2Bk88HY0kgX+FvO3qE434NIxPtGsWloFGeXYkgI T7jgpT9N0KisCmxPt/xCV6ZJhKUymgmXiVivLs05dFWu9niQnku5KjjzyOZ0GY0DTw JKEDUSEOA2Lx36tTN/ep+KxfLDXEziTvkSS+p6rbSEkw9kvWea7A5IQ3ovvNFXWiUQ 3RKvmcUBCxEp7HxZOJgmp9qCDi0h4cqixean/GmKY9CA7xQjArTiUF/L+OaYYILdUu Tutda+fyPmfK3a43eO/9dTvs2r/J07iAcjBVtfJfCr82nx5NGQsFJdWrlIJBwFoqF7 bY59ifDlOWtdg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 219B8C02181; Mon, 20 Jan 2025 13:50:30 +0000 (UTC) From: Dimitri Fedrau via B4 Relay Date: Mon, 20 Jan 2025 14:50:22 +0100 Subject: [PATCH net-next v2 2/3] net: phy: Add helper for getting tx amplitude gain Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250120-dp83822-tx-swing-v2-2-07c99dc42627@liebherr.com> References: <20250120-dp83822-tx-swing-v2-0-07c99dc42627@liebherr.com> In-Reply-To: <20250120-dp83822-tx-swing-v2-0-07c99dc42627@liebherr.com> 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@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Dimitri Fedrau , Dimitri Fedrau X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737381028; l=3500; i=dimitri.fedrau@liebherr.com; s=20241202; h=from:subject:message-id; bh=4NxnBs1iNWySfnRdwhDBtFEJqfO2yBjZ3zEEArurays=; b=Y6WsBzg2QbyamQ/T3MAMpH2WeREOUw1kk/Yl0CNEGrJYmxlphtQKiDbmsmabmGMCO9W2nM/Hy AU4VmKAOJGPBXUyEI7y0eSQQhd/X/YVi4gAVywmW8gSvjQJG1gF68E5 X-Developer-Key: i=dimitri.fedrau@liebherr.com; a=ed25519; pk=rT653x09JSQvotxIqQl4/XiI4AOiBZrdOGvxDUbb5m8= X-Endpoint-Received: by B4 Relay for dimitri.fedrau@liebherr.com/20241202 with auth_id=290 X-Original-From: Dimitri Fedrau Reply-To: dimitri.fedrau@liebherr.com X-Patchwork-Delegate: kuba@kernel.org From: Dimitri Fedrau 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 --- 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); From patchwork Mon Jan 20 13:50:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri Fedrau via B4 Relay X-Patchwork-Id: 13945140 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC35E1E25E5; Mon, 20 Jan 2025 13:50:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737381030; cv=none; b=ECUQCqVv62g8HxRC6yy448D/aXGcRWy4C84YQnc/8EenQI5R5O7mVGvKL//sdvLWVJupT+1ANirDqBu1V1mNWPdT2QcPQ756ARMIkVUGJz1VEwSAcXOomKvBMcONZ25WWGDFEdMFFbZs/lGc2uFMQAaVRHq5Jbta8+hMZxOeGYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737381030; c=relaxed/simple; bh=iE/bcwku4KTw3/iRUxcBK9x9PA9J1U2krhjU61zQY4s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sA2jBsWtiJXt9Vd5sjiHYxk0fQOuv38A7eYjEhInbYAY6k50LCLdVX7wXTokrAHM5LRr+leaiEKLIjsKQp83KbNlgAoLtv8bD6IOEem64cG+dY0ssworU5N7xKRMFoPJqqXZje4QCUOAdWTCnfNfh5ulEGqsGBKWW3FJxwKYplI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nKyr/zR4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nKyr/zR4" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3ED1AC4CEE9; Mon, 20 Jan 2025 13:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737381030; bh=iE/bcwku4KTw3/iRUxcBK9x9PA9J1U2krhjU61zQY4s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=nKyr/zR4MgdQsHzVaAi1eT6GU6kzeHrPXcHK03UIiiA8OskMYqztY/4jjmITrnttz pp3s+JppgbQiRZAW07vfcO6PyUSwQZqELGhEbgbWNNlgW/J21iVZwVWiazBgIBAh6x dAfjWaRH5sr67vuKy3e1aTtP0QYHGIZgJvVlLCKaVkeXUX/8fG58oe46ZpFAclb5MX hBRB6BemJwIepHV3IVfI+9R5jjw0UeBzpFS128+Ztls+DGqUczj1IHm9oKcWPsM354 hbnq3sUwV08VEjDIP9g2hJFyN5s0vFmXe+Mgoykd6Wkq7BmHLBLirV7WyyDEfQycp8 rU2/6N9QWe21g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3040DC02182; Mon, 20 Jan 2025 13:50:30 +0000 (UTC) From: Dimitri Fedrau via B4 Relay Date: Mon, 20 Jan 2025 14:50:23 +0100 Subject: [PATCH net-next v2 3/3] net: phy: dp83822: Add support for changing the transmit amplitude voltage Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250120-dp83822-tx-swing-v2-3-07c99dc42627@liebherr.com> References: <20250120-dp83822-tx-swing-v2-0-07c99dc42627@liebherr.com> In-Reply-To: <20250120-dp83822-tx-swing-v2-0-07c99dc42627@liebherr.com> 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@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Dimitri Fedrau , Dimitri Fedrau X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737381028; l=3492; i=dimitri.fedrau@liebherr.com; s=20241202; h=from:subject:message-id; bh=i7JK4ez08mIrB/fvCWOiiy6f3mWMVK6RC5dLYH/FlCk=; b=S/2O6vcc8bP/dacaUOWDYebuPHZGwfVOeZxhsnjym5v4Sfg3FdSWqCDKBgrsvMuetE+yZHA0R xctx5ih/nBjAqmwmPDG0syV8TJHAy1XKwTRh3XAXgz8MiybtYnzMjm1 X-Developer-Key: i=dimitri.fedrau@liebherr.com; a=ed25519; pk=rT653x09JSQvotxIqQl4/XiI4AOiBZrdOGvxDUbb5m8= X-Endpoint-Received: by B4 Relay for dimitri.fedrau@liebherr.com/20241202 with auth_id=290 X-Original-From: Dimitri Fedrau Reply-To: dimitri.fedrau@liebherr.com X-Patchwork-Delegate: kuba@kernel.org From: Dimitri Fedrau 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 --- 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); }