1 // SPDX-License-Identifier: ISC 2 /* Copyright (C) 2019 MediaTek Inc. 3 * 4 * Author: Ryder Lee <ryder.lee@mediatek.com> 5 * Felix Fietkau <nbd@nbd.name> 6 */ 7 8 #include <linux/kernel.h> 9 #include <linux/module.h> 10 #include <linux/pci.h> 11 12 #include "mt7615.h" 13 14 static const struct pci_device_id mt7615_pci_device_table[] = { 15 { PCI_DEVICE(0x14c3, 0x7615) }, 16 { PCI_DEVICE(0x14c3, 0x7663) }, 17 { }, 18 }; 19 20 static int mt7615_pci_probe(struct pci_dev *pdev, 21 const struct pci_device_id *id) 22 { 23 const u32 *map; 24 int ret; 25 26 ret = pcim_enable_device(pdev); 27 if (ret) 28 return ret; 29 30 ret = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev)); 31 if (ret) 32 return ret; 33 34 pci_set_master(pdev); 35 36 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 37 if (ret) 38 return ret; 39 40 map = id->device == 0x7663 ? mt7663e_reg_map : mt7615e_reg_map; 41 return mt7615_mmio_probe(&pdev->dev, pcim_iomap_table(pdev)[0], 42 pdev->irq, map); 43 } 44 45 static void mt7615_pci_remove(struct pci_dev *pdev) 46 { 47 struct mt76_dev *mdev = pci_get_drvdata(pdev); 48 struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76); 49 50 mt7615_unregister_device(dev); 51 } 52 53 struct pci_driver mt7615_pci_driver = { 54 .name = KBUILD_MODNAME, 55 .id_table = mt7615_pci_device_table, 56 .probe = mt7615_pci_probe, 57 .remove = mt7615_pci_remove, 58 }; 59 60 MODULE_DEVICE_TABLE(pci, mt7615_pci_device_table); 61 MODULE_FIRMWARE(MT7615_FIRMWARE_CR4); 62 MODULE_FIRMWARE(MT7615_FIRMWARE_N9); 63 MODULE_FIRMWARE(MT7615_ROM_PATCH); 64 MODULE_FIRMWARE(MT7663_FIRMWARE_N9); 65 MODULE_FIRMWARE(MT7663_ROM_PATCH); 66