Selaa lähdekoodia

qcacmn: Add and enable GPIO Component

Add the common GPIO component code for MCC and WIN

Change-Id: Id93629856d42afc433844b568deb2fa63a5b67e6
Chaoli Zhou 4 vuotta sitten
vanhempi
sitoutus
eb134979c1

+ 59 - 0
gpio/core/inc/wlan_gpio_api.h

@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2020, The Linux Foundation. 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 above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: wlan_gpio_api.h
+ *
+ * This header file provide API declarations required for gpio cfg
+ * that called by other components
+ */
+
+#ifndef __WLAN_GPIO_CFG_API_H__
+#define __WLAN_GPIO_CFG_API_H__
+
+#include <qdf_types.h>
+
+#ifdef WLAN_FEATURE_GPIO_CFG
+
+/**
+ * wlan_gpio_init() - API to init component
+ *
+ * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
+ */
+QDF_STATUS wlan_gpio_init(void);
+
+/**
+ * wlan_gpio_deinit() - API to deinit component
+ *
+ * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
+ */
+QDF_STATUS wlan_gpio_deinit(void);
+
+#else
+static inline
+QDF_STATUS wlan_gpio_init(void)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline
+QDF_STATUS wlan_gpio_deinit(void)
+{
+	return QDF_STATUS_SUCCESS;
+}
+#endif /* WLAN_FEATURE_GPIO_CFG */
+#endif /*__WLAN_GPIO_CFG_API_H__*/
+

+ 86 - 0
gpio/core/inc/wlan_gpio_priv_api.h

@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2020, The Linux Foundation. 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 above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: wlan_gpio_priv_api.h
+ *
+ * This header file provide API declarations required for gpio cfg
+ * that called internally
+ */
+
+#ifndef __WLAN_GPIO_CFG_PRIV_API_H__
+#define __WLAN_GPIO_CFG_PRIV_API_H__
+
+#include <wlan_objmgr_psoc_obj.h>
+#include <wlan_lmac_if_def.h>
+#include <qdf_lock.h>
+
+#define gpio_debug(args ...) \
+	QDF_TRACE_DEBUG(QDF_MODULE_ID_GPIO, ## args)
+#define gpio_err(args ...) \
+	QDF_TRACE_ERROR(QDF_MODULE_ID_GPIO, ## args)
+
+/**
+ * struct gpio_psoc_priv_obj - psoc private object
+ * @lock: qdf spin lock
+ * @soc: pointer to psoc object
+ */
+struct gpio_psoc_priv_obj {
+	qdf_spinlock_t lock;
+	struct wlan_objmgr_psoc *soc;
+};
+
+/**
+ * gpio_get_psoc_priv_obj() - get priv object from psoc object
+ * @psoc: pointer to psoc object
+ *
+ * Return: pointer to gpio psoc private object
+ */
+static inline
+struct gpio_psoc_priv_obj *
+gpio_get_psoc_priv_obj(struct wlan_objmgr_psoc *psoc)
+{
+	struct gpio_psoc_priv_obj *obj;
+
+	if (!psoc)
+		return NULL;
+	obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
+						    WLAN_UMAC_COMP_GPIO);
+
+	return obj;
+}
+
+/**
+ * wlan_psoc_get_gpio_txops() - get TX ops from the private object
+ * @psoc: pointer to psoc object
+ *
+ * Return: pointer to TX op callback
+ */
+
+static inline struct wlan_lmac_if_gpio_tx_ops *
+wlan_psoc_get_gpio_txops(struct wlan_objmgr_psoc *psoc)
+{
+	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 NULL;
+	}
+
+	return &tx_ops->gpio_ops;
+}
+#endif /*__WLAN_GPIO_CFG_PRIV_API_H__*/

+ 158 - 0
gpio/core/src/wlan_gpio_api.c

@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2020, The Linux Foundation. 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 above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: wlan_gpio_api.c
+ */
+#include <wlan_gpio_api.h>
+#include <wlan_gpio_priv_api.h>
+#include <wlan_objmgr_global_obj.h>
+
+/**
+ * gpio_psoc_obj_created_notification() - PSOC obj create callback
+ * @psoc: PSOC object
+ * @arg_list: Variable argument list
+ *
+ * This callback is registered with object manager during initialization to
+ * get notified when the object is created.
+ *
+ * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
+ */
+static QDF_STATUS
+gpio_psoc_obj_created_notification(struct wlan_objmgr_psoc *psoc,
+				   void *arg_list)
+{
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+	struct gpio_psoc_priv_obj *gpio_obj;
+
+	gpio_obj = qdf_mem_malloc(sizeof(*gpio_obj));
+	if (!gpio_obj)
+		return QDF_STATUS_E_NOMEM;
+
+	qdf_spinlock_create(&gpio_obj->lock);
+	status = wlan_objmgr_psoc_component_obj_attach(psoc,
+						       WLAN_UMAC_COMP_GPIO,
+						       gpio_obj,
+						       QDF_STATUS_SUCCESS);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		gpio_err("obj attach with psoc failed");
+		goto gpio_psoc_attach_failed;
+	}
+
+	return QDF_STATUS_SUCCESS;
+
+gpio_psoc_attach_failed:
+	qdf_spinlock_destroy(&gpio_obj->lock);
+	qdf_mem_free(gpio_obj);
+	return status;
+}
+
+/**
+ * gpio_psoc_obj_destroyed_notification() - obj delete callback
+ * @psoc: PSOC object
+ * @arg_list: Variable argument list
+ *
+ * This callback is registered with object manager during initialization to
+ * get notified when the object is deleted.
+ *
+ * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
+ */
+static QDF_STATUS
+gpio_psoc_obj_destroyed_notification(struct wlan_objmgr_psoc *psoc,
+				     void *arg_list)
+{
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+	struct gpio_psoc_priv_obj *gpio_obj;
+
+	gpio_obj = gpio_get_psoc_priv_obj(psoc);
+
+	if (!gpio_obj) {
+		gpio_err("gpio_obj is NULL");
+		return QDF_STATUS_E_FAULT;
+	}
+
+	status = wlan_objmgr_psoc_component_obj_detach(psoc,
+						       WLAN_UMAC_COMP_GPIO,
+						       gpio_obj);
+	if (QDF_IS_STATUS_ERROR(status))
+		gpio_err("gpio_obj detach failed");
+
+	qdf_spinlock_destroy(&gpio_obj->lock);
+	qdf_mem_free(gpio_obj);
+
+	return status;
+}
+
+QDF_STATUS wlan_gpio_init(void)
+{
+	QDF_STATUS status;
+
+	/* register psoc create handler functions. */
+	status = wlan_objmgr_register_psoc_create_handler(
+			WLAN_UMAC_COMP_GPIO,
+			gpio_psoc_obj_created_notification,
+			NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		gpio_err("register create handler failed");
+		return status;
+	}
+
+	/* register psoc delete handler functions. */
+	status = wlan_objmgr_register_psoc_destroy_handler(
+			WLAN_UMAC_COMP_GPIO,
+			gpio_psoc_obj_destroyed_notification,
+			NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		gpio_err("register destroy handler failed");
+		goto fail_delete_psoc;
+	}
+
+	return status;
+
+fail_delete_psoc:
+	wlan_objmgr_unregister_psoc_create_handler(
+				WLAN_UMAC_COMP_GPIO,
+				gpio_psoc_obj_created_notification,
+				NULL);
+	return status;
+}
+
+QDF_STATUS wlan_gpio_deinit(void)
+{
+	QDF_STATUS ret = QDF_STATUS_SUCCESS, status;
+
+	/* unregister psoc delete handler functions. */
+	status = wlan_objmgr_unregister_psoc_destroy_handler(
+			WLAN_UMAC_COMP_GPIO,
+			gpio_psoc_obj_destroyed_notification,
+			NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		gpio_err("unregister destroy handler failed");
+		ret = status;
+	}
+
+	/* unregister psoc create handler functions. */
+	status = wlan_objmgr_unregister_psoc_create_handler(
+			WLAN_UMAC_COMP_GPIO,
+			gpio_psoc_obj_created_notification,
+			NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		gpio_err("unregister create handler failed");
+		ret = status;
+	}
+
+	return ret;
+}

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

@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2020, The Linux Foundation. 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 above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: wlan_gpio_tgt_api.h
+ *
+ * This header file provide with API declarations to interface with Southbound
+ */
+#ifndef __WLAN_GPIO_CFG_TGT_API_H__
+#define __WLAN_GPIO_CFG_TGT_API_H__
+
+#ifdef WLAN_FEATURE_GPIO_CFG
+#include <qdf_status.h>
+#include <wmi_unified_param.h>
+struct wlan_objmgr_psoc;
+
+/**
+ * tgt_set_gpio_config_req(): API to set GPIO configuration to lmac
+ * @psoc: the pointer to psoc object manager
+ * @param: the pointer to gpio cfg info
+ *
+ * Return: status of operation
+ */
+QDF_STATUS
+tgt_set_gpio_config_req(struct wlan_objmgr_psoc *psoc,
+			struct gpio_config_params *param);
+
+/**
+ * tgt_set_gpio_output_req(): API to set GPIO output info to lmac
+ * @psoc: the pointer to psoc object manager
+ * @param: the pointer to gpio output info
+ *
+ * Return: status of operation
+ */
+
+QDF_STATUS
+tgt_set_gpio_output_req(struct wlan_objmgr_psoc *psoc,
+			struct gpio_output_params *param);
+#endif /* WLAN_FEATURE_GPIO_CFG */
+#endif /* __WLAN_GPIO_TGT_API_H__ */

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

@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2020, The Linux Foundation. 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 above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: wlan_gpio_ucfg_api.h
+ *
+ * This header file maintain API declaration required for northbound interaction
+ */
+
+#ifndef __WLAN_GPIO_CFG_UCFG_API_H__
+#define __WLAN_GPIO_CFG_UCFG_API_H__
+
+#include <qdf_status.h>
+#include <wmi_unified_param.h>
+struct wlan_objmgr_psoc;
+
+#ifdef WLAN_FEATURE_GPIO_CFG
+
+/**
+ * ucfg_set_gpio_config() - API to set gpio config
+ * @psoc: the pointer of psoc object
+ * @param: the pointer of gpio configuration info
+ *
+ * Return:QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
+ */
+QDF_STATUS ucfg_set_gpio_config(struct wlan_objmgr_psoc *psoc,
+				struct gpio_config_params *param);
+
+/**
+ * ucfg_set_gpio_output() - API to set gpio output
+ * @psoc: the pointer of psoc object
+ * @param: the pointer of gpio output info
+ *
+ * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
+ */
+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__ */

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

@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2020, The Linux Foundation. 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 above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC:wlan_gpio_tgt_api.c
+ *
+ * This file provide API definitions to update gpio configuration from interface
+ */
+#include <wlan_gpio_priv_api.h>
+#include <wlan_gpio_tgt_api.h>
+
+QDF_STATUS tgt_set_gpio_config_req(struct wlan_objmgr_psoc *psoc,
+				   struct gpio_config_params *param)
+{
+	struct wlan_lmac_if_gpio_tx_ops *gpio_tx_ops;
+
+	if (!psoc) {
+		gpio_err("NULL psoc");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+	gpio_tx_ops = wlan_psoc_get_gpio_txops(psoc);
+	if (!gpio_tx_ops)
+		return QDF_STATUS_E_NULL_VALUE;
+
+	return gpio_tx_ops->set_gpio_config(psoc, param);
+}
+
+QDF_STATUS tgt_set_gpio_output_req(struct wlan_objmgr_psoc *psoc,
+				   struct gpio_output_params *param)
+{
+	struct wlan_lmac_if_gpio_tx_ops *gpio_tx_ops;
+
+	if (!psoc) {
+		gpio_err("NULL psoc");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	gpio_tx_ops = wlan_psoc_get_gpio_txops(psoc);
+	if (!gpio_tx_ops)
+		return QDF_STATUS_E_NULL_VALUE;
+
+	return gpio_tx_ops->set_gpio_output(psoc, param);
+}

+ 38 - 0
gpio/dispatcher/src/wlan_gpio_ucfg_api.c

@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2020, The Linux Foundation. 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 above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: This file contains gpio north bound interface definitions
+ */
+#include <wlan_gpio_ucfg_api.h>
+#include <wlan_gpio_tgt_api.h>
+#include "qdf_module.h"
+
+QDF_STATUS
+ucfg_set_gpio_config(struct wlan_objmgr_psoc *psoc,
+		     struct gpio_config_params *param)
+{
+	return tgt_set_gpio_config_req(psoc, param);
+}
+qdf_export_symbol(ucfg_set_gpio_config);
+
+QDF_STATUS
+ucfg_set_gpio_output(struct wlan_objmgr_psoc *psoc,
+		     struct gpio_output_params *param)
+{
+	return tgt_set_gpio_output_req(psoc, param);
+}
+qdf_export_symbol(ucfg_set_gpio_output);

+ 9 - 0
init_deinit/dispatcher/src/dispatcher_init_deinit.c

@@ -85,6 +85,8 @@
 #include <wlan_if_mgr_main.h>
 #endif
 
+#include <wlan_gpio_api.h>
+
 /**
  * DOC: This file provides various init/deinit trigger point for new
  * components.
@@ -1006,6 +1008,9 @@ QDF_STATUS dispatcher_init(void)
 	if (QDF_STATUS_SUCCESS != dispatcher_if_mgr_init())
 		goto ifmgr_init_fail;
 
+	if (QDF_STATUS_SUCCESS != wlan_gpio_init())
+		goto gpio_init_fail;
+
 	/*
 	 * scheduler INIT has to be the last as each component's
 	 * initialization has to happen first and then at the end
@@ -1017,6 +1022,8 @@ QDF_STATUS dispatcher_init(void)
 	return QDF_STATUS_SUCCESS;
 
 scheduler_init_fail:
+	wlan_gpio_deinit();
+gpio_init_fail:
 	dispatcher_if_mgr_deinit();
 ifmgr_init_fail:
 	dispatcher_coex_deinit();
@@ -1076,6 +1083,8 @@ QDF_STATUS dispatcher_deinit(void)
 
 	QDF_BUG(QDF_STATUS_SUCCESS == scheduler_deinit());
 
+	QDF_BUG(QDF_STATUS_SUCCESS == wlan_gpio_deinit());
+
 	QDF_BUG(QDF_STATUS_SUCCESS == dispatcher_if_mgr_deinit());
 
 	QDF_BUG(QDF_STATUS_SUCCESS == dispatcher_coex_deinit());

+ 17 - 0
target_if/core/src/target_if_main.c

@@ -93,6 +93,8 @@
 #include <target_if_dcs.h>
 #endif
 
+#include <target_if_gpio.h>
+
 static struct target_if_ctx *g_target_if_ctx;
 
 struct target_if_ctx *target_if_get_ctx()
@@ -460,6 +462,19 @@ void target_if_ftm_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
 }
 #endif
 
+#ifdef WLAN_FEATURE_GPIO_CFG
+static
+void target_if_gpio_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
+{
+	target_if_gpio_register_tx_ops(tx_ops);
+}
+#else
+static
+void target_if_gpio_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
+{
+}
+#endif
+
 static
 QDF_STATUS target_if_register_umac_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
 {
@@ -506,6 +521,8 @@ QDF_STATUS target_if_register_umac_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
 
 	target_if_coex_tx_ops_register(tx_ops);
 
+	target_if_gpio_tx_ops_register(tx_ops);
+
 	/* Converged UMAC components to register their TX-ops here */
 	return QDF_STATUS_SUCCESS;
 }

+ 89 - 0
target_if/gpio/target_if_gpio.c

@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2020, The Linux Foundation. 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 above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: target_if_gpio.c
+ *
+ * This file provide definition for APIs registered through lmac Tx Ops
+ */
+
+#include <qdf_status.h>
+#include <target_if.h>
+#include <wlan_gpio_priv_api.h>
+#include <target_if_gpio.h>
+#include <wmi_unified_gpio_api.h>
+
+/**
+ * target_if_set_gpio_config() - API to send gpio config request to wmi
+ * @psoc: pointer to psoc object
+ * @param: pointer to gpio info
+ *
+ * Return: status of operation.
+ */
+static QDF_STATUS
+target_if_set_gpio_config(struct wlan_objmgr_psoc *psoc,
+			  struct gpio_config_params *param)
+{
+	struct wmi_unified *wmi_handle;
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("wmi_handle is null.");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	return wmi_unified_gpio_config_cmd_send(wmi_handle, param);
+}
+
+/**
+ * target_if_set_gpio_output() - API to send gpio output request to wmi
+ * @psoc: pointer to psoc object
+ * @param: pointer to gpio info
+ *
+ * Return: status of operation.
+ */
+static QDF_STATUS
+target_if_set_gpio_output(struct wlan_objmgr_psoc *psoc,
+			  struct gpio_output_params *param)
+{
+	struct wmi_unified *wmi_handle;
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("wmi_handle is null.");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	return wmi_unified_gpio_output_cmd_send(wmi_handle, param);
+}
+
+QDF_STATUS
+target_if_gpio_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
+{
+	struct wlan_lmac_if_gpio_tx_ops *gpio_ops;
+
+	if (!tx_ops) {
+		target_if_err("tx ops is NULL!");
+		return QDF_STATUS_E_INVAL;
+	}
+	gpio_ops = &tx_ops->gpio_ops;
+
+	gpio_ops->set_gpio_config = target_if_set_gpio_config;
+	gpio_ops->set_gpio_output = target_if_set_gpio_output;
+
+	return QDF_STATUS_SUCCESS;
+}
+

+ 37 - 0
target_if/gpio/target_if_gpio.h

@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2020, The Linux Foundation. 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 above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: offload lmac interface APIs for gpio cfg
+ */
+#ifndef __TARGET_IF_GPIO_CFG_H__
+#define __TARGET_IF_GPIO_CFG_H__
+
+#ifdef WLAN_FEATURE_GPIO_CFG
+#include <qdf_status.h>
+struct wlan_lmac_if_tx_ops;
+
+/**
+ * target_if_gpio_register_tx_ops() - register tx ops funcs
+ * @tx_ops: pointer to gpio tx ops
+ *
+ * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
+ */
+QDF_STATUS
+target_if_gpio_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops);
+
+#endif /* WLAN_FEATURE_GPIO_CFG */
+#endif /* __TARGET_IF_GPIO_CFG_H__ */

+ 22 - 0
umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h

@@ -1037,6 +1037,23 @@ struct wlan_lmac_if_coex_tx_ops {
 };
 #endif
 
+#ifdef WLAN_FEATURE_GPIO_CFG
+struct gpio_config_params;
+struct gpio_output_params;
+
+/**
+ * struct wlan_lmac_if_gpio_tx_ops - south bound tx function pointers for gpio
+ * @set_gpio_config: function pointert to send gpio config to fw
+ * @set_gpio_output: function pointert to send gpio output to fw
+ */
+struct wlan_lmac_if_gpio_tx_ops {
+	QDF_STATUS (*set_gpio_config)(struct wlan_objmgr_psoc *psoc,
+				      struct gpio_config_params *param);
+	QDF_STATUS (*set_gpio_output)(struct wlan_objmgr_psoc *psoc,
+				      struct gpio_output_params *param);
+};
+#endif
+
 /**
  * struct wlan_lmac_if_tx_ops - south bound tx function pointers
  * @mgmt_txrx_tx_ops: mgmt txrx tx ops
@@ -1045,6 +1062,7 @@ struct wlan_lmac_if_coex_tx_ops {
  * @green_ap_tx_ops: green_ap tx_ops
  * @cp_stats_tx_ops: cp stats tx_ops
  * @coex_ops: coex tx_ops
+ * @gpio_ops: gpio tx_ops
  *
  * Callback function tabled to be registered with umac.
  * umac will use the functional table to send events/frames to wmi
@@ -1126,6 +1144,10 @@ struct wlan_lmac_if_tx_ops {
 #ifdef FEATURE_COEX
 	struct wlan_lmac_if_coex_tx_ops coex_ops;
 #endif
+
+#ifdef WLAN_FEATURE_GPIO_CFG
+	struct wlan_lmac_if_gpio_tx_ops gpio_ops;
+#endif
 };
 
 /**