Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2900181pxk; Mon, 28 Sep 2020 03:14:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcQkNhCvJ7l+HyL9O5cpiG72ODJ7IZkVw+sWvBJUepZno4GZCHLFEVeR3MlktQyzYrU7Iq X-Received: by 2002:a50:84e8:: with SMTP id 95mr814473edq.99.1601288069056; Mon, 28 Sep 2020 03:14:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601288069; cv=none; d=google.com; s=arc-20160816; b=yWv1YYYZ8Hyu2kfYLXhl8N8Ufuk61nd/vZKMWtqmCiaRT5i2qg9MRlPhrqYqJtIyG7 kSbpUso83ebJPFsI7nWOuiRCfiBZYAHJ4NAAdrSRrVy22TqRbw6AACySEAWZjIC6LRZC uXhqHlduH9VXWGTgQkHSr51r2cAF9XR45IrK4hGt2912VPWXyvsGHsKVYlRs3QAruOaX Fm2eK/w6x1+hgJlmGG8GxBj2li1WKBPmPaU8/HuUp69hPWNRhDe5ZUsL3y3oqdjze4GW zR8JyKaipfNIkQL+NXgwSH7NxmtJAXywwGR2SEHkV7c5hln8tNvKCthogZ79adR9ziUi zA0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=MF1PzBq0DItAIWRnFAUkyJzLGDzMeiU0hvswYuIFh1k=; b=S55FW9ZYMdzMnZXNHHoZugghOquQHyElPpaSG40hywukWztLukv+oJl6DYnt6nJj/W yRBxlVj0sSq5iZJWjqdEiNtO4r+yqbRz6bj3YeTtej4lBZcv1Mc1nFFSc6sBHKh7dMXg QvoHLHbmOwnasFs3WtXTU9bjQr5FmLGzL0OZMS6vpHHBlvWGCeXds3GmGC5pPzWgHcoP LS3XvSxurl+J+Vy8+4yV9oD0wkWe981IqP5RZtx/WDxcfC43U3qxQP906QwiWljwL2Ho 3UlmWKTb4GnAInECkxnTKJQ903AsSf2Gj3Bojv6QIQkNl1wDHFZqfC3ANzqvd3jNlWxU S6tQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c20si314623ejm.28.2020.09.28.03.14.05; Mon, 28 Sep 2020 03:14:29 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726674AbgI1KMT (ORCPT + 99 others); Mon, 28 Sep 2020 06:12:19 -0400 Received: from mga09.intel.com ([134.134.136.24]:54519 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726461AbgI1KMS (ORCPT ); Mon, 28 Sep 2020 06:12:18 -0400 IronPort-SDR: r1iBsign+/aMU1hcAbRI+HFjYCxU+XvTFx1pF2ZuADE/JG12+pcPo1B9tLMQ9PDMEkS+VN4epZ ANaVsMri/9DQ== X-IronPort-AV: E=McAfee;i="6000,8403,9757"; a="162854842" X-IronPort-AV: E=Sophos;i="5.77,313,1596524400"; d="scan'208";a="162854842" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2020 03:12:16 -0700 IronPort-SDR: 4/5R8Z+uJ6S8nnQ01H23JPefZtrf3oqoGNaJwBGJ/sU/nbwup0LCSALwLyYFweNcD7i3z6Xx6g LJbEFcEP671A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,313,1596524400"; d="scan'208";a="311725475" Received: from climb.png.intel.com ([10.221.118.165]) by orsmga006.jf.intel.com with ESMTP; 28 Sep 2020 03:12:13 -0700 From: Voon Weifeng To: "David S . Miller" , Maxime Coquelin Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jose Abreu , Giuseppe Cavallaro , Andrew Lunn , Alexandre Torgue , Ong Boon Leong , Voon Weifeng , Seow Chen Yong , Mark Gross , Wong Vee Khee Subject: [PATCH v1 net-next] stmmac: intel: Adding ref clock 1us tic for LPI cntr Date: Mon, 28 Sep 2020 18:12:12 +0800 Message-Id: <20200928101212.12274-1-weifeng.voon@intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rusaimi Amira Ruslan Adding reference clock (1us tic) for all LPI timer on Intel platforms. The reference clock is derived from ptp clk. This also enables all LPI counter. Signed-off-by: Rusaimi Amira Ruslan Signed-off-by: Voon Weifeng --- drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c | 9 +++++++++ drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 9 +++++++++ include/linux/stmmac.h | 1 + 3 files changed, 19 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c index b1323d5c95b5..f61cb997a8f6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c @@ -11,6 +11,7 @@ #include #include +#include "dwmac4.h" #include "stmmac.h" #include "stmmac_platform.h" @@ -146,6 +147,14 @@ static int intel_eth_plat_probe(struct platform_device *pdev) } plat_dat->bsp_priv = dwmac; + plat_dat->eee_usecs_rate = plat_dat->clk_ptp_rate; + + if (plat_dat->eee_usecs_rate > 0) { + u32 tx_lpi_usec; + + tx_lpi_usec = (plat_dat->eee_usecs_rate / 1000000) - 1; + writel(tx_lpi_usec, stmmac_res.addr + GMAC_1US_TIC_COUNTER); + } ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); if (ret) { diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index ab0a81e0fea1..2af9458be95f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -6,6 +6,7 @@ #include #include #include "dwmac-intel.h" +#include "dwmac4.h" #include "stmmac.h" struct intel_priv_data { @@ -295,6 +296,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->axi->axi_blen[2] = 16; plat->ptp_max_adj = plat->clk_ptp_rate; + plat->eee_usecs_rate = plat->clk_ptp_rate; /* Set system clock */ plat->stmmac_clk = clk_register_fixed_rate(&pdev->dev, @@ -623,6 +625,13 @@ static int intel_eth_pci_probe(struct pci_dev *pdev, if (ret) return ret; + if (plat->eee_usecs_rate > 0) { + u32 tx_lpi_usec; + + tx_lpi_usec = (plat->eee_usecs_rate / 1000000) - 1; + writel(tx_lpi_usec, res.addr + GMAC_1US_TIC_COUNTER); + } + ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES); if (ret < 0) return ret; diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 00e83c877496..628e28903b8b 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -200,5 +200,6 @@ struct plat_stmmacenet_data { int has_xgmac; bool vlan_fail_q_en; u8 vlan_fail_q; + unsigned int eee_usecs_rate; }; #endif -- 2.17.1