Commit 190f73ab authored by Voon Weifeng's avatar Voon Weifeng Committed by David S. Miller

net: stmmac: setup higher frequency clk support for EHL & TGL

EHL DW EQOS is running on a 200MHz clock. Setting up stmmac-clk,
ptp clock and ptp_max_adj to 200MHz.
Signed-off-by: default avatarVoon Weifeng <weifeng.voon@intel.com>
Signed-off-by: default avatarOng Boon Leong <boon.leong.ong@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f6256585
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
*******************************************************************************/ *******************************************************************************/
#include <linux/clk-provider.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/dmi.h> #include <linux/dmi.h>
...@@ -174,6 +175,19 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, ...@@ -174,6 +175,19 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,
plat->axi->axi_blen[1] = 8; plat->axi->axi_blen[1] = 8;
plat->axi->axi_blen[2] = 16; plat->axi->axi_blen[2] = 16;
plat->ptp_max_adj = plat->clk_ptp_rate;
/* Set system clock */
plat->stmmac_clk = clk_register_fixed_rate(&pdev->dev,
"stmmac-clk", NULL, 0,
plat->clk_ptp_rate);
if (IS_ERR(plat->stmmac_clk)) {
dev_warn(&pdev->dev, "Fail to register stmmac-clk\n");
plat->stmmac_clk = NULL;
}
clk_prepare_enable(plat->stmmac_clk);
/* Set default value for multicast hash bins */ /* Set default value for multicast hash bins */
plat->multicast_filter_bins = HASH_TABLE_SIZE; plat->multicast_filter_bins = HASH_TABLE_SIZE;
...@@ -193,6 +207,7 @@ static int ehl_common_data(struct pci_dev *pdev, ...@@ -193,6 +207,7 @@ static int ehl_common_data(struct pci_dev *pdev,
plat->rx_queues_to_use = 8; plat->rx_queues_to_use = 8;
plat->tx_queues_to_use = 8; plat->tx_queues_to_use = 8;
plat->clk_ptp_rate = 200000000;
ret = intel_mgbe_common_data(pdev, plat); ret = intel_mgbe_common_data(pdev, plat);
if (ret) if (ret)
return ret; return ret;
...@@ -233,6 +248,7 @@ static int tgl_common_data(struct pci_dev *pdev, ...@@ -233,6 +248,7 @@ static int tgl_common_data(struct pci_dev *pdev,
plat->rx_queues_to_use = 6; plat->rx_queues_to_use = 6;
plat->tx_queues_to_use = 4; plat->tx_queues_to_use = 4;
plat->clk_ptp_rate = 200000000;
ret = intel_mgbe_common_data(pdev, plat); ret = intel_mgbe_common_data(pdev, plat);
if (ret) if (ret)
return ret; return ret;
...@@ -438,10 +454,15 @@ static int stmmac_pci_probe(struct pci_dev *pdev, ...@@ -438,10 +454,15 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
*/ */
static void stmmac_pci_remove(struct pci_dev *pdev) static void stmmac_pci_remove(struct pci_dev *pdev)
{ {
struct net_device *ndev = dev_get_drvdata(&pdev->dev);
struct stmmac_priv *priv = netdev_priv(ndev);
int i; int i;
stmmac_dvr_remove(&pdev->dev); stmmac_dvr_remove(&pdev->dev);
if (priv->plat->stmmac_clk)
clk_unregister_fixed_rate(priv->plat->stmmac_clk);
for (i = 0; i <= PCI_STD_RESOURCE_END; i++) { for (i = 0; i <= PCI_STD_RESOURCE_END; i++) {
if (pci_resource_len(pdev, i) == 0) if (pci_resource_len(pdev, i) == 0)
continue; continue;
......
...@@ -194,6 +194,9 @@ void stmmac_ptp_register(struct stmmac_priv *priv) ...@@ -194,6 +194,9 @@ void stmmac_ptp_register(struct stmmac_priv *priv)
priv->pps[i].available = true; priv->pps[i].available = true;
} }
if (priv->plat->ptp_max_adj)
stmmac_ptp_clock_ops.max_adj = priv->plat->ptp_max_adj;
stmmac_ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num; stmmac_ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num;
spin_lock_init(&priv->ptp_lock); spin_lock_init(&priv->ptp_lock);
......
...@@ -168,6 +168,7 @@ struct plat_stmmacenet_data { ...@@ -168,6 +168,7 @@ struct plat_stmmacenet_data {
struct clk *clk_ptp_ref; struct clk *clk_ptp_ref;
unsigned int clk_ptp_rate; unsigned int clk_ptp_rate;
unsigned int clk_ref_rate; unsigned int clk_ref_rate;
s32 ptp_max_adj;
struct reset_control *stmmac_rst; struct reset_control *stmmac_rst;
struct stmmac_axi *axi; struct stmmac_axi *axi;
int has_gmac4; int has_gmac4;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment