xref: /openbmc/linux/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
158da0cfaSVoon Weifeng // SPDX-License-Identifier: GPL-2.0
258da0cfaSVoon Weifeng /* Copyright (c) 2020, Intel Corporation
358da0cfaSVoon Weifeng  */
458da0cfaSVoon Weifeng 
558da0cfaSVoon Weifeng #include <linux/clk-provider.h>
658da0cfaSVoon Weifeng #include <linux/pci.h>
758da0cfaSVoon Weifeng #include <linux/dmi.h>
8b9663b7cSVoon Weifeng #include "dwmac-intel.h"
9b4c5f83aSRusaimi Amira Ruslan #include "dwmac4.h"
1058da0cfaSVoon Weifeng #include "stmmac.h"
11341f67e4STan Tee Min #include "stmmac_ptp.h"
1258da0cfaSVoon Weifeng 
13b9663b7cSVoon Weifeng struct intel_priv_data {
14b9663b7cSVoon Weifeng 	int mdio_adhoc_addr;	/* mdio address for serdes & etc */
151c137d47SWong Vee Khee 	unsigned long crossts_adj;
1676da35dcSWong, Vee Khee 	bool is_pse;
17b9663b7cSVoon Weifeng };
18b9663b7cSVoon Weifeng 
1958da0cfaSVoon Weifeng /* This struct is used to associate PCI Function of MAC controller on a board,
2058da0cfaSVoon Weifeng  * discovered via DMI, with the address of PHY connected to the MAC. The
2158da0cfaSVoon Weifeng  * negative value of the address means that MAC controller is not connected
2258da0cfaSVoon Weifeng  * with PHY.
2358da0cfaSVoon Weifeng  */
2458da0cfaSVoon Weifeng struct stmmac_pci_func_data {
2558da0cfaSVoon Weifeng 	unsigned int func;
2658da0cfaSVoon Weifeng 	int phy_addr;
2758da0cfaSVoon Weifeng };
2858da0cfaSVoon Weifeng 
2958da0cfaSVoon Weifeng struct stmmac_pci_dmi_data {
3058da0cfaSVoon Weifeng 	const struct stmmac_pci_func_data *func;
3158da0cfaSVoon Weifeng 	size_t nfuncs;
3258da0cfaSVoon Weifeng };
3358da0cfaSVoon Weifeng 
3458da0cfaSVoon Weifeng struct stmmac_pci_info {
3558da0cfaSVoon Weifeng 	int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
3658da0cfaSVoon Weifeng };
3758da0cfaSVoon Weifeng 
stmmac_pci_find_phy_addr(struct pci_dev * pdev,const struct dmi_system_id * dmi_list)3858da0cfaSVoon Weifeng static int stmmac_pci_find_phy_addr(struct pci_dev *pdev,
3958da0cfaSVoon Weifeng 				    const struct dmi_system_id *dmi_list)
4058da0cfaSVoon Weifeng {
4158da0cfaSVoon Weifeng 	const struct stmmac_pci_func_data *func_data;
4258da0cfaSVoon Weifeng 	const struct stmmac_pci_dmi_data *dmi_data;
4358da0cfaSVoon Weifeng 	const struct dmi_system_id *dmi_id;
4458da0cfaSVoon Weifeng 	int func = PCI_FUNC(pdev->devfn);
4558da0cfaSVoon Weifeng 	size_t n;
4658da0cfaSVoon Weifeng 
4758da0cfaSVoon Weifeng 	dmi_id = dmi_first_match(dmi_list);
4858da0cfaSVoon Weifeng 	if (!dmi_id)
4958da0cfaSVoon Weifeng 		return -ENODEV;
5058da0cfaSVoon Weifeng 
5158da0cfaSVoon Weifeng 	dmi_data = dmi_id->driver_data;
5258da0cfaSVoon Weifeng 	func_data = dmi_data->func;
5358da0cfaSVoon Weifeng 
5458da0cfaSVoon Weifeng 	for (n = 0; n < dmi_data->nfuncs; n++, func_data++)
5558da0cfaSVoon Weifeng 		if (func_data->func == func)
5658da0cfaSVoon Weifeng 			return func_data->phy_addr;
5758da0cfaSVoon Weifeng 
5858da0cfaSVoon Weifeng 	return -ENODEV;
5958da0cfaSVoon Weifeng }
6058da0cfaSVoon Weifeng 
serdes_status_poll(struct stmmac_priv * priv,int phyaddr,int phyreg,u32 mask,u32 val)61b9663b7cSVoon Weifeng static int serdes_status_poll(struct stmmac_priv *priv, int phyaddr,
62b9663b7cSVoon Weifeng 			      int phyreg, u32 mask, u32 val)
63b9663b7cSVoon Weifeng {
64b9663b7cSVoon Weifeng 	unsigned int retries = 10;
65b9663b7cSVoon Weifeng 	int val_rd;
66b9663b7cSVoon Weifeng 
67b9663b7cSVoon Weifeng 	do {
68b9663b7cSVoon Weifeng 		val_rd = mdiobus_read(priv->mii, phyaddr, phyreg);
69b9663b7cSVoon Weifeng 		if ((val_rd & mask) == (val & mask))
70b9663b7cSVoon Weifeng 			return 0;
71b9663b7cSVoon Weifeng 		udelay(POLL_DELAY_US);
72b9663b7cSVoon Weifeng 	} while (--retries);
73b9663b7cSVoon Weifeng 
74b9663b7cSVoon Weifeng 	return -ETIMEDOUT;
75b9663b7cSVoon Weifeng }
76b9663b7cSVoon Weifeng 
intel_serdes_powerup(struct net_device * ndev,void * priv_data)77b9663b7cSVoon Weifeng static int intel_serdes_powerup(struct net_device *ndev, void *priv_data)
78b9663b7cSVoon Weifeng {
79b9663b7cSVoon Weifeng 	struct intel_priv_data *intel_priv = priv_data;
80b9663b7cSVoon Weifeng 	struct stmmac_priv *priv = netdev_priv(ndev);
81b9663b7cSVoon Weifeng 	int serdes_phy_addr = 0;
82b9663b7cSVoon Weifeng 	u32 data = 0;
83b9663b7cSVoon Weifeng 
84b9663b7cSVoon Weifeng 	if (!intel_priv->mdio_adhoc_addr)
85b9663b7cSVoon Weifeng 		return 0;
86b9663b7cSVoon Weifeng 
87b9663b7cSVoon Weifeng 	serdes_phy_addr = intel_priv->mdio_adhoc_addr;
88b9663b7cSVoon Weifeng 
8946682cb8SVoon Weifeng 	/* Set the serdes rate and the PCLK rate */
9046682cb8SVoon Weifeng 	data = mdiobus_read(priv->mii, serdes_phy_addr,
9146682cb8SVoon Weifeng 			    SERDES_GCR0);
9246682cb8SVoon Weifeng 
9346682cb8SVoon Weifeng 	data &= ~SERDES_RATE_MASK;
9446682cb8SVoon Weifeng 	data &= ~SERDES_PCLK_MASK;
9546682cb8SVoon Weifeng 
9646682cb8SVoon Weifeng 	if (priv->plat->max_speed == 2500)
9746682cb8SVoon Weifeng 		data |= SERDES_RATE_PCIE_GEN2 << SERDES_RATE_PCIE_SHIFT |
9846682cb8SVoon Weifeng 			SERDES_PCLK_37p5MHZ << SERDES_PCLK_SHIFT;
9946682cb8SVoon Weifeng 	else
10046682cb8SVoon Weifeng 		data |= SERDES_RATE_PCIE_GEN1 << SERDES_RATE_PCIE_SHIFT |
10146682cb8SVoon Weifeng 			SERDES_PCLK_70MHZ << SERDES_PCLK_SHIFT;
10246682cb8SVoon Weifeng 
10346682cb8SVoon Weifeng 	mdiobus_write(priv->mii, serdes_phy_addr, SERDES_GCR0, data);
10446682cb8SVoon Weifeng 
105b9663b7cSVoon Weifeng 	/* assert clk_req */
106ccacb703SAndy Shevchenko 	data = mdiobus_read(priv->mii, serdes_phy_addr, SERDES_GCR0);
107b9663b7cSVoon Weifeng 	data |= SERDES_PLL_CLK;
108ccacb703SAndy Shevchenko 	mdiobus_write(priv->mii, serdes_phy_addr, SERDES_GCR0, data);
109b9663b7cSVoon Weifeng 
110b9663b7cSVoon Weifeng 	/* check for clk_ack assertion */
111b9663b7cSVoon Weifeng 	data = serdes_status_poll(priv, serdes_phy_addr,
112b9663b7cSVoon Weifeng 				  SERDES_GSR0,
113b9663b7cSVoon Weifeng 				  SERDES_PLL_CLK,
114b9663b7cSVoon Weifeng 				  SERDES_PLL_CLK);
115b9663b7cSVoon Weifeng 
116b9663b7cSVoon Weifeng 	if (data) {
117b9663b7cSVoon Weifeng 		dev_err(priv->device, "Serdes PLL clk request timeout\n");
118b9663b7cSVoon Weifeng 		return data;
119b9663b7cSVoon Weifeng 	}
120b9663b7cSVoon Weifeng 
121b9663b7cSVoon Weifeng 	/* assert lane reset */
122ccacb703SAndy Shevchenko 	data = mdiobus_read(priv->mii, serdes_phy_addr, SERDES_GCR0);
123b9663b7cSVoon Weifeng 	data |= SERDES_RST;
124ccacb703SAndy Shevchenko 	mdiobus_write(priv->mii, serdes_phy_addr, SERDES_GCR0, data);
125b9663b7cSVoon Weifeng 
126b9663b7cSVoon Weifeng 	/* check for assert lane reset reflection */
127b9663b7cSVoon Weifeng 	data = serdes_status_poll(priv, serdes_phy_addr,
128b9663b7cSVoon Weifeng 				  SERDES_GSR0,
129b9663b7cSVoon Weifeng 				  SERDES_RST,
130b9663b7cSVoon Weifeng 				  SERDES_RST);
131b9663b7cSVoon Weifeng 
132b9663b7cSVoon Weifeng 	if (data) {
133b9663b7cSVoon Weifeng 		dev_err(priv->device, "Serdes assert lane reset timeout\n");
134b9663b7cSVoon Weifeng 		return data;
135b9663b7cSVoon Weifeng 	}
136b9663b7cSVoon Weifeng 
137b9663b7cSVoon Weifeng 	/*  move power state to P0 */
138ccacb703SAndy Shevchenko 	data = mdiobus_read(priv->mii, serdes_phy_addr, SERDES_GCR0);
139b9663b7cSVoon Weifeng 
140b9663b7cSVoon Weifeng 	data &= ~SERDES_PWR_ST_MASK;
141b9663b7cSVoon Weifeng 	data |= SERDES_PWR_ST_P0 << SERDES_PWR_ST_SHIFT;
142b9663b7cSVoon Weifeng 
143ccacb703SAndy Shevchenko 	mdiobus_write(priv->mii, serdes_phy_addr, SERDES_GCR0, data);
144b9663b7cSVoon Weifeng 
145b9663b7cSVoon Weifeng 	/* Check for P0 state */
146b9663b7cSVoon Weifeng 	data = serdes_status_poll(priv, serdes_phy_addr,
147b9663b7cSVoon Weifeng 				  SERDES_GSR0,
148b9663b7cSVoon Weifeng 				  SERDES_PWR_ST_MASK,
149b9663b7cSVoon Weifeng 				  SERDES_PWR_ST_P0 << SERDES_PWR_ST_SHIFT);
150b9663b7cSVoon Weifeng 
151b9663b7cSVoon Weifeng 	if (data) {
152b9663b7cSVoon Weifeng 		dev_err(priv->device, "Serdes power state P0 timeout.\n");
153b9663b7cSVoon Weifeng 		return data;
154b9663b7cSVoon Weifeng 	}
155b9663b7cSVoon Weifeng 
156017d6250SVoon Weifeng 	/* PSE only - ungate SGMII PHY Rx Clock */
157017d6250SVoon Weifeng 	if (intel_priv->is_pse)
158017d6250SVoon Weifeng 		mdiobus_modify(priv->mii, serdes_phy_addr, SERDES_GCR0,
159017d6250SVoon Weifeng 			       0, SERDES_PHY_RX_CLK);
160017d6250SVoon Weifeng 
161b9663b7cSVoon Weifeng 	return 0;
162b9663b7cSVoon Weifeng }
163b9663b7cSVoon Weifeng 
intel_serdes_powerdown(struct net_device * ndev,void * intel_data)164b9663b7cSVoon Weifeng static void intel_serdes_powerdown(struct net_device *ndev, void *intel_data)
165b9663b7cSVoon Weifeng {
166b9663b7cSVoon Weifeng 	struct intel_priv_data *intel_priv = intel_data;
167b9663b7cSVoon Weifeng 	struct stmmac_priv *priv = netdev_priv(ndev);
168b9663b7cSVoon Weifeng 	int serdes_phy_addr = 0;
169b9663b7cSVoon Weifeng 	u32 data = 0;
170b9663b7cSVoon Weifeng 
171b9663b7cSVoon Weifeng 	if (!intel_priv->mdio_adhoc_addr)
172b9663b7cSVoon Weifeng 		return;
173b9663b7cSVoon Weifeng 
174b9663b7cSVoon Weifeng 	serdes_phy_addr = intel_priv->mdio_adhoc_addr;
175b9663b7cSVoon Weifeng 
176017d6250SVoon Weifeng 	/* PSE only - gate SGMII PHY Rx Clock */
177017d6250SVoon Weifeng 	if (intel_priv->is_pse)
178017d6250SVoon Weifeng 		mdiobus_modify(priv->mii, serdes_phy_addr, SERDES_GCR0,
179017d6250SVoon Weifeng 			       SERDES_PHY_RX_CLK, 0);
180017d6250SVoon Weifeng 
181b9663b7cSVoon Weifeng 	/*  move power state to P3 */
182ccacb703SAndy Shevchenko 	data = mdiobus_read(priv->mii, serdes_phy_addr, SERDES_GCR0);
183b9663b7cSVoon Weifeng 
184b9663b7cSVoon Weifeng 	data &= ~SERDES_PWR_ST_MASK;
185b9663b7cSVoon Weifeng 	data |= SERDES_PWR_ST_P3 << SERDES_PWR_ST_SHIFT;
186b9663b7cSVoon Weifeng 
187ccacb703SAndy Shevchenko 	mdiobus_write(priv->mii, serdes_phy_addr, SERDES_GCR0, data);
188b9663b7cSVoon Weifeng 
189b9663b7cSVoon Weifeng 	/* Check for P3 state */
190b9663b7cSVoon Weifeng 	data = serdes_status_poll(priv, serdes_phy_addr,
191b9663b7cSVoon Weifeng 				  SERDES_GSR0,
192b9663b7cSVoon Weifeng 				  SERDES_PWR_ST_MASK,
193b9663b7cSVoon Weifeng 				  SERDES_PWR_ST_P3 << SERDES_PWR_ST_SHIFT);
194b9663b7cSVoon Weifeng 
195b9663b7cSVoon Weifeng 	if (data) {
196b9663b7cSVoon Weifeng 		dev_err(priv->device, "Serdes power state P3 timeout\n");
197b9663b7cSVoon Weifeng 		return;
198b9663b7cSVoon Weifeng 	}
199b9663b7cSVoon Weifeng 
200b9663b7cSVoon Weifeng 	/* de-assert clk_req */
201ccacb703SAndy Shevchenko 	data = mdiobus_read(priv->mii, serdes_phy_addr, SERDES_GCR0);
202b9663b7cSVoon Weifeng 	data &= ~SERDES_PLL_CLK;
203ccacb703SAndy Shevchenko 	mdiobus_write(priv->mii, serdes_phy_addr, SERDES_GCR0, data);
204b9663b7cSVoon Weifeng 
205b9663b7cSVoon Weifeng 	/* check for clk_ack de-assert */
206b9663b7cSVoon Weifeng 	data = serdes_status_poll(priv, serdes_phy_addr,
207b9663b7cSVoon Weifeng 				  SERDES_GSR0,
208b9663b7cSVoon Weifeng 				  SERDES_PLL_CLK,
209b9663b7cSVoon Weifeng 				  (u32)~SERDES_PLL_CLK);
210b9663b7cSVoon Weifeng 
211b9663b7cSVoon Weifeng 	if (data) {
212b9663b7cSVoon Weifeng 		dev_err(priv->device, "Serdes PLL clk de-assert timeout\n");
213b9663b7cSVoon Weifeng 		return;
214b9663b7cSVoon Weifeng 	}
215b9663b7cSVoon Weifeng 
216b9663b7cSVoon Weifeng 	/* de-assert lane reset */
217ccacb703SAndy Shevchenko 	data = mdiobus_read(priv->mii, serdes_phy_addr, SERDES_GCR0);
218b9663b7cSVoon Weifeng 	data &= ~SERDES_RST;
219ccacb703SAndy Shevchenko 	mdiobus_write(priv->mii, serdes_phy_addr, SERDES_GCR0, data);
220b9663b7cSVoon Weifeng 
221b9663b7cSVoon Weifeng 	/* check for de-assert lane reset reflection */
222b9663b7cSVoon Weifeng 	data = serdes_status_poll(priv, serdes_phy_addr,
223b9663b7cSVoon Weifeng 				  SERDES_GSR0,
224b9663b7cSVoon Weifeng 				  SERDES_RST,
225b9663b7cSVoon Weifeng 				  (u32)~SERDES_RST);
226b9663b7cSVoon Weifeng 
227b9663b7cSVoon Weifeng 	if (data) {
228b9663b7cSVoon Weifeng 		dev_err(priv->device, "Serdes de-assert lane reset timeout\n");
229b9663b7cSVoon Weifeng 		return;
230b9663b7cSVoon Weifeng 	}
231b9663b7cSVoon Weifeng }
232b9663b7cSVoon Weifeng 
intel_speed_mode_2500(struct net_device * ndev,void * intel_data)23346682cb8SVoon Weifeng static void intel_speed_mode_2500(struct net_device *ndev, void *intel_data)
23446682cb8SVoon Weifeng {
23546682cb8SVoon Weifeng 	struct intel_priv_data *intel_priv = intel_data;
23646682cb8SVoon Weifeng 	struct stmmac_priv *priv = netdev_priv(ndev);
23746682cb8SVoon Weifeng 	int serdes_phy_addr = 0;
23846682cb8SVoon Weifeng 	u32 data = 0;
23946682cb8SVoon Weifeng 
24046682cb8SVoon Weifeng 	serdes_phy_addr = intel_priv->mdio_adhoc_addr;
24146682cb8SVoon Weifeng 
24246682cb8SVoon Weifeng 	/* Determine the link speed mode: 2.5Gbps/1Gbps */
24346682cb8SVoon Weifeng 	data = mdiobus_read(priv->mii, serdes_phy_addr,
24446682cb8SVoon Weifeng 			    SERDES_GCR);
24546682cb8SVoon Weifeng 
24646682cb8SVoon Weifeng 	if (((data & SERDES_LINK_MODE_MASK) >> SERDES_LINK_MODE_SHIFT) ==
24746682cb8SVoon Weifeng 	    SERDES_LINK_MODE_2G5) {
24846682cb8SVoon Weifeng 		dev_info(priv->device, "Link Speed Mode: 2.5Gbps\n");
24946682cb8SVoon Weifeng 		priv->plat->max_speed = 2500;
25046682cb8SVoon Weifeng 		priv->plat->phy_interface = PHY_INTERFACE_MODE_2500BASEX;
25146682cb8SVoon Weifeng 		priv->plat->mdio_bus_data->xpcs_an_inband = false;
25246682cb8SVoon Weifeng 	} else {
25346682cb8SVoon Weifeng 		priv->plat->max_speed = 1000;
25446682cb8SVoon Weifeng 	}
25546682cb8SVoon Weifeng }
25646682cb8SVoon Weifeng 
25776da35dcSWong, Vee Khee /* Program PTP Clock Frequency for different variant of
25876da35dcSWong, Vee Khee  * Intel mGBE that has slightly different GPO mapping
25976da35dcSWong, Vee Khee  */
intel_mgbe_ptp_clk_freq_config(struct stmmac_priv * priv)260d928d14bSAndrew Halaney static void intel_mgbe_ptp_clk_freq_config(struct stmmac_priv *priv)
26176da35dcSWong, Vee Khee {
26276da35dcSWong, Vee Khee 	struct intel_priv_data *intel_priv;
26376da35dcSWong, Vee Khee 	u32 gpio_value;
26476da35dcSWong, Vee Khee 
26576da35dcSWong, Vee Khee 	intel_priv = (struct intel_priv_data *)priv->plat->bsp_priv;
26676da35dcSWong, Vee Khee 
26776da35dcSWong, Vee Khee 	gpio_value = readl(priv->ioaddr + GMAC_GPIO_STATUS);
26876da35dcSWong, Vee Khee 
26976da35dcSWong, Vee Khee 	if (intel_priv->is_pse) {
27076da35dcSWong, Vee Khee 		/* For PSE GbE, use 200MHz */
27176da35dcSWong, Vee Khee 		gpio_value &= ~PSE_PTP_CLK_FREQ_MASK;
27276da35dcSWong, Vee Khee 		gpio_value |= PSE_PTP_CLK_FREQ_200MHZ;
27376da35dcSWong, Vee Khee 	} else {
27476da35dcSWong, Vee Khee 		/* For PCH GbE, use 200MHz */
27576da35dcSWong, Vee Khee 		gpio_value &= ~PCH_PTP_CLK_FREQ_MASK;
27676da35dcSWong, Vee Khee 		gpio_value |= PCH_PTP_CLK_FREQ_200MHZ;
27776da35dcSWong, Vee Khee 	}
27876da35dcSWong, Vee Khee 
27976da35dcSWong, Vee Khee 	writel(gpio_value, priv->ioaddr + GMAC_GPIO_STATUS);
28076da35dcSWong, Vee Khee }
28176da35dcSWong, Vee Khee 
get_arttime(struct mii_bus * mii,int intel_adhoc_addr,u64 * art_time)282341f67e4STan Tee Min static void get_arttime(struct mii_bus *mii, int intel_adhoc_addr,
283341f67e4STan Tee Min 			u64 *art_time)
284341f67e4STan Tee Min {
285341f67e4STan Tee Min 	u64 ns;
286341f67e4STan Tee Min 
287341f67e4STan Tee Min 	ns = mdiobus_read(mii, intel_adhoc_addr, PMC_ART_VALUE3);
288341f67e4STan Tee Min 	ns <<= GMAC4_ART_TIME_SHIFT;
289341f67e4STan Tee Min 	ns |= mdiobus_read(mii, intel_adhoc_addr, PMC_ART_VALUE2);
290341f67e4STan Tee Min 	ns <<= GMAC4_ART_TIME_SHIFT;
291341f67e4STan Tee Min 	ns |= mdiobus_read(mii, intel_adhoc_addr, PMC_ART_VALUE1);
292341f67e4STan Tee Min 	ns <<= GMAC4_ART_TIME_SHIFT;
293341f67e4STan Tee Min 	ns |= mdiobus_read(mii, intel_adhoc_addr, PMC_ART_VALUE0);
294341f67e4STan Tee Min 
295341f67e4STan Tee Min 	*art_time = ns;
296341f67e4STan Tee Min }
297341f67e4STan Tee Min 
stmmac_cross_ts_isr(struct stmmac_priv * priv)29876c16d3eSWong Vee Khee static int stmmac_cross_ts_isr(struct stmmac_priv *priv)
29976c16d3eSWong Vee Khee {
30076c16d3eSWong Vee Khee 	return (readl(priv->ioaddr + GMAC_INT_STATUS) & GMAC_INT_TSIE);
30176c16d3eSWong Vee Khee }
30276c16d3eSWong Vee Khee 
intel_crosststamp(ktime_t * device,struct system_counterval_t * system,void * ctx)303341f67e4STan Tee Min static int intel_crosststamp(ktime_t *device,
304341f67e4STan Tee Min 			     struct system_counterval_t *system,
305341f67e4STan Tee Min 			     void *ctx)
306341f67e4STan Tee Min {
307341f67e4STan Tee Min 	struct intel_priv_data *intel_priv;
308341f67e4STan Tee Min 
309341f67e4STan Tee Min 	struct stmmac_priv *priv = (struct stmmac_priv *)ctx;
310341f67e4STan Tee Min 	void __iomem *ptpaddr = priv->ptpaddr;
311341f67e4STan Tee Min 	void __iomem *ioaddr = priv->hw->pcsr;
312341f67e4STan Tee Min 	unsigned long flags;
313341f67e4STan Tee Min 	u64 art_time = 0;
314341f67e4STan Tee Min 	u64 ptp_time = 0;
315341f67e4STan Tee Min 	u32 num_snapshot;
316341f67e4STan Tee Min 	u32 gpio_value;
317341f67e4STan Tee Min 	u32 acr_value;
318341f67e4STan Tee Min 	int i;
319341f67e4STan Tee Min 
320341f67e4STan Tee Min 	if (!boot_cpu_has(X86_FEATURE_ART))
321341f67e4STan Tee Min 		return -EOPNOTSUPP;
322341f67e4STan Tee Min 
323341f67e4STan Tee Min 	intel_priv = priv->plat->bsp_priv;
324341f67e4STan Tee Min 
325f4da5652STan Tee Min 	/* Both internal crosstimestamping and external triggered event
326f4da5652STan Tee Min 	 * timestamping cannot be run concurrently.
327f4da5652STan Tee Min 	 */
328aa5513f5SBartosz Golaszewski 	if (priv->plat->flags & STMMAC_FLAG_EXT_SNAPSHOT_EN)
329f4da5652STan Tee Min 		return -EBUSY;
330f4da5652STan Tee Min 
331621ba7adSBartosz Golaszewski 	priv->plat->flags |= STMMAC_FLAG_INT_SNAPSHOT_EN;
33276c16d3eSWong Vee Khee 
333f4da5652STan Tee Min 	mutex_lock(&priv->aux_ts_lock);
334341f67e4STan Tee Min 	/* Enable Internal snapshot trigger */
335341f67e4STan Tee Min 	acr_value = readl(ptpaddr + PTP_ACR);
336341f67e4STan Tee Min 	acr_value &= ~PTP_ACR_MASK;
337341f67e4STan Tee Min 	switch (priv->plat->int_snapshot_num) {
338341f67e4STan Tee Min 	case AUX_SNAPSHOT0:
339341f67e4STan Tee Min 		acr_value |= PTP_ACR_ATSEN0;
340341f67e4STan Tee Min 		break;
341341f67e4STan Tee Min 	case AUX_SNAPSHOT1:
342341f67e4STan Tee Min 		acr_value |= PTP_ACR_ATSEN1;
343341f67e4STan Tee Min 		break;
344341f67e4STan Tee Min 	case AUX_SNAPSHOT2:
345341f67e4STan Tee Min 		acr_value |= PTP_ACR_ATSEN2;
346341f67e4STan Tee Min 		break;
347341f67e4STan Tee Min 	case AUX_SNAPSHOT3:
348341f67e4STan Tee Min 		acr_value |= PTP_ACR_ATSEN3;
349341f67e4STan Tee Min 		break;
350341f67e4STan Tee Min 	default:
35153e35ebbSDan Carpenter 		mutex_unlock(&priv->aux_ts_lock);
352621ba7adSBartosz Golaszewski 		priv->plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN;
353341f67e4STan Tee Min 		return -EINVAL;
354341f67e4STan Tee Min 	}
355341f67e4STan Tee Min 	writel(acr_value, ptpaddr + PTP_ACR);
356341f67e4STan Tee Min 
357341f67e4STan Tee Min 	/* Clear FIFO */
358341f67e4STan Tee Min 	acr_value = readl(ptpaddr + PTP_ACR);
359341f67e4STan Tee Min 	acr_value |= PTP_ACR_ATSFC;
360341f67e4STan Tee Min 	writel(acr_value, ptpaddr + PTP_ACR);
361f4da5652STan Tee Min 	/* Release the mutex */
362f4da5652STan Tee Min 	mutex_unlock(&priv->aux_ts_lock);
363341f67e4STan Tee Min 
364341f67e4STan Tee Min 	/* Trigger Internal snapshot signal
365341f67e4STan Tee Min 	 * Create a rising edge by just toggle the GPO1 to low
366341f67e4STan Tee Min 	 * and back to high.
367341f67e4STan Tee Min 	 */
368341f67e4STan Tee Min 	gpio_value = readl(ioaddr + GMAC_GPIO_STATUS);
369341f67e4STan Tee Min 	gpio_value &= ~GMAC_GPO1;
370341f67e4STan Tee Min 	writel(gpio_value, ioaddr + GMAC_GPIO_STATUS);
371341f67e4STan Tee Min 	gpio_value |= GMAC_GPO1;
372341f67e4STan Tee Min 	writel(gpio_value, ioaddr + GMAC_GPIO_STATUS);
373341f67e4STan Tee Min 
37476c16d3eSWong Vee Khee 	/* Time sync done Indication - Interrupt method */
37576c16d3eSWong Vee Khee 	if (!wait_event_interruptible_timeout(priv->tstamp_busy_wait,
37676c16d3eSWong Vee Khee 					      stmmac_cross_ts_isr(priv),
37776c16d3eSWong Vee Khee 					      HZ / 100)) {
378621ba7adSBartosz Golaszewski 		priv->plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN;
37976c16d3eSWong Vee Khee 		return -ETIMEDOUT;
380341f67e4STan Tee Min 	}
381341f67e4STan Tee Min 
382341f67e4STan Tee Min 	num_snapshot = (readl(ioaddr + GMAC_TIMESTAMP_STATUS) &
383341f67e4STan Tee Min 			GMAC_TIMESTAMP_ATSNS_MASK) >>
384341f67e4STan Tee Min 			GMAC_TIMESTAMP_ATSNS_SHIFT;
385341f67e4STan Tee Min 
386341f67e4STan Tee Min 	/* Repeat until the timestamps are from the FIFO last segment */
387341f67e4STan Tee Min 	for (i = 0; i < num_snapshot; i++) {
388642436a1SYannick Vignon 		read_lock_irqsave(&priv->ptp_lock, flags);
389341f67e4STan Tee Min 		stmmac_get_ptptime(priv, ptpaddr, &ptp_time);
390341f67e4STan Tee Min 		*device = ns_to_ktime(ptp_time);
391642436a1SYannick Vignon 		read_unlock_irqrestore(&priv->ptp_lock, flags);
392341f67e4STan Tee Min 		get_arttime(priv->mii, intel_priv->mdio_adhoc_addr, &art_time);
393341f67e4STan Tee Min 		*system = convert_art_to_tsc(art_time);
394341f67e4STan Tee Min 	}
395341f67e4STan Tee Min 
3961c137d47SWong Vee Khee 	system->cycles *= intel_priv->crossts_adj;
397621ba7adSBartosz Golaszewski 	priv->plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN;
3981c137d47SWong Vee Khee 
399341f67e4STan Tee Min 	return 0;
400341f67e4STan Tee Min }
401341f67e4STan Tee Min 
intel_mgbe_pse_crossts_adj(struct intel_priv_data * intel_priv,int base)4021c137d47SWong Vee Khee static void intel_mgbe_pse_crossts_adj(struct intel_priv_data *intel_priv,
4031c137d47SWong Vee Khee 				       int base)
4041c137d47SWong Vee Khee {
4051c137d47SWong Vee Khee 	if (boot_cpu_has(X86_FEATURE_ART)) {
4061c137d47SWong Vee Khee 		unsigned int art_freq;
4071c137d47SWong Vee Khee 
4081c137d47SWong Vee Khee 		/* On systems that support ART, ART frequency can be obtained
4091c137d47SWong Vee Khee 		 * from ECX register of CPUID leaf (0x15).
4101c137d47SWong Vee Khee 		 */
4111c137d47SWong Vee Khee 		art_freq = cpuid_ecx(ART_CPUID_LEAF);
4121c137d47SWong Vee Khee 		do_div(art_freq, base);
4131c137d47SWong Vee Khee 		intel_priv->crossts_adj = art_freq;
4141c137d47SWong Vee Khee 	}
4151c137d47SWong Vee Khee }
4161c137d47SWong Vee Khee 
common_default_data(struct plat_stmmacenet_data * plat)41758da0cfaSVoon Weifeng static void common_default_data(struct plat_stmmacenet_data *plat)
41858da0cfaSVoon Weifeng {
41958da0cfaSVoon Weifeng 	plat->clk_csr = 2;	/* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */
42058da0cfaSVoon Weifeng 	plat->has_gmac = 1;
42158da0cfaSVoon Weifeng 	plat->force_sf_dma_mode = 1;
42258da0cfaSVoon Weifeng 
42358da0cfaSVoon Weifeng 	plat->mdio_bus_data->needs_reset = true;
42458da0cfaSVoon Weifeng 
42558da0cfaSVoon Weifeng 	/* Set default value for multicast hash bins */
42658da0cfaSVoon Weifeng 	plat->multicast_filter_bins = HASH_TABLE_SIZE;
42758da0cfaSVoon Weifeng 
42858da0cfaSVoon Weifeng 	/* Set default value for unicast filter entries */
42958da0cfaSVoon Weifeng 	plat->unicast_filter_entries = 1;
43058da0cfaSVoon Weifeng 
43158da0cfaSVoon Weifeng 	/* Set the maxmtu to a default of JUMBO_LEN */
43258da0cfaSVoon Weifeng 	plat->maxmtu = JUMBO_LEN;
43358da0cfaSVoon Weifeng 
43458da0cfaSVoon Weifeng 	/* Set default number of RX and TX queues to use */
43558da0cfaSVoon Weifeng 	plat->tx_queues_to_use = 1;
43658da0cfaSVoon Weifeng 	plat->rx_queues_to_use = 1;
43758da0cfaSVoon Weifeng 
43858da0cfaSVoon Weifeng 	/* Disable Priority config by default */
43958da0cfaSVoon Weifeng 	plat->tx_queues_cfg[0].use_prio = false;
44058da0cfaSVoon Weifeng 	plat->rx_queues_cfg[0].use_prio = false;
44158da0cfaSVoon Weifeng 
44258da0cfaSVoon Weifeng 	/* Disable RX queues routing by default */
44358da0cfaSVoon Weifeng 	plat->rx_queues_cfg[0].pkt_route = 0x0;
44458da0cfaSVoon Weifeng }
44558da0cfaSVoon Weifeng 
intel_mgbe_common_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)44658da0cfaSVoon Weifeng static int intel_mgbe_common_data(struct pci_dev *pdev,
44758da0cfaSVoon Weifeng 				  struct plat_stmmacenet_data *plat)
44858da0cfaSVoon Weifeng {
44972edaf39SOng Boon Leong 	struct fwnode_handle *fwnode;
4508eb37ab7SWong Vee Khee 	char clk_name[20];
45109f012e6SAndy Shevchenko 	int ret;
45258da0cfaSVoon Weifeng 	int i;
45358da0cfaSVoon Weifeng 
45420e07e2cSWong Vee Khee 	plat->pdev = pdev;
455bff6f1dbSVoon Weifeng 	plat->phy_addr = -1;
45658da0cfaSVoon Weifeng 	plat->clk_csr = 5;
45758da0cfaSVoon Weifeng 	plat->has_gmac = 0;
45858da0cfaSVoon Weifeng 	plat->has_gmac4 = 1;
45958da0cfaSVoon Weifeng 	plat->force_sf_dma_mode = 0;
46068861a3bSBartosz Golaszewski 	plat->flags |= (STMMAC_FLAG_TSO_EN | STMMAC_FLAG_SPH_DISABLE);
46158da0cfaSVoon Weifeng 
462e80fe71bSMichael Sit Wei Hong 	/* Multiplying factor to the clk_eee_i clock time
463e80fe71bSMichael Sit Wei Hong 	 * period to make it closer to 100 ns. This value
464e80fe71bSMichael Sit Wei Hong 	 * should be programmed such that the clk_eee_time_period *
465e80fe71bSMichael Sit Wei Hong 	 * (MULT_FACT_100NS + 1) should be within 80 ns to 120 ns
466e80fe71bSMichael Sit Wei Hong 	 * clk_eee frequency is 19.2Mhz
467e80fe71bSMichael Sit Wei Hong 	 * clk_eee_time_period is 52ns
468e80fe71bSMichael Sit Wei Hong 	 * 52ns * (1 + 1) = 104ns
469e80fe71bSMichael Sit Wei Hong 	 * MULT_FACT_100NS = 1
470e80fe71bSMichael Sit Wei Hong 	 */
471e80fe71bSMichael Sit Wei Hong 	plat->mult_fact_100ns = 1;
472e80fe71bSMichael Sit Wei Hong 
47358da0cfaSVoon Weifeng 	plat->rx_sched_algorithm = MTL_RX_ALGORITHM_SP;
47458da0cfaSVoon Weifeng 
47558da0cfaSVoon Weifeng 	for (i = 0; i < plat->rx_queues_to_use; i++) {
47658da0cfaSVoon Weifeng 		plat->rx_queues_cfg[i].mode_to_use = MTL_QUEUE_DCB;
47758da0cfaSVoon Weifeng 		plat->rx_queues_cfg[i].chan = i;
47858da0cfaSVoon Weifeng 
47958da0cfaSVoon Weifeng 		/* Disable Priority config by default */
48058da0cfaSVoon Weifeng 		plat->rx_queues_cfg[i].use_prio = false;
48158da0cfaSVoon Weifeng 
48258da0cfaSVoon Weifeng 		/* Disable RX queues routing by default */
48358da0cfaSVoon Weifeng 		plat->rx_queues_cfg[i].pkt_route = 0x0;
48458da0cfaSVoon Weifeng 	}
48558da0cfaSVoon Weifeng 
48658da0cfaSVoon Weifeng 	for (i = 0; i < plat->tx_queues_to_use; i++) {
48758da0cfaSVoon Weifeng 		plat->tx_queues_cfg[i].mode_to_use = MTL_QUEUE_DCB;
48858da0cfaSVoon Weifeng 
48958da0cfaSVoon Weifeng 		/* Disable Priority config by default */
49058da0cfaSVoon Weifeng 		plat->tx_queues_cfg[i].use_prio = false;
49117cb0070SOng Boon Leong 		/* Default TX Q0 to use TSO and rest TXQ for TBS */
49217cb0070SOng Boon Leong 		if (i > 0)
49317cb0070SOng Boon Leong 			plat->tx_queues_cfg[i].tbs_en = 1;
49458da0cfaSVoon Weifeng 	}
49558da0cfaSVoon Weifeng 
49658da0cfaSVoon Weifeng 	/* FIFO size is 4096 bytes for 1 tx/rx queue */
49758da0cfaSVoon Weifeng 	plat->tx_fifo_size = plat->tx_queues_to_use * 4096;
49858da0cfaSVoon Weifeng 	plat->rx_fifo_size = plat->rx_queues_to_use * 4096;
49958da0cfaSVoon Weifeng 
50058da0cfaSVoon Weifeng 	plat->tx_sched_algorithm = MTL_TX_ALGORITHM_WRR;
50158da0cfaSVoon Weifeng 	plat->tx_queues_cfg[0].weight = 0x09;
50258da0cfaSVoon Weifeng 	plat->tx_queues_cfg[1].weight = 0x0A;
50358da0cfaSVoon Weifeng 	plat->tx_queues_cfg[2].weight = 0x0B;
50458da0cfaSVoon Weifeng 	plat->tx_queues_cfg[3].weight = 0x0C;
50558da0cfaSVoon Weifeng 	plat->tx_queues_cfg[4].weight = 0x0D;
50658da0cfaSVoon Weifeng 	plat->tx_queues_cfg[5].weight = 0x0E;
50758da0cfaSVoon Weifeng 	plat->tx_queues_cfg[6].weight = 0x0F;
50858da0cfaSVoon Weifeng 	plat->tx_queues_cfg[7].weight = 0x10;
50958da0cfaSVoon Weifeng 
51058da0cfaSVoon Weifeng 	plat->dma_cfg->pbl = 32;
51158da0cfaSVoon Weifeng 	plat->dma_cfg->pblx8 = true;
51258da0cfaSVoon Weifeng 	plat->dma_cfg->fixed_burst = 0;
51358da0cfaSVoon Weifeng 	plat->dma_cfg->mixed_burst = 0;
51458da0cfaSVoon Weifeng 	plat->dma_cfg->aal = 0;
515676b7ec6SMohammad Athari Bin Ismail 	plat->dma_cfg->dche = true;
51658da0cfaSVoon Weifeng 
51758da0cfaSVoon Weifeng 	plat->axi = devm_kzalloc(&pdev->dev, sizeof(*plat->axi),
51858da0cfaSVoon Weifeng 				 GFP_KERNEL);
51958da0cfaSVoon Weifeng 	if (!plat->axi)
52058da0cfaSVoon Weifeng 		return -ENOMEM;
52158da0cfaSVoon Weifeng 
52258da0cfaSVoon Weifeng 	plat->axi->axi_lpi_en = 0;
52358da0cfaSVoon Weifeng 	plat->axi->axi_xit_frm = 0;
52458da0cfaSVoon Weifeng 	plat->axi->axi_wr_osr_lmt = 1;
52558da0cfaSVoon Weifeng 	plat->axi->axi_rd_osr_lmt = 1;
52658da0cfaSVoon Weifeng 	plat->axi->axi_blen[0] = 4;
52758da0cfaSVoon Weifeng 	plat->axi->axi_blen[1] = 8;
52858da0cfaSVoon Weifeng 	plat->axi->axi_blen[2] = 16;
52958da0cfaSVoon Weifeng 
53058da0cfaSVoon Weifeng 	plat->ptp_max_adj = plat->clk_ptp_rate;
531b4c5f83aSRusaimi Amira Ruslan 	plat->eee_usecs_rate = plat->clk_ptp_rate;
53258da0cfaSVoon Weifeng 
53358da0cfaSVoon Weifeng 	/* Set system clock */
5348eb37ab7SWong Vee Khee 	sprintf(clk_name, "%s-%s", "stmmac", pci_name(pdev));
5358eb37ab7SWong Vee Khee 
53658da0cfaSVoon Weifeng 	plat->stmmac_clk = clk_register_fixed_rate(&pdev->dev,
5378eb37ab7SWong Vee Khee 						   clk_name, NULL, 0,
53858da0cfaSVoon Weifeng 						   plat->clk_ptp_rate);
53958da0cfaSVoon Weifeng 
54058da0cfaSVoon Weifeng 	if (IS_ERR(plat->stmmac_clk)) {
54158da0cfaSVoon Weifeng 		dev_warn(&pdev->dev, "Fail to register stmmac-clk\n");
54258da0cfaSVoon Weifeng 		plat->stmmac_clk = NULL;
54358da0cfaSVoon Weifeng 	}
54409f012e6SAndy Shevchenko 
54509f012e6SAndy Shevchenko 	ret = clk_prepare_enable(plat->stmmac_clk);
54609f012e6SAndy Shevchenko 	if (ret) {
54709f012e6SAndy Shevchenko 		clk_unregister_fixed_rate(plat->stmmac_clk);
54809f012e6SAndy Shevchenko 		return ret;
54909f012e6SAndy Shevchenko 	}
55058da0cfaSVoon Weifeng 
55176da35dcSWong, Vee Khee 	plat->ptp_clk_freq_config = intel_mgbe_ptp_clk_freq_config;
55276da35dcSWong, Vee Khee 
55358da0cfaSVoon Weifeng 	/* Set default value for multicast hash bins */
55458da0cfaSVoon Weifeng 	plat->multicast_filter_bins = HASH_TABLE_SIZE;
55558da0cfaSVoon Weifeng 
55658da0cfaSVoon Weifeng 	/* Set default value for unicast filter entries */
55758da0cfaSVoon Weifeng 	plat->unicast_filter_entries = 1;
55858da0cfaSVoon Weifeng 
55958da0cfaSVoon Weifeng 	/* Set the maxmtu to a default of JUMBO_LEN */
56058da0cfaSVoon Weifeng 	plat->maxmtu = JUMBO_LEN;
56158da0cfaSVoon Weifeng 
562fc02152bSBartosz Golaszewski 	plat->flags |= STMMAC_FLAG_VLAN_FAIL_Q_EN;
563e0f9956aSChuah, Kim Tatt 
564e0f9956aSChuah, Kim Tatt 	/* Use the last Rx queue */
565e0f9956aSChuah, Kim Tatt 	plat->vlan_fail_q = plat->rx_queues_to_use - 1;
566e0f9956aSChuah, Kim Tatt 
56772edaf39SOng Boon Leong 	/* For fixed-link setup, we allow phy-mode setting */
56872edaf39SOng Boon Leong 	fwnode = dev_fwnode(&pdev->dev);
56972edaf39SOng Boon Leong 	if (fwnode) {
57072edaf39SOng Boon Leong 		int phy_mode;
57172edaf39SOng Boon Leong 
57272edaf39SOng Boon Leong 		/* "phy-mode" setting is optional. If it is set,
57372edaf39SOng Boon Leong 		 *  we allow either sgmii or 1000base-x for now.
57472edaf39SOng Boon Leong 		 */
57572edaf39SOng Boon Leong 		phy_mode = fwnode_get_phy_mode(fwnode);
57672edaf39SOng Boon Leong 		if (phy_mode >= 0) {
57772edaf39SOng Boon Leong 			if (phy_mode == PHY_INTERFACE_MODE_SGMII ||
57872edaf39SOng Boon Leong 			    phy_mode == PHY_INTERFACE_MODE_1000BASEX)
57972edaf39SOng Boon Leong 				plat->phy_interface = phy_mode;
58072edaf39SOng Boon Leong 			else
58172edaf39SOng Boon Leong 				dev_warn(&pdev->dev, "Invalid phy-mode\n");
58272edaf39SOng Boon Leong 		}
58372edaf39SOng Boon Leong 	}
58472edaf39SOng Boon Leong 
5857310fe53SOng Boon Leong 	/* Intel mgbe SGMII interface uses pcs-xcps */
586c8238631SOng Boon Leong 	if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII ||
587c8238631SOng Boon Leong 	    plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) {
5887310fe53SOng Boon Leong 		plat->mdio_bus_data->has_xpcs = true;
5897310fe53SOng Boon Leong 		plat->mdio_bus_data->xpcs_an_inband = true;
5907310fe53SOng Boon Leong 	}
5917310fe53SOng Boon Leong 
59272edaf39SOng Boon Leong 	/* For fixed-link setup, we clear xpcs_an_inband */
59372edaf39SOng Boon Leong 	if (fwnode) {
59472edaf39SOng Boon Leong 		struct fwnode_handle *fixed_node;
59572edaf39SOng Boon Leong 
59672edaf39SOng Boon Leong 		fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link");
59772edaf39SOng Boon Leong 		if (fixed_node)
59872edaf39SOng Boon Leong 			plat->mdio_bus_data->xpcs_an_inband = false;
59972edaf39SOng Boon Leong 
60072edaf39SOng Boon Leong 		fwnode_handle_put(fixed_node);
60172edaf39SOng Boon Leong 	}
60272edaf39SOng Boon Leong 
6037310fe53SOng Boon Leong 	/* Ensure mdio bus scan skips intel serdes and pcs-xpcs */
6047310fe53SOng Boon Leong 	plat->mdio_bus_data->phy_mask = 1 << INTEL_MGBE_ADHOC_ADDR;
6057310fe53SOng Boon Leong 	plat->mdio_bus_data->phy_mask |= 1 << INTEL_MGBE_XPCS_ADDR;
6067310fe53SOng Boon Leong 
607341f67e4STan Tee Min 	plat->int_snapshot_num = AUX_SNAPSHOT1;
608f4da5652STan Tee Min 	plat->ext_snapshot_num = AUX_SNAPSHOT0;
609341f67e4STan Tee Min 
610341f67e4STan Tee Min 	plat->crosststamp = intel_crosststamp;
611621ba7adSBartosz Golaszewski 	plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN;
612341f67e4STan Tee Min 
613b42446b9SOng Boon Leong 	/* Setup MSI vector offset specific to Intel mGbE controller */
614b42446b9SOng Boon Leong 	plat->msi_mac_vec = 29;
615b42446b9SOng Boon Leong 	plat->msi_lpi_vec = 28;
616b42446b9SOng Boon Leong 	plat->msi_sfty_ce_vec = 27;
617b42446b9SOng Boon Leong 	plat->msi_sfty_ue_vec = 26;
618b42446b9SOng Boon Leong 	plat->msi_rx_base_vec = 0;
619b42446b9SOng Boon Leong 	plat->msi_tx_base_vec = 1;
620b42446b9SOng Boon Leong 
62158da0cfaSVoon Weifeng 	return 0;
62258da0cfaSVoon Weifeng }
62358da0cfaSVoon Weifeng 
ehl_common_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)62458da0cfaSVoon Weifeng static int ehl_common_data(struct pci_dev *pdev,
62558da0cfaSVoon Weifeng 			   struct plat_stmmacenet_data *plat)
62658da0cfaSVoon Weifeng {
62758da0cfaSVoon Weifeng 	plat->rx_queues_to_use = 8;
62858da0cfaSVoon Weifeng 	plat->tx_queues_to_use = 8;
629fd1d62d8SBartosz Golaszewski 	plat->flags |= STMMAC_FLAG_USE_PHY_WOL;
630*58f2ffdeSKurt Kanzenbach 	plat->flags |= STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY;
63158da0cfaSVoon Weifeng 
6325ac712dcSWong Vee Khee 	plat->safety_feat_cfg->tsoee = 1;
6335ac712dcSWong Vee Khee 	plat->safety_feat_cfg->mrxpee = 1;
6345ac712dcSWong Vee Khee 	plat->safety_feat_cfg->mestee = 1;
6355ac712dcSWong Vee Khee 	plat->safety_feat_cfg->mrxee = 1;
6365ac712dcSWong Vee Khee 	plat->safety_feat_cfg->mtxee = 1;
6375ac712dcSWong Vee Khee 	plat->safety_feat_cfg->epsi = 0;
6385ac712dcSWong Vee Khee 	plat->safety_feat_cfg->edpp = 0;
6395ac712dcSWong Vee Khee 	plat->safety_feat_cfg->prtyen = 0;
6405ac712dcSWong Vee Khee 	plat->safety_feat_cfg->tmouten = 0;
6415ac712dcSWong Vee Khee 
642d5383b03SAndy Shevchenko 	return intel_mgbe_common_data(pdev, plat);
64358da0cfaSVoon Weifeng }
64458da0cfaSVoon Weifeng 
ehl_sgmii_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)64558da0cfaSVoon Weifeng static int ehl_sgmii_data(struct pci_dev *pdev,
64658da0cfaSVoon Weifeng 			  struct plat_stmmacenet_data *plat)
64758da0cfaSVoon Weifeng {
64858da0cfaSVoon Weifeng 	plat->bus_id = 1;
64958da0cfaSVoon Weifeng 	plat->phy_interface = PHY_INTERFACE_MODE_SGMII;
65046682cb8SVoon Weifeng 	plat->speed_mode_2500 = intel_speed_mode_2500;
651b9663b7cSVoon Weifeng 	plat->serdes_powerup = intel_serdes_powerup;
652b9663b7cSVoon Weifeng 	plat->serdes_powerdown = intel_serdes_powerdown;
653b9663b7cSVoon Weifeng 
654dcea1a81STan, Tee Min 	plat->clk_ptp_rate = 204800000;
655dcea1a81STan, Tee Min 
65658da0cfaSVoon Weifeng 	return ehl_common_data(pdev, plat);
65758da0cfaSVoon Weifeng }
65858da0cfaSVoon Weifeng 
659ccacb703SAndy Shevchenko static struct stmmac_pci_info ehl_sgmii1g_info = {
66058da0cfaSVoon Weifeng 	.setup = ehl_sgmii_data,
66158da0cfaSVoon Weifeng };
66258da0cfaSVoon Weifeng 
ehl_rgmii_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)66358da0cfaSVoon Weifeng static int ehl_rgmii_data(struct pci_dev *pdev,
66458da0cfaSVoon Weifeng 			  struct plat_stmmacenet_data *plat)
66558da0cfaSVoon Weifeng {
66658da0cfaSVoon Weifeng 	plat->bus_id = 1;
66758da0cfaSVoon Weifeng 	plat->phy_interface = PHY_INTERFACE_MODE_RGMII;
66858da0cfaSVoon Weifeng 
669dcea1a81STan, Tee Min 	plat->clk_ptp_rate = 204800000;
670dcea1a81STan, Tee Min 
67158da0cfaSVoon Weifeng 	return ehl_common_data(pdev, plat);
67258da0cfaSVoon Weifeng }
67358da0cfaSVoon Weifeng 
674ccacb703SAndy Shevchenko static struct stmmac_pci_info ehl_rgmii1g_info = {
67558da0cfaSVoon Weifeng 	.setup = ehl_rgmii_data,
67658da0cfaSVoon Weifeng };
67758da0cfaSVoon Weifeng 
ehl_pse0_common_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)67867c08ac4SVoon Weifeng static int ehl_pse0_common_data(struct pci_dev *pdev,
67967c08ac4SVoon Weifeng 				struct plat_stmmacenet_data *plat)
68067c08ac4SVoon Weifeng {
68176da35dcSWong, Vee Khee 	struct intel_priv_data *intel_priv = plat->bsp_priv;
68276da35dcSWong, Vee Khee 
68376da35dcSWong, Vee Khee 	intel_priv->is_pse = true;
68467c08ac4SVoon Weifeng 	plat->bus_id = 2;
685070246e4SJochen Henneberg 	plat->host_dma_width = 32;
68676da35dcSWong, Vee Khee 
687dcea1a81STan, Tee Min 	plat->clk_ptp_rate = 200000000;
688dcea1a81STan, Tee Min 
6891c137d47SWong Vee Khee 	intel_mgbe_pse_crossts_adj(intel_priv, EHL_PSE_ART_MHZ);
6901c137d47SWong Vee Khee 
69167c08ac4SVoon Weifeng 	return ehl_common_data(pdev, plat);
69267c08ac4SVoon Weifeng }
69367c08ac4SVoon Weifeng 
ehl_pse0_rgmii1g_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)69467c08ac4SVoon Weifeng static int ehl_pse0_rgmii1g_data(struct pci_dev *pdev,
69567c08ac4SVoon Weifeng 				 struct plat_stmmacenet_data *plat)
69667c08ac4SVoon Weifeng {
69767c08ac4SVoon Weifeng 	plat->phy_interface = PHY_INTERFACE_MODE_RGMII_ID;
69867c08ac4SVoon Weifeng 	return ehl_pse0_common_data(pdev, plat);
69967c08ac4SVoon Weifeng }
70067c08ac4SVoon Weifeng 
701ccacb703SAndy Shevchenko static struct stmmac_pci_info ehl_pse0_rgmii1g_info = {
70267c08ac4SVoon Weifeng 	.setup = ehl_pse0_rgmii1g_data,
70367c08ac4SVoon Weifeng };
70467c08ac4SVoon Weifeng 
ehl_pse0_sgmii1g_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)70567c08ac4SVoon Weifeng static int ehl_pse0_sgmii1g_data(struct pci_dev *pdev,
70667c08ac4SVoon Weifeng 				 struct plat_stmmacenet_data *plat)
70767c08ac4SVoon Weifeng {
70867c08ac4SVoon Weifeng 	plat->phy_interface = PHY_INTERFACE_MODE_SGMII;
70946682cb8SVoon Weifeng 	plat->speed_mode_2500 = intel_speed_mode_2500;
710b9663b7cSVoon Weifeng 	plat->serdes_powerup = intel_serdes_powerup;
711b9663b7cSVoon Weifeng 	plat->serdes_powerdown = intel_serdes_powerdown;
71267c08ac4SVoon Weifeng 	return ehl_pse0_common_data(pdev, plat);
71367c08ac4SVoon Weifeng }
71467c08ac4SVoon Weifeng 
715ccacb703SAndy Shevchenko static struct stmmac_pci_info ehl_pse0_sgmii1g_info = {
71667c08ac4SVoon Weifeng 	.setup = ehl_pse0_sgmii1g_data,
71767c08ac4SVoon Weifeng };
71867c08ac4SVoon Weifeng 
ehl_pse1_common_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)71967c08ac4SVoon Weifeng static int ehl_pse1_common_data(struct pci_dev *pdev,
72067c08ac4SVoon Weifeng 				struct plat_stmmacenet_data *plat)
72167c08ac4SVoon Weifeng {
72276da35dcSWong, Vee Khee 	struct intel_priv_data *intel_priv = plat->bsp_priv;
72376da35dcSWong, Vee Khee 
72476da35dcSWong, Vee Khee 	intel_priv->is_pse = true;
72567c08ac4SVoon Weifeng 	plat->bus_id = 3;
726070246e4SJochen Henneberg 	plat->host_dma_width = 32;
72776da35dcSWong, Vee Khee 
728dcea1a81STan, Tee Min 	plat->clk_ptp_rate = 200000000;
729dcea1a81STan, Tee Min 
7301c137d47SWong Vee Khee 	intel_mgbe_pse_crossts_adj(intel_priv, EHL_PSE_ART_MHZ);
7311c137d47SWong Vee Khee 
73267c08ac4SVoon Weifeng 	return ehl_common_data(pdev, plat);
73367c08ac4SVoon Weifeng }
73467c08ac4SVoon Weifeng 
ehl_pse1_rgmii1g_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)73567c08ac4SVoon Weifeng static int ehl_pse1_rgmii1g_data(struct pci_dev *pdev,
73667c08ac4SVoon Weifeng 				 struct plat_stmmacenet_data *plat)
73767c08ac4SVoon Weifeng {
73867c08ac4SVoon Weifeng 	plat->phy_interface = PHY_INTERFACE_MODE_RGMII_ID;
73967c08ac4SVoon Weifeng 	return ehl_pse1_common_data(pdev, plat);
74067c08ac4SVoon Weifeng }
74167c08ac4SVoon Weifeng 
742ccacb703SAndy Shevchenko static struct stmmac_pci_info ehl_pse1_rgmii1g_info = {
74367c08ac4SVoon Weifeng 	.setup = ehl_pse1_rgmii1g_data,
74467c08ac4SVoon Weifeng };
74567c08ac4SVoon Weifeng 
ehl_pse1_sgmii1g_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)74667c08ac4SVoon Weifeng static int ehl_pse1_sgmii1g_data(struct pci_dev *pdev,
74767c08ac4SVoon Weifeng 				 struct plat_stmmacenet_data *plat)
74867c08ac4SVoon Weifeng {
74967c08ac4SVoon Weifeng 	plat->phy_interface = PHY_INTERFACE_MODE_SGMII;
75046682cb8SVoon Weifeng 	plat->speed_mode_2500 = intel_speed_mode_2500;
751b9663b7cSVoon Weifeng 	plat->serdes_powerup = intel_serdes_powerup;
752b9663b7cSVoon Weifeng 	plat->serdes_powerdown = intel_serdes_powerdown;
75367c08ac4SVoon Weifeng 	return ehl_pse1_common_data(pdev, plat);
75467c08ac4SVoon Weifeng }
75567c08ac4SVoon Weifeng 
756ccacb703SAndy Shevchenko static struct stmmac_pci_info ehl_pse1_sgmii1g_info = {
75767c08ac4SVoon Weifeng 	.setup = ehl_pse1_sgmii1g_data,
75867c08ac4SVoon Weifeng };
75967c08ac4SVoon Weifeng 
tgl_common_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)76058da0cfaSVoon Weifeng static int tgl_common_data(struct pci_dev *pdev,
76158da0cfaSVoon Weifeng 			   struct plat_stmmacenet_data *plat)
76258da0cfaSVoon Weifeng {
76358da0cfaSVoon Weifeng 	plat->rx_queues_to_use = 6;
76458da0cfaSVoon Weifeng 	plat->tx_queues_to_use = 4;
765dcea1a81STan, Tee Min 	plat->clk_ptp_rate = 204800000;
76623d74330SWong Vee Khee 	plat->speed_mode_2500 = intel_speed_mode_2500;
76758da0cfaSVoon Weifeng 
7685ac712dcSWong Vee Khee 	plat->safety_feat_cfg->tsoee = 1;
7695ac712dcSWong Vee Khee 	plat->safety_feat_cfg->mrxpee = 0;
7705ac712dcSWong Vee Khee 	plat->safety_feat_cfg->mestee = 1;
7715ac712dcSWong Vee Khee 	plat->safety_feat_cfg->mrxee = 1;
7725ac712dcSWong Vee Khee 	plat->safety_feat_cfg->mtxee = 1;
7735ac712dcSWong Vee Khee 	plat->safety_feat_cfg->epsi = 0;
7745ac712dcSWong Vee Khee 	plat->safety_feat_cfg->edpp = 0;
7755ac712dcSWong Vee Khee 	plat->safety_feat_cfg->prtyen = 0;
7765ac712dcSWong Vee Khee 	plat->safety_feat_cfg->tmouten = 0;
7775ac712dcSWong Vee Khee 
778d5383b03SAndy Shevchenko 	return intel_mgbe_common_data(pdev, plat);
77958da0cfaSVoon Weifeng }
78058da0cfaSVoon Weifeng 
tgl_sgmii_phy0_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)781fa706dceSWong Vee Khee static int tgl_sgmii_phy0_data(struct pci_dev *pdev,
78258da0cfaSVoon Weifeng 			       struct plat_stmmacenet_data *plat)
78358da0cfaSVoon Weifeng {
78458da0cfaSVoon Weifeng 	plat->bus_id = 1;
78558da0cfaSVoon Weifeng 	plat->phy_interface = PHY_INTERFACE_MODE_SGMII;
786b9663b7cSVoon Weifeng 	plat->serdes_powerup = intel_serdes_powerup;
787b9663b7cSVoon Weifeng 	plat->serdes_powerdown = intel_serdes_powerdown;
78858da0cfaSVoon Weifeng 	return tgl_common_data(pdev, plat);
78958da0cfaSVoon Weifeng }
79058da0cfaSVoon Weifeng 
791fa706dceSWong Vee Khee static struct stmmac_pci_info tgl_sgmii1g_phy0_info = {
792fa706dceSWong Vee Khee 	.setup = tgl_sgmii_phy0_data,
79358da0cfaSVoon Weifeng };
79458da0cfaSVoon Weifeng 
tgl_sgmii_phy1_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)795fa706dceSWong Vee Khee static int tgl_sgmii_phy1_data(struct pci_dev *pdev,
796fa706dceSWong Vee Khee 			       struct plat_stmmacenet_data *plat)
797fa706dceSWong Vee Khee {
798fa706dceSWong Vee Khee 	plat->bus_id = 2;
799fa706dceSWong Vee Khee 	plat->phy_interface = PHY_INTERFACE_MODE_SGMII;
800fa706dceSWong Vee Khee 	plat->serdes_powerup = intel_serdes_powerup;
801fa706dceSWong Vee Khee 	plat->serdes_powerdown = intel_serdes_powerdown;
802fa706dceSWong Vee Khee 	return tgl_common_data(pdev, plat);
803fa706dceSWong Vee Khee }
804fa706dceSWong Vee Khee 
805fa706dceSWong Vee Khee static struct stmmac_pci_info tgl_sgmii1g_phy1_info = {
806fa706dceSWong Vee Khee 	.setup = tgl_sgmii_phy1_data,
807fa706dceSWong Vee Khee };
808fa706dceSWong Vee Khee 
adls_sgmii_phy0_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)809fa706dceSWong Vee Khee static int adls_sgmii_phy0_data(struct pci_dev *pdev,
81088af9bd4SWong, Vee Khee 				struct plat_stmmacenet_data *plat)
81188af9bd4SWong, Vee Khee {
81288af9bd4SWong, Vee Khee 	plat->bus_id = 1;
81388af9bd4SWong, Vee Khee 	plat->phy_interface = PHY_INTERFACE_MODE_SGMII;
81488af9bd4SWong, Vee Khee 
81588af9bd4SWong, Vee Khee 	/* SerDes power up and power down are done in BIOS for ADL */
81688af9bd4SWong, Vee Khee 
81788af9bd4SWong, Vee Khee 	return tgl_common_data(pdev, plat);
81888af9bd4SWong, Vee Khee }
81988af9bd4SWong, Vee Khee 
820fa706dceSWong Vee Khee static struct stmmac_pci_info adls_sgmii1g_phy0_info = {
821fa706dceSWong Vee Khee 	.setup = adls_sgmii_phy0_data,
82288af9bd4SWong, Vee Khee };
82388af9bd4SWong, Vee Khee 
adls_sgmii_phy1_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)824fa706dceSWong Vee Khee static int adls_sgmii_phy1_data(struct pci_dev *pdev,
825fa706dceSWong Vee Khee 				struct plat_stmmacenet_data *plat)
826fa706dceSWong Vee Khee {
827fa706dceSWong Vee Khee 	plat->bus_id = 2;
828fa706dceSWong Vee Khee 	plat->phy_interface = PHY_INTERFACE_MODE_SGMII;
829fa706dceSWong Vee Khee 
830fa706dceSWong Vee Khee 	/* SerDes power up and power down are done in BIOS for ADL */
831fa706dceSWong Vee Khee 
832fa706dceSWong Vee Khee 	return tgl_common_data(pdev, plat);
833fa706dceSWong Vee Khee }
834fa706dceSWong Vee Khee 
835fa706dceSWong Vee Khee static struct stmmac_pci_info adls_sgmii1g_phy1_info = {
836fa706dceSWong Vee Khee 	.setup = adls_sgmii_phy1_data,
837fa706dceSWong Vee Khee };
83858da0cfaSVoon Weifeng static const struct stmmac_pci_func_data galileo_stmmac_func_data[] = {
83958da0cfaSVoon Weifeng 	{
84058da0cfaSVoon Weifeng 		.func = 6,
84158da0cfaSVoon Weifeng 		.phy_addr = 1,
84258da0cfaSVoon Weifeng 	},
84358da0cfaSVoon Weifeng };
84458da0cfaSVoon Weifeng 
84558da0cfaSVoon Weifeng static const struct stmmac_pci_dmi_data galileo_stmmac_dmi_data = {
84658da0cfaSVoon Weifeng 	.func = galileo_stmmac_func_data,
84758da0cfaSVoon Weifeng 	.nfuncs = ARRAY_SIZE(galileo_stmmac_func_data),
84858da0cfaSVoon Weifeng };
84958da0cfaSVoon Weifeng 
85058da0cfaSVoon Weifeng static const struct stmmac_pci_func_data iot2040_stmmac_func_data[] = {
85158da0cfaSVoon Weifeng 	{
85258da0cfaSVoon Weifeng 		.func = 6,
85358da0cfaSVoon Weifeng 		.phy_addr = 1,
85458da0cfaSVoon Weifeng 	},
85558da0cfaSVoon Weifeng 	{
85658da0cfaSVoon Weifeng 		.func = 7,
85758da0cfaSVoon Weifeng 		.phy_addr = 1,
85858da0cfaSVoon Weifeng 	},
85958da0cfaSVoon Weifeng };
86058da0cfaSVoon Weifeng 
86158da0cfaSVoon Weifeng static const struct stmmac_pci_dmi_data iot2040_stmmac_dmi_data = {
86258da0cfaSVoon Weifeng 	.func = iot2040_stmmac_func_data,
86358da0cfaSVoon Weifeng 	.nfuncs = ARRAY_SIZE(iot2040_stmmac_func_data),
86458da0cfaSVoon Weifeng };
86558da0cfaSVoon Weifeng 
86658da0cfaSVoon Weifeng static const struct dmi_system_id quark_pci_dmi[] = {
86758da0cfaSVoon Weifeng 	{
86858da0cfaSVoon Weifeng 		.matches = {
86958da0cfaSVoon Weifeng 			DMI_EXACT_MATCH(DMI_BOARD_NAME, "Galileo"),
87058da0cfaSVoon Weifeng 		},
87158da0cfaSVoon Weifeng 		.driver_data = (void *)&galileo_stmmac_dmi_data,
87258da0cfaSVoon Weifeng 	},
87358da0cfaSVoon Weifeng 	{
87458da0cfaSVoon Weifeng 		.matches = {
87558da0cfaSVoon Weifeng 			DMI_EXACT_MATCH(DMI_BOARD_NAME, "GalileoGen2"),
87658da0cfaSVoon Weifeng 		},
87758da0cfaSVoon Weifeng 		.driver_data = (void *)&galileo_stmmac_dmi_data,
87858da0cfaSVoon Weifeng 	},
87958da0cfaSVoon Weifeng 	/* There are 2 types of SIMATIC IOT2000: IOT2020 and IOT2040.
88058da0cfaSVoon Weifeng 	 * The asset tag "6ES7647-0AA00-0YA2" is only for IOT2020 which
88158da0cfaSVoon Weifeng 	 * has only one pci network device while other asset tags are
88258da0cfaSVoon Weifeng 	 * for IOT2040 which has two.
88358da0cfaSVoon Weifeng 	 */
88458da0cfaSVoon Weifeng 	{
88558da0cfaSVoon Weifeng 		.matches = {
88658da0cfaSVoon Weifeng 			DMI_EXACT_MATCH(DMI_BOARD_NAME, "SIMATIC IOT2000"),
88758da0cfaSVoon Weifeng 			DMI_EXACT_MATCH(DMI_BOARD_ASSET_TAG,
88858da0cfaSVoon Weifeng 					"6ES7647-0AA00-0YA2"),
88958da0cfaSVoon Weifeng 		},
89058da0cfaSVoon Weifeng 		.driver_data = (void *)&galileo_stmmac_dmi_data,
89158da0cfaSVoon Weifeng 	},
89258da0cfaSVoon Weifeng 	{
89358da0cfaSVoon Weifeng 		.matches = {
89458da0cfaSVoon Weifeng 			DMI_EXACT_MATCH(DMI_BOARD_NAME, "SIMATIC IOT2000"),
89558da0cfaSVoon Weifeng 		},
89658da0cfaSVoon Weifeng 		.driver_data = (void *)&iot2040_stmmac_dmi_data,
89758da0cfaSVoon Weifeng 	},
89858da0cfaSVoon Weifeng 	{}
89958da0cfaSVoon Weifeng };
90058da0cfaSVoon Weifeng 
quark_default_data(struct pci_dev * pdev,struct plat_stmmacenet_data * plat)90158da0cfaSVoon Weifeng static int quark_default_data(struct pci_dev *pdev,
90258da0cfaSVoon Weifeng 			      struct plat_stmmacenet_data *plat)
90358da0cfaSVoon Weifeng {
90458da0cfaSVoon Weifeng 	int ret;
90558da0cfaSVoon Weifeng 
90658da0cfaSVoon Weifeng 	/* Set common default data first */
90758da0cfaSVoon Weifeng 	common_default_data(plat);
90858da0cfaSVoon Weifeng 
90958da0cfaSVoon Weifeng 	/* Refuse to load the driver and register net device if MAC controller
91058da0cfaSVoon Weifeng 	 * does not connect to any PHY interface.
91158da0cfaSVoon Weifeng 	 */
91258da0cfaSVoon Weifeng 	ret = stmmac_pci_find_phy_addr(pdev, quark_pci_dmi);
91358da0cfaSVoon Weifeng 	if (ret < 0) {
91458da0cfaSVoon Weifeng 		/* Return error to the caller on DMI enabled boards. */
91558da0cfaSVoon Weifeng 		if (dmi_get_system_info(DMI_BOARD_NAME))
91658da0cfaSVoon Weifeng 			return ret;
91758da0cfaSVoon Weifeng 
91858da0cfaSVoon Weifeng 		/* Galileo boards with old firmware don't support DMI. We always
91958da0cfaSVoon Weifeng 		 * use 1 here as PHY address, so at least the first found MAC
92058da0cfaSVoon Weifeng 		 * controller would be probed.
92158da0cfaSVoon Weifeng 		 */
92258da0cfaSVoon Weifeng 		ret = 1;
92358da0cfaSVoon Weifeng 	}
92458da0cfaSVoon Weifeng 
92558da0cfaSVoon Weifeng 	plat->bus_id = pci_dev_id(pdev);
92658da0cfaSVoon Weifeng 	plat->phy_addr = ret;
92758da0cfaSVoon Weifeng 	plat->phy_interface = PHY_INTERFACE_MODE_RMII;
92858da0cfaSVoon Weifeng 
92958da0cfaSVoon Weifeng 	plat->dma_cfg->pbl = 16;
93058da0cfaSVoon Weifeng 	plat->dma_cfg->pblx8 = true;
93158da0cfaSVoon Weifeng 	plat->dma_cfg->fixed_burst = 1;
93258da0cfaSVoon Weifeng 	/* AXI (TODO) */
93358da0cfaSVoon Weifeng 
93458da0cfaSVoon Weifeng 	return 0;
93558da0cfaSVoon Weifeng }
93658da0cfaSVoon Weifeng 
937ccacb703SAndy Shevchenko static const struct stmmac_pci_info quark_info = {
93858da0cfaSVoon Weifeng 	.setup = quark_default_data,
93958da0cfaSVoon Weifeng };
94058da0cfaSVoon Weifeng 
stmmac_config_single_msi(struct pci_dev * pdev,struct plat_stmmacenet_data * plat,struct stmmac_resources * res)941b42446b9SOng Boon Leong static int stmmac_config_single_msi(struct pci_dev *pdev,
942b42446b9SOng Boon Leong 				    struct plat_stmmacenet_data *plat,
943b42446b9SOng Boon Leong 				    struct stmmac_resources *res)
944b42446b9SOng Boon Leong {
945b42446b9SOng Boon Leong 	int ret;
946b42446b9SOng Boon Leong 
947b42446b9SOng Boon Leong 	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
948b42446b9SOng Boon Leong 	if (ret < 0) {
949b42446b9SOng Boon Leong 		dev_info(&pdev->dev, "%s: Single IRQ enablement failed\n",
950b42446b9SOng Boon Leong 			 __func__);
951b42446b9SOng Boon Leong 		return ret;
952b42446b9SOng Boon Leong 	}
953b42446b9SOng Boon Leong 
954b42446b9SOng Boon Leong 	res->irq = pci_irq_vector(pdev, 0);
955b42446b9SOng Boon Leong 	res->wol_irq = res->irq;
956956c3f09SBartosz Golaszewski 	plat->flags &= ~STMMAC_FLAG_MULTI_MSI_EN;
957b42446b9SOng Boon Leong 	dev_info(&pdev->dev, "%s: Single IRQ enablement successful\n",
958b42446b9SOng Boon Leong 		 __func__);
959b42446b9SOng Boon Leong 
960b42446b9SOng Boon Leong 	return 0;
961b42446b9SOng Boon Leong }
962b42446b9SOng Boon Leong 
stmmac_config_multi_msi(struct pci_dev * pdev,struct plat_stmmacenet_data * plat,struct stmmac_resources * res)963b42446b9SOng Boon Leong static int stmmac_config_multi_msi(struct pci_dev *pdev,
964b42446b9SOng Boon Leong 				   struct plat_stmmacenet_data *plat,
965b42446b9SOng Boon Leong 				   struct stmmac_resources *res)
966b42446b9SOng Boon Leong {
967b42446b9SOng Boon Leong 	int ret;
968b42446b9SOng Boon Leong 	int i;
969b42446b9SOng Boon Leong 
970b42446b9SOng Boon Leong 	if (plat->msi_rx_base_vec >= STMMAC_MSI_VEC_MAX ||
971b42446b9SOng Boon Leong 	    plat->msi_tx_base_vec >= STMMAC_MSI_VEC_MAX) {
972b42446b9SOng Boon Leong 		dev_info(&pdev->dev, "%s: Invalid RX & TX vector defined\n",
973b42446b9SOng Boon Leong 			 __func__);
974b42446b9SOng Boon Leong 		return -1;
975b42446b9SOng Boon Leong 	}
976b42446b9SOng Boon Leong 
977b42446b9SOng Boon Leong 	ret = pci_alloc_irq_vectors(pdev, 2, STMMAC_MSI_VEC_MAX,
978b42446b9SOng Boon Leong 				    PCI_IRQ_MSI | PCI_IRQ_MSIX);
979b42446b9SOng Boon Leong 	if (ret < 0) {
980b42446b9SOng Boon Leong 		dev_info(&pdev->dev, "%s: multi MSI enablement failed\n",
981b42446b9SOng Boon Leong 			 __func__);
982b42446b9SOng Boon Leong 		return ret;
983b42446b9SOng Boon Leong 	}
984b42446b9SOng Boon Leong 
985b42446b9SOng Boon Leong 	/* For RX MSI */
986b42446b9SOng Boon Leong 	for (i = 0; i < plat->rx_queues_to_use; i++) {
987b42446b9SOng Boon Leong 		res->rx_irq[i] = pci_irq_vector(pdev,
988b42446b9SOng Boon Leong 						plat->msi_rx_base_vec + i * 2);
989b42446b9SOng Boon Leong 	}
990b42446b9SOng Boon Leong 
991b42446b9SOng Boon Leong 	/* For TX MSI */
992b42446b9SOng Boon Leong 	for (i = 0; i < plat->tx_queues_to_use; i++) {
993b42446b9SOng Boon Leong 		res->tx_irq[i] = pci_irq_vector(pdev,
994b42446b9SOng Boon Leong 						plat->msi_tx_base_vec + i * 2);
995b42446b9SOng Boon Leong 	}
996b42446b9SOng Boon Leong 
997b42446b9SOng Boon Leong 	if (plat->msi_mac_vec < STMMAC_MSI_VEC_MAX)
998b42446b9SOng Boon Leong 		res->irq = pci_irq_vector(pdev, plat->msi_mac_vec);
999b42446b9SOng Boon Leong 	if (plat->msi_wol_vec < STMMAC_MSI_VEC_MAX)
1000b42446b9SOng Boon Leong 		res->wol_irq = pci_irq_vector(pdev, plat->msi_wol_vec);
1001b42446b9SOng Boon Leong 	if (plat->msi_lpi_vec < STMMAC_MSI_VEC_MAX)
1002b42446b9SOng Boon Leong 		res->lpi_irq = pci_irq_vector(pdev, plat->msi_lpi_vec);
1003b42446b9SOng Boon Leong 	if (plat->msi_sfty_ce_vec < STMMAC_MSI_VEC_MAX)
1004b42446b9SOng Boon Leong 		res->sfty_ce_irq = pci_irq_vector(pdev, plat->msi_sfty_ce_vec);
1005b42446b9SOng Boon Leong 	if (plat->msi_sfty_ue_vec < STMMAC_MSI_VEC_MAX)
1006b42446b9SOng Boon Leong 		res->sfty_ue_irq = pci_irq_vector(pdev, plat->msi_sfty_ue_vec);
1007b42446b9SOng Boon Leong 
1008956c3f09SBartosz Golaszewski 	plat->flags |= STMMAC_FLAG_MULTI_MSI_EN;
1009b42446b9SOng Boon Leong 	dev_info(&pdev->dev, "%s: multi MSI enablement successful\n", __func__);
1010b42446b9SOng Boon Leong 
1011b42446b9SOng Boon Leong 	return 0;
1012b42446b9SOng Boon Leong }
1013b42446b9SOng Boon Leong 
101458da0cfaSVoon Weifeng /**
101558da0cfaSVoon Weifeng  * intel_eth_pci_probe
101658da0cfaSVoon Weifeng  *
101758da0cfaSVoon Weifeng  * @pdev: pci device pointer
101858da0cfaSVoon Weifeng  * @id: pointer to table of device id/id's.
101958da0cfaSVoon Weifeng  *
102058da0cfaSVoon Weifeng  * Description: This probing function gets called for all PCI devices which
102158da0cfaSVoon Weifeng  * match the ID table and are not "owned" by other driver yet. This function
102258da0cfaSVoon Weifeng  * gets passed a "struct pci_dev *" for each device whose entry in the ID table
102358da0cfaSVoon Weifeng  * matches the device. The probe functions returns zero when the driver choose
102458da0cfaSVoon Weifeng  * to take "ownership" of the device or an error code(-ve no) otherwise.
102558da0cfaSVoon Weifeng  */
intel_eth_pci_probe(struct pci_dev * pdev,const struct pci_device_id * id)102658da0cfaSVoon Weifeng static int intel_eth_pci_probe(struct pci_dev *pdev,
102758da0cfaSVoon Weifeng 			       const struct pci_device_id *id)
102858da0cfaSVoon Weifeng {
102958da0cfaSVoon Weifeng 	struct stmmac_pci_info *info = (struct stmmac_pci_info *)id->driver_data;
1030b9663b7cSVoon Weifeng 	struct intel_priv_data *intel_priv;
103158da0cfaSVoon Weifeng 	struct plat_stmmacenet_data *plat;
103258da0cfaSVoon Weifeng 	struct stmmac_resources res;
103358da0cfaSVoon Weifeng 	int ret;
103458da0cfaSVoon Weifeng 
1035ccacb703SAndy Shevchenko 	intel_priv = devm_kzalloc(&pdev->dev, sizeof(*intel_priv), GFP_KERNEL);
1036b9663b7cSVoon Weifeng 	if (!intel_priv)
1037b9663b7cSVoon Weifeng 		return -ENOMEM;
1038b9663b7cSVoon Weifeng 
103958da0cfaSVoon Weifeng 	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
104058da0cfaSVoon Weifeng 	if (!plat)
104158da0cfaSVoon Weifeng 		return -ENOMEM;
104258da0cfaSVoon Weifeng 
104358da0cfaSVoon Weifeng 	plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
104458da0cfaSVoon Weifeng 					   sizeof(*plat->mdio_bus_data),
104558da0cfaSVoon Weifeng 					   GFP_KERNEL);
104658da0cfaSVoon Weifeng 	if (!plat->mdio_bus_data)
104758da0cfaSVoon Weifeng 		return -ENOMEM;
104858da0cfaSVoon Weifeng 
104958da0cfaSVoon Weifeng 	plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg),
105058da0cfaSVoon Weifeng 				     GFP_KERNEL);
105158da0cfaSVoon Weifeng 	if (!plat->dma_cfg)
105258da0cfaSVoon Weifeng 		return -ENOMEM;
105358da0cfaSVoon Weifeng 
10545ac712dcSWong Vee Khee 	plat->safety_feat_cfg = devm_kzalloc(&pdev->dev,
10555ac712dcSWong Vee Khee 					     sizeof(*plat->safety_feat_cfg),
10565ac712dcSWong Vee Khee 					     GFP_KERNEL);
10575ac712dcSWong Vee Khee 	if (!plat->safety_feat_cfg)
10585ac712dcSWong Vee Khee 		return -ENOMEM;
10595ac712dcSWong Vee Khee 
106058da0cfaSVoon Weifeng 	/* Enable pci device */
10618accc467SWong Vee Khee 	ret = pcim_enable_device(pdev);
106258da0cfaSVoon Weifeng 	if (ret) {
106358da0cfaSVoon Weifeng 		dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n",
106458da0cfaSVoon Weifeng 			__func__);
106558da0cfaSVoon Weifeng 		return ret;
106658da0cfaSVoon Weifeng 	}
106758da0cfaSVoon Weifeng 
1068e578f043SAndy Shevchenko 	ret = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev));
106958da0cfaSVoon Weifeng 	if (ret)
107058da0cfaSVoon Weifeng 		return ret;
107158da0cfaSVoon Weifeng 
107258da0cfaSVoon Weifeng 	pci_set_master(pdev);
107358da0cfaSVoon Weifeng 
1074b9663b7cSVoon Weifeng 	plat->bsp_priv = intel_priv;
10757310fe53SOng Boon Leong 	intel_priv->mdio_adhoc_addr = INTEL_MGBE_ADHOC_ADDR;
10761c137d47SWong Vee Khee 	intel_priv->crossts_adj = 1;
1077b9663b7cSVoon Weifeng 
1078b42446b9SOng Boon Leong 	/* Initialize all MSI vectors to invalid so that it can be set
1079b42446b9SOng Boon Leong 	 * according to platform data settings below.
1080b42446b9SOng Boon Leong 	 * Note: MSI vector takes value from 0 upto 31 (STMMAC_MSI_VEC_MAX)
1081b42446b9SOng Boon Leong 	 */
1082b42446b9SOng Boon Leong 	plat->msi_mac_vec = STMMAC_MSI_VEC_MAX;
1083b42446b9SOng Boon Leong 	plat->msi_wol_vec = STMMAC_MSI_VEC_MAX;
1084b42446b9SOng Boon Leong 	plat->msi_lpi_vec = STMMAC_MSI_VEC_MAX;
1085b42446b9SOng Boon Leong 	plat->msi_sfty_ce_vec = STMMAC_MSI_VEC_MAX;
1086b42446b9SOng Boon Leong 	plat->msi_sfty_ue_vec = STMMAC_MSI_VEC_MAX;
1087b42446b9SOng Boon Leong 	plat->msi_rx_base_vec = STMMAC_MSI_VEC_MAX;
1088b42446b9SOng Boon Leong 	plat->msi_tx_base_vec = STMMAC_MSI_VEC_MAX;
1089b42446b9SOng Boon Leong 
109058da0cfaSVoon Weifeng 	ret = info->setup(pdev, plat);
109158da0cfaSVoon Weifeng 	if (ret)
109258da0cfaSVoon Weifeng 		return ret;
109358da0cfaSVoon Weifeng 
109458da0cfaSVoon Weifeng 	memset(&res, 0, sizeof(res));
1095e578f043SAndy Shevchenko 	res.addr = pcim_iomap_table(pdev)[0];
109658da0cfaSVoon Weifeng 
1097785ff20bSWong Vee Khee 	if (plat->eee_usecs_rate > 0) {
1098785ff20bSWong Vee Khee 		u32 tx_lpi_usec;
1099785ff20bSWong Vee Khee 
1100785ff20bSWong Vee Khee 		tx_lpi_usec = (plat->eee_usecs_rate / 1000000) - 1;
1101785ff20bSWong Vee Khee 		writel(tx_lpi_usec, res.addr + GMAC_1US_TIC_COUNTER);
1102785ff20bSWong Vee Khee 	}
1103785ff20bSWong Vee Khee 
1104b42446b9SOng Boon Leong 	ret = stmmac_config_multi_msi(pdev, plat, &res);
110509f012e6SAndy Shevchenko 	if (ret) {
1106b42446b9SOng Boon Leong 		ret = stmmac_config_single_msi(pdev, plat, &res);
1107b42446b9SOng Boon Leong 		if (ret) {
1108b42446b9SOng Boon Leong 			dev_err(&pdev->dev, "%s: ERROR: failed to enable IRQ\n",
1109b42446b9SOng Boon Leong 				__func__);
1110b42446b9SOng Boon Leong 			goto err_alloc_irq;
1111b42446b9SOng Boon Leong 		}
111209f012e6SAndy Shevchenko 	}
111309f012e6SAndy Shevchenko 
1114b42446b9SOng Boon Leong 	ret = stmmac_dvr_probe(&pdev->dev, plat, &res);
1115b42446b9SOng Boon Leong 	if (ret) {
11165e74a4b3SChristophe JAILLET 		goto err_alloc_irq;
1117b42446b9SOng Boon Leong 	}
1118b42446b9SOng Boon Leong 
1119b42446b9SOng Boon Leong 	return 0;
1120b42446b9SOng Boon Leong 
1121b42446b9SOng Boon Leong err_alloc_irq:
1122b42446b9SOng Boon Leong 	clk_disable_unprepare(plat->stmmac_clk);
1123b42446b9SOng Boon Leong 	clk_unregister_fixed_rate(plat->stmmac_clk);
112409f012e6SAndy Shevchenko 	return ret;
112558da0cfaSVoon Weifeng }
112658da0cfaSVoon Weifeng 
112758da0cfaSVoon Weifeng /**
112858da0cfaSVoon Weifeng  * intel_eth_pci_remove
112958da0cfaSVoon Weifeng  *
11303c3ea630SWong Vee Khee  * @pdev: pci device pointer
113158da0cfaSVoon Weifeng  * Description: this function calls the main to free the net resources
113258da0cfaSVoon Weifeng  * and releases the PCI resources.
113358da0cfaSVoon Weifeng  */
intel_eth_pci_remove(struct pci_dev * pdev)113458da0cfaSVoon Weifeng static void intel_eth_pci_remove(struct pci_dev *pdev)
113558da0cfaSVoon Weifeng {
113658da0cfaSVoon Weifeng 	struct net_device *ndev = dev_get_drvdata(&pdev->dev);
113758da0cfaSVoon Weifeng 	struct stmmac_priv *priv = netdev_priv(ndev);
113858da0cfaSVoon Weifeng 
113958da0cfaSVoon Weifeng 	stmmac_dvr_remove(&pdev->dev);
114058da0cfaSVoon Weifeng 
11415c23d6b7SChristophe JAILLET 	clk_disable_unprepare(priv->plat->stmmac_clk);
114258da0cfaSVoon Weifeng 	clk_unregister_fixed_rate(priv->plat->stmmac_clk);
114358da0cfaSVoon Weifeng }
114458da0cfaSVoon Weifeng 
intel_eth_pci_suspend(struct device * dev)114558da0cfaSVoon Weifeng static int __maybe_unused intel_eth_pci_suspend(struct device *dev)
114658da0cfaSVoon Weifeng {
114758da0cfaSVoon Weifeng 	struct pci_dev *pdev = to_pci_dev(dev);
114858da0cfaSVoon Weifeng 	int ret;
114958da0cfaSVoon Weifeng 
115058da0cfaSVoon Weifeng 	ret = stmmac_suspend(dev);
115158da0cfaSVoon Weifeng 	if (ret)
115258da0cfaSVoon Weifeng 		return ret;
115358da0cfaSVoon Weifeng 
115458da0cfaSVoon Weifeng 	ret = pci_save_state(pdev);
115558da0cfaSVoon Weifeng 	if (ret)
115658da0cfaSVoon Weifeng 		return ret;
115758da0cfaSVoon Weifeng 
115858da0cfaSVoon Weifeng 	pci_wake_from_d3(pdev, true);
11591dd53a61SVoon Weifeng 	pci_set_power_state(pdev, PCI_D3hot);
116058da0cfaSVoon Weifeng 	return 0;
116158da0cfaSVoon Weifeng }
116258da0cfaSVoon Weifeng 
intel_eth_pci_resume(struct device * dev)116358da0cfaSVoon Weifeng static int __maybe_unused intel_eth_pci_resume(struct device *dev)
116458da0cfaSVoon Weifeng {
116558da0cfaSVoon Weifeng 	struct pci_dev *pdev = to_pci_dev(dev);
116658da0cfaSVoon Weifeng 	int ret;
116758da0cfaSVoon Weifeng 
116858da0cfaSVoon Weifeng 	pci_restore_state(pdev);
116958da0cfaSVoon Weifeng 	pci_set_power_state(pdev, PCI_D0);
117058da0cfaSVoon Weifeng 
11718accc467SWong Vee Khee 	ret = pcim_enable_device(pdev);
117258da0cfaSVoon Weifeng 	if (ret)
117358da0cfaSVoon Weifeng 		return ret;
117458da0cfaSVoon Weifeng 
117558da0cfaSVoon Weifeng 	pci_set_master(pdev);
117658da0cfaSVoon Weifeng 
117758da0cfaSVoon Weifeng 	return stmmac_resume(dev);
117858da0cfaSVoon Weifeng }
117958da0cfaSVoon Weifeng 
118058da0cfaSVoon Weifeng static SIMPLE_DEV_PM_OPS(intel_eth_pm_ops, intel_eth_pci_suspend,
118158da0cfaSVoon Weifeng 			 intel_eth_pci_resume);
118258da0cfaSVoon Weifeng 
11833036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_QUARK		0x0937
11843036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_EHL_RGMII1G		0x4b30
11853036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_EHL_SGMII1G		0x4b31
11863036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_EHL_SGMII2G5	0x4b32
118767c08ac4SVoon Weifeng /* Intel(R) Programmable Services Engine (Intel(R) PSE) consist of 2 MAC
118867c08ac4SVoon Weifeng  * which are named PSE0 and PSE1
118967c08ac4SVoon Weifeng  */
11903036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_EHL_PSE0_RGMII1G	0x4ba0
11913036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_EHL_PSE0_SGMII1G	0x4ba1
11923036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_EHL_PSE0_SGMII2G5	0x4ba2
11933036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_EHL_PSE1_RGMII1G	0x4bb0
11943036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_EHL_PSE1_SGMII1G	0x4bb1
11953036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_EHL_PSE1_SGMII2G5	0x4bb2
11963036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_TGLH_SGMII1G_0	0x43ac
11973036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_TGLH_SGMII1G_1	0x43a2
11983036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_TGL_SGMII1G		0xa0ac
11993036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_ADLS_SGMII1G_0	0x7aac
12003036ec03SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_ADLS_SGMII1G_1	0x7aad
120130c5601fSMichael Sit Wei Hong #define PCI_DEVICE_ID_INTEL_ADLN_SGMII1G	0x54ac
120283450bbaSMichael Sit Wei Hong #define PCI_DEVICE_ID_INTEL_RPLP_SGMII1G	0x51ac
120358da0cfaSVoon Weifeng 
120458da0cfaSVoon Weifeng static const struct pci_device_id intel_eth_pci_id_table[] = {
12053036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, QUARK, &quark_info) },
12063036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, EHL_RGMII1G, &ehl_rgmii1g_info) },
12073036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, EHL_SGMII1G, &ehl_sgmii1g_info) },
12083036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, EHL_SGMII2G5, &ehl_sgmii1g_info) },
12093036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, EHL_PSE0_RGMII1G, &ehl_pse0_rgmii1g_info) },
12103036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, EHL_PSE0_SGMII1G, &ehl_pse0_sgmii1g_info) },
12113036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, EHL_PSE0_SGMII2G5, &ehl_pse0_sgmii1g_info) },
12123036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, EHL_PSE1_RGMII1G, &ehl_pse1_rgmii1g_info) },
12133036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, EHL_PSE1_SGMII1G, &ehl_pse1_sgmii1g_info) },
12143036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, EHL_PSE1_SGMII2G5, &ehl_pse1_sgmii1g_info) },
12153036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, TGL_SGMII1G, &tgl_sgmii1g_phy0_info) },
12163036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, TGLH_SGMII1G_0, &tgl_sgmii1g_phy0_info) },
12173036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, TGLH_SGMII1G_1, &tgl_sgmii1g_phy1_info) },
12183036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, ADLS_SGMII1G_0, &adls_sgmii1g_phy0_info) },
12193036ec03SAndy Shevchenko 	{ PCI_DEVICE_DATA(INTEL, ADLS_SGMII1G_1, &adls_sgmii1g_phy1_info) },
122030c5601fSMichael Sit Wei Hong 	{ PCI_DEVICE_DATA(INTEL, ADLN_SGMII1G, &tgl_sgmii1g_phy0_info) },
122183450bbaSMichael Sit Wei Hong 	{ PCI_DEVICE_DATA(INTEL, RPLP_SGMII1G, &tgl_sgmii1g_phy0_info) },
122258da0cfaSVoon Weifeng 	{}
122358da0cfaSVoon Weifeng };
122458da0cfaSVoon Weifeng MODULE_DEVICE_TABLE(pci, intel_eth_pci_id_table);
122558da0cfaSVoon Weifeng 
122658da0cfaSVoon Weifeng static struct pci_driver intel_eth_pci_driver = {
122758da0cfaSVoon Weifeng 	.name = "intel-eth-pci",
122858da0cfaSVoon Weifeng 	.id_table = intel_eth_pci_id_table,
122958da0cfaSVoon Weifeng 	.probe = intel_eth_pci_probe,
123058da0cfaSVoon Weifeng 	.remove = intel_eth_pci_remove,
123158da0cfaSVoon Weifeng 	.driver         = {
123258da0cfaSVoon Weifeng 		.pm     = &intel_eth_pm_ops,
123358da0cfaSVoon Weifeng 	},
123458da0cfaSVoon Weifeng };
123558da0cfaSVoon Weifeng 
123658da0cfaSVoon Weifeng module_pci_driver(intel_eth_pci_driver);
123758da0cfaSVoon Weifeng 
123858da0cfaSVoon Weifeng MODULE_DESCRIPTION("INTEL 10/100/1000 Ethernet PCI driver");
123958da0cfaSVoon Weifeng MODULE_AUTHOR("Voon Weifeng <weifeng.voon@intel.com>");
124058da0cfaSVoon Weifeng MODULE_LICENSE("GPL v2");
1241