From a36c0f1a99a80b9099f7b643f184cad973e3851e Mon Sep 17 00:00:00 2001 From: Yue Ma Date: Thu, 22 Aug 2019 13:47:17 -0700 Subject: [PATCH] qcacld-3.0: Add QMI send related APIs These APIs can be used to send data request to firmware over QMI as well as receive response from firmware. Change-Id: I186d4c53e846af028b5ea75079027217af1580b4 CRs-fixed: 2517225 --- core/pld/inc/pld_common.h | 5 +++ core/pld/src/pld_common.c | 87 +++++++++++++++++++++++++++++++++++++++ core/pld/src/pld_pcie.h | 36 ++++++++++++++++ 3 files changed, 128 insertions(+) diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h index f92853c481..455b6de8b7 100644 --- a/core/pld/inc/pld_common.h +++ b/core/pld/inc/pld_common.h @@ -643,6 +643,11 @@ int pld_is_fw_down(struct device *dev); void pld_block_shutdown(struct device *dev, bool status); 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 20e6cb3b8c..c1fa5b5bd8 100644 --- a/core/pld/src/pld_common.c +++ b/core/pld/src/pld_common.c @@ -1768,6 +1768,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 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) {