xref: /wlan-driver/qcacld-3.0/components/coex/dispatcher/src/wlan_coex_utils_api.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for any
6*5113495bSYour Name  * purpose with or without fee is hereby granted, provided that the above
7*5113495bSYour Name  * copyright notice and this permission notice appear in all copies.
8*5113495bSYour Name  *
9*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*5113495bSYour Name  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*5113495bSYour Name  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*5113495bSYour Name  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*5113495bSYour Name  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*5113495bSYour Name  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*5113495bSYour Name  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*5113495bSYour Name  */
17*5113495bSYour Name 
18*5113495bSYour Name /**
19*5113495bSYour Name  * DOC: wlan_coex_utils_api.c
20*5113495bSYour Name  *
21*5113495bSYour Name  * This file provides definitions of public APIs exposed to other UMAC
22*5113495bSYour Name  * components.
23*5113495bSYour Name  */
24*5113495bSYour Name 
25*5113495bSYour Name #include <wlan_coex_main.h>
26*5113495bSYour Name #include <wlan_objmgr_global_obj.h>
27*5113495bSYour Name #include <wlan_coex_utils_api.h>
28*5113495bSYour Name #include "cfg_ucfg_api.h"
29*5113495bSYour Name 
wlan_coex_init(void)30*5113495bSYour Name QDF_STATUS wlan_coex_init(void)
31*5113495bSYour Name {
32*5113495bSYour Name 	QDF_STATUS status;
33*5113495bSYour Name 
34*5113495bSYour Name 	status = wlan_objmgr_register_psoc_create_handler(
35*5113495bSYour Name 			WLAN_UMAC_COMP_COEX,
36*5113495bSYour Name 			wlan_coex_psoc_created_notification, NULL);
37*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status)) {
38*5113495bSYour Name 		coex_err("Failed to register psoc create handler");
39*5113495bSYour Name 		goto fail_create_psoc;
40*5113495bSYour Name 	}
41*5113495bSYour Name 
42*5113495bSYour Name 	status = wlan_objmgr_register_psoc_destroy_handler(
43*5113495bSYour Name 			WLAN_UMAC_COMP_COEX,
44*5113495bSYour Name 			wlan_coex_psoc_destroyed_notification, NULL);
45*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status)) {
46*5113495bSYour Name 		coex_err("Failed to create psoc delete handler");
47*5113495bSYour Name 		goto fail_psoc_destroy;
48*5113495bSYour Name 	}
49*5113495bSYour Name 
50*5113495bSYour Name 	coex_debug("coex psoc create and delete handler registered");
51*5113495bSYour Name 	return status;
52*5113495bSYour Name 
53*5113495bSYour Name fail_psoc_destroy:
54*5113495bSYour Name 	wlan_objmgr_unregister_psoc_create_handler(
55*5113495bSYour Name 			WLAN_UMAC_COMP_COEX,
56*5113495bSYour Name 			wlan_coex_psoc_created_notification, NULL);
57*5113495bSYour Name fail_create_psoc:
58*5113495bSYour Name 	return status;
59*5113495bSYour Name }
60*5113495bSYour Name 
wlan_coex_deinit(void)61*5113495bSYour Name QDF_STATUS wlan_coex_deinit(void)
62*5113495bSYour Name {
63*5113495bSYour Name 	QDF_STATUS status;
64*5113495bSYour Name 
65*5113495bSYour Name 	status = wlan_objmgr_unregister_psoc_destroy_handler(
66*5113495bSYour Name 			WLAN_UMAC_COMP_COEX,
67*5113495bSYour Name 			wlan_coex_psoc_destroyed_notification, NULL);
68*5113495bSYour Name 	if (status != QDF_STATUS_SUCCESS)
69*5113495bSYour Name 		coex_err("Failed to unregister psoc delete handler");
70*5113495bSYour Name 
71*5113495bSYour Name 	status = wlan_objmgr_unregister_psoc_create_handler(
72*5113495bSYour Name 			WLAN_UMAC_COMP_COEX,
73*5113495bSYour Name 			wlan_coex_psoc_created_notification, NULL);
74*5113495bSYour Name 	if (status != QDF_STATUS_SUCCESS)
75*5113495bSYour Name 		coex_err("Failed to unregister psoc create handler");
76*5113495bSYour Name 
77*5113495bSYour Name 	return status;
78*5113495bSYour Name }
79*5113495bSYour Name 
80*5113495bSYour Name #ifdef FEATURE_BTC_CHAIN_MODE
81*5113495bSYour Name /**
82*5113495bSYour Name  * wlan_coex_set_btc_chain_mode_with_ini() - set BTC init chain mode
83*5113495bSYour Name  * with ini
84*5113495bSYour Name  * @psoc: pointer to psoc object
85*5113495bSYour Name  *
86*5113495bSYour Name  * This function is used to set BTC init chain mode with ini
87*5113495bSYour Name  *
88*5113495bSYour Name  * Return: None
89*5113495bSYour Name  */
90*5113495bSYour Name static void
wlan_coex_set_btc_chain_mode_with_ini(struct wlan_objmgr_psoc * psoc)91*5113495bSYour Name wlan_coex_set_btc_chain_mode_with_ini(struct wlan_objmgr_psoc *psoc)
92*5113495bSYour Name {
93*5113495bSYour Name 	enum coex_btc_chain_mode btc_chain_mode;
94*5113495bSYour Name 	QDF_STATUS status;
95*5113495bSYour Name 
96*5113495bSYour Name 	status = wlan_coex_psoc_get_btc_chain_mode(psoc, &btc_chain_mode);
97*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status)) {
98*5113495bSYour Name 		coex_err("error for getting btc chain mode");
99*5113495bSYour Name 		return;
100*5113495bSYour Name 	}
101*5113495bSYour Name 
102*5113495bSYour Name 	if (btc_chain_mode == WLAN_COEX_BTC_CHAIN_MODE_UNSETTLED) {
103*5113495bSYour Name 		btc_chain_mode = cfg_get(psoc, CFG_SET_INIT_CHAIN_MODE_FOR_BTC);
104*5113495bSYour Name 		if (btc_chain_mode > WLAN_COEX_BTC_CHAIN_MODE_HYBRID &&
105*5113495bSYour Name 		    btc_chain_mode != WLAN_COEX_BTC_CHAIN_MODE_UNSETTLED) {
106*5113495bSYour Name 			coex_err("invalid ini config %d for btc chain mode",
107*5113495bSYour Name 				 btc_chain_mode);
108*5113495bSYour Name 			return;
109*5113495bSYour Name 		}
110*5113495bSYour Name 
111*5113495bSYour Name 		status = wlan_coex_psoc_set_btc_chain_mode(psoc,
112*5113495bSYour Name 							   btc_chain_mode);
113*5113495bSYour Name 		if (QDF_IS_STATUS_ERROR(status))
114*5113495bSYour Name 			coex_err("error for setting btc init chain mode from ini");
115*5113495bSYour Name 	}
116*5113495bSYour Name }
117*5113495bSYour Name #else
118*5113495bSYour Name static void
wlan_coex_set_btc_chain_mode_with_ini(struct wlan_objmgr_psoc * psoc)119*5113495bSYour Name wlan_coex_set_btc_chain_mode_with_ini(struct wlan_objmgr_psoc *psoc)
120*5113495bSYour Name {
121*5113495bSYour Name }
122*5113495bSYour Name #endif
123*5113495bSYour Name 
124*5113495bSYour Name QDF_STATUS
wlan_coex_psoc_open(struct wlan_objmgr_psoc * psoc)125*5113495bSYour Name wlan_coex_psoc_open(struct wlan_objmgr_psoc *psoc)
126*5113495bSYour Name {
127*5113495bSYour Name 	wlan_coex_set_btc_chain_mode_with_ini(psoc);
128*5113495bSYour Name 	return wlan_coex_psoc_init(psoc);
129*5113495bSYour Name }
130*5113495bSYour Name 
131*5113495bSYour Name QDF_STATUS
wlan_coex_psoc_close(struct wlan_objmgr_psoc * psoc)132*5113495bSYour Name wlan_coex_psoc_close(struct wlan_objmgr_psoc *psoc)
133*5113495bSYour Name {
134*5113495bSYour Name 	return wlan_coex_psoc_deinit(psoc);
135*5113495bSYour Name }
136*5113495bSYour Name 
137*5113495bSYour Name #ifdef WLAN_FEATURE_DBAM_CONFIG
wlan_dbam_psoc_enable(struct wlan_objmgr_psoc * psoc)138*5113495bSYour Name QDF_STATUS wlan_dbam_psoc_enable(struct wlan_objmgr_psoc *psoc)
139*5113495bSYour Name {
140*5113495bSYour Name 	return wlan_dbam_attach(psoc);
141*5113495bSYour Name }
142*5113495bSYour Name 
wlan_dbam_psoc_disable(struct wlan_objmgr_psoc * psoc)143*5113495bSYour Name QDF_STATUS wlan_dbam_psoc_disable(struct wlan_objmgr_psoc *psoc)
144*5113495bSYour Name {
145*5113495bSYour Name 	return wlan_dbam_detach(psoc);
146*5113495bSYour Name }
147*5113495bSYour Name #endif
148