From nobody Wed Apr 29 08:52:53 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22DFDC43334 for ; Tue, 14 Jun 2022 08:46:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241272AbiFNIqm (ORCPT ); Tue, 14 Jun 2022 04:46:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241702AbiFNIqW (ORCPT ); Tue, 14 Jun 2022 04:46:22 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ED54433A1 for ; Tue, 14 Jun 2022 01:46:19 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id y29so8921392ljd.7 for ; Tue, 14 Jun 2022 01:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ij41iYIrsaYScwS30JeqaDifxteKwIBwdtXN2yvAeBg=; b=b3TVykTo337jeVgLKyyE7dHh4PorhizQMUTCOrLnEdrkBsT8zv+H8A44Otm10TVuZC YUY590z5NPAJSYNH/9KYhGVd915VuP2yOVtUFoI0hFrN8BeckzXNMg1EYCBHz4JNBfif F9tkV1fKUxpsUEFWuGpMyudCeixMG8Gtml0Ug= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ij41iYIrsaYScwS30JeqaDifxteKwIBwdtXN2yvAeBg=; b=18K+L42d6mG3vscb08UC/ZRHGrO3y+guBnsKwGLG9O8j0kEyCcIvm6d+8iEcWdcsoD a0+CEbE9r7kjnJTfCF8EY8tl8m/I+Lb4K80j7pqUyI/n/4FDFbTdCMllEtVBtGULY08C KeK5EffqP0jdu1FFFa4uRg/1EYOavyQysPJVIiD3xqy7SLbT7aMFZdHGkb34AxAWhg0m 5koU/oc9VtcMiBmKoUayvELhF+j13VZmd25wA7rgURCGeZwIuAxFlS8f3uN0g4ksWreL IiRu7eV6l46c8KrkpebisV9RgF2uFgpsiUUUJ6MwmLyyTTwOEZPpa/YZ/6Y6w4kdYk6f hmAw== X-Gm-Message-State: AJIora/DzZ1rF/G/i+Lpg6riSicgTcOJSJcTqmFcMcojI6/Z5EP2LVd+ 6L0yH2jVg6RfqbjoguJYCzLTpg== X-Google-Smtp-Source: AGRyM1vgJAmSuIrSAaT4aB4D/Mrty59U5anACJbPi65s/ospCO3ybzP+GZ+4ju+aMf8cfsXPd/T1yw== X-Received: by 2002:a2e:9b0d:0:b0:255:92b9:eb3c with SMTP id u13-20020a2e9b0d000000b0025592b9eb3cmr1911477lji.5.1655196377781; Tue, 14 Jun 2022 01:46:17 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id g1-20020ac24d81000000b0047255d2118fsm1306116lfe.190.2022.06.14.01.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 01:46:17 -0700 (PDT) From: Rasmus Villemoes To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: devicetree@vger.kernel.org, Rob Herring , Jakub Kicinski , "David S. Miller" , Grygorii Strashko , Praneeth Bajjuri , linux-kernel@vger.kernel.org, Rasmus Villemoes , Rob Herring Subject: [PATCH net-next v2 1/3] dt-bindings: dp83867: add binding for io_impedance_ctrl nvmem cell Date: Tue, 14 Jun 2022 10:46:10 +0200 Message-Id: <20220614084612.325229-2-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220614084612.325229-1-linux@rasmusvillemoes.dk> References: <20220606202220.1670714-1-linux@rasmusvillemoes.dk> <20220614084612.325229-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" We have a board where measurements indicate that the current three options - leaving IO_IMPEDANCE_CTRL at the reset value (which is factory calibrated to a value corresponding to approximately 50 ohms) or using one of the two boolean properties to set it to the min/max value - are too coarse. There is no fixed mapping from register values to values in the range 35-70 ohms; it varies from chip to chip, and even that target range is approximate. So add a DT binding for an nvmem cell which can be populated during production with a value suitable for each specific board. Reviewed-by: Rob Herring Signed-off-by: Rasmus Villemoes --- .../devicetree/bindings/net/ti,dp83867.yaml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/net/ti,dp83867.yaml b/Docume= ntation/devicetree/bindings/net/ti,dp83867.yaml index 047d757e8d82..76ff08a477ba 100644 --- a/Documentation/devicetree/bindings/net/ti,dp83867.yaml +++ b/Documentation/devicetree/bindings/net/ti,dp83867.yaml @@ -31,6 +31,16 @@ properties: reg: maxItems: 1 =20 + nvmem-cells: + maxItems: 1 + description: + Nvmem data cell containing the value to write to the + IO_IMPEDANCE_CTRL field of the IO_MUX_CFG register. + + nvmem-cell-names: + items: + - const: io_impedance_ctrl + ti,min-output-impedance: type: boolean description: | @@ -42,9 +52,11 @@ properties: description: | MAC Interface Impedance control to set the programmable output imped= ance to a maximum value (70 ohms). - Note: ti,min-output-impedance and ti,max-output-impedance are mutual= ly - exclusive. When both properties are present ti,max-output-impedance - takes precedence. + Note: Specifying an io_impedance_ctrl nvmem cell or one of the + ti,min-output-impedance, ti,max-output-impedance properties + are mutually exclusive. If more than one is present, an nvmem + cell takes precedence over ti,max-output-impedance, which in + turn takes precedence over ti,min-output-impedance. =20 tx-fifo-depth: $ref: /schemas/types.yaml#/definitions/uint32 --=20 2.31.1 From nobody Wed Apr 29 08:52:53 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B13EC433EF for ; Tue, 14 Jun 2022 08:46:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240485AbiFNIqq (ORCPT ); Tue, 14 Jun 2022 04:46:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355842AbiFNIqZ (ORCPT ); Tue, 14 Jun 2022 04:46:25 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF1CD434AB for ; Tue, 14 Jun 2022 01:46:20 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id w20so12760970lfa.11 for ; Tue, 14 Jun 2022 01:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cmCUkZyYqf+fSr+qmDna92LF/wD5Dj/Ah1fbqp/t9Fc=; b=Lhk2HAruK6blf2W2bSttgu1d3q5FpOqeHtDxEokN5BstejeSqf7oKTZJqKzbbEhyce YMleKqWyPKI0c2R9KA2xZc6Br0LmeyolK1HHT2x2roKGKKLBx1R0Idq/Eq+60YZ6uPSM v+/ciSTtW7Tyb18KJq3p0Mx3YpseXHWSDPyxo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cmCUkZyYqf+fSr+qmDna92LF/wD5Dj/Ah1fbqp/t9Fc=; b=5ZMcn6SIAjDEQF1xN6MF3ozlyGP3eqSwujhDhDYd628hesAH3mhHibTlc2mVK+pPeV l92gFlUMQae1BYO07lyxilucrqLzyghKs1OSX1opXqvzBCZULeHGhh164GKHMGbPL1Mu 1ZGny2i23hc4/eRcdBdKSOf3i2oikfVGQzoKpI2jRB8J9eiNcmrk4s8d7emz4DiLHFXK KyxF92EI5bhCdrmr+uD0Z3spO6+Up1Bpti5dXyzhNYYL2KKu7NeHv0XECvLIyLhFMWsN OeOiCG1HvmJCLsiQHTPg0n1oDNB3qLkzvy/gLAx9Mo/FzWSQQeDapy1b5JUTk7AR4gLQ 0IyQ== X-Gm-Message-State: AOAM5323McCdDa2GhoTynRu+QL7oeTHpJBMZAwnXrUB7zNCt/0prEGcm xaoEPPA6mZBxYVa58fSRHfXReQ== X-Google-Smtp-Source: AGRyM1tnVrDoaAyRb7zBWF5L0aoS5WCry23V8yDCUItYQSOXYDQhQDayc83GCERdmZO4XMcgqES6Rw== X-Received: by 2002:a05:6512:31c5:b0:479:47a1:2024 with SMTP id j5-20020a05651231c500b0047947a12024mr2407749lfe.420.1655196378944; Tue, 14 Jun 2022 01:46:18 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id g1-20020ac24d81000000b0047255d2118fsm1306116lfe.190.2022.06.14.01.46.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 01:46:18 -0700 (PDT) From: Rasmus Villemoes To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: devicetree@vger.kernel.org, Rob Herring , Jakub Kicinski , "David S. Miller" , Grygorii Strashko , Praneeth Bajjuri , linux-kernel@vger.kernel.org, Rasmus Villemoes Subject: [PATCH net-next v2 2/3] linux/phy.h: add phydev_err_probe() wrapper for dev_err_probe() Date: Tue, 14 Jun 2022 10:46:11 +0200 Message-Id: <20220614084612.325229-3-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220614084612.325229-1-linux@rasmusvillemoes.dk> References: <20220606202220.1670714-1-linux@rasmusvillemoes.dk> <20220614084612.325229-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The dev_err_probe() function is quite useful to avoid boilerplate related to -EPROBE_DEFER handling. Add a phydev_err_probe() helper to simplify making use of that from phy drivers which otherwise use the phydev_* helpers. Signed-off-by: Rasmus Villemoes --- include/linux/phy.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/phy.h b/include/linux/phy.h index 508f1149665b..bed9a347481b 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1539,6 +1539,9 @@ static inline void phy_device_reset(struct phy_device= *phydev, int value) #define phydev_err(_phydev, format, args...) \ dev_err(&_phydev->mdio.dev, format, ##args) =20 +#define phydev_err_probe(_phydev, err, format, args...) \ + dev_err_probe(&_phydev->mdio.dev, err, format, ##args) + #define phydev_info(_phydev, format, args...) \ dev_info(&_phydev->mdio.dev, format, ##args) =20 --=20 2.31.1 From nobody Wed Apr 29 08:52:53 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F38C8C433EF for ; Tue, 14 Jun 2022 08:47:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241624AbiFNIr2 (ORCPT ); Tue, 14 Jun 2022 04:47:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242359AbiFNIq0 (ORCPT ); Tue, 14 Jun 2022 04:46:26 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC96B42A01 for ; Tue, 14 Jun 2022 01:46:21 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id m25so8906153lji.11 for ; Tue, 14 Jun 2022 01:46:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VUSdGLwnJ0Y/lNfZiFkctM/6S+/lIr4cXT4yYV5L0eg=; b=ds3Ls87l3/RTps8cjzbiCoEtfAT/UNTYNbmZ3vxsR0hnyRIM4JISzsT8HkoR+6+4eP 3Cqfb+JGxyWAcNqNoxVve8rYObAC8MnNPQ+zdDSbT547/eFDUrPgC4XCC1yhvfm7wVDs gBoQe8fxIVPWmwyvCxK0peaqzLKc2z/XRjO1Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VUSdGLwnJ0Y/lNfZiFkctM/6S+/lIr4cXT4yYV5L0eg=; b=OaCI+tYv+UqNuL+k/tqEOJ8mqFawVXH9mpKTvSfv2skHb5EgngwREPs+/bMWTP9DxV SYE2kxxWj6BBbaZ087gX5RZwlgU+4bOFtmUOVun5AGRgToi2/M+xbTo00JyH8t58zKXW zu/BX+Acvjz1oiR0wKtNJWf6ZzV8O4WIQdp3ct5zjCRdXJtwGY+bUSzxq89uhc3eCoQQ 5YTcB9S3AGoT5UawDmV2rvwjEMYnwf5OHHGopr4z4c9At/FGmNw8+lgQWxehO/ESJuhn yJtnwvf0bLvGnAKdy9lT7w22h7aQFSQmlV1zxfYlrXENxEZDri4mGvPrBjVKni9WU/bw x6Iw== X-Gm-Message-State: AJIora8ndcdPf89gZw3LNgiTgNbxjd+HF3RmtSToRhOhfEl1O9CR0kh8 RT7A+SkYg2RFcAuaZsOYTlPp2g== X-Google-Smtp-Source: AGRyM1uPQusPCcTNkLDd/2DQXmi8U8XilZO13Hy3ENCammmq5MEL9OxcbgTxh2SVU/vHcJkV+z5GGA== X-Received: by 2002:a2e:3a17:0:b0:255:772a:e9e2 with SMTP id h23-20020a2e3a17000000b00255772ae9e2mr1859147lja.440.1655196380110; Tue, 14 Jun 2022 01:46:20 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id g1-20020ac24d81000000b0047255d2118fsm1306116lfe.190.2022.06.14.01.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 01:46:19 -0700 (PDT) From: Rasmus Villemoes To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: devicetree@vger.kernel.org, Rob Herring , Jakub Kicinski , "David S. Miller" , Grygorii Strashko , Praneeth Bajjuri , linux-kernel@vger.kernel.org, Rasmus Villemoes Subject: [PATCH net-next v2 3/3] net: phy: dp83867: implement support for io_impedance_ctrl nvmem cell Date: Tue, 14 Jun 2022 10:46:12 +0200 Message-Id: <20220614084612.325229-4-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220614084612.325229-1-linux@rasmusvillemoes.dk> References: <20220606202220.1670714-1-linux@rasmusvillemoes.dk> <20220614084612.325229-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" We have a board where measurements indicate that the current three options - leaving IO_IMPEDANCE_CTRL at the (factory calibrated) reset value or using one of the two boolean properties to set it to the min/max value - are too coarse. Implement support for the newly added binding allowing device tree to specify an nvmem cell containing an appropriate value for this specific board. Signed-off-by: Rasmus Villemoes --- drivers/net/phy/dp83867.c | 55 ++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c index 8561f2d4443b..45d8a9298251 100644 --- a/drivers/net/phy/dp83867.c +++ b/drivers/net/phy/dp83867.c @@ -14,6 +14,7 @@ #include #include #include +#include =20 #include =20 @@ -521,6 +522,51 @@ static int dp83867_verify_rgmii_cfg(struct phy_device = *phydev) } =20 #if IS_ENABLED(CONFIG_OF_MDIO) +static int dp83867_of_init_io_impedance(struct phy_device *phydev) +{ + struct dp83867_private *dp83867 =3D phydev->priv; + struct device *dev =3D &phydev->mdio.dev; + struct device_node *of_node =3D dev->of_node; + struct nvmem_cell *cell; + u8 *buf, val; + int ret; + + cell =3D of_nvmem_cell_get(of_node, "io_impedance_ctrl"); + if (IS_ERR(cell)) { + ret =3D PTR_ERR(cell); + if (ret !=3D -ENOENT) + return phydev_err_probe(phydev, ret, + "failed to get nvmem cell io_impedance_ctrl\n"); + + /* If no nvmem cell, check for the boolean properties. */ + if (of_property_read_bool(of_node, "ti,max-output-impedance")) + dp83867->io_impedance =3D DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX; + else if (of_property_read_bool(of_node, "ti,min-output-impedance")) + dp83867->io_impedance =3D DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN; + else + dp83867->io_impedance =3D -1; /* leave at default */ + + return 0; + } + + buf =3D nvmem_cell_read(cell, NULL); + nvmem_cell_put(cell); + + if (IS_ERR(buf)) + return PTR_ERR(buf); + + val =3D *buf; + kfree(buf); + + if ((val & DP83867_IO_MUX_CFG_IO_IMPEDANCE_MASK) !=3D val) { + phydev_err(phydev, "nvmem cell 'io_impedance_ctrl' contents out of range= \n"); + return -ERANGE; + } + dp83867->io_impedance =3D val; + + return 0; +} + static int dp83867_of_init(struct phy_device *phydev) { struct dp83867_private *dp83867 =3D phydev->priv; @@ -548,12 +594,9 @@ static int dp83867_of_init(struct phy_device *phydev) } } =20 - if (of_property_read_bool(of_node, "ti,max-output-impedance")) - dp83867->io_impedance =3D DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX; - else if (of_property_read_bool(of_node, "ti,min-output-impedance")) - dp83867->io_impedance =3D DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN; - else - dp83867->io_impedance =3D -1; /* leave at default */ + ret =3D dp83867_of_init_io_impedance(phydev); + if (ret) + return ret; =20 dp83867->rxctrl_strap_quirk =3D of_property_read_bool(of_node, "ti,dp83867-rxctrl-strap-quirk"); --=20 2.31.1