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/platform_device.h> 11 #include <linux/regmap.h> 12 #include <linux/mfd/syscon.h> 13 #include <linux/of.h> 14 #include "mt7615.h" 15 16 int mt7622_wmac_init(struct mt7615_dev *dev) 17 { 18 struct device_node *np = dev->mt76.dev->of_node; 19 20 if (!is_mt7622(&dev->mt76)) 21 return 0; 22 23 dev->infracfg = syscon_regmap_lookup_by_phandle(np, "mediatek,infracfg"); 24 if (IS_ERR(dev->infracfg)) { 25 dev_err(dev->mt76.dev, "Cannot find infracfg controller\n"); 26 return PTR_ERR(dev->infracfg); 27 } 28 29 return 0; 30 } 31 32 static int mt7622_wmac_probe(struct platform_device *pdev) 33 { 34 void __iomem *mem_base; 35 int irq; 36 37 irq = platform_get_irq(pdev, 0); 38 if (irq < 0) 39 return irq; 40 41 mem_base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); 42 if (IS_ERR(mem_base)) 43 return PTR_ERR(mem_base); 44 45 return mt7615_mmio_probe(&pdev->dev, mem_base, irq, mt7615e_reg_map); 46 } 47 48 static void mt7622_wmac_remove(struct platform_device *pdev) 49 { 50 struct mt7615_dev *dev = platform_get_drvdata(pdev); 51 52 mt7615_unregister_device(dev); 53 } 54 55 static const struct of_device_id mt7622_wmac_of_match[] = { 56 { .compatible = "mediatek,mt7622-wmac" }, 57 {}, 58 }; 59 60 struct platform_driver mt7622_wmac_driver = { 61 .driver = { 62 .name = "mt7622-wmac", 63 .of_match_table = mt7622_wmac_of_match, 64 }, 65 .probe = mt7622_wmac_probe, 66 .remove_new = mt7622_wmac_remove, 67 }; 68 69 MODULE_FIRMWARE(MT7622_FIRMWARE_N9); 70 MODULE_FIRMWARE(MT7622_ROM_PATCH); 71