Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6384013pxv; Thu, 29 Jul 2021 13:14:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKRmQvaEfo/3URuBJgtCWQQhZC8CSIYTmhvPW0a92sTP1+WbvdMYjeYlc0R1dz1ZrHMr/Z X-Received: by 2002:a05:6402:206a:: with SMTP id bd10mr7903068edb.263.1627589696445; Thu, 29 Jul 2021 13:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627589696; cv=none; d=google.com; s=arc-20160816; b=pokA5UBdUshTrOelEdRiTVvQa41jxVYTHM/9+sJLWHsXiDuVH/G1FCDcApvn98WsrV ihBGMJaKTvuWHTn20qOfwqmlroGhWx78z+3YOaNmv3c1SvWN7E1GBxIMSDJ8I65tMtWn qj4+Vp84fnEkHI9qnWibj2YIPfWXoJ4QdOH59qA/gynx/pBeBO/SGifipJ/vbbWA8K1b X1D6joCbPL6nTYc18GlcS0fqJaCNI8er8QUcL/l5TWTuNp9BR72ZL4grCgBeAVjtZ5Kz 2FNVVoASUqzO1txJPBYdNxPYKvoOAMGI6Xni6dUBfiPmMXd4GBc+vVrjS8DmQNCG99eQ nxPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uFCBpDGM4hFIxc9yi8Eu0cialujSpGXKpLF4MnHX0N4=; b=UVDAuC27P3rBiM10iIS5qW56Zgr+LFgUu662L9yWMl3oP9nyxH+FjnWnFtSBRYNKFK PJDGEiHDiVNVUxWxeUmFwvwOeb86d78BHAjASQkgaB7eYAeR+hk03fXAJU+uWXtvODt6 e+2TNuA98lSm2jwNYdUvQPFoLI3j2rtlhbYnNbbFSXFOiQvFinxsYRv0u1D7Ra9VfVvo b0sfl/HiQlfDI1Ah4l3D+VeqaVad+y/1lMzc0XsN62AQvlXsAs/gj2GlV5RkwDxKDCPv Vr7/igg0hRN5VeN8sAQF9wai4ZbTr2y5ibCfKSOu+4Q2a80qWn0y9n6B+31MOv7oSSIi V12A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o4j5NmYt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r26si3877906edt.275.2021.07.29.13.14.32; Thu, 29 Jul 2021 13:14:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o4j5NmYt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbhG2UMB (ORCPT + 99 others); Thu, 29 Jul 2021 16:12:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229743AbhG2UMA (ORCPT ); Thu, 29 Jul 2021 16:12:00 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3872CC061765; Thu, 29 Jul 2021 13:11:56 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id q17-20020a17090a2e11b02901757deaf2c8so11323981pjd.0; Thu, 29 Jul 2021 13:11:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uFCBpDGM4hFIxc9yi8Eu0cialujSpGXKpLF4MnHX0N4=; b=o4j5NmYtOd2b6pXYrmg7YUJhk/ntJ1U45lCUKITehyjndOnUXczd6eaYzoajkza/Dq 6JmJHdTr3dahediTrHJt7WkawEEXnmo7o0mHt1OMLJ7Icx1CsA9ssknXBPvw/KtA9KKs UZHUviyVuD4nVGIu72SAfEwiYGfF6qDKUUD4WXfIArHFFCbdE1p/bDYZlnZFF5mLYS+5 P/Z6+xx2Rdx+bT/x7S4oGHAs6+FWAz5F79dFDwOY8J+CoqJL//mHSTFz8Xg/YZfxb6Qi 5Ref+r7ObgYFgExWA9S24uP5m/MhSwEALIPKaDywkjZQtU5jtUmgIoKKMRtGdmQhLA8A kovA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=uFCBpDGM4hFIxc9yi8Eu0cialujSpGXKpLF4MnHX0N4=; b=qtjmiGt2S/+DohxnezWRTXGAaLsw8hdN5bYwPHx0TJlKz3vcoBZT3x3TOw6J88DxhZ NqnnXROKOREJNPxGKGkkJW2/RFtJMHRkPl/savJ6O2bl9T7tmE0AP13bJtxMCr5QGyT2 X6e85vdTP0LOKeIjlxwkvpzL3IqF95vlpcKd1T0TZ8n8p2U8/2QP4qf+aR/PP6nR6VJw 02/rstuBQp50gnIhzCXMR6woQnGrEszYL76WdzdM5WTt6sd6pAT5bdSIvf2omxS2ZIpQ 36pyHi4yfxF1L6z0zDtJ+yvyKgI7OtCZkksBchAz9puN+W1K6T0xCuL7gOWPVAlEyl5q lofg== X-Gm-Message-State: AOAM53306utLtL4o08MMekmOfYnoreHA4z3B9sLNSBSOZHHan0Tg3nY/ A8CJBKZzvaDUD1nV+dQkJPPHBPTSalj3+w== X-Received: by 2002:a17:90b:34e:: with SMTP id fh14mr6956614pjb.100.1627589515588; Thu, 29 Jul 2021 13:11:55 -0700 (PDT) Received: from archl-on1.. ([103.51.72.31]) by smtp.gmail.com with ESMTPSA id i25sm4581407pfo.20.2021.07.29.13.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 13:11:55 -0700 (PDT) From: Anand Moon To: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, devicetree@vger.kernel.org Cc: Anand Moon , Jerome Brunet , Neil Armstrong , Martin Blumenstingl , Rob Herring , Kevin Hilman , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Maxime Coquelin , Philipp Zabel , Emiliano Ingrassia Subject: [PATCHv1 3/3] net: stmmac: dwmac-meson8b: Add reset controller for ethernet phy Date: Fri, 30 Jul 2021 01:40:52 +0530 Message-Id: <20210729201100.3994-4-linux.amoon@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210729201100.3994-1-linux.amoon@gmail.com> References: <20210729201100.3994-1-linux.amoon@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add reset controller for Ethernet phy reset on every boot for Amlogic SoC. Cc: Jerome Brunet Cc: Neil Armstrong Cc: Martin Blumenstingl Signed-off-by: Anand Moon --- .../ethernet/stmicro/stmmac/dwmac-meson8b.c | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c index c7a6588d9398..8b3b5e8c2a8a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "stmmac_platform.h" @@ -95,6 +96,7 @@ struct meson8b_dwmac { u32 tx_delay_ns; u32 rx_delay_ps; struct clk *timing_adj_clk; + struct reset_control *eth_reset; }; struct meson8b_dwmac_clk_configs { @@ -384,6 +386,17 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac) meson8b_dwmac_mask_bits(dwmac, PRG_ETH0, PRG_ETH0_TX_AND_PHY_REF_CLK, PRG_ETH0_TX_AND_PHY_REF_CLK); + /* Make sure the Ethernet PHY is properly reseted, as U-Boot may leave + * it at deasserted state, and thus it may fail to reset EMAC. + * + * This assumes the driver has exclusive access to the EPHY reset. + */ + ret = reset_control_reset(dwmac->eth_reset); + if (ret) { + dev_err(dwmac->dev, "Cannot reset internal PHY\n"); + return ret; + } + return 0; } @@ -465,6 +478,13 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) goto err_remove_config_dt; } + dwmac->eth_reset = devm_reset_control_get_exclusive(dwmac->dev, "ethreset"); + if (IS_ERR_OR_NULL(dwmac->eth_reset)) { + dev_err(dwmac->dev, "Failed to get Ethernet reset\n"); + ret = PTR_ERR(dwmac->eth_reset); + goto err_remove_config_dt; + } + ret = meson8b_init_rgmii_delays(dwmac); if (ret) goto err_remove_config_dt; -- 2.32.0