blob: f9fa886ce12ac998c47db745a2e356a724f6c82b [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2015 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 * 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 */
50void hif_bus_prevent_linkdown(bool flag)
51{
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/**
104 * dump_ce_debug_register(): dump CE debug registers
105 *
106 * This function dumps CE debug registers
107 *
108 * @scn: struct ol_softc
109 *
110 * Return: void
111 */
112void dump_ce_debug_register(struct ol_softc *scn)
113{
114 return;
115}
116
117/**
118 * hif_bus_suspend() - suspend the bus
119 *
120 * This function suspends the bus, but snoc doesn't need to suspend.
121 * Therefore do nothing.
122 *
123 * Return: 0 for success and non-zero for failure
124 */
125int hif_bus_suspend(void)
126{
127 return 0;
128}
129
130/**
131 * hif_bus_resume() - hif resume API
132 *
133 * This function resumes the bus. but snoc doesn't need to resume.
134 * Therefore do nothing.
135 *
136 * Return: 0 for success and non-zero for failure
137 */
138int hif_bus_resume(void)
139{
140 return 0;
141}
142
143/**
144 * hif_enable_power_gating(): enable HW power gating
145 *
146 * Return: n/a
147 */
148void hif_enable_power_gating(void *hif_ctx)
149{
150}
151
152/**
153 * hif_disable_aspm(): hif_disable_aspm
154 *
155 * Return: n/a
156 */
157void hif_disable_aspm(void)
158{
159}
160
161/**
162 * hif_bus_close(): hif_bus_close
163 *
164 * Return: n/a
165 */
166void hif_bus_close(struct ol_softc *scn)
167{
168}
169
170/**
171 * hif_bus_open(): hif_bus_open
172 * @scn: scn
173 * @bus_type: bus type
174 *
175 * Return: n/a
176 */
177CDF_STATUS hif_bus_open(struct ol_softc *scn, enum ath_hal_bus_type bus_type)
178{
179 return CDF_STATUS_SUCCESS;
180}
181
182/**
183 * hif_get_target_type(): Get the target type
184 *
185 * This function is used to query the target type.
186 *
187 * @ol_sc: ol_softc struct pointer
188 * @dev: device pointer
189 * @bdev: bus dev pointer
190 * @bid: bus id pointer
191 * @hif_type: HIF type such as HIF_TYPE_QCA6180
192 * @target_type: target type such as TARGET_TYPE_QCA6180
193 *
194 * Return: 0 for success
195 */
196int hif_get_target_type(struct ol_softc *ol_sc, struct device *dev,
197 void *bdev, const hif_bus_id *bid, uint32_t *hif_type,
198 uint32_t *target_type)
199{
200 /* TODO: need to use CNSS's HW version. Hard code for now */
201#ifdef QCA_WIFI_3_0_ADRASTEA
202 *hif_type = HIF_TYPE_ADRASTEA;
203 *target_type = TARGET_TYPE_ADRASTEA;
204#else
205 *hif_type = 0;
206 *target_type = 0;
207#endif
208 return 0;
209}
210
211/**
212 * hif_enable_bus(): hif_enable_bus
213 * @dev: dev
214 * @bdev: bus dev
215 * @bid: bus id
216 * @type: bus type
217 *
218 * Return: CDF_STATUS
219 */
220CDF_STATUS hif_enable_bus(struct ol_softc *ol_sc,
221 struct device *dev, void *bdev,
222 const hif_bus_id *bid,
223 enum hif_enable_type type)
224{
225 int ret;
226 int hif_type;
227 int target_type;
228 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
229 if (ret) {
230 HIF_ERROR("%s: failed to set dma mask error = %d",
231 __func__, ret);
232 return ret;
233 }
234
235 if (!ol_sc) {
236 HIF_ERROR("%s: hif_ctx is NULL", __func__);
237 return CDF_STATUS_E_NOMEM;
238 }
239
240 ol_sc->aps_osdev.device = dev;
241 ol_sc->aps_osdev.bc.bc_handle = (void *)ol_sc->mem;
242 ol_sc->aps_osdev.bc.bc_bustype = type;
243
244 ret = hif_get_target_type(ol_sc, dev, bdev, bid,
245 &hif_type, &target_type);
246 if (ret < 0) {
247 HIF_ERROR("%s: invalid device id/revision_id", __func__);
248 return CDF_STATUS_E_FAILURE;
249 }
250
251 hif_register_tbl_attach(ol_sc, hif_type);
252 target_register_tbl_attach(ol_sc, target_type);
253
254 HIF_TRACE("%s: X - hif_type = 0x%x, target_type = 0x%x",
255 __func__, hif_type, target_type);
256
257 ret = hif_init_cdf_ctx(ol_sc);
258 if (ret != 0) {
259 HIF_ERROR("%s: cannot init CDF", __func__);
260 return CDF_STATUS_E_FAILURE;
261 }
262
263 return CDF_STATUS_SUCCESS;
264}
265
266/**
267 * hif_disable_bus(): hif_disable_bus
268 *
269 * This function disables the bus
270 *
271 * @bdev: bus dev
272 *
273 * Return: none
274 */
275void hif_disable_bus(void *bdev)
276{
277}
278
279/**
280 * hif_nointrs(): disable IRQ
281 *
282 * This function stops interrupt(s)
283 *
284 * @scn: struct ol_softc
285 *
286 * Return: none
287 */
288void hif_nointrs(struct ol_softc *scn)
289{
290 if (scn->request_irq_done) {
291 ce_unregister_irq(scn->hif_hdl, 0xfff);
292 scn->request_irq_done = false;
293 }
294}