History

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.

Voon Weifeng committed 7 years ago

Commit 190f73a1 parent f6256583 files · +25 −0Browse files

Unified · Split

3 files
  1. drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +21 −0
  2. drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +3 −0
  3. include/linux/stmmac.h +1 −0
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c+21−0
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
1010 *******************************************************************************/
1111
12+#include <linux/clk-provider.h>
1213 #include <linux/pci.h>
1314 #include <linux/dmi.h>
1415
@@ -174,6 +175,19 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, · 159 unmodified lines
174175 plat->axi->axi_blen[1] = 8;
175176 plat->axi->axi_blen[2] = 16;
176177
178+ plat->ptp_max_adj = plat->clk_ptp_rate;
179+
180+ /* Set system clock */
181+ plat->stmmac_clk = clk_register_fixed_rate(&pdev->dev,
182+ "stmmac-clk", NULL, 0,
183+ plat->clk_ptp_rate);
184+
185+ if (IS_ERR(plat->stmmac_clk)) {
186+ dev_warn(&pdev->dev, "Fail to register stmmac-clk\n");
187+ plat->stmmac_clk = NULL;
188+ }
189+ clk_prepare_enable(plat->stmmac_clk);
190+
177191 /* Set default value for multicast hash bins */
178192 plat->multicast_filter_bins = HASH_TABLE_SIZE;
179193
@@ -193,6 +207,7 @@ static int ehl_common_data(struct pci_dev *pdev, · 13 unmodified lines
193207
194208 plat->rx_queues_to_use = 8;
195209 plat->tx_queues_to_use = 8;
210+ plat->clk_ptp_rate = 200000000;
196211 ret = intel_mgbe_common_data(pdev, plat);
197212 if (ret)
198213 return ret;
@@ -233,6 +248,7 @@ static int tgl_common_data(struct pci_dev *pdev, · 34 unmodified lines
233248
234249 plat->rx_queues_to_use = 6;
235250 plat->tx_queues_to_use = 4;
251+ plat->clk_ptp_rate = 200000000;
236252 ret = intel_mgbe_common_data(pdev, plat);
237253 if (ret)
238254 return ret;
@@ -438,10 +454,15 @@ static int stmmac_pci_probe(struct pci_dev *pdev, · 199 unmodified lines
438454 */
439455 static void stmmac_pci_remove(struct pci_dev *pdev)
440456 {
457+ struct net_device *ndev = dev_get_drvdata(&pdev->dev);
458+ struct stmmac_priv *priv = netdev_priv(ndev);
441459 int i;
442460
443461 stmmac_dvr_remove(&pdev->dev);
444462
463+ if (priv->plat->stmmac_clk)
464+ clk_unregister_fixed_rate(priv->plat->stmmac_clk);
465+
445466 for (i = 0; i <= PCI_STD_RESOURCE_END; i++) {
446467 if (pci_resource_len(pdev, i) == 0)
447468 continue;
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c+3−0
@@ -194,6 +194,9 @@ void stmmac_ptp_register(struct stmmac_priv *priv) · 193 unmodified lines
194194 priv->pps[i].available = true;
195195 }
196196
197+ if (priv->plat->ptp_max_adj)
198+ stmmac_ptp_clock_ops.max_adj = priv->plat->ptp_max_adj;
199+
197200 stmmac_ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num;
198201
199202 spin_lock_init(&priv->ptp_lock);
include/linux/stmmac.h+1−0
@@ -168,6 +168,7 @@ struct plat_stmmacenet_data { · 167 unmodified lines
168168 struct clk *clk_ptp_ref;
169169 unsigned int clk_ptp_rate;
170170 unsigned int clk_ref_rate;
171+ s32 ptp_max_adj;
171172 struct reset_control *stmmac_rst;
172173 struct stmmac_axi *axi;
173174 int has_gmac4;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t