1 /*
2  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. 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_afc_main.h
19  *
20  * This Head file provides declaration for UMAC AFC common APIs.
21  */
22 
23 #ifndef __WLAN_AFC_MAIN_H__
24 #define __WLAN_AFC_MAIN_H__
25 
26 #include <qdf_trace.h>
27 #include <wlan_objmgr_psoc_obj.h>
28 #include <wlan_objmgr_pdev_obj.h>
29 #include <reg_services_public_struct.h>
30 
31 #ifdef CONFIG_AFC_SUPPORT
32 
33 #define afc_alert(params...) \
34 	QDF_TRACE_FATAL(QDF_MODULE_ID_AFC, params)
35 #define afc_err(params...) \
36 	QDF_TRACE_ERROR(QDF_MODULE_ID_AFC, params)
37 #define afc_warn(params...) \
38 	QDF_TRACE_WARN(QDF_MODULE_ID_AFC, params)
39 #define afc_notice(params...) \
40 	QDF_TRACE_INFO(QDF_MODULE_ID_AFC, params)
41 #define afc_info(params...) \
42 	QDF_TRACE_INFO(QDF_MODULE_ID_AFC, params)
43 #define afc_debug(params...) \
44 	QDF_TRACE_DEBUG(QDF_MODULE_ID_AFC, params)
45 
46 /**
47  * afc_psoc_priv() - Helper function to get AFC private object of PSOC
48  * @psoc: Pointer to PSOC object
49  *
50  * Return: AFC private object of PSOC
51  */
52 static inline struct wlan_afc_psoc_priv *
afc_psoc_priv(struct wlan_objmgr_psoc * psoc)53 afc_psoc_priv(struct wlan_objmgr_psoc *psoc)
54 {
55 	struct wlan_afc_psoc_priv *afc_priv;
56 
57 	afc_priv = wlan_objmgr_psoc_get_comp_private_obj(psoc,
58 							 WLAN_UMAC_COMP_AFC);
59 	return afc_priv;
60 }
61 
62 /**
63  * typedef send_response_to_afcmem() - Function prototype of send AFC response
64  * to share memory.
65  * @psoc: Pointer to PSOC object
66  * @pdev: Pointer to PDEV object
67  * @data: AFC response data
68  * @len: AFC response length
69  *
70  * Return: 0 if success, otherwise failure
71  */
72 typedef int (*send_response_to_afcmem)(struct wlan_objmgr_psoc *psoc,
73 				       struct wlan_objmgr_pdev *pdev,
74 				       struct wlan_afc_host_resp *data,
75 				       uint32_t len);
76 
77 /**
78  * typedef osif_send_afc_request() - Function prototype of sending
79  * AFC request to osif.
80  * @pdev: Pointer to PDEV object
81  * @afc_req: Pointer to AFC request
82  *
83  * Return: 0 if success, otherwise failure
84  */
85 typedef int
86 (*osif_send_afc_request)(struct wlan_objmgr_pdev *pdev,
87 			 struct wlan_afc_host_request *afc_req);
88 
89 /**
90  * typedef osif_send_afc_power_update_complete() - Function prototype of sending
91  * AFC update complete event to osif.
92  * @pdev: Pointer to PDEV object
93  * @afc_pwr_evt: Pointer to AFC power update event
94  *
95  * Return: 0 if success, otherwise failure
96  */
97 typedef int
98 (*osif_send_afc_power_update_complete)(struct wlan_objmgr_pdev *pdev,
99 				       struct reg_fw_afc_power_event *afc_pwr_evt);
100 
101 /**
102  * wlan_afc_data_send() - Function to send AFC response through platform
103  * interface
104  * @psoc: Pointer to PSOC object
105  * @pdev: Pointer to PDEV object
106  * @data: Pointer to AFC response data
107  * @len: AFC response data length in bytes
108  *
109  * Return: 0 if success, otherwise failure
110  */
111 int wlan_afc_data_send(struct wlan_objmgr_psoc *psoc,
112 		       struct wlan_objmgr_pdev *pdev,
113 		       struct wlan_afc_host_resp *data,
114 		       uint32_t len);
115 
116 /**
117  * wlan_afc_register_data_send_cb() - Function to register data send AFC
118  * callback
119  * @psoc: Pointer to PSOC object
120  * @func: AFC PLD function to be register
121  *
122  * Return: QDF STATUS
123  */
124 QDF_STATUS wlan_afc_register_data_send_cb(struct wlan_objmgr_psoc *psoc,
125 					  send_response_to_afcmem func);
126 
127 /**
128  * wlan_afc_psoc_created_notification() - Callback function to be invoked when
129  * POSC create AFC component.
130  * @psoc: Pointer to PSOC object
131  * @arg: Pointer to argument list
132  *
133  * Return: QDF STATUS
134  */
135 QDF_STATUS
136 wlan_afc_psoc_created_notification(struct wlan_objmgr_psoc *psoc,
137 				   void *arg);
138 
139 /**
140  * wlan_afc_psoc_destroyed_notification() - Callback function to be invoked when
141  * PSOC destroy AFC component.
142  * @psoc: Pointer to PSOC object
143  * @arg: Pointer to argument list
144  *
145  * Return: QDF STATUS
146  */
147 QDF_STATUS
148 wlan_afc_psoc_destroyed_notification(struct wlan_objmgr_psoc *psoc,
149 				     void *arg);
150 
151 /**
152  * wlan_afc_pdev_obj_create_handler() - Callback function of PDEV create AFC
153  * component.
154  * @pdev: Pointer to PDEV object
155  * @arg: Pointer to argument list
156  *
157  * Return: QDF STATUS
158  */
159 QDF_STATUS
160 wlan_afc_pdev_obj_create_handler(struct wlan_objmgr_pdev *pdev,
161 				 void *arg);
162 
163 /**
164  * wlan_afc_pdev_obj_destroy_handler() - Callback function of PDEV destroy AFC
165  * component.
166  * @pdev: Pointer to PDEV object
167  * @arg: Pointer to argument list
168  *
169  * Return: QDF STATUS
170  */
171 QDF_STATUS
172 wlan_afc_pdev_obj_destroy_handler(struct wlan_objmgr_pdev *pdev, void *arg);
173 #endif
174 #endif
175