blob: 8378df3b481286c95758428d599d1d0fb34e25c0 [file] [log] [blame]
Mukul Sharmad75a6672017-06-22 15:40:53 +05301/*
2 * Copyright (c) 2017 The Linux Foundation. All rights reserved.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18/**
19 * DOC: target_if_pmo_static.c
20 *
21 * Target interface file for pmo component to
22 * send suspend / resume related cmd and process event.
23 */
24
25
26#include "target_if.h"
27#include "target_if_pmo.h"
28#include "wmi_unified_api.h"
29
30#define TGT_WILDCARD_PDEV_ID 0x0
31
32QDF_STATUS target_if_pmo_send_vdev_update_param_req(
33 struct wlan_objmgr_vdev *vdev,
34 uint32_t param_id, uint32_t param_value)
35{
36 uint8_t vdev_id;
37 struct wlan_objmgr_psoc *psoc;
38 struct vdev_set_params param = {0};
39
40 if (!vdev) {
41 target_if_err("vdev ptr passed is NULL");
42 return QDF_STATUS_E_INVAL;
43 }
44
45 psoc = wlan_vdev_get_psoc(vdev);
46 vdev_id = wlan_vdev_get_id(vdev);
47 if (!psoc) {
48 target_if_err("psoc handle is NULL");
49 return QDF_STATUS_E_INVAL;
50 }
51
52 switch (param_id) {
53 case pmo_vdev_param_listen_interval:
54 param_id = WMI_VDEV_PARAM_LISTEN_INTERVAL;
55 break;
56 case pmo_vdev_param_dtim_policy:
57 param_id = WMI_VDEV_PARAM_DTIM_POLICY;
58 break;
59 default:
60 target_if_err("invalid vdev param id %d", param_id);
61 return QDF_STATUS_E_INVAL;
62 }
63
64 param.if_id = vdev_id;
65 param.param_id = param_id;
66 param.param_value = param_value;
67 target_if_info("set vdev param vdev_id: %d value: %d for param_id: %d",
68 vdev_id, param_value, param_id);
69 return wmi_unified_vdev_set_param_send(GET_WMI_HDL_FROM_PSOC(psoc),
70 &param);
71}
72
73QDF_STATUS target_if_pmo_send_vdev_ps_param_req(
74 struct wlan_objmgr_vdev *vdev,
75 uint32_t param_id,
76 uint32_t param_value)
77{
78 uint8_t vdev_id;
79 struct wlan_objmgr_psoc *psoc;
80 QDF_STATUS status;
81 struct sta_ps_params sta_ps_param = {0};
82
83 if (!vdev) {
84 target_if_err("vdev ptr passed is NULL");
85 return QDF_STATUS_E_INVAL;
86 }
87
88 psoc = wlan_vdev_get_psoc(vdev);
89 vdev_id = wlan_vdev_get_id(vdev);
90 if (!psoc) {
91 target_if_err("psoc handle is NULL");
92 return QDF_STATUS_E_INVAL;
93 }
94
95 switch (param_id) {
96 case pmo_sta_ps_enable_qpower:
97 param_id = WMI_STA_PS_ENABLE_QPOWER;
98 break;
99 default:
100 target_if_err("invalid vdev param id %d", param_id);
101 return QDF_STATUS_E_INVAL;
102 }
103
104 sta_ps_param.vdev_id = vdev_id;
105 sta_ps_param.param = param_id;
106 sta_ps_param.value = param_value;
107 target_if_info("set vdev param vdev_id: %d value: %d for param_id: %d",
108 vdev_id, param_value, param_id);
109
110 status = wmi_unified_sta_ps_cmd_send(GET_WMI_HDL_FROM_PSOC(psoc),
111 &sta_ps_param);
112 if (QDF_IS_STATUS_ERROR(status))
113 return status;
114
115 return status;
116
117}
118
119void target_if_pmo_psoc_update_bus_suspend(struct wlan_objmgr_psoc *psoc,
120 uint8_t value)
121{
122 wmi_set_is_wow_bus_suspended(GET_WMI_HDL_FROM_PSOC(psoc), value);
123}
124
125int target_if_pmo_psoc_get_host_credits(struct wlan_objmgr_psoc *psoc)
126{
127 return wmi_get_host_credits(GET_WMI_HDL_FROM_PSOC(psoc));
128}
129
130int target_if_pmo_psoc_get_pending_cmnds(struct wlan_objmgr_psoc *psoc)
131{
132 return wmi_get_pending_cmds(GET_WMI_HDL_FROM_PSOC(psoc));
133}
134
135void target_if_pmo_update_target_suspend_flag(struct wlan_objmgr_psoc *psoc,
136 uint8_t value)
137{
138 wmi_set_target_suspend(GET_WMI_HDL_FROM_PSOC(psoc), value);
139}
140
141QDF_STATUS target_if_pmo_psoc_send_wow_enable_req(
142 struct wlan_objmgr_psoc *psoc,
143 struct pmo_wow_cmd_params *param)
144{
145 return wmi_unified_wow_enable_send(GET_WMI_HDL_FROM_PSOC(psoc),
146 (struct wow_cmd_params *)param,
147 TGT_WILDCARD_PDEV_ID);
148}
149
150QDF_STATUS target_if_pmo_psoc_send_suspend_req(
151 struct wlan_objmgr_psoc *psoc,
152 struct pmo_suspend_params *param)
153{
154 return wmi_unified_suspend_send(GET_WMI_HDL_FROM_PSOC(psoc),
155 (struct suspend_params *) param,
156 TGT_WILDCARD_PDEV_ID);
157}
158
159void target_if_pmo_set_runtime_pm_in_progress(struct wlan_objmgr_psoc *psoc,
160 bool value)
161{
162 return wmi_set_runtime_pm_inprogress(GET_WMI_HDL_FROM_PSOC(psoc),
163 value);
164}
165
166bool target_if_pmo_get_runtime_pm_in_progress(
167 struct wlan_objmgr_psoc *psoc)
168{
169 return wmi_get_runtime_pm_inprogress(GET_WMI_HDL_FROM_PSOC(psoc));
170}
171
172QDF_STATUS target_if_pmo_psoc_send_host_wakeup_ind(
173 struct wlan_objmgr_psoc *psoc)
174{
175 return wmi_unified_host_wakeup_ind_to_fw_cmd(
176 GET_WMI_HDL_FROM_PSOC(psoc));
177}
178
179QDF_STATUS target_if_pmo_psoc_send_target_resume_req(
180 struct wlan_objmgr_psoc *psoc)
181{
182 return wmi_unified_resume_send(GET_WMI_HDL_FROM_PSOC(psoc),
183 TGT_WILDCARD_PDEV_ID);
184}
185
Will Huang3cd2b7c2017-11-17 13:16:56 +0800186#ifdef FEATURE_WLAN_D0WOW
187QDF_STATUS target_if_pmo_psoc_send_d0wow_enable_req(
188 struct wlan_objmgr_psoc *psoc)
189{
190 return wmi_unified_d0wow_enable_send(GET_WMI_HDL_FROM_PSOC(psoc),
191 TGT_WILDCARD_PDEV_ID);
192}
193
194QDF_STATUS target_if_pmo_psoc_send_d0wow_disable_req(
195 struct wlan_objmgr_psoc *psoc)
196{
197 return wmi_unified_d0wow_disable_send(GET_WMI_HDL_FROM_PSOC(psoc),
198 TGT_WILDCARD_PDEV_ID);
199}
200#else
201QDF_STATUS target_if_pmo_psoc_send_d0wow_enable_req(
202 struct wlan_objmgr_psoc *psoc)
203{
204 return QDF_STATUS_E_INVAL;
205}
206
207QDF_STATUS target_if_pmo_psoc_send_d0wow_disable_req(
208 struct wlan_objmgr_psoc *psoc)
209{
210 return QDF_STATUS_E_INVAL;
211}
212#endif