This source file includes following definitions.
- mt76pci_probe
- mt76pci_remove
1
2
3
4
5
6 #include <linux/kernel.h>
7 #include <linux/module.h>
8 #include <linux/pci.h>
9
10 #include "mt76x2.h"
11
12 static const struct pci_device_id mt76pci_device_table[] = {
13 { PCI_DEVICE(0x14c3, 0x7662) },
14 { PCI_DEVICE(0x14c3, 0x7612) },
15 { PCI_DEVICE(0x14c3, 0x7602) },
16 { },
17 };
18
19 static int
20 mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
21 {
22 static const struct mt76_driver_ops drv_ops = {
23 .txwi_size = sizeof(struct mt76x02_txwi),
24 .tx_aligned4_skbs = true,
25 .update_survey = mt76x02_update_channel,
26 .tx_prepare_skb = mt76x02_tx_prepare_skb,
27 .tx_complete_skb = mt76x02_tx_complete_skb,
28 .rx_skb = mt76x02_queue_rx_skb,
29 .rx_poll_complete = mt76x02_rx_poll_complete,
30 .sta_ps = mt76x02_sta_ps,
31 .sta_add = mt76x02_sta_add,
32 .sta_remove = mt76x02_sta_remove,
33 };
34 struct mt76x02_dev *dev;
35 struct mt76_dev *mdev;
36 int ret;
37
38 ret = pcim_enable_device(pdev);
39 if (ret)
40 return ret;
41
42 ret = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev));
43 if (ret)
44 return ret;
45
46 pci_set_master(pdev);
47
48 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
49 if (ret)
50 return ret;
51
52 mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt76x2_ops,
53 &drv_ops);
54 if (!mdev)
55 return -ENOMEM;
56
57 dev = container_of(mdev, struct mt76x02_dev, mt76);
58 mt76_mmio_init(mdev, pcim_iomap_table(pdev)[0]);
59 mt76x2_reset_wlan(dev, false);
60
61 mdev->rev = mt76_rr(dev, MT_ASIC_VERSION);
62 dev_info(mdev->dev, "ASIC revision: %08x\n", mdev->rev);
63
64 ret = devm_request_irq(mdev->dev, pdev->irq, mt76x02_irq_handler,
65 IRQF_SHARED, KBUILD_MODNAME, dev);
66 if (ret)
67 goto error;
68
69 ret = mt76x2_register_device(dev);
70 if (ret)
71 goto error;
72
73
74
75
76 mt76_rmw_field(dev, 0x15a10, 0x1f << 16, 0x9);
77
78
79 mt76_rmw_field(dev, 0x15a0c, 0xf << 28, 0xf);
80
81
82 mt76_rmw_field(dev, 0x15c58, 0x3 << 6, 0x3);
83
84 mt76_pci_disable_aspm(pdev);
85
86 return 0;
87
88 error:
89 ieee80211_free_hw(mt76_hw(dev));
90 return ret;
91 }
92
93 static void
94 mt76pci_remove(struct pci_dev *pdev)
95 {
96 struct mt76_dev *mdev = pci_get_drvdata(pdev);
97 struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
98
99 mt76_unregister_device(mdev);
100 mt76x2_cleanup(dev);
101 mt76_free_device(mdev);
102 }
103
104 MODULE_DEVICE_TABLE(pci, mt76pci_device_table);
105 MODULE_FIRMWARE(MT7662_FIRMWARE);
106 MODULE_FIRMWARE(MT7662_ROM_PATCH);
107 MODULE_LICENSE("Dual BSD/GPL");
108
109 static struct pci_driver mt76pci_driver = {
110 .name = KBUILD_MODNAME,
111 .id_table = mt76pci_device_table,
112 .probe = mt76pci_probe,
113 .remove = mt76pci_remove,
114 };
115
116 module_pci_driver(mt76pci_driver);