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: target_if_gpio.c
19  *
20  * This file provide definition for APIs registered through lmac Tx Ops
21  */
22 
23 #include <qdf_status.h>
24 #include <target_if.h>
25 #include <wlan_gpio_priv_api.h>
26 #include <target_if_gpio.h>
27 #include <wmi_unified_gpio_api.h>
28 
29 /**
30  * target_if_set_gpio_config() - API to send gpio config request to wmi
31  * @psoc: pointer to psoc object
32  * @param: pointer to gpio info
33  *
34  * Return: status of operation.
35  */
36 static QDF_STATUS
target_if_set_gpio_config(struct wlan_objmgr_psoc * psoc,struct gpio_config_params * param)37 target_if_set_gpio_config(struct wlan_objmgr_psoc *psoc,
38 			  struct gpio_config_params *param)
39 {
40 	struct wmi_unified *wmi_handle;
41 
42 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
43 	if (!wmi_handle) {
44 		target_if_err("wmi_handle is null.");
45 		return QDF_STATUS_E_NULL_VALUE;
46 	}
47 
48 	return wmi_unified_gpio_config_cmd_send(wmi_handle, param);
49 }
50 
51 /**
52  * target_if_set_gpio_output() - API to send gpio output request to wmi
53  * @psoc: pointer to psoc object
54  * @param: pointer to gpio info
55  *
56  * Return: status of operation.
57  */
58 static QDF_STATUS
target_if_set_gpio_output(struct wlan_objmgr_psoc * psoc,struct gpio_output_params * param)59 target_if_set_gpio_output(struct wlan_objmgr_psoc *psoc,
60 			  struct gpio_output_params *param)
61 {
62 	struct wmi_unified *wmi_handle;
63 
64 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
65 	if (!wmi_handle) {
66 		target_if_err("wmi_handle is null.");
67 		return QDF_STATUS_E_NULL_VALUE;
68 	}
69 
70 	return wmi_unified_gpio_output_cmd_send(wmi_handle, param);
71 }
72 
73 QDF_STATUS
target_if_gpio_register_tx_ops(struct wlan_lmac_if_tx_ops * tx_ops)74 target_if_gpio_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
75 {
76 	struct wlan_lmac_if_gpio_tx_ops *gpio_ops;
77 
78 	if (!tx_ops) {
79 		target_if_err("tx ops is NULL!");
80 		return QDF_STATUS_E_INVAL;
81 	}
82 	gpio_ops = &tx_ops->gpio_ops;
83 
84 	gpio_ops->set_gpio_config = target_if_set_gpio_config;
85 	gpio_ops->set_gpio_output = target_if_set_gpio_output;
86 
87 	return QDF_STATUS_SUCCESS;
88 }
89 
90