From patchwork Wed Feb 1 21:53:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13125040 X-Patchwork-Delegate: kuba@kernel.org 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 99CFFC05027 for ; Wed, 1 Feb 2023 21:53:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231200AbjBAVx2 (ORCPT ); Wed, 1 Feb 2023 16:53:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbjBAVx1 (ORCPT ); Wed, 1 Feb 2023 16:53:27 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 541438680; Wed, 1 Feb 2023 13:53:26 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id o13so90403pjg.2; Wed, 01 Feb 2023 13:53:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8zwRSKbGTUujqFIojImH5B73/GPqNmHMeo69BZFjNQ8=; b=NqlAFbyXSN7RSrD60ELXRot++RoLteUH/WCCWknfvc/Aaqu3A5kwvT2G4f1e66ZCUO lvjk8qsSD0GHeBX45rJf2gFIfLBuN2Zf9tCbkxfNEmGvqS6tPWZcW9w8wWDQ+UnR8+BX DVeHb7IJ8oLGUVhuQqREOLFTvhBJvNms2oOTAsVlre+J+af7fNuDTOJUx3AcdGk8UuaE dmC3uUBdbdY1VpBLWOTTgekDdcd5lAGLIGuW4OCLVNK8ciEgNPwaaf+xPz/ahjUmz2uF NJ3Jr5q7vajsj3nEONQIAeesBOaw5c2zYXRhrwQ84O3Su12ku9cxol3kptpW+FebJvUH H/lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8zwRSKbGTUujqFIojImH5B73/GPqNmHMeo69BZFjNQ8=; b=cCNkMRqhET0SV9COAXIhSiHqLPgVcREg1+eTWOF/SCi+cCVksYL47ag98yloxOB8PB yasTi6Fg2vWmPBFjvXUwfB/rwS+9MX8cnpzKlrzdBY+SdIwNtcLb6gsINf8+mkXR6lw6 VUtDrbExjYjeVha6YHZzfiKTN1VihvThSElzaQWjmCj4VqKgorBb5Fd25/tNevOnhV5P R0T9KE6RspnpCzNW+s7fz1PTqmbNa1FKlq/kKGpd44P3D/4iBTD3kfTmvuntfWXNbw0+ pYR1B3i5w6686njXS7PAUIqME7Whhbhq226QyTD0saC3ZUSYRmx5ooKrK/G9gC/wXldW Jr7w== X-Gm-Message-State: AO0yUKW1K5v88t8LpgCnyOxw8LivJxoym6wQoVZ/TfKjuVrRMV/QP6pH 3opGTC425eqPeqP9XV1aMmc= X-Google-Smtp-Source: AK7set9XC3lLto515i1KBYnKzbRZRvqT7zYrOnmavr/KCHXCH3MTPE5I8FWGoulhWwrxCk7N200wxA== X-Received: by 2002:a17:90a:1955:b0:22c:3ce3:29f1 with SMTP id 21-20020a17090a195500b0022c3ce329f1mr3776325pjh.46.1675288405604; Wed, 01 Feb 2023 13:53:25 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:ce3a:44de:62b3:7a4b]) by smtp.gmail.com with ESMTPSA id h15-20020a17090a054f00b002276ba8fb71sm1781957pjf.25.2023.02.01.13.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 13:53:24 -0800 (PST) From: Dmitry Torokhov To: Wei Fang , Jakub Kicinski , Andrew Lunn Cc: Arnd Bergmann , Shenwei Wang , Clark Wang , NXP Linux Team , "David S. Miller" , Eric Dumazet , Paolo Abeni , Marc Kleine-Budde , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] net: fec: restore handling of PHY reset line as optional Date: Wed, 1 Feb 2023 13:53:19 -0800 Message-Id: <20230201215320.528319-1-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Conversion of the driver to gpiod API done in 468ba54bd616 ("fec: convert to gpio descriptor") incorrectly made reset line mandatory and resulted in aborting driver probe in cases where reset line was not specified (note: this way of specifying PHY reset line is actually deprecated). Switch to using devm_gpiod_get_optional() and skip manipulating reset line if it can not be located. Fixes: 468ba54bd616 ("fec: convert to gpio descriptor") Signed-off-by: Dmitry Torokhov Reviewed-by: Andrew Lunn Reported-by: Marc Kleine-Budde Tested-by: Marc Kleine-Budde Reviewed-by: Arnd Bergmann --- v3: removed handling of 'phy-reset-active-high', it was moved to patch #2 v2: dropped conversion to generic device properties from the patch drivers/net/ethernet/freescale/fec_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 2716898e0b9b..00115b55d0ff 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -4056,12 +4056,15 @@ static int fec_reset_phy(struct platform_device *pdev) active_high = of_property_read_bool(np, "phy-reset-active-high"); - phy_reset = devm_gpiod_get(&pdev->dev, "phy-reset", + phy_reset = devm_gpiod_get_optional(&pdev->dev, "phy-reset", active_high ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW); if (IS_ERR(phy_reset)) return dev_err_probe(&pdev->dev, PTR_ERR(phy_reset), "failed to get phy-reset-gpios\n"); + if (!phy_reset) + return 0; + if (msec > 20) msleep(msec); else From patchwork Wed Feb 1 21:53:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13125041 X-Patchwork-Delegate: kuba@kernel.org 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 0CAD2C636D4 for ; Wed, 1 Feb 2023 21:53:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231503AbjBAVxb (ORCPT ); Wed, 1 Feb 2023 16:53:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231465AbjBAVx2 (ORCPT ); Wed, 1 Feb 2023 16:53:28 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 201818680; Wed, 1 Feb 2023 13:53:28 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id h9so11276608plf.9; Wed, 01 Feb 2023 13:53:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tLp5ZQAmIsso9n6U/cVas1dfVfKmm+HocsrQi1jdGpU=; b=U+w3KMMxuYROKu607z5NG19MS4JmHQ/C+C2opcAdLW98xCmjTjl4aceqX0CjOM6T2h oFyrOv2crppvW+BRotVz3yEZpi2SAwxnhp7GDTn2FQj2wEBVcf/f6rR5sFufviwXqbJZ pJFErase+EmB8IWPW1X7JzXz7xqMb61bmwuN4za1qo0/LysOvuuTYEVQhY9t+k9oagSa 0woC9BwJ4RRQ7RFCc8SrDM9wtkwRmtlmTDk/jwcpfznsYUpxd/GJaG4cgouEqdSN326Z 9ze6kOvxXDPi1omAee89uoFRQEBSRo7XzySgc8tWrYORxf86LKDgAt7ymlEMzqFhxUvW jUvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tLp5ZQAmIsso9n6U/cVas1dfVfKmm+HocsrQi1jdGpU=; b=rLJNJLFPQF8AP623MFPL7/y8+G03q9UpxjJkS5JvJPBuUeMczG5Cp34JyeEkIUBVqP K5KnT3a+3GaCiypT/BPPXQiW09SSKxtmpatDQD/q1oNhL6lJ47EZzrDuHjIb4DO2lxhc pQgIwd9btOZZWcqHxRSXMs5pkr8/MRZPWYK0qUf/En5LxvdlmSTs6irhjjHmWxEuZRcA Jc8AHSbzpo5FIeE2eR2WNUowQmAZis8YWZcEwz8BBQrjSEe+bhy0EdgWDuNuuKWr8nRX Kg22bVmji2iQQnC5l8YlsUO8RZiA23lt3CXM8gMGixRBGZFP1mbKirdmVcw05OHJ7n8w CYgQ== X-Gm-Message-State: AO0yUKXgu/dSFU8SjIYKX1iLyWQhU/qs3dXlvuQXdZvPM1lBP68GhD8Y Y6bjS50mPZk23e3M+wCGKBU= X-Google-Smtp-Source: AK7set+z5jn1JNydUIn8dfJKpEJOsXUBw8l6JElR9IJ/yHoNNcLnTonmZkHBUcR6TxJKFaLjoJ8EJQ== X-Received: by 2002:a17:90a:ec07:b0:228:f13b:9649 with SMTP id l7-20020a17090aec0700b00228f13b9649mr4035768pjy.43.1675288407417; Wed, 01 Feb 2023 13:53:27 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:ce3a:44de:62b3:7a4b]) by smtp.gmail.com with ESMTPSA id h15-20020a17090a054f00b002276ba8fb71sm1781957pjf.25.2023.02.01.13.53.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 13:53:26 -0800 (PST) From: Dmitry Torokhov To: Wei Fang , Jakub Kicinski , Andrew Lunn Cc: Arnd Bergmann , Shenwei Wang , Clark Wang , NXP Linux Team , "David S. Miller" , Eric Dumazet , Paolo Abeni , Marc Kleine-Budde , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] net: fec: do not double-parse 'phy-reset-active-high' property Date: Wed, 1 Feb 2023 13:53:20 -0800 Message-Id: <20230201215320.528319-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog In-Reply-To: <20230201215320.528319-1-dmitry.torokhov@gmail.com> References: <20230201215320.528319-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Conversion to gpiod API done in commit 468ba54bd616 ("fec: convert to gpio descriptor") clashed with gpiolib applying the same quirk to the reset GPIO polarity (introduced in commit b02c85c9458c). This results in the reset line being left active/device being left in reset state when reset line is "active low". Remove handling of 'phy-reset-active-high' property from the driver and rely on gpiolib to apply needed adjustments to avoid ending up with the double inversion/flipped logic. Fixes: 468ba54bd616 ("fec: convert to gpio descriptor") Signed-off-by: Dmitry Torokhov Reviewed-by: Andrew Lunn --- v3: new patch, split from the original one drivers/net/ethernet/freescale/fec_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 00115b55d0ff..c73e25f8995e 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -4036,7 +4036,6 @@ static int fec_enet_init(struct net_device *ndev) static int fec_reset_phy(struct platform_device *pdev) { struct gpio_desc *phy_reset; - bool active_high = false; int msec = 1, phy_post_delay = 0; struct device_node *np = pdev->dev.of_node; int err; @@ -4054,10 +4053,8 @@ static int fec_reset_phy(struct platform_device *pdev) if (!err && phy_post_delay > 1000) return -EINVAL; - active_high = of_property_read_bool(np, "phy-reset-active-high"); - phy_reset = devm_gpiod_get_optional(&pdev->dev, "phy-reset", - active_high ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW); + GPIOD_OUT_HIGH); if (IS_ERR(phy_reset)) return dev_err_probe(&pdev->dev, PTR_ERR(phy_reset), "failed to get phy-reset-gpios\n"); @@ -4070,7 +4067,7 @@ static int fec_reset_phy(struct platform_device *pdev) else usleep_range(msec * 1000, msec * 1000 + 1000); - gpiod_set_value_cansleep(phy_reset, !active_high); + gpiod_set_value_cansleep(phy_reset, 0); if (!phy_post_delay) return 0;