1 /*
2 * Copyright (c) 2020, The Linux Foundation. All rights reserved.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 /**
18 * DOC: wlan_gpio_priv_api.h
19 *
20 * This header file provide API declarations required for gpio cfg
21 * that called internally
22 */
23
24 #ifndef __WLAN_GPIO_CFG_PRIV_API_H__
25 #define __WLAN_GPIO_CFG_PRIV_API_H__
26
27 #include <wlan_objmgr_psoc_obj.h>
28 #include <wlan_lmac_if_def.h>
29 #include <qdf_lock.h>
30
31 #define gpio_debug(args ...) \
32 QDF_TRACE_DEBUG(QDF_MODULE_ID_GPIO, ## args)
33 #define gpio_err(args ...) \
34 QDF_TRACE_ERROR(QDF_MODULE_ID_GPIO, ## args)
35
36 /**
37 * struct gpio_psoc_priv_obj - psoc private object
38 * @lock: qdf spin lock
39 * @soc: pointer to psoc object
40 */
41 struct gpio_psoc_priv_obj {
42 qdf_spinlock_t lock;
43 struct wlan_objmgr_psoc *soc;
44 };
45
46 /**
47 * gpio_get_psoc_priv_obj() - get priv object from psoc object
48 * @psoc: pointer to psoc object
49 *
50 * Return: pointer to gpio psoc private object
51 */
52 static inline
53 struct gpio_psoc_priv_obj *
gpio_get_psoc_priv_obj(struct wlan_objmgr_psoc * psoc)54 gpio_get_psoc_priv_obj(struct wlan_objmgr_psoc *psoc)
55 {
56 struct gpio_psoc_priv_obj *obj;
57
58 if (!psoc)
59 return NULL;
60 obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
61 WLAN_UMAC_COMP_GPIO);
62
63 return obj;
64 }
65
66 /**
67 * wlan_psoc_get_gpio_txops() - get TX ops from the private object
68 * @psoc: pointer to psoc object
69 *
70 * Return: pointer to TX op callback
71 */
72
73 static inline struct wlan_lmac_if_gpio_tx_ops *
wlan_psoc_get_gpio_txops(struct wlan_objmgr_psoc * psoc)74 wlan_psoc_get_gpio_txops(struct wlan_objmgr_psoc *psoc)
75 {
76 struct wlan_lmac_if_tx_ops *tx_ops;
77
78 tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
79 if (!tx_ops) {
80 gpio_err("tx_ops is NULL");
81 return NULL;
82 }
83
84 return &tx_ops->gpio_ops;
85 }
86 #endif /*__WLAN_GPIO_CFG_PRIV_API_H__*/
87