Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3396268imu; Mon, 17 Dec 2018 19:51:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/XD0q3NEgofhE1oaKDtMcnHmdVSpNJDYLEHvDe9IkXr5EGz3ZinmRtq5Sj+wmWusGwMELGU X-Received: by 2002:a62:9719:: with SMTP id n25mr1345180pfe.240.1545105084741; Mon, 17 Dec 2018 19:51:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545105084; cv=none; d=google.com; s=arc-20160816; b=JJNy+NFB1G/OMMbA3DqFKYu+Y2PYJThLuFMD2KRzlhWMctOmyaFdP47HGAHuNFSD+E 27h2Frie1jwjcqpn15FmKMkzeiEmV8gHenMi30QpeeGFXrbISoHxK1iuV/C8FgN6flXN LJ+ukxKD0wYm72XAOzqMVXkTvq4f2OlMaOmBijIpVAZiUK9KicHRALla5KBQovVuj8QW LWqUwHVQ0ykzZpQvzcPU9oL8/cdGFx4yndzZUNv2GxO9YFRNM/Loodj/AjfyOyqatR8e HQMQpf8v0XHB2A0eyqrACK8XE5M3lA591+2O6x+sGQG9ga9sXNsn78o4VFTBlsH06i+s 4WGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=JD9XyZwN4byF2xGURyCjlL4AfqUlbnIVRmyNvNII35k=; b=zYL9V2ndRy85GGnJwNfjTRlTA9ObMO3YPy5AHOCOTMVML+ACMU427kf5qeZBdX0YRB KD6vn00Bi13xhSFIan/QCzbuFaceQ3NjnC7d0gm3M+SPKqXq8JD3kbh9yicQbH1PsYT3 NRLs0R77LQRfw8AzPbhFAn4fhhf/g2E6xmSC633Wo3jGunyJHUY6hgxPdZAbv2VWatls 8UA8FMfIdeO2+d4GYIt/6e6eolBI28TNp2ufubPH+QSkB5Ojl8XTj7b6q9aJggUfK5Gk Uhr7d1KmIuSULdUIu4zJnwiLl8zzB1E2GMxscdAXtW0M88dO2pxGOCMfsUi0uEFkeVS2 VLFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Izb3/GFO"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3si12639779pgc.232.2018.12.17.19.51.09; Mon, 17 Dec 2018 19:51:24 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b="Izb3/GFO"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726594AbeLRDuS (ORCPT + 99 others); Mon, 17 Dec 2018 22:50:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:52068 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726303AbeLRDuS (ORCPT ); Mon, 17 Dec 2018 22:50:18 -0500 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B8C4F2184B; Tue, 18 Dec 2018 03:50:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545105017; bh=nf9/1bm3hBCP/Y6CurT6Mh3N1LPIZB808p5rFP/voUM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Izb3/GFOGJnyrJMxgIQQ7weSJI75nqElZD2I2AbpagDgIFKTa7mwKkJak+2NvWOov b6Up+49rZ5yEBoo/uUgAqG/fNbh8sbsOQvVE5uSuE6ZRGKiRc8garfBiJdnYARcQKO w8D33SCQsA8eIi/jNDRqFHVACMFzoGLAvXlMZpS0= Received: by mail-wm1-f50.google.com with SMTP id y139so1185547wmc.5; Mon, 17 Dec 2018 19:50:16 -0800 (PST) X-Gm-Message-State: AA+aEWZ9o13Wqrgkkx70gqDz6HLabJZKNo1DRfPciiSWHLAXpG5J+oZM alzFGcMxLBeKAXKv84oPZZOuO1eZrmvqYtiOOO8= X-Received: by 2002:a1c:2e43:: with SMTP id u64mr1452607wmu.52.1545105015165; Mon, 17 Dec 2018 19:50:15 -0800 (PST) MIME-Version: 1.0 References: <1545100937-16093-1-git-send-email-biao.huang@mediatek.com> <1545100937-16093-3-git-send-email-biao.huang@mediatek.com> In-Reply-To: <1545100937-16093-3-git-send-email-biao.huang@mediatek.com> From: Sean Wang Date: Mon, 17 Dec 2018 19:49:47 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] net-next: stmmac: dwmac-mediatek: remove fine-tune property To: Biao Huang Cc: davem@davemloft.net, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, nelson.chang@mediatek.com, Andrew Lunn , netdev@vger.kernel.org, Liguo Zhang , linux-kernel@vger.kernel.org, Matthias Brugger , joabreu@synopsys.com, linux-mediatek@lists.infradead.org, honghui.zhang@mediatek.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 17, 2018 at 6:43 PM Biao Huang wrote: > > 1. remove fine-tune property and related setting to simplify > the timing adjustment flow. > 2. set timing value according to the value from device tree, > and will not care whether PHY insert internal delay. > > Signed-off-by: Biao Huang > --- > .../net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 71 +++++++------------- > 1 file changed, 24 insertions(+), 47 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c > index e400cbd..801c797 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c > @@ -44,7 +44,6 @@ struct mac_delay_struct { > u32 rx_delay; > bool tx_inv; > bool rx_inv; > - bool fine_tune; > }; > > struct mediatek_dwmac_plat_data { > @@ -105,16 +104,28 @@ static int mt2712_set_interface(struct mediatek_dwmac_plat_data *plat) > return 0; > } > > -static void mt2712_delay_ps2stage(struct mac_delay_struct *mac_delay) > +static void mt2712_delay_ps2stage(struct mediatek_dwmac_plat_data *plat) > { > - if (mac_delay->fine_tune) { > - /* 170ps per stage for fine tune delay macro circuit*/ > - mac_delay->tx_delay /= 170; > - mac_delay->rx_delay /= 170; > - } else { > - /* 550ps per stage for coarse tune delay macro circuit*/ > + 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 mii/rmii*/ mii/rmii appear to be a typo here. Additionally, I'd suggest using the capital letters for these abbreviations. > + mac_delay->tx_delay /= 170; > + mac_delay->rx_delay /= 170; > + break; > + default: > + dev_err(plat->dev, "phy interface not supported\n"); > + break; > } > } > > @@ -123,7 +134,7 @@ static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat) > struct mac_delay_struct *mac_delay = &plat->mac_delay; > u32 delay_val = 0, fine_val = 0; > > - mt2712_delay_ps2stage(mac_delay); > + mt2712_delay_ps2stage(plat); > > switch (plat->phy_mode) { > case PHY_INTERFACE_MODE_MII: > @@ -167,13 +178,10 @@ static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat) > fine_val = ETH_RMII_DLY_TX_INV; > break; > case PHY_INTERFACE_MODE_RGMII: > - /* the PHY is not responsible for inserting any internal > - * delay by itself in PHY_INTERFACE_MODE_RGMII case, > - * so Ethernet MAC will insert delays for both transmit > - * and receive path here. > - */ > - if (mac_delay->fine_tune) > - fine_val = ETH_FINE_DLY_GTXC | ETH_FINE_DLY_RXC; > + case PHY_INTERFACE_MODE_RGMII_TXID: > + case PHY_INTERFACE_MODE_RGMII_RXID: > + case PHY_INTERFACE_MODE_RGMII_ID: > + fine_val = ETH_FINE_DLY_GTXC | ETH_FINE_DLY_RXC; > > delay_val |= FIELD_PREP(ETH_DLY_GTXC_ENABLE, !!mac_delay->tx_delay); > delay_val |= FIELD_PREP(ETH_DLY_GTXC_STAGES, mac_delay->tx_delay); > @@ -183,36 +191,6 @@ static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat) > delay_val |= FIELD_PREP(ETH_DLY_RXC_STAGES, mac_delay->rx_delay); > delay_val |= FIELD_PREP(ETH_DLY_RXC_INV, mac_delay->rx_inv); > break; > - case PHY_INTERFACE_MODE_RGMII_TXID: > - /* the PHY should insert an internal delay for the transmit > - * path in PHY_INTERFACE_MODE_RGMII_TXID case, > - * so Ethernet MAC will insert the delay for receive path here. > - */ > - if (mac_delay->fine_tune) > - fine_val = ETH_FINE_DLY_RXC; > - > - delay_val |= FIELD_PREP(ETH_DLY_RXC_ENABLE, !!mac_delay->rx_delay); > - delay_val |= FIELD_PREP(ETH_DLY_RXC_STAGES, mac_delay->rx_delay); > - delay_val |= FIELD_PREP(ETH_DLY_RXC_INV, mac_delay->rx_inv); > - break; > - case PHY_INTERFACE_MODE_RGMII_RXID: > - /* the PHY should insert an internal delay for the receive > - * path in PHY_INTERFACE_MODE_RGMII_RXID case, > - * so Ethernet MAC will insert the delay for transmit path here. > - */ > - if (mac_delay->fine_tune) > - fine_val = ETH_FINE_DLY_GTXC; > - > - delay_val |= FIELD_PREP(ETH_DLY_GTXC_ENABLE, !!mac_delay->tx_delay); > - delay_val |= FIELD_PREP(ETH_DLY_GTXC_STAGES, mac_delay->tx_delay); > - delay_val |= FIELD_PREP(ETH_DLY_GTXC_INV, mac_delay->tx_inv); > - break; > - case PHY_INTERFACE_MODE_RGMII_ID: > - /* the PHY should insert internal delays for both transmit > - * and receive path in PHY_INTERFACE_MODE_RGMII_RXID case, > - * so Ethernet MAC will NOT insert any delay here. > - */ > - break; > default: > dev_err(plat->dev, "phy interface not supported\n"); > return -EINVAL; > @@ -270,7 +248,6 @@ static int mediatek_dwmac_config_dt(struct mediatek_dwmac_plat_data *plat) > > mac_delay->tx_inv = of_property_read_bool(plat->np, "mediatek,txc-inverse"); > mac_delay->rx_inv = of_property_read_bool(plat->np, "mediatek,rxc-inverse"); > - mac_delay->fine_tune = of_property_read_bool(plat->np, "mediatek,fine-tune"); > plat->rmii_rxc = of_property_read_bool(plat->np, "mediatek,rmii-rxc"); > > return 0; > -- > 1.7.9.5 > > > _______________________________________________ > Linux-mediatek mailing list > Linux-mediatek@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-mediatek