diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h index a79291143f..1f7d4517e0 100644 --- a/core/pld/inc/pld_common.h +++ b/core/pld/inc/pld_common.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. - * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -851,6 +851,7 @@ void pld_lock_pm_sem(struct device *dev); void pld_release_pm_sem(struct device *dev); void pld_lock_reg_window(struct device *dev, unsigned long *flags); void pld_unlock_reg_window(struct device *dev, unsigned long *flags); +int pld_get_pci_slot(struct device *dev); int pld_power_on(struct device *dev); int pld_power_off(struct device *dev); int pld_athdiag_read(struct device *dev, uint32_t offset, uint32_t memtype, diff --git a/core/pld/src/pld_common.c b/core/pld/src/pld_common.c index 94debfc820..62021d306d 100644 --- a/core/pld/src/pld_common.c +++ b/core/pld/src/pld_common.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. - * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -1839,6 +1839,35 @@ void pld_unlock_reg_window(struct device *dev, unsigned long *flags) } } +/** + * pld_get_pci_slot() - Get PCI slot of attached device + * @dev: device + * + * Return: pci slot + */ +int pld_get_pci_slot(struct device *dev) +{ + int ret = 0; + + switch (pld_get_bus_type(dev)) { + case PLD_BUS_TYPE_PCIE: + ret = pld_pcie_get_pci_slot(dev); + break; + case PLD_BUS_TYPE_PCIE_FW_SIM: + case PLD_BUS_TYPE_IPCI_FW_SIM: + case PLD_BUS_TYPE_SNOC_FW_SIM: + case PLD_BUS_TYPE_SNOC: + case PLD_BUS_TYPE_IPCI: + break; + default: + pr_err("Invalid device type\n"); + ret = -EINVAL; + break; + } + + return ret; +} + /** * pld_power_on() - Power on WLAN hardware * @dev: device diff --git a/core/pld/src/pld_pcie.h b/core/pld/src/pld_pcie.h index 4cade9a07d..e0a7e53f63 100644 --- a/core/pld/src/pld_pcie.h +++ b/core/pld/src/pld_pcie.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -347,6 +348,11 @@ static inline void pld_pcie_unlock_reg_window(struct device *dev, { } +static inline int pld_pcie_get_pci_slot(struct device *dev) +{ + return 0; +} + static inline int pld_pcie_power_on(struct device *dev) { return 0; @@ -645,6 +651,18 @@ static inline void pld_pcie_unlock_reg_window(struct device *dev, cnss_pci_unlock_reg_window(dev, flags); } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) +static inline int pld_pcie_get_pci_slot(struct device *dev) +{ + return cnss_get_pci_slot(dev); +} +#else +static inline int pld_pcie_get_pci_slot(struct device *dev) +{ + return 0; +} +#endif + static inline int pld_pcie_power_on(struct device *dev) { return cnss_power_up(dev);