1 // SPDX-License-Identifier: ISC
3 * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
6 #include <linux/kernel.h>
7 #include <linux/module.h>
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) },
20 mt76pci_probe(struct pci_dev
*pdev
, const struct pci_device_id
*id
)
22 static const struct mt76_driver_ops drv_ops
= {
23 .txwi_size
= sizeof(struct mt76x02_txwi
),
24 .drv_flags
= MT_DRV_TX_ALIGNED4_SKBS
|
26 .survey_flags
= SURVEY_INFO_TIME_TX
,
27 .update_survey
= mt76x02_update_channel
,
28 .tx_prepare_skb
= mt76x02_tx_prepare_skb
,
29 .tx_complete_skb
= mt76x02_tx_complete_skb
,
30 .rx_skb
= mt76x02_queue_rx_skb
,
31 .rx_poll_complete
= mt76x02_rx_poll_complete
,
32 .sta_ps
= mt76x02_sta_ps
,
33 .sta_add
= mt76x02_sta_add
,
34 .sta_remove
= mt76x02_sta_remove
,
36 struct mt76x02_dev
*dev
;
37 struct mt76_dev
*mdev
;
40 ret
= pcim_enable_device(pdev
);
44 ret
= pcim_iomap_regions(pdev
, BIT(0), pci_name(pdev
));
50 ret
= pci_set_dma_mask(pdev
, DMA_BIT_MASK(32));
54 mdev
= mt76_alloc_device(&pdev
->dev
, sizeof(*dev
), &mt76x2_ops
,
59 dev
= container_of(mdev
, struct mt76x02_dev
, mt76
);
60 mt76_mmio_init(mdev
, pcim_iomap_table(pdev
)[0]);
61 mt76x2_reset_wlan(dev
, false);
63 mdev
->rev
= mt76_rr(dev
, MT_ASIC_VERSION
);
64 dev_info(mdev
->dev
, "ASIC revision: %08x\n", mdev
->rev
);
66 ret
= devm_request_irq(mdev
->dev
, pdev
->irq
, mt76x02_irq_handler
,
67 IRQF_SHARED
, KBUILD_MODNAME
, dev
);
71 ret
= mt76x2_register_device(dev
);
75 /* Fix up ASPM configuration */
77 /* RG_SSUSB_G1_CDR_BIR_LTR = 0x9 */
78 mt76_rmw_field(dev
, 0x15a10, 0x1f << 16, 0x9);
80 /* RG_SSUSB_G1_CDR_BIC_LTR = 0xf */
81 mt76_rmw_field(dev
, 0x15a0c, 0xf << 28, 0xf);
83 /* RG_SSUSB_CDR_BR_PE1D = 0x3 */
84 mt76_rmw_field(dev
, 0x15c58, 0x3 << 6, 0x3);
86 mt76_pci_disable_aspm(pdev
);
91 ieee80211_free_hw(mt76_hw(dev
));
96 mt76pci_remove(struct pci_dev
*pdev
)
98 struct mt76_dev
*mdev
= pci_get_drvdata(pdev
);
99 struct mt76x02_dev
*dev
= container_of(mdev
, struct mt76x02_dev
, mt76
);
101 mt76_unregister_device(mdev
);
103 mt76_free_device(mdev
);
106 MODULE_DEVICE_TABLE(pci
, mt76pci_device_table
);
107 MODULE_FIRMWARE(MT7662_FIRMWARE
);
108 MODULE_FIRMWARE(MT7662_ROM_PATCH
);
109 MODULE_LICENSE("Dual BSD/GPL");
111 static struct pci_driver mt76pci_driver
= {
112 .name
= KBUILD_MODNAME
,
113 .id_table
= mt76pci_device_table
,
114 .probe
= mt76pci_probe
,
115 .remove
= mt76pci_remove
,
118 module_pci_driver(mt76pci_driver
);