1 // SPDX-License-Identifier: ISC 2 3 #include <linux/kernel.h> 4 #include <linux/module.h> 5 #include <linux/platform_device.h> 6 7 #include "mt7603.h" 8 9 static int 10 mt76_wmac_probe(struct platform_device *pdev) 11 { 12 struct mt7603_dev *dev; 13 void __iomem *mem_base; 14 struct mt76_dev *mdev; 15 int irq; 16 int ret; 17 18 irq = platform_get_irq(pdev, 0); 19 if (irq < 0) 20 return irq; 21 22 mem_base = devm_platform_ioremap_resource(pdev, 0); 23 if (IS_ERR(mem_base)) 24 return PTR_ERR(mem_base); 25 26 mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt7603_ops, 27 &mt7603_drv_ops); 28 if (!mdev) 29 return -ENOMEM; 30 31 dev = container_of(mdev, struct mt7603_dev, mt76); 32 mt76_mmio_init(mdev, mem_base); 33 34 mdev->rev = (mt76_rr(dev, MT_HW_CHIPID) << 16) | 35 (mt76_rr(dev, MT_HW_REV) & 0xff); 36 dev_info(mdev->dev, "ASIC revision: %04x\n", mdev->rev); 37 38 mt76_wr(dev, MT_INT_MASK_CSR, 0); 39 40 ret = devm_request_irq(mdev->dev, irq, mt7603_irq_handler, 41 IRQF_SHARED, KBUILD_MODNAME, dev); 42 if (ret) 43 goto error; 44 45 ret = mt7603_register_device(dev); 46 if (ret) 47 goto error; 48 49 return 0; 50 error: 51 ieee80211_free_hw(mt76_hw(dev)); 52 return ret; 53 } 54 55 static void mt76_wmac_remove(struct platform_device *pdev) 56 { 57 struct mt76_dev *mdev = platform_get_drvdata(pdev); 58 struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76); 59 60 mt7603_unregister_device(dev); 61 } 62 63 static const struct of_device_id of_wmac_match[] = { 64 { .compatible = "mediatek,mt7628-wmac" }, 65 {}, 66 }; 67 68 MODULE_DEVICE_TABLE(of, of_wmac_match); 69 MODULE_FIRMWARE(MT7628_FIRMWARE_E1); 70 MODULE_FIRMWARE(MT7628_FIRMWARE_E2); 71 72 struct platform_driver mt76_wmac_driver = { 73 .probe = mt76_wmac_probe, 74 .remove = mt76_wmac_remove, 75 .driver = { 76 .name = "mt76_wmac", 77 .of_match_table = of_wmac_match, 78 }, 79 }; 80