xgbe-pci.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. /*
  2. * AMD 10Gb Ethernet driver
  3. *
  4. * This file is available to you under your choice of the following two
  5. * licenses:
  6. *
  7. * License 1: GPLv2
  8. *
  9. * Copyright (c) 2016 Advanced Micro Devices, Inc.
  10. *
  11. * This file is free software; you may copy, redistribute and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation, either version 2 of the License, or (at
  14. * your option) any later version.
  15. *
  16. * This file is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. * This file incorporates work covered by the following copyright and
  25. * permission notice:
  26. * The Synopsys DWC ETHER XGMAC Software Driver and documentation
  27. * (hereinafter "Software") is an unsupported proprietary work of Synopsys,
  28. * Inc. unless otherwise expressly agreed to in writing between Synopsys
  29. * and you.
  30. *
  31. * The Software IS NOT an item of Licensed Software or Licensed Product
  32. * under any End User Software License Agreement or Agreement for Licensed
  33. * Product with Synopsys or any supplement thereto. Permission is hereby
  34. * granted, free of charge, to any person obtaining a copy of this software
  35. * annotated with this license and the Software, to deal in the Software
  36. * without restriction, including without limitation the rights to use,
  37. * copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  38. * of the Software, and to permit persons to whom the Software is furnished
  39. * to do so, subject to the following conditions:
  40. *
  41. * The above copyright notice and this permission notice shall be included
  42. * in all copies or substantial portions of the Software.
  43. *
  44. * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
  45. * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  46. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  47. * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
  48. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  49. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  50. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  51. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  52. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  53. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  54. * THE POSSIBILITY OF SUCH DAMAGE.
  55. *
  56. *
  57. * License 2: Modified BSD
  58. *
  59. * Copyright (c) 2016 Advanced Micro Devices, Inc.
  60. * All rights reserved.
  61. *
  62. * Redistribution and use in source and binary forms, with or without
  63. * modification, are permitted provided that the following conditions are met:
  64. * * Redistributions of source code must retain the above copyright
  65. * notice, this list of conditions and the following disclaimer.
  66. * * Redistributions in binary form must reproduce the above copyright
  67. * notice, this list of conditions and the following disclaimer in the
  68. * documentation and/or other materials provided with the distribution.
  69. * * Neither the name of Advanced Micro Devices, Inc. nor the
  70. * names of its contributors may be used to endorse or promote products
  71. * derived from this software without specific prior written permission.
  72. *
  73. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  74. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  75. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  76. * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  77. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  78. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  79. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  80. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  81. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  82. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  83. *
  84. * This file incorporates work covered by the following copyright and
  85. * permission notice:
  86. * The Synopsys DWC ETHER XGMAC Software Driver and documentation
  87. * (hereinafter "Software") is an unsupported proprietary work of Synopsys,
  88. * Inc. unless otherwise expressly agreed to in writing between Synopsys
  89. * and you.
  90. *
  91. * The Software IS NOT an item of Licensed Software or Licensed Product
  92. * under any End User Software License Agreement or Agreement for Licensed
  93. * Product with Synopsys or any supplement thereto. Permission is hereby
  94. * granted, free of charge, to any person obtaining a copy of this software
  95. * annotated with this license and the Software, to deal in the Software
  96. * without restriction, including without limitation the rights to use,
  97. * copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  98. * of the Software, and to permit persons to whom the Software is furnished
  99. * to do so, subject to the following conditions:
  100. *
  101. * The above copyright notice and this permission notice shall be included
  102. * in all copies or substantial portions of the Software.
  103. *
  104. * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
  105. * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  106. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  107. * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
  108. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  109. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  110. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  111. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  112. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  113. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  114. * THE POSSIBILITY OF SUCH DAMAGE.
  115. */
  116. #include <linux/module.h>
  117. #include <linux/device.h>
  118. #include <linux/pci.h>
  119. #include <linux/log2.h>
  120. #include "xgbe.h"
  121. #include "xgbe-common.h"
  122. static int xgbe_config_msi(struct xgbe_prv_data *pdata)
  123. {
  124. unsigned int msi_count;
  125. unsigned int i, j;
  126. int ret;
  127. msi_count = XGBE_MSIX_BASE_COUNT;
  128. msi_count += max(pdata->rx_ring_count,
  129. pdata->tx_ring_count);
  130. msi_count = roundup_pow_of_two(msi_count);
  131. ret = pci_enable_msi_exact(pdata->pcidev, msi_count);
  132. if (ret < 0) {
  133. dev_info(pdata->dev, "MSI request for %u interrupts failed\n",
  134. msi_count);
  135. ret = pci_enable_msi(pdata->pcidev);
  136. if (ret < 0) {
  137. dev_info(pdata->dev, "MSI enablement failed\n");
  138. return ret;
  139. }
  140. msi_count = 1;
  141. }
  142. pdata->irq_count = msi_count;
  143. pdata->dev_irq = pdata->pcidev->irq;
  144. if (msi_count > 1) {
  145. pdata->ecc_irq = pdata->pcidev->irq + 1;
  146. pdata->i2c_irq = pdata->pcidev->irq + 2;
  147. pdata->an_irq = pdata->pcidev->irq + 3;
  148. for (i = XGBE_MSIX_BASE_COUNT, j = 0;
  149. (i < msi_count) && (j < XGBE_MAX_DMA_CHANNELS);
  150. i++, j++)
  151. pdata->channel_irq[j] = pdata->pcidev->irq + i;
  152. pdata->channel_irq_count = j;
  153. pdata->per_channel_irq = 1;
  154. pdata->channel_irq_mode = XGBE_IRQ_MODE_LEVEL;
  155. } else {
  156. pdata->ecc_irq = pdata->pcidev->irq;
  157. pdata->i2c_irq = pdata->pcidev->irq;
  158. pdata->an_irq = pdata->pcidev->irq;
  159. }
  160. if (netif_msg_probe(pdata))
  161. dev_dbg(pdata->dev, "MSI interrupts enabled\n");
  162. return 0;
  163. }
  164. static int xgbe_config_msix(struct xgbe_prv_data *pdata)
  165. {
  166. unsigned int msix_count;
  167. unsigned int i, j;
  168. int ret;
  169. msix_count = XGBE_MSIX_BASE_COUNT;
  170. msix_count += max(pdata->rx_ring_count,
  171. pdata->tx_ring_count);
  172. pdata->msix_entries = devm_kcalloc(pdata->dev, msix_count,
  173. sizeof(struct msix_entry),
  174. GFP_KERNEL);
  175. if (!pdata->msix_entries)
  176. return -ENOMEM;
  177. for (i = 0; i < msix_count; i++)
  178. pdata->msix_entries[i].entry = i;
  179. ret = pci_enable_msix_range(pdata->pcidev, pdata->msix_entries,
  180. XGBE_MSIX_MIN_COUNT, msix_count);
  181. if (ret < 0) {
  182. dev_info(pdata->dev, "MSI-X enablement failed\n");
  183. devm_kfree(pdata->dev, pdata->msix_entries);
  184. pdata->msix_entries = NULL;
  185. return ret;
  186. }
  187. pdata->irq_count = ret;
  188. pdata->dev_irq = pdata->msix_entries[0].vector;
  189. pdata->ecc_irq = pdata->msix_entries[1].vector;
  190. pdata->i2c_irq = pdata->msix_entries[2].vector;
  191. pdata->an_irq = pdata->msix_entries[3].vector;
  192. for (i = XGBE_MSIX_BASE_COUNT, j = 0; i < ret; i++, j++)
  193. pdata->channel_irq[j] = pdata->msix_entries[i].vector;
  194. pdata->channel_irq_count = j;
  195. pdata->per_channel_irq = 1;
  196. pdata->channel_irq_mode = XGBE_IRQ_MODE_LEVEL;
  197. if (netif_msg_probe(pdata))
  198. dev_dbg(pdata->dev, "MSI-X interrupts enabled\n");
  199. return 0;
  200. }
  201. static int xgbe_config_irqs(struct xgbe_prv_data *pdata)
  202. {
  203. int ret;
  204. ret = xgbe_config_msix(pdata);
  205. if (!ret)
  206. goto out;
  207. ret = xgbe_config_msi(pdata);
  208. if (!ret)
  209. goto out;
  210. pdata->irq_count = 1;
  211. pdata->irq_shared = 1;
  212. pdata->dev_irq = pdata->pcidev->irq;
  213. pdata->ecc_irq = pdata->pcidev->irq;
  214. pdata->i2c_irq = pdata->pcidev->irq;
  215. pdata->an_irq = pdata->pcidev->irq;
  216. out:
  217. if (netif_msg_probe(pdata)) {
  218. unsigned int i;
  219. dev_dbg(pdata->dev, " dev irq=%d\n", pdata->dev_irq);
  220. dev_dbg(pdata->dev, " ecc irq=%d\n", pdata->ecc_irq);
  221. dev_dbg(pdata->dev, " i2c irq=%d\n", pdata->i2c_irq);
  222. dev_dbg(pdata->dev, " an irq=%d\n", pdata->an_irq);
  223. for (i = 0; i < pdata->channel_irq_count; i++)
  224. dev_dbg(pdata->dev, " dma%u irq=%d\n",
  225. i, pdata->channel_irq[i]);
  226. }
  227. return 0;
  228. }
  229. static int xgbe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
  230. {
  231. struct xgbe_prv_data *pdata;
  232. struct device *dev = &pdev->dev;
  233. void __iomem * const *iomap_table;
  234. unsigned int ma_lo, ma_hi;
  235. unsigned int reg;
  236. int bar_mask;
  237. int ret;
  238. pdata = xgbe_alloc_pdata(dev);
  239. if (IS_ERR(pdata)) {
  240. ret = PTR_ERR(pdata);
  241. goto err_alloc;
  242. }
  243. pdata->pcidev = pdev;
  244. pci_set_drvdata(pdev, pdata);
  245. /* Get the version data */
  246. pdata->vdata = (struct xgbe_version_data *)id->driver_data;
  247. ret = pcim_enable_device(pdev);
  248. if (ret) {
  249. dev_err(dev, "pcim_enable_device failed\n");
  250. goto err_pci_enable;
  251. }
  252. /* Obtain the mmio areas for the device */
  253. bar_mask = pci_select_bars(pdev, IORESOURCE_MEM);
  254. ret = pcim_iomap_regions(pdev, bar_mask, XGBE_DRV_NAME);
  255. if (ret) {
  256. dev_err(dev, "pcim_iomap_regions failed\n");
  257. goto err_pci_enable;
  258. }
  259. iomap_table = pcim_iomap_table(pdev);
  260. if (!iomap_table) {
  261. dev_err(dev, "pcim_iomap_table failed\n");
  262. ret = -ENOMEM;
  263. goto err_pci_enable;
  264. }
  265. pdata->xgmac_regs = iomap_table[XGBE_XGMAC_BAR];
  266. if (!pdata->xgmac_regs) {
  267. dev_err(dev, "xgmac ioremap failed\n");
  268. ret = -ENOMEM;
  269. goto err_pci_enable;
  270. }
  271. pdata->xprop_regs = pdata->xgmac_regs + XGBE_MAC_PROP_OFFSET;
  272. pdata->xi2c_regs = pdata->xgmac_regs + XGBE_I2C_CTRL_OFFSET;
  273. if (netif_msg_probe(pdata)) {
  274. dev_dbg(dev, "xgmac_regs = %p\n", pdata->xgmac_regs);
  275. dev_dbg(dev, "xprop_regs = %p\n", pdata->xprop_regs);
  276. dev_dbg(dev, "xi2c_regs = %p\n", pdata->xi2c_regs);
  277. }
  278. pdata->xpcs_regs = iomap_table[XGBE_XPCS_BAR];
  279. if (!pdata->xpcs_regs) {
  280. dev_err(dev, "xpcs ioremap failed\n");
  281. ret = -ENOMEM;
  282. goto err_pci_enable;
  283. }
  284. if (netif_msg_probe(pdata))
  285. dev_dbg(dev, "xpcs_regs = %p\n", pdata->xpcs_regs);
  286. /* Configure the PCS indirect addressing support */
  287. reg = XPCS32_IOREAD(pdata, PCS_V2_WINDOW_DEF);
  288. pdata->xpcs_window = XPCS_GET_BITS(reg, PCS_V2_WINDOW_DEF, OFFSET);
  289. pdata->xpcs_window <<= 6;
  290. pdata->xpcs_window_size = XPCS_GET_BITS(reg, PCS_V2_WINDOW_DEF, SIZE);
  291. pdata->xpcs_window_size = 1 << (pdata->xpcs_window_size + 7);
  292. pdata->xpcs_window_mask = pdata->xpcs_window_size - 1;
  293. if (netif_msg_probe(pdata)) {
  294. dev_dbg(dev, "xpcs window = %#010x\n",
  295. pdata->xpcs_window);
  296. dev_dbg(dev, "xpcs window size = %#010x\n",
  297. pdata->xpcs_window_size);
  298. dev_dbg(dev, "xpcs window mask = %#010x\n",
  299. pdata->xpcs_window_mask);
  300. }
  301. pci_set_master(pdev);
  302. /* Enable all interrupts in the hardware */
  303. XP_IOWRITE(pdata, XP_INT_EN, 0x1fffff);
  304. /* Retrieve the MAC address */
  305. ma_lo = XP_IOREAD(pdata, XP_MAC_ADDR_LO);
  306. ma_hi = XP_IOREAD(pdata, XP_MAC_ADDR_HI);
  307. pdata->mac_addr[0] = ma_lo & 0xff;
  308. pdata->mac_addr[1] = (ma_lo >> 8) & 0xff;
  309. pdata->mac_addr[2] = (ma_lo >> 16) & 0xff;
  310. pdata->mac_addr[3] = (ma_lo >> 24) & 0xff;
  311. pdata->mac_addr[4] = ma_hi & 0xff;
  312. pdata->mac_addr[5] = (ma_hi >> 8) & 0xff;
  313. if (!XP_GET_BITS(ma_hi, XP_MAC_ADDR_HI, VALID) ||
  314. !is_valid_ether_addr(pdata->mac_addr)) {
  315. dev_err(dev, "invalid mac address\n");
  316. ret = -EINVAL;
  317. goto err_pci_enable;
  318. }
  319. /* Clock settings */
  320. pdata->sysclk_rate = XGBE_V2_DMA_CLOCK_FREQ;
  321. pdata->ptpclk_rate = XGBE_V2_PTP_CLOCK_FREQ;
  322. /* Set the DMA coherency values */
  323. pdata->coherent = 1;
  324. pdata->axdomain = XGBE_DMA_OS_AXDOMAIN;
  325. pdata->arcache = XGBE_DMA_OS_ARCACHE;
  326. pdata->awcache = XGBE_DMA_OS_AWCACHE;
  327. /* Set the maximum channels and queues */
  328. reg = XP_IOREAD(pdata, XP_PROP_1);
  329. pdata->tx_max_channel_count = XP_GET_BITS(reg, XP_PROP_1, MAX_TX_DMA);
  330. pdata->rx_max_channel_count = XP_GET_BITS(reg, XP_PROP_1, MAX_RX_DMA);
  331. pdata->tx_max_q_count = XP_GET_BITS(reg, XP_PROP_1, MAX_TX_QUEUES);
  332. pdata->rx_max_q_count = XP_GET_BITS(reg, XP_PROP_1, MAX_RX_QUEUES);
  333. if (netif_msg_probe(pdata)) {
  334. dev_dbg(dev, "max tx/rx channel count = %u/%u\n",
  335. pdata->tx_max_channel_count,
  336. pdata->tx_max_channel_count);
  337. dev_dbg(dev, "max tx/rx hw queue count = %u/%u\n",
  338. pdata->tx_max_q_count, pdata->rx_max_q_count);
  339. }
  340. /* Set the hardware channel and queue counts */
  341. xgbe_set_counts(pdata);
  342. /* Set the maximum fifo amounts */
  343. reg = XP_IOREAD(pdata, XP_PROP_2);
  344. pdata->tx_max_fifo_size = XP_GET_BITS(reg, XP_PROP_2, TX_FIFO_SIZE);
  345. pdata->tx_max_fifo_size *= 16384;
  346. pdata->tx_max_fifo_size = min(pdata->tx_max_fifo_size,
  347. pdata->vdata->tx_max_fifo_size);
  348. pdata->rx_max_fifo_size = XP_GET_BITS(reg, XP_PROP_2, RX_FIFO_SIZE);
  349. pdata->rx_max_fifo_size *= 16384;
  350. pdata->rx_max_fifo_size = min(pdata->rx_max_fifo_size,
  351. pdata->vdata->rx_max_fifo_size);
  352. if (netif_msg_probe(pdata))
  353. dev_dbg(dev, "max tx/rx max fifo size = %u/%u\n",
  354. pdata->tx_max_fifo_size, pdata->rx_max_fifo_size);
  355. /* Configure interrupt support */
  356. ret = xgbe_config_irqs(pdata);
  357. if (ret)
  358. goto err_pci_enable;
  359. /* Configure the netdev resource */
  360. ret = xgbe_config_netdev(pdata);
  361. if (ret)
  362. goto err_pci_enable;
  363. netdev_notice(pdata->netdev, "net device enabled\n");
  364. return 0;
  365. err_pci_enable:
  366. xgbe_free_pdata(pdata);
  367. err_alloc:
  368. dev_notice(dev, "net device not enabled\n");
  369. return ret;
  370. }
  371. static void xgbe_pci_remove(struct pci_dev *pdev)
  372. {
  373. struct xgbe_prv_data *pdata = pci_get_drvdata(pdev);
  374. xgbe_deconfig_netdev(pdata);
  375. xgbe_free_pdata(pdata);
  376. }
  377. #ifdef CONFIG_PM
  378. static int xgbe_pci_suspend(struct pci_dev *pdev, pm_message_t state)
  379. {
  380. struct xgbe_prv_data *pdata = pci_get_drvdata(pdev);
  381. struct net_device *netdev = pdata->netdev;
  382. int ret = 0;
  383. if (netif_running(netdev))
  384. ret = xgbe_powerdown(netdev, XGMAC_DRIVER_CONTEXT);
  385. pdata->lpm_ctrl = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_CTRL1);
  386. pdata->lpm_ctrl |= MDIO_CTRL1_LPOWER;
  387. XMDIO_WRITE(pdata, MDIO_MMD_PCS, MDIO_CTRL1, pdata->lpm_ctrl);
  388. return ret;
  389. }
  390. static int xgbe_pci_resume(struct pci_dev *pdev)
  391. {
  392. struct xgbe_prv_data *pdata = pci_get_drvdata(pdev);
  393. struct net_device *netdev = pdata->netdev;
  394. int ret = 0;
  395. pdata->lpm_ctrl &= ~MDIO_CTRL1_LPOWER;
  396. XMDIO_WRITE(pdata, MDIO_MMD_PCS, MDIO_CTRL1, pdata->lpm_ctrl);
  397. if (netif_running(netdev)) {
  398. ret = xgbe_powerup(netdev, XGMAC_DRIVER_CONTEXT);
  399. /* Schedule a restart in case the link or phy state changed
  400. * while we were powered down.
  401. */
  402. schedule_work(&pdata->restart_work);
  403. }
  404. return ret;
  405. }
  406. #endif /* CONFIG_PM */
  407. static const struct xgbe_version_data xgbe_v2a = {
  408. .init_function_ptrs_phy_impl = xgbe_init_function_ptrs_phy_v2,
  409. .xpcs_access = XGBE_XPCS_ACCESS_V2,
  410. .mmc_64bit = 1,
  411. .tx_max_fifo_size = 229376,
  412. .rx_max_fifo_size = 229376,
  413. .tx_tstamp_workaround = 1,
  414. .ecc_support = 1,
  415. .i2c_support = 1,
  416. };
  417. static const struct xgbe_version_data xgbe_v2b = {
  418. .init_function_ptrs_phy_impl = xgbe_init_function_ptrs_phy_v2,
  419. .xpcs_access = XGBE_XPCS_ACCESS_V2,
  420. .mmc_64bit = 1,
  421. .tx_max_fifo_size = 65536,
  422. .rx_max_fifo_size = 65536,
  423. .tx_tstamp_workaround = 1,
  424. .ecc_support = 1,
  425. .i2c_support = 1,
  426. };
  427. static const struct pci_device_id xgbe_pci_table[] = {
  428. { PCI_VDEVICE(AMD, 0x1458),
  429. .driver_data = (kernel_ulong_t)&xgbe_v2a },
  430. { PCI_VDEVICE(AMD, 0x1459),
  431. .driver_data = (kernel_ulong_t)&xgbe_v2b },
  432. /* Last entry must be zero */
  433. { 0, }
  434. };
  435. MODULE_DEVICE_TABLE(pci, xgbe_pci_table);
  436. static struct pci_driver xgbe_driver = {
  437. .name = XGBE_DRV_NAME,
  438. .id_table = xgbe_pci_table,
  439. .probe = xgbe_pci_probe,
  440. .remove = xgbe_pci_remove,
  441. #ifdef CONFIG_PM
  442. .suspend = xgbe_pci_suspend,
  443. .resume = xgbe_pci_resume,
  444. #endif
  445. };
  446. int xgbe_pci_init(void)
  447. {
  448. return pci_register_driver(&xgbe_driver);
  449. }
  450. void xgbe_pci_exit(void)
  451. {
  452. pci_unregister_driver(&xgbe_driver);
  453. }