blob: 3b8fc2cbdca0c5f74ec1dd3da3702d85cd357154 [file] [log] [blame]
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -08001/*
Houston Hoffmanf2ff37a2015-11-03 11:33:36 -08002 * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -08003 *
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 * DOC: if_snoc.c
30 *
31 * c file for snoc specif implementations.
32 */
33
34#include "hif.h"
35#include "hif_main.h"
36#include "hif_debug.h"
37#include "hif_io32.h"
38#include "ce_main.h"
39#include "ce_tasklet.h"
40
41/**
42 * hif_bus_prevent_linkdown(): prevent linkdown
43 *
44 * Dummy function for busses and platforms that do not support
45 * link down. This may need to be replaced with a wakelock.
46 *
47 * This is duplicated here because CONFIG_CNSS can be defined
48 * even though it is not used for the snoc bus.
49 */
Houston Hoffmancceec342015-11-11 11:37:20 -080050void hif_bus_prevent_linkdown(struct ol_softc *scn, bool flag)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080051{
52 HIF_ERROR("wlan: %s pcie power collapse ignored",
53 (flag ? "disable" : "enable"));
54}
55
56/**
57 * hif_targ_is_awake(): check if target is awake
58 *
59 * This function returns true if the target is awake
60 *
61 * @scn: struct ol_softc
62 * @mem: mapped mem base
63 *
64 * Return: bool
65 */
66bool hif_targ_is_awake(struct ol_softc *scn, void *__iomem *mem)
67{
68 return true;
69}
70
71/**
72 * hif_reset_soc(): reset soc
73 *
74 * this function resets soc
75 *
76 * @hif_ctx: HIF context
77 *
78 * Return: void
79 */
80/* Function to reset SoC */
81void hif_reset_soc(void *hif_ctx)
82{
83}
84
85/**
86 * hif_disable_isr(): disable isr
87 *
88 * This function disables isr and kills tasklets
89 *
90 * @hif_ctx: struct ol_softc
91 *
92 * Return: void
93 */
94void hif_disable_isr(void *hif_ctx)
95{
96 struct ol_softc *scn = (struct ol_softc *)hif_ctx;
97
98 hif_nointrs(scn);
99 ce_tasklet_kill(scn->hif_hdl);
100 cdf_atomic_set(&scn->active_tasklet_cnt, 0);
101}
102
103/**
Govind Singh2443fb32016-01-13 17:44:48 +0530104 * hif_dump_snoc_registers(): dump CE debug registers
105 * @scn: struct ol_softc
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800106 *
Komal Seelam7fca1062016-02-03 15:02:18 +0530107 * This function dumps SNOC debug registers
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800108 *
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800109 * Return: void
110 */
Govind Singh2443fb32016-01-13 17:44:48 +0530111static void hif_dump_snoc_registers(struct ol_softc *scn)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800112{
113 return;
114}
115
116/**
Govind Singh2443fb32016-01-13 17:44:48 +0530117 * hif_dump_registers(): dump bus debug registers
118 * @scn: struct ol_softc
119 *
120 * This function dumps hif bus debug registers
121 *
122 * Return: 0 for success or error code
123 */
124int hif_dump_registers(struct ol_softc *scn)
125{
126 int status;
127
128 status = hif_dump_ce_registers(scn);
129 if (status)
130 HIF_ERROR("%s: Dump CE Registers Failed", __func__);
131
132 hif_dump_snoc_registers(scn);
133
134 return 0;
135}
136
137/**
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800138 * hif_bus_suspend() - suspend the bus
139 *
140 * This function suspends the bus, but snoc doesn't need to suspend.
141 * Therefore do nothing.
142 *
143 * Return: 0 for success and non-zero for failure
144 */
145int hif_bus_suspend(void)
146{
147 return 0;
148}
149
150/**
151 * hif_bus_resume() - hif resume API
152 *
153 * This function resumes the bus. but snoc doesn't need to resume.
154 * Therefore do nothing.
155 *
156 * Return: 0 for success and non-zero for failure
157 */
158int hif_bus_resume(void)
159{
160 return 0;
161}
162
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800163/**
164 * hif_enable_power_gating(): enable HW power gating
165 *
166 * Return: n/a
167 */
168void hif_enable_power_gating(void *hif_ctx)
169{
170}
171
172/**
173 * hif_disable_aspm(): hif_disable_aspm
174 *
175 * Return: n/a
176 */
177void hif_disable_aspm(void)
178{
179}
180
181/**
182 * hif_bus_close(): hif_bus_close
183 *
184 * Return: n/a
185 */
186void hif_bus_close(struct ol_softc *scn)
187{
188}
189
190/**
191 * hif_bus_open(): hif_bus_open
192 * @scn: scn
193 * @bus_type: bus type
194 *
195 * Return: n/a
196 */
197CDF_STATUS hif_bus_open(struct ol_softc *scn, enum ath_hal_bus_type bus_type)
198{
199 return CDF_STATUS_SUCCESS;
200}
201
202/**
203 * hif_get_target_type(): Get the target type
204 *
205 * This function is used to query the target type.
206 *
207 * @ol_sc: ol_softc struct pointer
208 * @dev: device pointer
209 * @bdev: bus dev pointer
210 * @bid: bus id pointer
211 * @hif_type: HIF type such as HIF_TYPE_QCA6180
212 * @target_type: target type such as TARGET_TYPE_QCA6180
213 *
214 * Return: 0 for success
215 */
216int hif_get_target_type(struct ol_softc *ol_sc, struct device *dev,
217 void *bdev, const hif_bus_id *bid, uint32_t *hif_type,
218 uint32_t *target_type)
219{
220 /* TODO: need to use CNSS's HW version. Hard code for now */
221#ifdef QCA_WIFI_3_0_ADRASTEA
222 *hif_type = HIF_TYPE_ADRASTEA;
223 *target_type = TARGET_TYPE_ADRASTEA;
224#else
225 *hif_type = 0;
226 *target_type = 0;
227#endif
228 return 0;
229}
230
231/**
232 * hif_enable_bus(): hif_enable_bus
233 * @dev: dev
234 * @bdev: bus dev
235 * @bid: bus id
236 * @type: bus type
237 *
238 * Return: CDF_STATUS
239 */
240CDF_STATUS hif_enable_bus(struct ol_softc *ol_sc,
241 struct device *dev, void *bdev,
242 const hif_bus_id *bid,
243 enum hif_enable_type type)
244{
245 int ret;
246 int hif_type;
247 int target_type;
248 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
249 if (ret) {
250 HIF_ERROR("%s: failed to set dma mask error = %d",
251 __func__, ret);
252 return ret;
253 }
254
255 if (!ol_sc) {
256 HIF_ERROR("%s: hif_ctx is NULL", __func__);
257 return CDF_STATUS_E_NOMEM;
258 }
259
260 ol_sc->aps_osdev.device = dev;
261 ol_sc->aps_osdev.bc.bc_handle = (void *)ol_sc->mem;
262 ol_sc->aps_osdev.bc.bc_bustype = type;
263
264 ret = hif_get_target_type(ol_sc, dev, bdev, bid,
265 &hif_type, &target_type);
266 if (ret < 0) {
267 HIF_ERROR("%s: invalid device id/revision_id", __func__);
268 return CDF_STATUS_E_FAILURE;
269 }
270
271 hif_register_tbl_attach(ol_sc, hif_type);
272 target_register_tbl_attach(ol_sc, target_type);
273
274 HIF_TRACE("%s: X - hif_type = 0x%x, target_type = 0x%x",
275 __func__, hif_type, target_type);
276
277 ret = hif_init_cdf_ctx(ol_sc);
278 if (ret != 0) {
279 HIF_ERROR("%s: cannot init CDF", __func__);
280 return CDF_STATUS_E_FAILURE;
281 }
282
283 return CDF_STATUS_SUCCESS;
284}
285
286/**
287 * hif_disable_bus(): hif_disable_bus
288 *
289 * This function disables the bus
290 *
291 * @bdev: bus dev
292 *
293 * Return: none
294 */
295void hif_disable_bus(void *bdev)
296{
297}
298
299/**
300 * hif_nointrs(): disable IRQ
301 *
302 * This function stops interrupt(s)
303 *
304 * @scn: struct ol_softc
305 *
306 * Return: none
307 */
308void hif_nointrs(struct ol_softc *scn)
309{
310 if (scn->request_irq_done) {
311 ce_unregister_irq(scn->hif_hdl, 0xfff);
312 scn->request_irq_done = false;
313 }
314}