diff options
-rw-r--r-- | core/pld/inc/pld_common.h | 5 | ||||
-rw-r--r-- | core/pld/src/pld_common.c | 87 | ||||
-rw-r--r-- | core/pld/src/pld_pcie.h | 36 |
3 files changed, 128 insertions, 0 deletions
diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h index 9fcb54117c..8b2d501b56 100644 --- a/core/pld/inc/pld_common.h +++ b/core/pld/inc/pld_common.h @@ -639,6 +639,11 @@ int pld_is_qmi_disable(struct device *dev); int pld_is_fw_down(struct device *dev); int pld_force_assert_target(struct device *dev); int pld_collect_rddm(struct device *dev); +int pld_qmi_send_get(struct device *dev); +int pld_qmi_send_put(struct device *dev); +int pld_qmi_send(struct device *dev, int type, void *cmd, + int cmd_len, void *cb_ctx, + int (*cb)(void *ctx, void *event, int event_len)); bool pld_is_fw_dump_skipped(struct device *dev); /** diff --git a/core/pld/src/pld_common.c b/core/pld/src/pld_common.c index 73d3024279..65ed1cb66c 100644 --- a/core/pld/src/pld_common.c +++ b/core/pld/src/pld_common.c @@ -1767,6 +1767,93 @@ int pld_collect_rddm(struct device *dev) } /** + * pld_qmi_send_get() - Indicate certain data to be sent over QMI + * @dev: device pointer + * + * This API can be used to indicate certain data to be sent over QMI. + * pld_qmi_send() is expected to be called later. + * + * Return: 0 for success + * Non zero failure code for errors + */ +int pld_qmi_send_get(struct device *dev) +{ + enum pld_bus_type type = pld_get_bus_type(dev); + + switch (type) { + case PLD_BUS_TYPE_PCIE: + return pld_pcie_qmi_send_get(dev); + case PLD_BUS_TYPE_SNOC: + case PLD_BUS_TYPE_SDIO: + case PLD_BUS_TYPE_USB: + return 0; + default: + pr_err("Invalid device type %d\n", type); + return -EINVAL; + } +} + +/** + * pld_qmi_send_put() - Indicate response sent over QMI has been processed + * @dev: device pointer + * + * This API can be used to indicate response of the data sent over QMI has + * been processed. + * + * Return: 0 for success + * Non zero failure code for errors + */ +int pld_qmi_send_put(struct device *dev) +{ + enum pld_bus_type type = pld_get_bus_type(dev); + + switch (type) { + case PLD_BUS_TYPE_PCIE: + return pld_pcie_qmi_send_put(dev); + case PLD_BUS_TYPE_SNOC: + case PLD_BUS_TYPE_SDIO: + case PLD_BUS_TYPE_USB: + return 0; + default: + pr_err("Invalid device type %d\n", type); + return -EINVAL; + } +} + +/** + * pld_qmi_send() - Send data request over QMI + * @dev: device pointer + * @type: type of the send data operation + * @cmd: buffer pointer of send data request command + * @cmd_len: size of the command buffer + * @cb_ctx: context pointer if any to pass back in callback + * @cb: callback pointer to pass response back + * + * This API can be used to send data request over QMI. + * + * Return: 0 if data request sends successfully + * Non zero failure code for errors + */ +int pld_qmi_send(struct device *dev, int type, void *cmd, + int cmd_len, void *cb_ctx, + int (*cb)(void *ctx, void *event, int event_len)) +{ + enum pld_bus_type bus_type = pld_get_bus_type(dev); + + switch (bus_type) { + case PLD_BUS_TYPE_PCIE: + return pld_pcie_qmi_send(dev, type, cmd, cmd_len, cb_ctx, cb); + case PLD_BUS_TYPE_SNOC: + case PLD_BUS_TYPE_SDIO: + case PLD_BUS_TYPE_USB: + return -EINVAL; + default: + pr_err("Invalid device type %d\n", bus_type); + return -EINVAL; + } +} + +/** * pld_is_fw_dump_skipped() - get fw dump skipped status. * The subsys ssr status help the driver to decide whether to skip * the FW memory dump when FW assert. diff --git a/core/pld/src/pld_pcie.h b/core/pld/src/pld_pcie.h index 2930881eb1..aab8196ba5 100644 --- a/core/pld/src/pld_pcie.h +++ b/core/pld/src/pld_pcie.h @@ -312,6 +312,24 @@ static inline int pld_pcie_collect_rddm(struct device *dev) return 0; } +static inline int pld_pcie_qmi_send_get(struct device *dev) +{ + return 0; +} + +static inline int pld_pcie_qmi_send_put(struct device *dev) +{ + return 0; +} + +static inline int +pld_pcie_qmi_send(struct device *dev, int type, void *cmd, + int cmd_len, void *cb_ctx, + int (*cb)(void *ctx, void *event, int event_len)) +{ + return -EINVAL; +} + static inline int pld_pcie_get_user_msi_assignment(struct device *dev, char *user_name, int *num_vectors, @@ -357,6 +375,24 @@ static inline int pld_pcie_collect_rddm(struct device *dev) return cnss_force_collect_rddm(dev); } +static inline int pld_pcie_qmi_send_get(struct device *dev) +{ + return cnss_qmi_send_get(dev); +} + +static inline int pld_pcie_qmi_send_put(struct device *dev) +{ + return cnss_qmi_send_put(dev); +} + +static inline int +pld_pcie_qmi_send(struct device *dev, int type, void *cmd, + int cmd_len, void *cb_ctx, + int (*cb)(void *ctx, void *event, int event_len)) +{ + return cnss_qmi_send(dev, type, cmd, cmd_len, cb_ctx, cb); +} + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) static inline void *pld_pcie_smmu_get_domain(struct device *dev) { |