Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp583444ybp; Wed, 9 Oct 2019 00:34:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxUEB8SR3J7kd0BRtUqaP4BD2ixpUa7wL7aOL2JqteYunb5rQ8AaazUXSBEe/dknejIYowi X-Received: by 2002:aa7:d756:: with SMTP id a22mr1715073eds.198.1570606479469; Wed, 09 Oct 2019 00:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570606479; cv=none; d=google.com; s=arc-20160816; b=TqTknizUrC1YjaQ9GGcv/vv8RMxOQDDQTZssP1A/iXIc0Z519/sW+PFmk36Jlls9ww 9ESDxCSLlejjXRtSmGRvUiQn+S0uRBs8vrfTzk0d8YPtSS1e2R1kyBAlZezme4OYgRxS Wys/iBSBQ35lWzC9dHCAsOSQwE0ZWsu62sdyBL4XydKtGyrrbH5f3lJ9DrPbwDMFuX+R /4xrBAraxNUJpw60aIYgAAj+UFPRk4pHUTxRqP0iWyhHpllffR27+EiRemjMWBKlhxNY pCsuZlamMzG5b74xQjAdzfRhczmxFgGsAmKeVrW8cPzFNYFZSm8a2+5z/136dDEfmhgu tsvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=AnRrK0c4HqwrZIM8RVTKgLdzUN0IrqbD/cl/KSwxQUU=; b=pN5VjA3ya2s3Yfj1Ci57lI7wJ2dg5Op2lhMHySJjkh2B5X/DNR6IdvjNIZ3Dgo9BLm XN5alVS/2GCCVcDzzW2ArzaKtIOzMDgS5o4gjeyuWyAp6a7zfwEVfaeztYjKgz7vtJFu NNSSXNh9MM805ub5b+J1xhVLZ91kvrHYzCK/A1OGlo22Tyqgf8vYHyLGqQcL0H3/JW/X F38D0hcr7b02F0oKYyQnaFeF3zgr8W16Nnyc9yL6J92Z4SpWHjCr47DmvQT6h6Utmbbr jtkNfQS4jakHnVoDBjpcIm3oT88GDiKjswI5L+NAjt59Y3cAwoEn+VEswp4qt7FvnyLh dE0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w55si803036eda.15.2019.10.09.00.34.15; Wed, 09 Oct 2019 00:34:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729698AbfJIHeG (ORCPT + 99 others); Wed, 9 Oct 2019 03:34:06 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:45656 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725440AbfJIHeG (ORCPT ); Wed, 9 Oct 2019 03:34:06 -0400 X-UUID: 2ef24db3d304487ebc5022ae301ab5b1-20191009 X-UUID: 2ef24db3d304487ebc5022ae301ab5b1-20191009 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 649381377; Wed, 09 Oct 2019 15:33:59 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 9 Oct 2019 15:33:49 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 9 Oct 2019 15:33:48 +0800 From: Biao Huang To: , Jose Abreu , CC: Giuseppe Cavallaro , Alexandre Torgue , Maxime Coquelin , Matthias Brugger , , , , , , , , , Subject: [RESEND,PATCH] net: stmmac: dwmac-mediatek: fix wrong delay value issue when resume back Date: Wed, 9 Oct 2019 15:33:48 +0800 Message-ID: <20191009073348.5503-1-biao.huang@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org mac_delay value will be divided by 550/170 in mt2712_delay_ps2stage(), which is invoked at the beginning of mt2712_set_delay(), and the value should be restored at the end of mt2712_set_delay(). Or, mac_delay will be divided again when invoking mt2712_set_delay() when resume back. So, add mt2712_delay_stage2ps() to mt2712_set_delay() to recovery the original mac_delay value. Signed-off-by: Biao Huang --- .../ethernet/stmicro/stmmac/dwmac-mediatek.c | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c index 79f2ee37afed..cea7a0c7ce68 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c @@ -130,6 +130,31 @@ static void mt2712_delay_ps2stage(struct mediatek_dwmac_plat_data *plat) } } +static void mt2712_delay_stage2ps(struct mediatek_dwmac_plat_data *plat) +{ + struct mac_delay_struct *mac_delay = &plat->mac_delay; + + switch (plat->phy_mode) { + case PHY_INTERFACE_MODE_MII: + case PHY_INTERFACE_MODE_RMII: + /* 550ps per stage for MII/RMII */ + mac_delay->tx_delay *= 550; + mac_delay->rx_delay *= 550; + break; + case PHY_INTERFACE_MODE_RGMII: + case PHY_INTERFACE_MODE_RGMII_TXID: + case PHY_INTERFACE_MODE_RGMII_RXID: + case PHY_INTERFACE_MODE_RGMII_ID: + /* 170ps per stage for RGMII */ + mac_delay->tx_delay *= 170; + mac_delay->rx_delay *= 170; + break; + default: + dev_err(plat->dev, "phy interface not supported\n"); + break; + } +} + static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat) { struct mac_delay_struct *mac_delay = &plat->mac_delay; @@ -199,6 +224,8 @@ static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat) regmap_write(plat->peri_regmap, PERI_ETH_DLY, delay_val); regmap_write(plat->peri_regmap, PERI_ETH_DLY_FINE, fine_val); + mt2712_delay_stage2ps(plat); + return 0; } -- 2.18.0