Debian Codegraph @

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c

raw
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2020, Loongson Corporation
3 */
4
5 #include <linux/clk-provider.h>
6 #include <linux/pci.h>
7 #include <linux/dmi.h>
8 #include <linux/device.h>
9 #include <linux/of_irq.h>
10 #include "stmmac.h"
11 #include "stmmac_libpci.h"
12 #include "dwmac_dma.h"
13 #include "dwmac1000.h"
14
15 #define DRIVER_NAME "dwmac-loongson-pci"
16
17 /* Normal Loongson Tx Summary */
18 #define DMA_INTR_ENA_NIE_TX_LOONGSON 0x00040000
19 /* Normal Loongson Rx Summary */
20 #define DMA_INTR_ENA_NIE_RX_LOONGSON 0x00020000
21
22 #define DMA_INTR_NORMAL_LOONGSON (DMA_INTR_ENA_NIE_TX_LOONGSON | \
23 DMA_INTR_ENA_NIE_RX_LOONGSON | \
24 DMA_INTR_ENA_RIE | DMA_INTR_ENA_TIE)
25
26 /* Abnormal Loongson Tx Summary */
27 #define DMA_INTR_ENA_AIE_TX_LOONGSON 0x00010000
28 /* Abnormal Loongson Rx Summary */
29 #define DMA_INTR_ENA_AIE_RX_LOONGSON 0x00008000
30
31 #define DMA_INTR_ABNORMAL_LOONGSON (DMA_INTR_ENA_AIE_TX_LOONGSON | \
32 DMA_INTR_ENA_AIE_RX_LOONGSON | \
33 DMA_INTR_ENA_FBE | DMA_INTR_ENA_UNE)
34
35 #define DMA_INTR_DEFAULT_MASK_LOONGSON (DMA_INTR_NORMAL_LOONGSON | \
36 DMA_INTR_ABNORMAL_LOONGSON)
37
38 /* Normal Loongson Tx Interrupt Summary */
39 #define DMA_STATUS_NIS_TX_LOONGSON 0x00040000
40 /* Normal Loongson Rx Interrupt Summary */
41 #define DMA_STATUS_NIS_RX_LOONGSON 0x00020000
42
43 /* Abnormal Loongson Tx Interrupt Summary */
44 #define DMA_STATUS_AIS_TX_LOONGSON 0x00010000
45 /* Abnormal Loongson Rx Interrupt Summary */
46 #define DMA_STATUS_AIS_RX_LOONGSON 0x00008000
47
48 /* Fatal Loongson Tx Bus Error Interrupt */
49 #define DMA_STATUS_FBI_TX_LOONGSON 0x00002000
50 /* Fatal Loongson Rx Bus Error Interrupt */
51 #define DMA_STATUS_FBI_RX_LOONGSON 0x00001000
52
53 #define DMA_STATUS_MSK_COMMON_LOONGSON (DMA_STATUS_NIS_TX_LOONGSON | \
54 DMA_STATUS_NIS_RX_LOONGSON | \
55 DMA_STATUS_AIS_TX_LOONGSON | \
56 DMA_STATUS_AIS_RX_LOONGSON | \
57 DMA_STATUS_FBI_TX_LOONGSON | \
58 DMA_STATUS_FBI_RX_LOONGSON)
59
60 #define DMA_STATUS_MSK_RX_LOONGSON (DMA_STATUS_ERI | DMA_STATUS_RWT | \
61 DMA_STATUS_RPS | DMA_STATUS_RU | \
62 DMA_STATUS_RI | DMA_STATUS_OVF | \
63 DMA_STATUS_MSK_COMMON_LOONGSON)
64
65 #define DMA_STATUS_MSK_TX_LOONGSON (DMA_STATUS_ETI | DMA_STATUS_UNF | \
66 DMA_STATUS_TJT | DMA_STATUS_TU | \
67 DMA_STATUS_TPS | DMA_STATUS_TI | \
68 DMA_STATUS_MSK_COMMON_LOONGSON)
69
70 #define PCI_DEVICE_ID_LOONGSON_GMAC1 0x7a03
71 #define PCI_DEVICE_ID_LOONGSON_GMAC2 0x7a23
72 #define PCI_DEVICE_ID_LOONGSON_GNET 0x7a13
73 #define DWMAC_CORE_MULTICHAN_V1 0x10 /* Loongson custom ID 0x10 */
74 #define DWMAC_CORE_MULTICHAN_V2 0x12 /* Loongson custom ID 0x12 */
75
76 struct loongson_data {
77 u32 multichan;
78 u32 loongson_id;
79 struct device *dev;
80 };
81
82 struct stmmac_pci_info {
83 int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
84 };
85
86 static void loongson_default_data(struct pci_dev *pdev,
87 struct plat_stmmacenet_data *plat)
88 {
89 struct loongson_data *ld = plat->bsp_priv;
90
91 /* Get bus_id, this can be overwritten later */
92 plat->bus_id = pci_dev_id(pdev);
93
94 /* clk_csr_i = 100-150MHz & MDC = clk_csr_i/62 */
95 plat->clk_csr = STMMAC_CSR_100_150M;
96 plat->core_type = DWMAC_CORE_GMAC;
97 plat->force_sf_dma_mode = 1;
98
99 /* Increase the default value for multicast hash bins */
100 plat->multicast_filter_bins = 256;
101
102 plat->clk_ref_rate = 125000000;
103 plat->clk_ptp_rate = 125000000;
104
105 plat->dma_cfg->pbl = 32;
106 plat->dma_cfg->pblx8 = true;
107
108 switch (ld->loongson_id) {
109 case DWMAC_CORE_MULTICHAN_V1:
110 ld->multichan = 1;
111 plat->rx_queues_to_use = 8;
112 plat->tx_queues_to_use = 8;
113
114 /* Only channel 0 supports checksum,
115 * so turn off checksum to enable multiple channels.
116 */
117 for (int i = 1; i < 8; i++)
118 plat->tx_queues_cfg[i].coe_unsupported = 1;
119
120 break;
121 case DWMAC_CORE_MULTICHAN_V2:
122 ld->multichan = 1;
123 plat->rx_queues_to_use = 4;
124 plat->tx_queues_to_use = 4;
125 break;
126 default:
127 ld->multichan = 0;
128 break;
129 }
130 }
131
132 static int loongson_gmac_data(struct pci_dev *pdev,
133 struct plat_stmmacenet_data *plat)
134 {
135 loongson_default_data(pdev, plat);
136
137 plat->phy_interface = PHY_INTERFACE_MODE_RGMII_ID;
138
139 return 0;
140 }
141
142 static struct stmmac_pci_info loongson_gmac_pci_info = {
143 .setup = loongson_gmac_data,
144 };
145
146 static void loongson_gnet_fix_speed(void *priv, int speed, unsigned int mode)
147 {
148 struct loongson_data *ld = (struct loongson_data *)priv;
149 struct net_device *ndev = dev_get_drvdata(ld->dev);
150 struct stmmac_priv *ptr = netdev_priv(ndev);
151
152 /* The integrated PHY has a weird problem with switching from the low
153 * speeds to 1000Mbps mode. The speedup procedure requires the PHY-link
154 * re-negotiation.
155 */
156 if (speed == SPEED_1000) {
157 if (readl(ptr->ioaddr + MAC_CTRL_REG) &
158 GMAC_CONTROL_PS)
159 /* Word around hardware bug, restart autoneg */
160 phy_restart_aneg(ndev->phydev);
161 }
162 }
163
164 static int loongson_gnet_data(struct pci_dev *pdev,
165 struct plat_stmmacenet_data *plat)
166 {
167 loongson_default_data(pdev, plat);
168
169 plat->phy_interface = PHY_INTERFACE_MODE_GMII;
170 plat->mdio_bus_data->phy_mask = ~(u32)BIT(2);
171 plat->fix_mac_speed = loongson_gnet_fix_speed;
172
173 return 0;
174 }
175
176 static struct stmmac_pci_info loongson_gnet_pci_info = {
177 .setup = loongson_gnet_data,
178 };
179
180 static void loongson_dwmac_dma_init_channel(struct stmmac_priv *priv,
181 void __iomem *ioaddr,
182 struct stmmac_dma_cfg *dma_cfg,
183 u32 chan)
184 {
185 int txpbl = dma_cfg->txpbl ?: dma_cfg->pbl;
186 int rxpbl = dma_cfg->rxpbl ?: dma_cfg->pbl;
187 u32 value;
188
189 value = readl(ioaddr + DMA_CHAN_BUS_MODE(chan));
190
191 if (dma_cfg->pblx8)
192 value |= DMA_BUS_MODE_MAXPBL;
193
194 value |= DMA_BUS_MODE_USP;
195 value = u32_replace_bits(value, txpbl, DMA_BUS_MODE_PBL_MASK);
196 value = u32_replace_bits(value, rxpbl, DMA_BUS_MODE_RPBL_MASK);
197
198 /* Set the Fixed burst mode */
199 if (dma_cfg->fixed_burst)
200 value |= DMA_BUS_MODE_FB;
201
202 /* Mixed Burst has no effect when fb is set */
203 if (dma_cfg->mixed_burst)
204 value |= DMA_BUS_MODE_MB;
205
206 if (dma_cfg->atds)
207 value |= DMA_BUS_MODE_ATDS;
208
209 if (dma_cfg->aal)
210 value |= DMA_BUS_MODE_AAL;
211
212 writel(value, ioaddr + DMA_CHAN_BUS_MODE(chan));
213
214 /* Mask interrupts by writing to CSR7 */
215 writel(DMA_INTR_DEFAULT_MASK_LOONGSON, ioaddr +
216 DMA_CHAN_INTR_ENA(chan));
217 }
218
219 static int loongson_dwmac_dma_interrupt(struct stmmac_priv *priv,
220 void __iomem *ioaddr,
221 struct stmmac_extra_stats *x,
222 u32 chan, u32 dir)
223 {
224 struct stmmac_pcpu_stats *stats = this_cpu_ptr(priv->xstats.pcpu_stats);
225 u32 abnor_intr_status;
226 u32 nor_intr_status;
227 u32 fb_intr_status;
228 u32 intr_status;
229 int ret = 0;
230
231 /* read the status register (CSR5) */
232 intr_status = readl(ioaddr + DMA_CHAN_STATUS(chan));
233
234 if (dir == DMA_DIR_RX)
235 intr_status &= DMA_STATUS_MSK_RX_LOONGSON;
236 else if (dir == DMA_DIR_TX)
237 intr_status &= DMA_STATUS_MSK_TX_LOONGSON;
238
239 nor_intr_status = intr_status & (DMA_STATUS_NIS_TX_LOONGSON |
240 DMA_STATUS_NIS_RX_LOONGSON);
241 abnor_intr_status = intr_status & (DMA_STATUS_AIS_TX_LOONGSON |
242 DMA_STATUS_AIS_RX_LOONGSON);
243 fb_intr_status = intr_status & (DMA_STATUS_FBI_TX_LOONGSON |
244 DMA_STATUS_FBI_RX_LOONGSON);
245
246 /* ABNORMAL interrupts */
247 if (unlikely(abnor_intr_status)) {
248 if (unlikely(intr_status & DMA_STATUS_UNF)) {
249 ret = tx_hard_error_bump_tc;
250 x->tx_undeflow_irq++;
251 }
252 if (unlikely(intr_status & DMA_STATUS_TJT))
253 x->tx_jabber_irq++;
254 if (unlikely(intr_status & DMA_STATUS_OVF))
255 x->rx_overflow_irq++;
256 if (unlikely(intr_status & DMA_STATUS_RU))
257 x->rx_buf_unav_irq++;
258 if (unlikely(intr_status & DMA_STATUS_RPS))
259 x->rx_process_stopped_irq++;
260 if (unlikely(intr_status & DMA_STATUS_RWT))
261 x->rx_watchdog_irq++;
262 if (unlikely(intr_status & DMA_STATUS_ETI))
263 x->tx_early_irq++;
264 if (unlikely(intr_status & DMA_STATUS_TPS)) {
265 x->tx_process_stopped_irq++;
266 ret = tx_hard_error;
267 }
268 if (unlikely(fb_intr_status)) {
269 x->fatal_bus_error_irq++;
270 ret = tx_hard_error;
271 }
272 }
273 /* TX/RX NORMAL interrupts */
274 if (likely(nor_intr_status)) {
275 if (likely(intr_status & DMA_STATUS_RI)) {
276 u32 value = readl(ioaddr + DMA_INTR_ENA);
277 /* to schedule NAPI on real RIE event. */
278 if (likely(value & DMA_INTR_ENA_RIE)) {
279 u64_stats_update_begin(&stats->syncp);
280 u64_stats_inc(&stats->rx_normal_irq_n[chan]);
281 u64_stats_update_end(&stats->syncp);
282 ret |= handle_rx;
283 }
284 }
285 if (likely(intr_status & DMA_STATUS_TI)) {
286 u64_stats_update_begin(&stats->syncp);
287 u64_stats_inc(&stats->tx_normal_irq_n[chan]);
288 u64_stats_update_end(&stats->syncp);
289 ret |= handle_tx;
290 }
291 if (unlikely(intr_status & DMA_STATUS_ERI))
292 x->rx_early_irq++;
293 }
294 /* Optional hardware blocks, interrupts should be disabled */
295 if (unlikely(intr_status &
296 (DMA_STATUS_GPI | DMA_STATUS_GMI | DMA_STATUS_GLI)))
297 pr_warn("%s: unexpected status %08x\n", __func__, intr_status);
298
299 /* Clear the interrupt by writing a logic 1 to the CSR5[19-0] */
300 writel((intr_status & 0x7ffff), ioaddr + DMA_CHAN_STATUS(chan));
301
302 return ret;
303 }
304
305 static int loongson_dwmac_setup(void *apriv, struct mac_device_info *mac)
306 {
307 struct stmmac_priv *priv = apriv;
308 struct stmmac_dma_ops *dma;
309 struct loongson_data *ld;
310 struct pci_dev *pdev;
311
312 ld = priv->plat->bsp_priv;
313 pdev = to_pci_dev(priv->device);
314
315 dma = devm_kzalloc(priv->device, sizeof(*dma), GFP_KERNEL);
316 if (!dma)
317 return -ENOMEM;
318
319 /* The Loongson GMAC and GNET devices are based on the DW GMAC
320 * v3.50a and v3.73a IP-cores. But the HW designers have changed
321 * the GMAC_VERSION.SNPSVER field to the custom 0x10/0x12 value
322 * on the network controllers with the multi-channels feature
323 * available to emphasize the differences: multiple DMA-channels,
324 * AV feature and GMAC_INT_STATUS CSR flags layout. Get back the
325 * original value so the correct HW-interface would be selected.
326 */
327 if (ld->multichan) {
328 priv->synopsys_id = DWMAC_CORE_3_70;
329 *dma = dwmac1000_dma_ops;
330 dma->init_chan = loongson_dwmac_dma_init_channel;
331 dma->dma_interrupt = loongson_dwmac_dma_interrupt;
332 mac->dma = dma;
333 }
334
335 priv->dev->priv_flags |= IFF_UNICAST_FLT;
336
337 /* Pre-initialize the respective "mac" fields as it's done in
338 * dwmac1000_setup()
339 */
340 mac->pcsr = priv->ioaddr;
341 mac->multicast_filter_bins = priv->plat->multicast_filter_bins;
342 mac->unicast_filter_entries = priv->plat->unicast_filter_entries;
343 mac->mcast_bits_log2 = 0;
344
345 if (mac->multicast_filter_bins)
346 mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
347
348 /* Loongson GMAC doesn't support the flow control. Loongson GNET
349 * without multi-channel doesn't support the half-duplex link mode.
350 */
351 if (pdev->device != PCI_DEVICE_ID_LOONGSON_GNET) {
352 mac->link.caps = MAC_10 | MAC_100 | MAC_1000;
353 } else {
354 if (ld->multichan)
355 mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
356 MAC_10 | MAC_100 | MAC_1000;
357 else
358 mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
359 MAC_10FD | MAC_100FD | MAC_1000FD;
360 }
361
362 mac->link.duplex = GMAC_CONTROL_DM;
363 mac->link.speed10 = GMAC_CONTROL_PS;
364 mac->link.speed100 = GMAC_CONTROL_PS | GMAC_CONTROL_FES;
365 mac->link.speed1000 = 0;
366 mac->link.speed_mask = GMAC_CONTROL_PS | GMAC_CONTROL_FES;
367 mac->mii.addr = GMAC_MII_ADDR;
368 mac->mii.data = GMAC_MII_DATA;
369 mac->mii.addr_shift = 11;
370 mac->mii.addr_mask = 0x0000F800;
371 mac->mii.reg_shift = 6;
372 mac->mii.reg_mask = 0x000007C0;
373 mac->mii.clk_csr_shift = 2;
374 mac->mii.clk_csr_mask = GENMASK(5, 2);
375
376 return 0;
377 }
378
379 static int loongson_dwmac_msi_config(struct pci_dev *pdev,
380 struct plat_stmmacenet_data *plat,
381 struct stmmac_resources *res)
382 {
383 int i, ch_num, ret, vecs;
384
385 ch_num = min(plat->tx_queues_to_use, plat->rx_queues_to_use);
386
387 vecs = roundup_pow_of_two(ch_num * 2 + 1);
388 ret = pci_alloc_irq_vectors(pdev, vecs, vecs, PCI_IRQ_MSI);
389 if (ret < 0) {
390 dev_warn(&pdev->dev, "Failed to allocate MSI IRQs\n");
391 return ret;
392 }
393
394 res->irq = pci_irq_vector(pdev, 0);
395
396 for (i = 0; i < ch_num; i++) {
397 res->rx_irq[ch_num - 1 - i] = pci_irq_vector(pdev, 1 + i * 2);
398 }
399
400 for (i = 0; i < ch_num; i++) {
401 res->tx_irq[ch_num - 1 - i] = pci_irq_vector(pdev, 2 + i * 2);
402 }
403
404 plat->flags |= STMMAC_FLAG_MULTI_MSI_EN;
405
406 return 0;
407 }
408
409 static void loongson_dwmac_msi_clear(struct pci_dev *pdev)
410 {
411 pci_free_irq_vectors(pdev);
412 }
413
414 static int loongson_dwmac_dt_config(struct pci_dev *pdev,
415 struct plat_stmmacenet_data *plat,
416 struct stmmac_resources *res)
417 {
418 struct device_node *np = dev_of_node(&pdev->dev);
419 int ret;
420
421 plat->mdio_node = of_get_child_by_name(np, "mdio");
422 if (plat->mdio_node) {
423 dev_info(&pdev->dev, "Found MDIO subnode\n");
424 plat->mdio_bus_data->needs_reset = true;
425 }
426
427 ret = of_alias_get_id(np, "ethernet");
428 if (ret >= 0)
429 plat->bus_id = ret;
430
431 res->irq = of_irq_get_byname(np, "macirq");
432 if (res->irq < 0) {
433 dev_err(&pdev->dev, "IRQ macirq not found\n");
434 ret = -ENODEV;
435 goto err_put_node;
436 }
437
438 res->wol_irq = of_irq_get_byname(np, "eth_wake_irq");
439 if (res->wol_irq < 0) {
440 dev_info(&pdev->dev,
441 "IRQ eth_wake_irq not found, using macirq\n");
442 res->wol_irq = res->irq;
443 }
444
445 ret = device_get_phy_mode(&pdev->dev);
446 if (ret < 0) {
447 dev_err(&pdev->dev, "phy_mode not found\n");
448 ret = -ENODEV;
449 goto err_put_node;
450 }
451
452 plat->phy_interface = ret;
453
454 return 0;
455
456 err_put_node:
457 of_node_put(plat->mdio_node);
458
459 return ret;
460 }
461
462 static void loongson_dwmac_dt_clear(struct pci_dev *pdev,
463 struct plat_stmmacenet_data *plat)
464 {
465 of_node_put(plat->mdio_node);
466 }
467
468 static int loongson_dwmac_acpi_config(struct pci_dev *pdev,
469 struct plat_stmmacenet_data *plat,
470 struct stmmac_resources *res)
471 {
472 if (!pdev->irq)
473 return -EINVAL;
474
475 res->irq = pdev->irq;
476
477 return 0;
478 }
479
480 /* Loongson's DWMAC device may take nearly two seconds to complete DMA reset */
481 static int loongson_dwmac_fix_reset(struct stmmac_priv *priv)
482 {
483 void __iomem *ioaddr = priv->ioaddr;
484 u32 value;
485
486 value = readl(ioaddr + DMA_BUS_MODE);
487 if (value & DMA_BUS_MODE_SFT_RESET) {
488 netdev_err(priv->dev, "the PHY clock is missing\n");
489 return -EINVAL;
490 }
491
492 value |= DMA_BUS_MODE_SFT_RESET;
493 writel(value, ioaddr + DMA_BUS_MODE);
494
495 return readl_poll_timeout(ioaddr + DMA_BUS_MODE, value,
496 !(value & DMA_BUS_MODE_SFT_RESET),
497 10000, 2000000);
498 }
499
500 static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id *id)
501 {
502 struct plat_stmmacenet_data *plat;
503 struct stmmac_resources res = {};
504 struct stmmac_pci_info *info;
505 struct loongson_data *ld;
506 int ret;
507
508 plat = stmmac_plat_dat_alloc(&pdev->dev);
509 if (!plat)
510 return -ENOMEM;
511
512 plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
513 sizeof(*plat->mdio_bus_data),
514 GFP_KERNEL);
515 if (!plat->mdio_bus_data)
516 return -ENOMEM;
517
518 plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg), GFP_KERNEL);
519 if (!plat->dma_cfg)
520 return -ENOMEM;
521
522 ld = devm_kzalloc(&pdev->dev, sizeof(*ld), GFP_KERNEL);
523 if (!ld)
524 return -ENOMEM;
525
526 /* Enable pci device */
527 ret = pci_enable_device(pdev);
528 if (ret) {
529 dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n", __func__);
530 return ret;
531 }
532
533 pci_set_master(pdev);
534
535 /* Get the base address of device */
536 res.addr = pcim_iomap_region(pdev, 0, DRIVER_NAME);
537 ret = PTR_ERR_OR_ZERO(res.addr);
538 if (ret)
539 goto err_disable_device;
540
541 plat->bsp_priv = ld;
542 plat->mac_setup = loongson_dwmac_setup;
543 plat->fix_soc_reset = loongson_dwmac_fix_reset;
544 plat->suspend = stmmac_pci_plat_suspend;
545 plat->resume = stmmac_pci_plat_resume;
546 ld->dev = &pdev->dev;
547 ld->loongson_id = readl(res.addr + GMAC_VERSION) & 0xff;
548
549 info = (struct stmmac_pci_info *)id->driver_data;
550 ret = info->setup(pdev, plat);
551 if (ret)
552 goto err_disable_device;
553
554 plat->tx_fifo_size = SZ_16K * plat->tx_queues_to_use;
555 plat->rx_fifo_size = SZ_16K * plat->rx_queues_to_use;
556
557 if (dev_of_node(&pdev->dev))
558 ret = loongson_dwmac_dt_config(pdev, plat, &res);
559 else
560 ret = loongson_dwmac_acpi_config(pdev, plat, &res);
561 if (ret)
562 goto err_disable_device;
563
564 /* Use the common MAC IRQ if per-channel MSIs allocation failed */
565 if (ld->multichan)
566 loongson_dwmac_msi_config(pdev, plat, &res);
567
568 ret = stmmac_dvr_probe(&pdev->dev, plat, &res);
569 if (ret)
570 goto err_plat_clear;
571
572 return 0;
573
574 err_plat_clear:
575 if (dev_of_node(&pdev->dev))
576 loongson_dwmac_dt_clear(pdev, plat);
577 if (ld->multichan)
578 loongson_dwmac_msi_clear(pdev);
579 err_disable_device:
580 pci_disable_device(pdev);
581 return ret;
582 }
583
584 static void loongson_dwmac_remove(struct pci_dev *pdev)
585 {
586 struct net_device *ndev = dev_get_drvdata(&pdev->dev);
587 struct stmmac_priv *priv = netdev_priv(ndev);
588 struct loongson_data *ld;
589
590 ld = priv->plat->bsp_priv;
591 stmmac_dvr_remove(&pdev->dev);
592
593 if (dev_of_node(&pdev->dev))
594 loongson_dwmac_dt_clear(pdev, priv->plat);
595
596 if (ld->multichan)
597 loongson_dwmac_msi_clear(pdev);
598
599 pci_disable_device(pdev);
600 }
601
602 static const struct pci_device_id loongson_dwmac_id_table[] = {
603 { PCI_DEVICE_DATA(LOONGSON, GMAC1, &loongson_gmac_pci_info) },
604 { PCI_DEVICE_DATA(LOONGSON, GMAC2, &loongson_gmac_pci_info) },
605 { PCI_DEVICE_DATA(LOONGSON, GNET, &loongson_gnet_pci_info) },
606 {}
607 };
608 MODULE_DEVICE_TABLE(pci, loongson_dwmac_id_table);
609
610 static struct pci_driver loongson_dwmac_driver = {
611 .name = DRIVER_NAME,
612 .id_table = loongson_dwmac_id_table,
613 .probe = loongson_dwmac_probe,
614 .remove = loongson_dwmac_remove,
615 .driver = {
616 .pm = &stmmac_simple_pm_ops,
617 },
618 };
619
620 module_pci_driver(loongson_dwmac_driver);
621
622 MODULE_DESCRIPTION("Loongson DWMAC PCI driver");
623 MODULE_AUTHOR("Qing Zhang <[email protected]>");
624 MODULE_AUTHOR("Yanteng Si <[email protected]>");
625 MODULE_LICENSE("GPL v2");