Browse Source

qcacmn: Add support to config gpio cfg/output

Add support to config gpio cfg/output

CRs-Fixed: 2785829
Change-Id: Ibb26a36791de584ee6a90d539e17d326545633fa
Surya Prakash Raajen 4 years ago
parent
commit
8e8ac2c5d1

+ 37 - 0
gpio/dispatcher/inc/wlan_gpio_tgt_api.h

@@ -49,5 +49,42 @@ tgt_set_gpio_config_req(struct wlan_objmgr_psoc *psoc,
 QDF_STATUS
 tgt_set_gpio_output_req(struct wlan_objmgr_psoc *psoc,
 			struct gpio_output_params *param);
+
+/**
+ * tgt_if_gpio_config() - API to send gpio config request
+ * @psoc: pointer to psoc object
+ * @gpio_num: gpio pin number
+ * @input: enable/disable the gpio pin
+ * @pull_type: gpio pull type
+ * @intr_mode: gpio interrupt mode
+ *
+ * Return: status of operation
+ */
+QDF_STATUS tgt_gpio_config(struct wlan_objmgr_psoc *psoc, uint32_t gpio_num,
+			   uint32_t input, uint32_t pull_type,
+			   uint32_t intr_mode);
+/**
+ * tgt_if_gpio_output() - API to send gpio output request
+ * @psoc: pointer to psoc object
+ * @gpio_num: gpio pin number
+ * @set: enable/disable the gpio pin
+ *
+ * Return: status of operation
+ */
+QDF_STATUS tgt_gpio_output(struct wlan_objmgr_psoc *psoc, uint32_t gpio_num,
+			   uint32_t set);
+#else
+static QDF_STATUS tgt_gpio_config(struct wlan_objmgr_psoc *psoc,
+				  uint32_t gpio_num, uint32_t input,
+				  uint32_t pull_type, uint32_t intr_mode)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS tgt_gpio_output(struct wlan_objmgr_psoc *psoc,
+				  uint32_t gpio_num, uint32_t set)
+{
+	return QDF_STATUS_SUCCESS;
+}
 #endif /* WLAN_FEATURE_GPIO_CFG */
 #endif /* __WLAN_GPIO_TGT_API_H__ */

+ 0 - 14
gpio/dispatcher/inc/wlan_gpio_ucfg_api.h

@@ -48,19 +48,5 @@ QDF_STATUS ucfg_set_gpio_config(struct wlan_objmgr_psoc *psoc,
  */
 QDF_STATUS ucfg_set_gpio_output(struct wlan_objmgr_psoc *psoc,
 				struct gpio_output_params *param);
-#else
-static inline
-QDF_STATUS ucfg_set_gpio_config(struct wlan_objmgr_psoc *psoc,
-				struct gpio_config_params *param)
-{
-	return QDF_STATUS_SUCCESS;
-}
-
-static inline
-QDF_STATUS ucfg_set_gpio_output(struct wlan_objmgr_psoc *psoc,
-				struct gpio_output_params *param)
-{
-	return QDF_STATUS_SUCCESS;
-}
 #endif /* WLAN_FEATURE_GPIO_CFG */
 #endif /* __WLAN_GPIO_CFG_UCFG_API_H__ */

+ 73 - 0
gpio/dispatcher/src/wlan_gpio_tgt_api.c

@@ -21,6 +21,8 @@
  */
 #include <wlan_gpio_priv_api.h>
 #include <wlan_gpio_tgt_api.h>
+#include <target_type.h>
+#include <qdf_module.h>
 
 QDF_STATUS tgt_set_gpio_config_req(struct wlan_objmgr_psoc *psoc,
 				   struct gpio_config_params *param)
@@ -54,3 +56,74 @@ QDF_STATUS tgt_set_gpio_output_req(struct wlan_objmgr_psoc *psoc,
 
 	return gpio_tx_ops->set_gpio_output(psoc, param);
 }
+
+QDF_STATUS tgt_gpio_config(struct wlan_objmgr_psoc *psoc, uint32_t gpio_num,
+			   uint32_t input, uint32_t pull_type,
+			   uint32_t intr_mode)
+{
+	struct gpio_config_params param;
+
+	if (!psoc) {
+		gpio_err("psoc_obj is null");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	qdf_mem_set(&param, sizeof(param), 0);
+	param.pin_pull_type = pull_type;
+	param.pin_num = gpio_num;
+	param.pin_dir = input;
+	param.pin_intr_mode = intr_mode;
+
+	return tgt_set_gpio_config_req(psoc, &param);
+}
+
+qdf_export_symbol(tgt_gpio_config);
+
+static bool tgt_gpio_disabled(struct wlan_objmgr_psoc *psoc)
+{
+	uint32_t target_type = 0;
+	struct wlan_lmac_if_target_tx_ops *target_type_tx_ops;
+	struct wlan_lmac_if_tx_ops *tx_ops;
+
+	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
+	if (!tx_ops) {
+		gpio_err("tx_ops is NULL");
+		return false;
+	}
+	target_type_tx_ops = &tx_ops->target_tx_ops;
+
+	if (target_type_tx_ops->tgt_get_tgt_type)
+		target_type = target_type_tx_ops->tgt_get_tgt_type(psoc);
+
+	if ((target_type == TARGET_TYPE_QCA8074) ||
+	    (target_type == TARGET_TYPE_QCN9100) ||
+	    (target_type == TARGET_TYPE_QCA8074V2) ||
+	    (target_type == TARGET_TYPE_QCA5018) ||
+	    (target_type == TARGET_TYPE_QCA6018)) {
+		return true;
+	}
+
+	return false;
+}
+
+QDF_STATUS tgt_gpio_output(struct wlan_objmgr_psoc *psoc, uint32_t gpio_num,
+			   uint32_t set)
+{
+	struct gpio_output_params param;
+
+	if (!psoc) {
+		gpio_err("psoc_obj is null");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	if (tgt_gpio_disabled(psoc))
+		return QDF_STATUS_E_INVAL;
+
+	qdf_mem_set(&param, sizeof(param), 0);
+	param.pin_num = gpio_num;
+	param.pin_set = set;
+
+	return tgt_set_gpio_output_req(psoc, &param);
+}
+
+qdf_export_symbol(tgt_gpio_output);