diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h index 94854a79f390..22e08bca0d15 100644 --- a/core/pld/inc/pld_common.h +++ b/core/pld/inc/pld_common.h @@ -356,6 +356,12 @@ int pld_athdiag_write(struct device *dev, uint32_t offset, uint32_t memtype, void *pld_smmu_get_mapping(struct device *dev); int pld_smmu_map(struct device *dev, phys_addr_t paddr, uint32_t *iova_addr, size_t size); +int pld_get_user_msi_assignment(struct device *dev, char *user_name, + int *num_vectors, uint32_t *user_base_data, + uint32_t *base_vector); +int pld_get_msi_irq(struct device *dev, unsigned int vector); +void pld_get_msi_address(struct device *dev, uint32_t *msi_addr_low, + uint32_t *msi_addr_high); unsigned int pld_socinfo_get_serial_number(struct device *dev); uint8_t *pld_common_get_wlan_mac_address(struct device *dev, uint32_t *num); int pld_is_qmi_disable(struct device *dev); diff --git a/core/pld/src/pld_common.c b/core/pld/src/pld_common.c index 60e669faa2d9..13694e4592c9 100644 --- a/core/pld/src/pld_common.c +++ b/core/pld/src/pld_common.c @@ -1501,6 +1501,107 @@ int pld_smmu_map(struct device *dev, phys_addr_t paddr, return ret; } +/** + * pld_get_user_msi_assignment() - Get MSI assignment information + * @dev: device structure + * @user_name: name of the user who requests the MSI assignment + * @num_vectors: number of the MSI vectors assigned for the user + * @user_base_data: MSI base data assigned for the user, this equals to + * endpoint base data from config space plus base vector + * @base_vector: base MSI vector (offset) number assigned for the user + * + * Return: 0 for success + * Negative failure code for errors + */ +int pld_get_user_msi_assignment(struct device *dev, char *user_name, + int *num_vectors, uint32_t *user_base_data, + uint32_t *base_vector) +{ + int ret = 0; + enum pld_bus_type type = pld_get_bus_type(dev); + + switch (type) { + case PLD_BUS_TYPE_PCIE: + ret = pld_pcie_get_user_msi_assignment(dev, user_name, + num_vectors, + user_base_data, + base_vector); + break; + case PLD_BUS_TYPE_SNOC: + case PLD_BUS_TYPE_SDIO: + case PLD_BUS_TYPE_USB: + pr_err("Not supported on type %d\n", type); + ret = -ENODEV; + break; + default: + pr_err("Invalid device type %d\n", type); + ret = -EINVAL; + break; + } + + return ret; +} + +/** + * pld_get_msi_irq() - Get MSI IRQ number used for request_irq() + * @dev: device structure + * @vector: MSI vector (offset) number + * + * Return: Positive IRQ number for success + * Negative failure code for errors + */ +int pld_get_msi_irq(struct device *dev, unsigned int vector) +{ + int ret = 0; + enum pld_bus_type type = pld_get_bus_type(dev); + + switch (type) { + case PLD_BUS_TYPE_PCIE: + ret = pld_pcie_get_msi_irq(dev, vector); + break; + case PLD_BUS_TYPE_SNOC: + case PLD_BUS_TYPE_SDIO: + case PLD_BUS_TYPE_USB: + pr_err("Not supported on type %d\n", type); + ret = -ENODEV; + break; + default: + pr_err("Invalid device type %d\n", type); + ret = -EINVAL; + break; + } + + return ret; +} + +/** + * pld_get_msi_address() - Get the MSI address + * @dev: device structure + * @msi_addr_low: lower 32-bit of the address + * @msi_addr_high: higher 32-bit of the address + * + * Return: Void + */ +void pld_get_msi_address(struct device *dev, uint32_t *msi_addr_low, + uint32_t *msi_addr_high) +{ + enum pld_bus_type type = pld_get_bus_type(dev); + + switch (type) { + case PLD_BUS_TYPE_PCIE: + pld_pcie_get_msi_address(dev, msi_addr_low, msi_addr_high); + break; + case PLD_BUS_TYPE_SNOC: + case PLD_BUS_TYPE_SDIO: + case PLD_BUS_TYPE_USB: + pr_err("Not supported on type %d\n", type); + break; + default: + pr_err("Invalid device type %d\n", type); + break; + } +} + /** * pld_socinfo_get_serial_number() - Get SOC serial number * @dev: device diff --git a/core/pld/src/pld_pcie.h b/core/pld/src/pld_pcie.h index ec0bde748a57..a325e21f2f37 100644 --- a/core/pld/src/pld_pcie.h +++ b/core/pld/src/pld_pcie.h @@ -234,6 +234,24 @@ static inline uint8_t *pld_pcie_get_wlan_mac_address(struct device *dev, *num = 0; return NULL; } +static inline int pld_pcie_get_user_msi_assignment(struct device *dev, + char *user_name, + int *num_vectors, + uint32_t *user_base_data, + uint32_t *base_vector) +{ + return 0; +} +static inline int pld_pcie_get_msi_irq(struct device *dev, unsigned int vector) +{ + return 0; +} +static inline void pld_pcie_get_msi_address(struct device *dev, + uint32_t *msi_addr_low, + uint32_t *msi_addr_high) +{ + return; +} #else int pld_pcie_get_fw_files_for_target(struct pld_fw_files *pfw_files, u32 target_type, u32 target_version); @@ -324,5 +342,24 @@ static inline uint8_t *pld_pcie_get_wlan_mac_address(struct device *dev, { return cnss_common_get_wlan_mac_address(dev, num); } +static inline int pld_pcie_get_user_msi_assignment(struct device *dev, + char *user_name, + int *num_vectors, + uint32_t *user_base_data, + uint32_t *base_vector) +{ + return cnss_get_user_msi_assignment(dev, user_name, num_vectors, + user_base_data, base_vector); +} +static inline int pld_pcie_get_msi_irq(struct device *dev, unsigned int vector) +{ + return cnss_get_msi_irq(dev, vector); +} +static inline void pld_pcie_get_msi_address(struct device *dev, + uint32_t *msi_addr_low, + uint32_t *msi_addr_high) +{ + cnss_get_msi_address(dev, msi_addr_low, msi_addr_high); +} #endif #endif