1*6e0355afSGovind Singh // SPDX-License-Identifier: BSD-3-Clause-Clear 2*6e0355afSGovind Singh /* 3*6e0355afSGovind Singh * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved. 4*6e0355afSGovind Singh */ 5*6e0355afSGovind Singh 6*6e0355afSGovind Singh #include <linux/module.h> 7*6e0355afSGovind Singh #include <linux/pci.h> 8*6e0355afSGovind Singh 9*6e0355afSGovind Singh #include "core.h" 10*6e0355afSGovind Singh #include "debug.h" 11*6e0355afSGovind Singh 12*6e0355afSGovind Singh #define QCA6390_DEVICE_ID 0x1101 13*6e0355afSGovind Singh 14*6e0355afSGovind Singh static const struct pci_device_id ath11k_pci_id_table[] = { 15*6e0355afSGovind Singh { PCI_VDEVICE(QCOM, QCA6390_DEVICE_ID) }, 16*6e0355afSGovind Singh {0} 17*6e0355afSGovind Singh }; 18*6e0355afSGovind Singh 19*6e0355afSGovind Singh MODULE_DEVICE_TABLE(pci, ath11k_pci_id_table); 20*6e0355afSGovind Singh 21*6e0355afSGovind Singh static int ath11k_pci_probe(struct pci_dev *pdev, 22*6e0355afSGovind Singh const struct pci_device_id *pci_dev) 23*6e0355afSGovind Singh { 24*6e0355afSGovind Singh struct ath11k_base *ab; 25*6e0355afSGovind Singh enum ath11k_hw_rev hw_rev; 26*6e0355afSGovind Singh 27*6e0355afSGovind Singh dev_warn(&pdev->dev, "WARNING: ath11k PCI support is experimental!\n"); 28*6e0355afSGovind Singh 29*6e0355afSGovind Singh switch (pci_dev->device) { 30*6e0355afSGovind Singh case QCA6390_DEVICE_ID: 31*6e0355afSGovind Singh hw_rev = ATH11K_HW_QCA6390_HW20; 32*6e0355afSGovind Singh break; 33*6e0355afSGovind Singh default: 34*6e0355afSGovind Singh dev_err(&pdev->dev, "Unknown PCI device found: 0x%x\n", 35*6e0355afSGovind Singh pci_dev->device); 36*6e0355afSGovind Singh return -ENOTSUPP; 37*6e0355afSGovind Singh } 38*6e0355afSGovind Singh 39*6e0355afSGovind Singh ab = ath11k_core_alloc(&pdev->dev, 0, ATH11K_BUS_PCI); 40*6e0355afSGovind Singh if (!ab) { 41*6e0355afSGovind Singh dev_err(&pdev->dev, "failed to allocate ath11k base\n"); 42*6e0355afSGovind Singh return -ENOMEM; 43*6e0355afSGovind Singh } 44*6e0355afSGovind Singh 45*6e0355afSGovind Singh ab->dev = &pdev->dev; 46*6e0355afSGovind Singh ab->hw_rev = hw_rev; 47*6e0355afSGovind Singh pci_set_drvdata(pdev, ab); 48*6e0355afSGovind Singh 49*6e0355afSGovind Singh return 0; 50*6e0355afSGovind Singh } 51*6e0355afSGovind Singh 52*6e0355afSGovind Singh static void ath11k_pci_remove(struct pci_dev *pdev) 53*6e0355afSGovind Singh { 54*6e0355afSGovind Singh struct ath11k_base *ab = pci_get_drvdata(pdev); 55*6e0355afSGovind Singh 56*6e0355afSGovind Singh set_bit(ATH11K_FLAG_UNREGISTERING, &ab->dev_flags); 57*6e0355afSGovind Singh ath11k_core_free(ab); 58*6e0355afSGovind Singh } 59*6e0355afSGovind Singh 60*6e0355afSGovind Singh static struct pci_driver ath11k_pci_driver = { 61*6e0355afSGovind Singh .name = "ath11k_pci", 62*6e0355afSGovind Singh .id_table = ath11k_pci_id_table, 63*6e0355afSGovind Singh .probe = ath11k_pci_probe, 64*6e0355afSGovind Singh .remove = ath11k_pci_remove, 65*6e0355afSGovind Singh }; 66*6e0355afSGovind Singh 67*6e0355afSGovind Singh static int ath11k_pci_init(void) 68*6e0355afSGovind Singh { 69*6e0355afSGovind Singh int ret; 70*6e0355afSGovind Singh 71*6e0355afSGovind Singh ret = pci_register_driver(&ath11k_pci_driver); 72*6e0355afSGovind Singh if (ret) 73*6e0355afSGovind Singh pr_err("failed to register ath11k pci driver: %d\n", 74*6e0355afSGovind Singh ret); 75*6e0355afSGovind Singh 76*6e0355afSGovind Singh return ret; 77*6e0355afSGovind Singh } 78*6e0355afSGovind Singh module_init(ath11k_pci_init); 79*6e0355afSGovind Singh 80*6e0355afSGovind Singh static void ath11k_pci_exit(void) 81*6e0355afSGovind Singh { 82*6e0355afSGovind Singh pci_unregister_driver(&ath11k_pci_driver); 83*6e0355afSGovind Singh } 84*6e0355afSGovind Singh 85*6e0355afSGovind Singh module_exit(ath11k_pci_exit); 86*6e0355afSGovind Singh 87*6e0355afSGovind Singh MODULE_DESCRIPTION("Driver support for Qualcomm Technologies 802.11ax WLAN PCIe devices"); 88*6e0355afSGovind Singh MODULE_LICENSE("Dual BSD/GPL"); 89