blob: f96c128aa19d492f6da9b5d682d46efbc746315a [file] [log] [blame]
Govind Singhd475ea92016-03-06 19:55:02 +05301/*
2 * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 * This file contains the API definitions for the Unified Wireless Module Interface (WMI).
30 */
31
32#ifndef _WMI_UNIFIED_API_H_
33#define _WMI_UNIFIED_API_H_
34
35#include <osdep.h>
36#include "a_types.h"
37#include "ol_defines.h"
38#include "wmi.h"
39#include "htc_api.h"
40
41typedef cdf_nbuf_t wmi_buf_t;
42#define wmi_buf_data(_buf) cdf_nbuf_data(_buf)
43
44/**
45 * attach for unified WMI
46 *
47 * @param scn_handle : handle to SCN.
48 * @return opaque handle.
49 */
50void *wmi_unified_attach(void *scn_handle,
51 int (*func)(struct wmi_unified *, wmi_buf_t));
52/**
53 * detach for unified WMI
54 *
55 * @param wmi_handle : handle to WMI.
56 * @return void.
57 */
58void wmi_unified_detach(struct wmi_unified *wmi_handle);
59
60void
61wmi_unified_remove_work(struct wmi_unified *wmi_handle);
62
63/**
64 * generic function to allocate WMI buffer
65 *
66 * @param wmi_handle : handle to WMI.
67 * @param len : length of the buffer
68 * @return wmi_buf_t.
69 */
70#ifdef MEMORY_DEBUG
71#define wmi_buf_alloc(h, l) wmi_buf_alloc_debug(h, l, __FILE__, __LINE__)
72wmi_buf_t
73wmi_buf_alloc_debug(wmi_unified_t wmi_handle, uint16_t len,
74 uint8_t *file_name, uint32_t line_num);
75#else
76wmi_buf_t wmi_buf_alloc(wmi_unified_t wmi_handle, uint16_t len);
77#endif
78
79/**
80 * generic function frees WMI net buffer
81 *
82 * @param net_buf : Pointer ot net_buf to be freed
83 */
84void wmi_buf_free(wmi_buf_t net_buf);
85
86/**
87 * generic function to send unified WMI command
88 *
89 * @param wmi_handle : handle to WMI.
90 * @param buf : wmi command buffer
91 * @param buflen : wmi command buffer length
92 * @return 0 on success and -ve on failure.
93 */
94int
95wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf, int buflen,
96 WMI_CMD_ID cmd_id);
97
98/**
99 * WMI event handler register function
100 *
101 * @param wmi_handle : handle to WMI.
102 * @param event_id : WMI event ID
103 * @param handler_func : Event handler call back function
104 * @return 0 on success and -ve on failure.
105 */
106int
107wmi_unified_register_event_handler(wmi_unified_t wmi_handle,
108 WMI_EVT_ID event_id,
109 wmi_unified_event_handler handler_func);
110
111/**
112 * WMI event handler unregister function
113 *
114 * @param wmi_handle : handle to WMI.
115 * @param event_id : WMI event ID
116 * @return 0 on success and -ve on failure.
117 */
118int
119wmi_unified_unregister_event_handler(wmi_unified_t wmi_handle,
120 WMI_EVT_ID event_id);
121
122/**
123 * request wmi to connet its htc service.
124 * @param wmi_handle : handle to WMI.
125 * @return void
126 */
127int
128wmi_unified_connect_htc_service(struct wmi_unified *wmi_handle,
129 void *htc_handle);
130
131/*
132 * WMI API to verify the host has enough credits to suspend
133 */
134
135int wmi_is_suspend_ready(wmi_unified_t wmi_handle);
136
137/**
138 WMI API to get updated host_credits
139 */
140
141int wmi_get_host_credits(wmi_unified_t wmi_handle);
142
143/**
144 WMI API to get WMI Pending Commands in the HTC queue
145 */
146
147int wmi_get_pending_cmds(wmi_unified_t wmi_handle);
148
149/**
150 WMI API to set target suspend state
151 */
152
153void wmi_set_target_suspend(wmi_unified_t wmi_handle, bool val);
154
155#ifdef FEATURE_RUNTIME_PM
156void
157wmi_set_runtime_pm_inprogress(wmi_unified_t wmi_handle, bool val);
158bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle);
159#else
160static inline void
161wmi_set_runtime_pm_inprogress(wmi_unified_t wmi_handle, bool val)
162{
163 return;
164}
165static inline bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle)
166{
167 return false;
168}
169#endif
170
171
172/**
173 * WMA Callback to process fw event.
174 */
175typedef int (*wma_process_fw_event_handler_cbk)(struct wmi_unified *wmi_handle,
176 wmi_buf_t evt_buf);
177
178void wmi_process_fw_event(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf);
179uint16_t wmi_get_max_msg_len(wmi_unified_t wmi_handle);
180#endif /* _WMI_UNIFIED_API_H_ */