From patchwork Mon Jun 6 20:22:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 579624 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 B5B75CCA473 for ; Mon, 6 Jun 2022 20:22:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232119AbiFFUWg (ORCPT ); Mon, 6 Jun 2022 16:22:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233522AbiFFUWc (ORCPT ); Mon, 6 Jun 2022 16:22:32 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEA6A6550 for ; Mon, 6 Jun 2022 13:22:30 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id v25so20319500eda.6 for ; Mon, 06 Jun 2022 13:22:30 -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=ramRhPzzIanDTBc4YnvbtflH7YCV/CY9bbWKmWrFq+o=; b=N3f1F70RSHOFUi0/95Am3KcViH7CUmDqqDllaG1ylIXteKA1EkETYVMSFYjiwpGrET FTO+f+0s394CngQLk3wD/L9VwZlk2ds+xfL8yntxprVroIHL62K0VSmvfj7krHr0YTKX IxtUuaGyebDJuwxo+20qpc7cj9dFUlOmSGZ/8= 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=ramRhPzzIanDTBc4YnvbtflH7YCV/CY9bbWKmWrFq+o=; b=wa5LCn7hRqW8u03FfA+rxdMwp/qjHQDA/RF11Kj8mbvUnaM5rXhjdjMtca45rLupDj 8ZSC7TAY94FgYEa8LSus6tH/v/nFXWDdLC0b+MgDwBWeKCGX53BHxCNERd5bD6yuWPNc d9N+uT9o/x41yNNgGnp/39G0vqniynhKmpoCljWvTMazb2Dz5T6x2moKWy9KVfExye8K ECQVfesL90tZ6t6MjNQTxHQYon2Md0Gm4yBGH628ZqZexAXj+l1k6/01ekyP04La62/t 6GaoxJtwTuSKDb652hqKLEl8lHr+W+GEzuEE67WBiORIodggxRdqyJgH4ugitROMrXug 8GlQ== X-Gm-Message-State: AOAM530M1wmx3AfoUZ8bGGmnmFkD+Mr+qakJ2Enf3Zf8xvs73hdCRa9b R92XCxJI8uxN114xvUj4vrOI9A== X-Google-Smtp-Source: ABdhPJxf90ydtFhUbmr0z/WGR2mG8fWABtzc4aXbMKhN9fZFmMOgy+j8tmFnkR00S/KUbHBjbVI/6Q== X-Received: by 2002:a05:6402:358a:b0:431:20d5:f4ad with SMTP id y10-20020a056402358a00b0043120d5f4admr15251525edc.375.1654546949175; Mon, 06 Jun 2022 13:22:29 -0700 (PDT) Received: from prevas-ravi.tritech.se ([80.208.64.233]) by smtp.gmail.com with ESMTPSA id d20-20020aa7ce14000000b0042dd4ccccf5sm9043789edv.82.2022.06.06.13.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 13:22:28 -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" , Dan Murphy , Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/3] dt-bindings: dp83867: add binding for io_impedance_ctrl nvmem cell Date: Mon, 6 Jun 2022 22:22:18 +0200 Message-Id: <20220606202220.1670714-2-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220606202220.1670714-1-linux@rasmusvillemoes.dk> References: <20220606202220.1670714-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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. There is no documented mapping from the 32 possible values of the IO_IMPEDANCE_CTRL field to values in the range 35-70 ohms, and the exact mapping is likely to vary from chip to chip. So add a DT binding for an nvmem cell which can be populated during production with a value suitable for each specific board. Signed-off-by: Rasmus Villemoes Reviewed-by: Rob Herring --- .../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/Documentation/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 + 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 impedance to a maximum value (70 ohms). - Note: ti,min-output-impedance and ti,max-output-impedance are mutually - 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. tx-fifo-depth: $ref: /schemas/types.yaml#/definitions/uint32 From patchwork Mon Jun 6 20:22:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 579623 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 2D7CEC433EF for ; Mon, 6 Jun 2022 20:22:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233336AbiFFUWl (ORCPT ); Mon, 6 Jun 2022 16:22:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233538AbiFFUWc (ORCPT ); Mon, 6 Jun 2022 16:22:32 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1BFD9FCE for ; Mon, 6 Jun 2022 13:22:31 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id s12so23923484ejx.3 for ; Mon, 06 Jun 2022 13:22:31 -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=X1/fjuqL6gfslDXWoRX9h2iUMDP2o8h40GZNbgq4k2cPA/WIpPN/LIgiyPkBen6+T+ ik/ftNMZIdrs+WRaYig6cWAECSG9pNA0q6S54xIM+PMpKpS+7Oe7HLk4Y9JHTB8KpdT6 TS/RlSX6kawniKhAbMEivgVRmpyGX+Npd9HUc= 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=4SCtxY6lRYe/vo62RoFTyZ5JbN0KsnYaMQP1qsVu4ag9cO49JR109kD7cmWgBs2mkl 0U0pc7D4IQD9cilf0skrMGKUHrsoN7rPgI7MQw0G9qJPK66tH7tpTqHFm8xodach3fke S7gcYJVsxqftzrHOQusec6jIMV4pmLkPd8mKwsyn0fbW2UunwServSQ5vTlCgLveAlsk Nu/FrkSwZiyfvbOQ306X2qNY0H0711PfjrVoQyvmJA4thU6IlhRKBBc9KUAo58xpDzEt 3uGZ4wfnQDtqouL+BVx5yggJl47KJ3DBLvkCRhfj/ydz4vRa+ljFSgTwJ32I+g3TMPKX vbgg== X-Gm-Message-State: AOAM530QJX+mij5uYmFeIlGMG1fN0X7wQUlBrcrKAtxyEpkP0CK+v7iw 63qX3lxGznaLtbewPNsin6lGbQ== X-Google-Smtp-Source: ABdhPJyB6ulO52fBmOqz/f6uv8gPY4QaiOeSAQEKRaPOA9PwbUcbRDC6JJFKBVnfBl8X5S7F0Tw6xg== X-Received: by 2002:a17:906:37c6:b0:70c:f9f:f0c5 with SMTP id o6-20020a17090637c600b0070c0f9ff0c5mr19313158ejc.743.1654546950375; Mon, 06 Jun 2022 13:22:30 -0700 (PDT) Received: from prevas-ravi.tritech.se ([80.208.64.233]) by smtp.gmail.com with ESMTPSA id d20-20020aa7ce14000000b0042dd4ccccf5sm9043789edv.82.2022.06.06.13.22.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 13:22:30 -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" , Dan Murphy , Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/3] linux/phy.h: add phydev_err_probe() wrapper for dev_err_probe() Date: Mon, 6 Jun 2022 22:22:19 +0200 Message-Id: <20220606202220.1670714-3-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220606202220.1670714-1-linux@rasmusvillemoes.dk> References: <20220606202220.1670714-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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) +#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) From patchwork Mon Jun 6 20:22:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 579111 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 7C544C433EF for ; Mon, 6 Jun 2022 20:22:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233374AbiFFUWj (ORCPT ); Mon, 6 Jun 2022 16:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233369AbiFFUWe (ORCPT ); Mon, 6 Jun 2022 16:22:34 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01DBBEE1C for ; Mon, 6 Jun 2022 13:22:33 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id z7so20285317edm.13 for ; Mon, 06 Jun 2022 13:22:32 -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=fyyHVyXBohzxlEcKJtNBA0J4PW/3kKJlkInCdkTTIOy0hCUdbc6wQLZdjnNKUKDiUq neoo5gxyaB/TmYq+WyXdo11Lh+xPQSr0h4H538Rs10wdiiPnzjFKnZTh4rqsHC9OK6fy P9bCMhASV6zjcr0aeBlMdsn52n2/CZv6gfwXw= 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=d0lfVHoetEL5PXrNowwDYlUA2+bYJk7WVEawU9deA1NOG93oPFBH9kqIPArniP+CRY lqzQ2cpudnfxnvNdPn9JX5BKwNZMtpJM00H7VnUBFaYfqg70oOBzkBx+6U8LFNothnrX ek15Q0jgs+JhhTzhaLUETGKT+r3cDuwWHgP9MYpYynuN7a75Xc483ROzyDEGKIHTLy+p E+zn7sOVp7r/3VONce+TrA0K0bRaRKdqCy5/JAxUAY3pFjI+sXcpT+qhKSVwVcP0/b7f 6DGE29tQLzDo4S79zhPWeYp1EAUFKwg6Ewk9U47fAlj5xn/O7K9ESuDUK4W6GjlT9uiA Eq5A== X-Gm-Message-State: AOAM533/pn5npDfCZjTrkb4s5J0UV1dEUBrLoRg8taCVrdZ3oc1rBT8A DUHBpanaHAE5JYex++EDQk8oOQ== X-Google-Smtp-Source: ABdhPJxhEaNa/rFWgmZj8irzos8l14CPgg7Dl5BaZLkXL9q5+PuuKp0icUIG5T5d33851ZBnt9yGXg== X-Received: by 2002:a05:6402:4003:b0:42d:fb4d:dada with SMTP id d3-20020a056402400300b0042dfb4ddadamr29129905eda.183.1654546951582; Mon, 06 Jun 2022 13:22:31 -0700 (PDT) Received: from prevas-ravi.tritech.se ([80.208.64.233]) by smtp.gmail.com with ESMTPSA id d20-20020aa7ce14000000b0042dd4ccccf5sm9043789edv.82.2022.06.06.13.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 13:22:31 -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" , Dan Murphy , Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/3] net: phy: dp83867: implement support for io_impedance_ctrl nvmem cell Date: Mon, 6 Jun 2022 22:22:20 +0200 Message-Id: <20220606202220.1670714-4-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220606202220.1670714-1-linux@rasmusvillemoes.dk> References: <20220606202220.1670714-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 #include @@ -521,6 +522,51 @@ static int dp83867_verify_rgmii_cfg(struct phy_device *phydev) } #if IS_ENABLED(CONFIG_OF_MDIO) +static int dp83867_of_init_io_impedance(struct phy_device *phydev) +{ + struct dp83867_private *dp83867 = phydev->priv; + struct device *dev = &phydev->mdio.dev; + struct device_node *of_node = dev->of_node; + struct nvmem_cell *cell; + u8 *buf, val; + int ret; + + cell = of_nvmem_cell_get(of_node, "io_impedance_ctrl"); + if (IS_ERR(cell)) { + ret = PTR_ERR(cell); + if (ret != -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 = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX; + else if (of_property_read_bool(of_node, "ti,min-output-impedance")) + dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN; + else + dp83867->io_impedance = -1; /* leave at default */ + + return 0; + } + + buf = nvmem_cell_read(cell, NULL); + nvmem_cell_put(cell); + + if (IS_ERR(buf)) + return PTR_ERR(buf); + + val = *buf; + kfree(buf); + + if ((val & DP83867_IO_MUX_CFG_IO_IMPEDANCE_MASK) != val) { + phydev_err(phydev, "nvmem cell 'io_impedance_ctrl' contents out of range\n"); + return -ERANGE; + } + dp83867->io_impedance = val; + + return 0; +} + static int dp83867_of_init(struct phy_device *phydev) { struct dp83867_private *dp83867 = phydev->priv; @@ -548,12 +594,9 @@ static int dp83867_of_init(struct phy_device *phydev) } } - if (of_property_read_bool(of_node, "ti,max-output-impedance")) - dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX; - else if (of_property_read_bool(of_node, "ti,min-output-impedance")) - dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN; - else - dp83867->io_impedance = -1; /* leave at default */ + ret = dp83867_of_init_io_impedance(phydev); + if (ret) + return ret; dp83867->rxctrl_strap_quirk = of_property_read_bool(of_node, "ti,dp83867-rxctrl-strap-quirk");