Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87785ff8 authored by Chaoli Zhou's avatar Chaoli Zhou Committed by Madan Koyyalamudi
Browse files

qcacmn: Add and enable GPIO Component

Add the common GPIO component code for MCC and WIN

Change-Id: Id93629856d42afc433844b568deb2fa63a5b67e6
parent b4d54f2a
Loading
Loading
Loading
Loading
+59 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2020-2021, 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
Original line number Diff line number Diff line
/*
 * Copyright (c) 2020-2021, 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
Original line number Diff line number Diff line
/*
 * Copyright (c) 2020-2021, 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
Original line number Diff line number Diff line
/*
 * Copyright (c) 2020-2021, 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
Original line number Diff line number Diff line
/*
 * Copyright (c) 2020-2021, 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__ */
Loading