From patchwork Mon May 22 09:15:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 100268 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp155088qge; Mon, 22 May 2017 02:16:29 -0700 (PDT) X-Received: by 10.84.147.71 with SMTP id r7mr6612183ple.58.1495444589240; Mon, 22 May 2017 02:16:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495444589; cv=none; d=google.com; s=arc-20160816; b=uMIh94XLz2SS2LXb/tcYmTyW03Csrd4E5MP09xnHY5clBxkUX/D5LzbsL0SsaaYvKw hJHOG5GdsUsCxJ8lYJLzsMjlFds2+O1JnHUshRKTNgWTXRjibkCvH/hKvtIH1x6MPuFH Vv0apR3PSdirx+C5TtTG7HuDyTPW8FJBvQrsSfql+I/e2FE8EjroXJpU53BRIiTXWQR4 TwJ2by80gv5WNzDI4zPL3ZzhglbiFQD42eVT5iFnWv2KGYPVzwZRpxSXlLHS74jms7oM ZZasAjS+9t8tVcRuRL5nO/8yw0oqUK3OgZYyJiUk05tkPhpXzv//LQlURywWxsmhPfoD MWEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=/Xa/YXJev79C0AaPmmWFxW4vSamudMeaK+nmNXmf6pE=; b=lJvjBr7NlwvgnAvQg31CSZ+bJChBHminMfWXq8gAXmrXFQJQVQ+kfsRBQdaU5ySf0e zjkIsifP/cEJ/fV15vCkb49YbR0sDdhvZS7hpz9vvDsZ9n8LAayxn1YrH6Zcf139/Od1 sFb2HLv6kFmXn15vMuutMin6zsxgGVvEbm3EdSPT7HCJKJV4b1lIBJGwmN//9MSKxo6n JKcEyfNrTX6dpPPcogl9BvW9Fj2nhUYMua2hn495Im8pmlRjh84dHk81tMvU5aIDAUhy KI4wQ681uw70d0c+A6CZKWKn6rxME2QRlBcOC861K3MPN8NIjE6MkYGiGAAa/Nzsdji4 8A+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h62si16187857pge.75.2017.05.22.02.16.28; Mon, 22 May 2017 02:16:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932772AbdEVJQ1 (ORCPT + 7 others); Mon, 22 May 2017 05:16:27 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:32894 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932230AbdEVJQ0 (ORCPT ); Mon, 22 May 2017 05:16:26 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id 26F972082A; Mon, 22 May 2017 11:16:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id E1033206ED; Mon, 22 May 2017 11:16:13 +0200 (CEST) From: Quentin Schulz To: fugang.duan@nxp.com, robh+dt@kernel.org, mark.rutland@arm.com Cc: Quentin Schulz , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@free-electrons.com Subject: [PATCH] net: fec: add post PHY reset delay DT property Date: Mon, 22 May 2017 11:15:17 +0200 Message-Id: <20170522091517.6857-1-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Some PHY require to wait for a bit after the reset GPIO has been toggled. This adds support for the DT property `phy-reset-post-delay` which gives the delay in milliseconds to wait after reset. If the DT property is not given, no delay is observed. Post reset delay greater than 1000ms are invalid and are default to 1ms. Signed-off-by: Quentin Schulz --- Documentation/devicetree/bindings/net/fsl-fec.txt | 5 +++++ drivers/net/ethernet/freescale/fec_main.c | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt b/Documentation/devicetree/bindings/net/fsl-fec.txt index a1e3693cca16..8795e8ca5793 100644 --- a/Documentation/devicetree/bindings/net/fsl-fec.txt +++ b/Documentation/devicetree/bindings/net/fsl-fec.txt @@ -15,6 +15,11 @@ Optional properties: - phy-reset-active-high : If present then the reset sequence using the GPIO specified in the "phy-reset-gpios" property is reversed (H=reset state, L=operation state). +- phy-reset-post-delay : Post reset delay in milliseconds. If present then + a delay of phy-reset-post-delay milliseconds will be observed after the + phy-reset-gpios has been toggled. Can be omitted thus no delay is + observed. Delay is in range of 1ms to 1000ms. If given delay is higher + than 1000ms, 1ms delay is done instead. - phy-supply : regulator that powers the Ethernet PHY. - phy-handle : phandle to the PHY device connected to this device. - fixed-link : Assume a fixed link. See fixed-link.txt in the same directory. diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 56a563f90b0b..00a7fd0bcd59 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3192,7 +3192,7 @@ static int fec_reset_phy(struct platform_device *pdev) { int err, phy_reset; bool active_high = false; - int msec = 1; + int msec = 1, phy_post_delay = 0; struct device_node *np = pdev->dev.of_node; if (!np) @@ -3210,7 +3210,6 @@ static int fec_reset_phy(struct platform_device *pdev) return 0; active_high = of_property_read_bool(np, "phy-reset-active-high"); - err = devm_gpio_request_one(&pdev->dev, phy_reset, active_high ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW, "phy-reset"); @@ -3219,6 +3218,11 @@ static int fec_reset_phy(struct platform_device *pdev) return err; } + err = of_property_read_u32(np, "phy-reset-post-delay", &phy_post_delay); + /* valid reset duration should be less than 1s */ + if (!err && phy_post_delay > 1000) + phy_post_delay = 1; + if (msec > 20) msleep(msec); else @@ -3226,6 +3230,15 @@ static int fec_reset_phy(struct platform_device *pdev) gpio_set_value_cansleep(phy_reset, !active_high); + if (!phy_post_delay) + return 0; + + if (phy_post_delay > 20) + msleep(phy_post_delay); + else + usleep_range(phy_post_delay * 1000, + phy_post_delay * 1000 + 1000); + return 0; } #else /* CONFIG_OF */