| @@ -9,6 +9,7 @@ · 8 unmodified lines |
| 9 | 9 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> |
| 10 | 10 | *******************************************************************************/ |
| 11 | 11 | |
| 12 | +#include <linux/clk-provider.h> |
| 12 | 13 | #include <linux/pci.h> |
| 13 | 14 | #include <linux/dmi.h> |
| 14 | 15 | |
| @@ -174,6 +175,19 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, · 159 unmodified lines |
| 174 | 175 | plat->axi->axi_blen[1] = 8; |
| 175 | 176 | plat->axi->axi_blen[2] = 16; |
| 176 | 177 | |
| 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 | + |
| 177 | 191 | /* Set default value for multicast hash bins */ |
| 178 | 192 | plat->multicast_filter_bins = HASH_TABLE_SIZE; |
| 179 | 193 | |
| @@ -193,6 +207,7 @@ static int ehl_common_data(struct pci_dev *pdev, · 13 unmodified lines |
| 193 | 207 | |
| 194 | 208 | plat->rx_queues_to_use = 8; |
| 195 | 209 | plat->tx_queues_to_use = 8; |
| 210 | + plat->clk_ptp_rate = 200000000; |
| 196 | 211 | ret = intel_mgbe_common_data(pdev, plat); |
| 197 | 212 | if (ret) |
| 198 | 213 | return ret; |
| @@ -233,6 +248,7 @@ static int tgl_common_data(struct pci_dev *pdev, · 34 unmodified lines |
| 233 | 248 | |
| 234 | 249 | plat->rx_queues_to_use = 6; |
| 235 | 250 | plat->tx_queues_to_use = 4; |
| 251 | + plat->clk_ptp_rate = 200000000; |
| 236 | 252 | ret = intel_mgbe_common_data(pdev, plat); |
| 237 | 253 | if (ret) |
| 238 | 254 | return ret; |
| @@ -438,10 +454,15 @@ static int stmmac_pci_probe(struct pci_dev *pdev, · 199 unmodified lines |
| 438 | 454 | */ |
| 439 | 455 | static void stmmac_pci_remove(struct pci_dev *pdev) |
| 440 | 456 | { |
| 457 | + struct net_device *ndev = dev_get_drvdata(&pdev->dev); |
| 458 | + struct stmmac_priv *priv = netdev_priv(ndev); |
| 441 | 459 | int i; |
| 442 | 460 | |
| 443 | 461 | stmmac_dvr_remove(&pdev->dev); |
| 444 | 462 | |
| 463 | + if (priv->plat->stmmac_clk) |
| 464 | + clk_unregister_fixed_rate(priv->plat->stmmac_clk); |
| 465 | + |
| 445 | 466 | for (i = 0; i <= PCI_STD_RESOURCE_END; i++) { |
| 446 | 467 | if (pci_resource_len(pdev, i) == 0) |
| 447 | 468 | continue; |