From patchwork Sun Jun 17 11:18:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Nazzareno Trimarchi X-Patchwork-Id: 930484 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="IoUns1bg"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 417sD06JR9z9s4n for ; Sun, 17 Jun 2018 21:18:23 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 70726C21DE8; Sun, 17 Jun 2018 11:18:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2749AC21C27; Sun, 17 Jun 2018 11:18:14 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 99B6EC21C27; Sun, 17 Jun 2018 11:18:12 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by lists.denx.de (Postfix) with ESMTPS id 61D17C21BE5 for ; Sun, 17 Jun 2018 11:18:11 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id e16-v6so9754066wmd.0 for ; Sun, 17 Jun 2018 04:18:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id; bh=bu6xaBY8R7gJl/7mTzb4o7DMsZ4ivw8vQ7YsJ1YFTEA=; b=IoUns1bgZ1zcX3Y3efZpv0s3mESM0vxVVDIxSAT2kgxBS5/Y3uifhjxatU6bTlc79P x1AXH5WoSa4pw22s+Q/E+gFsA7sMBVVBte5g7fRCdNoBQLFlIg2xXkkZp7rmoqXV/nXA +xG9y4VDpRu34UM19eTotMZTmnuMvA83+vfiw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bu6xaBY8R7gJl/7mTzb4o7DMsZ4ivw8vQ7YsJ1YFTEA=; b=sTyXXHuCx1i8U2UF6/de2pqPch72ow6FC9haWKYPRFpCSY3PIN/p4a0/StSsBtLQv4 Dg4lihGZY1TrhmMrtx51SeeyKXwBc4Xl6h62QHpO4mjKVL5d0Rp7HnwyKD7yEgPU9HSE GfKfDc50l4BRu7io3pysYGAjAPxcPop2uCoJn7YuHjokxo2QYziR7aJN3yjOkdHNxDny 5vcbJSgFTU8aP8ehnb41we55KtFZQ5/MzRE2MWO0H/PCJ7HXjknH774A73qh1lXQKA3g spMtZPLeYfUb0y8UGEfBI5m7TSclgH6gb/3/J9z1KLthRSRbui7BCnYIulqn2kldIW5+ BBRg== X-Gm-Message-State: APt69E0yAeI/0ZVF9oB69mc/b/vzQU1Z3ccB0UMe6/pVu++RNTLWYbSs HB0AhbXJbp2kjo4hZROhmMb+QA== X-Google-Smtp-Source: ADUXVKIWlSS9TEahQuJj+9QM1azbBrfZ67tVFsggnTPlzHEwIiOmC/t8b3MFgxLm1/FGxHUyFGQf0Q== X-Received: by 2002:a1c:7e8c:: with SMTP id z134-v6mr5734609wmc.156.1529234290849; Sun, 17 Jun 2018 04:18:10 -0700 (PDT) Received: from localhost.localdomain ([151.64.114.239]) by smtp.gmail.com with ESMTPSA id m16-v6sm10976901wro.91.2018.06.17.04.18.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Jun 2018 04:18:09 -0700 (PDT) From: Michael Trimarchi To: Joe Hershberger Date: Sun, 17 Jun 2018 13:18:03 +0200 Message-Id: <1529234283-4211-1-git-send-email-michael@amarulasolutions.com> X-Mailer: git-send-email 2.7.4 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH] eth: dm: fec: Add gpio phy reset binding X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add the missing gpio phy reset binding to the gpio and it's reset time configuration Signed-off-by: Michael Trimarchi --- drivers/net/fec_mxc.c | 42 ++++++++++++++++++++++++++++++++++++------ drivers/net/fec_mxc.h | 5 ++++- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 694a0b2..9eb2693 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -15,7 +15,6 @@ #include #include #include -#include "fec_mxc.h" #include #include @@ -24,6 +23,9 @@ #include #include #include +#include + +#include "fec_mxc.h" DECLARE_GLOBAL_DATA_PTR; @@ -1245,6 +1247,19 @@ static int fec_phy_init(struct fec_priv *priv, struct udevice *dev) return 0; } +#ifdef CONFIG_DM_GPIO +/* FEC GPIO reset */ +static void fec_gpio_reset(struct fec_priv *priv) +{ + debug("fec_gpio_reset: fec_gpio_reset(dev)\n"); + if (dm_gpio_is_valid(&priv->phy_reset_gpio)) { + dm_gpio_set_value(&priv->phy_reset_gpio, 1); + udelay(priv->reset_delay); + dm_gpio_set_value(&priv->phy_reset_gpio, 0); + } +} +#endif + static int fecmxc_probe(struct udevice *dev) { struct eth_pdata *pdata = dev_get_platdata(dev); @@ -1257,6 +1272,9 @@ static int fecmxc_probe(struct udevice *dev) if (ret) return ret; +#ifdef CONFIG_DM_GPIO + fec_gpio_reset(priv); +#endif /* Reset chip. */ writel(readl(&priv->eth->ecntrl) | FEC_ECNTRL_RESET, &priv->eth->ecntrl); @@ -1314,6 +1332,7 @@ static int fecmxc_remove(struct udevice *dev) static int fecmxc_ofdata_to_platdata(struct udevice *dev) { + int ret = 0; struct eth_pdata *pdata = dev_get_platdata(dev); struct fec_priv *priv = dev_get_priv(dev); const char *phy_mode; @@ -1331,12 +1350,23 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev) return -EINVAL; } - /* TODO - * Need to get the reset-gpio and related properties from DT - * and implemet the enet reset code on .probe call - */ +#ifdef CONFIG_DM_GPIO + ret = gpio_request_by_name(dev, "phy-reset-gpios", 0, + &priv->phy_reset_gpio, GPIOD_IS_OUT); + if (ret == 0) { + ret = dev_read_u32_array(dev, "phy-reset-duration", + &priv->reset_delay, 1000); + } else if (ret == -ENOENT) { + ret = 0; + } - return 0; + if (priv->reset_delay > 1000) { + printf("FEX MXC: gpio reset timeout should be less the 1000\n"); + priv->reset_delay = 1000; + } +#endif + + return ret; } static const struct udevice_id fecmxc_ids[] = { diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h index 3b935af..fd89443 100644 --- a/drivers/net/fec_mxc.h +++ b/drivers/net/fec_mxc.h @@ -250,7 +250,10 @@ struct fec_priv { int phy_id; int (*mii_postcall)(int); #endif - +#ifdef CONFIG_DM_GPIO + struct gpio_desc phy_reset_gpio; + uint32_t reset_delay; +#endif #ifdef CONFIG_DM_ETH u32 interface; #endif