blob: 72523e37fff6f6ad03d1519d2efe4dc7102a91cc [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Komal Seelam02cf2f82016-02-22 20:44:25 +05302 * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -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#include <osdep.h>
29#include "a_types.h"
30#include "athdefs.h"
31#include "osapi_linux.h"
32#include "targcfg.h"
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053033#include "qdf_lock.h"
34#include "qdf_status.h"
35#include "qdf_status.h"
36#include <qdf_atomic.h> /* qdf_atomic_read */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080037#include <targaddrs.h>
38#include <bmi_msg.h>
39#include "hif_io32.h"
40#include <hif.h>
41#include <htc_services.h>
42#include "regtable.h"
43#include <a_debug.h>
44#include "hif_main.h"
45#include "ce_api.h"
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053046#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#ifdef CONFIG_CNSS
48#include <net/cnss.h>
49#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include "hif_debug.h"
51#include "epping_main.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052
Komal Seelam5584a7c2016-02-24 19:22:48 +053053void
54hif_dump_target_memory(struct hif_opaque_softc *hif_ctx, void *ramdump_base,
55 uint32_t address, uint32_t size)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056{
Komal Seelam644263d2016-02-22 20:45:49 +053057 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080058 uint32_t loc = address;
59 uint32_t val = 0;
60 uint32_t j = 0;
61 u8 *temp = ramdump_base;
62
Houston Hoffmanbac94542016-03-14 21:11:59 -070063 if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
64 return;
65
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066 while (j < size) {
67 val = hif_read32_mb(scn->mem + loc + j);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053068 qdf_mem_copy(temp, &val, 4);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069 j += 4;
70 temp += 4;
71 }
Houston Hoffmanbac94542016-03-14 21:11:59 -070072
73 Q_TARGET_ACCESS_END(scn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080074}
75/*
76 * TBDXXX: Should be a function call specific to each Target-type.
77 * This convoluted macro converts from Target CPU Virtual Address
78 * Space to CE Address Space. As part of this process, we
79 * conservatively fetch the current PCIE_BAR. MOST of the time,
80 * this should match the upper bits of PCI space for this device;
81 * but that's not guaranteed.
82 */
83#ifdef QCA_WIFI_3_0
84#define TARG_CPU_SPACE_TO_CE_SPACE(pci_addr, addr) \
85 (scn->mem_pa + addr)
86#else
87#define TARG_CPU_SPACE_TO_CE_SPACE(pci_addr, addr) \
88 (((hif_read32_mb((pci_addr) + \
89 (SOC_CORE_BASE_ADDRESS|CORE_CTRL_ADDRESS)) & 0x7ff) << 21) \
90 | 0x100000 | ((addr) & 0xfffff))
91#endif
92/* Wait up to this many Ms for a Diagnostic Access CE operation to complete */
93#define DIAG_ACCESS_CE_TIMEOUT_MS 10
94
95/*
96 * Diagnostic read/write access is provided for startup/config/debug usage.
97 * Caller must guarantee proper alignment, when applicable, and single user
98 * at any moment.
99 */
100
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530101QDF_STATUS
Komal Seelam5584a7c2016-02-24 19:22:48 +0530102hif_diag_read_mem(struct hif_opaque_softc *hif_ctx, uint32_t address,
103 uint8_t *data, int nbytes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800104{
Komal Seelam644263d2016-02-22 20:45:49 +0530105 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Komal Seelam02cf2f82016-02-22 20:44:25 +0530106 struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530107 QDF_STATUS status = QDF_STATUS_SUCCESS;
108 qdf_dma_addr_t buf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800109 unsigned int completed_nbytes, orig_nbytes, remaining_bytes;
110 unsigned int id;
111 unsigned int flags;
112 struct CE_handle *ce_diag;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530113 qdf_dma_addr_t CE_data; /* Host buffer address in CE space */
114 qdf_dma_addr_t CE_data_base = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800115 void *data_buf = NULL;
116 int i;
117 unsigned int mux_id = 0;
118 unsigned int transaction_id = 0xffff;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530119 qdf_dma_addr_t ce_phy_addr = address;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800120 unsigned int toeplitz_hash_result;
121 unsigned int user_flags = 0;
122
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800123 transaction_id = (mux_id & MUX_ID_MASK) |
124 (transaction_id & TRANSACTION_ID_MASK);
125#ifdef QCA_WIFI_3_0
126 user_flags &= DESC_DATA_FLAG_MASK;
127#endif
128
129 /* This code cannot handle reads to non-memory space. Redirect to the
130 * register read fn but preserve the multi word read capability of
131 * this fn
132 */
133 if (address < DRAM_BASE_ADDRESS) {
134
135 if ((address & 0x3) || ((uintptr_t) data & 0x3))
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530136 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800137
138 while ((nbytes >= 4) &&
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530139 (QDF_STATUS_SUCCESS == (status =
Komal Seelam644263d2016-02-22 20:45:49 +0530140 hif_diag_read_access(hif_ctx, address,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800141 (uint32_t *)data)))) {
142
143 nbytes -= sizeof(uint32_t);
144 address += sizeof(uint32_t);
145 data += sizeof(uint32_t);
146
147 }
148
149 return status;
150 }
151 ce_diag = hif_state->ce_diag;
152
153 A_TARGET_ACCESS_LIKELY(scn);
154
155 /*
156 * Allocate a temporary bounce buffer to hold caller's data
157 * to be DMA'ed from Target. This guarantees
158 * 1) 4-byte alignment
159 * 2) Buffer in DMA-able space
160 */
161 orig_nbytes = nbytes;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530162 data_buf = qdf_mem_alloc_consistent(scn->qdf_dev, scn->qdf_dev->dev,
163 orig_nbytes, &CE_data_base);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 if (!data_buf) {
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530165 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 goto done;
167 }
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530168 qdf_mem_set(data_buf, orig_nbytes, 0);
169 qdf_mem_dma_sync_single_for_device(scn->qdf_dev, CE_data_base,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 orig_nbytes, DMA_FROM_DEVICE);
171
172 remaining_bytes = orig_nbytes;
173 CE_data = CE_data_base;
174 while (remaining_bytes) {
175 nbytes = min(remaining_bytes, DIAG_TRANSFER_LIMIT);
176 {
177 status = ce_recv_buf_enqueue(ce_diag, NULL, CE_data);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530178 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179 goto done;
180 }
181
182 { /* Request CE to send from Target(!)
183 * address to Host buffer */
184 /*
185 * The address supplied by the caller is in the
186 * Target CPU virtual address space.
187 *
188 * In order to use this address with the diagnostic CE,
189 * convert it from
190 * Target CPU virtual address space
191 * to
192 * CE address space
193 */
194 A_TARGET_ACCESS_BEGIN_RET(scn);
195 ce_phy_addr =
196 TARG_CPU_SPACE_TO_CE_SPACE(scn->mem, address);
197 A_TARGET_ACCESS_END_RET(scn);
198
199 status =
200 ce_send(ce_diag, NULL, ce_phy_addr, nbytes,
201 transaction_id, 0, user_flags);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530202 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 goto done;
204 }
205
206 i = 0;
207 while (ce_completed_send_next(ce_diag, NULL, NULL, &buf,
208 &completed_nbytes, &id, NULL, NULL,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530209 &toeplitz_hash_result) != QDF_STATUS_SUCCESS) {
210 qdf_mdelay(1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800211 if (i++ > DIAG_ACCESS_CE_TIMEOUT_MS) {
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530212 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213 goto done;
214 }
215 }
216 if (nbytes != completed_nbytes) {
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530217 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800218 goto done;
219 }
220 if (buf != ce_phy_addr) {
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530221 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 goto done;
223 }
224
225 i = 0;
226 while (ce_completed_recv_next
227 (ce_diag, NULL, NULL, &buf,
228 &completed_nbytes, &id,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530229 &flags) != QDF_STATUS_SUCCESS) {
230 qdf_mdelay(1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 if (i++ > DIAG_ACCESS_CE_TIMEOUT_MS) {
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530232 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 goto done;
234 }
235 }
236 if (nbytes != completed_nbytes) {
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530237 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238 goto done;
239 }
240 if (buf != CE_data) {
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530241 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 goto done;
243 }
244
245 remaining_bytes -= nbytes;
246 address += nbytes;
247 CE_data += nbytes;
248 }
249
250done:
251 A_TARGET_ACCESS_UNLIKELY(scn);
252
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530253 if (status == QDF_STATUS_SUCCESS)
254 qdf_mem_copy(data, data_buf, orig_nbytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800255 else
256 HIF_ERROR("%s failure (0x%x)", __func__, address);
257
258 if (data_buf)
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530259 qdf_mem_free_consistent(scn->qdf_dev, scn->qdf_dev->dev,
260 orig_nbytes, data_buf, CE_data_base, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800261
262 return status;
263}
264
265/* Read 4-byte aligned data from Target memory or register */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530266QDF_STATUS hif_diag_read_access(struct hif_opaque_softc *hif_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800267 uint32_t address, uint32_t *data)
268{
Komal Seelam644263d2016-02-22 20:45:49 +0530269 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800271 if (address >= DRAM_BASE_ADDRESS) {
272 /* Assume range doesn't cross this boundary */
Komal Seelam644263d2016-02-22 20:45:49 +0530273 return hif_diag_read_mem(hif_ctx, address, (uint8_t *) data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800274 sizeof(uint32_t));
275 } else {
276 A_TARGET_ACCESS_BEGIN_RET(scn);
277 *data = A_TARGET_READ(scn, address);
278 A_TARGET_ACCESS_END_RET(scn);
279
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530280 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281 }
282}
283
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530284QDF_STATUS hif_diag_write_mem(struct hif_opaque_softc *hif_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800285 uint32_t address, uint8_t *data, int nbytes)
286{
Komal Seelam644263d2016-02-22 20:45:49 +0530287 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Komal Seelam02cf2f82016-02-22 20:44:25 +0530288 struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530289 QDF_STATUS status = QDF_STATUS_SUCCESS;
290 qdf_dma_addr_t buf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291 unsigned int completed_nbytes, orig_nbytes, remaining_bytes;
292 unsigned int id;
293 unsigned int flags;
294 struct CE_handle *ce_diag;
295 void *data_buf = NULL;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530296 qdf_dma_addr_t CE_data; /* Host buffer address in CE space */
297 qdf_dma_addr_t CE_data_base = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298 int i;
299 unsigned int mux_id = 0;
300 unsigned int transaction_id = 0xffff;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530301 qdf_dma_addr_t ce_phy_addr = address;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800302 unsigned int toeplitz_hash_result;
303 unsigned int user_flags = 0;
304
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305 ce_diag = hif_state->ce_diag;
306 transaction_id = (mux_id & MUX_ID_MASK) |
307 (transaction_id & TRANSACTION_ID_MASK);
308#ifdef QCA_WIFI_3_0
309 user_flags &= DESC_DATA_FLAG_MASK;
310#endif
311
312 A_TARGET_ACCESS_LIKELY(scn);
313
314 /*
315 * Allocate a temporary bounce buffer to hold caller's data
316 * to be DMA'ed to Target. This guarantees
317 * 1) 4-byte alignment
318 * 2) Buffer in DMA-able space
319 */
320 orig_nbytes = nbytes;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530321 data_buf = qdf_mem_alloc_consistent(scn->qdf_dev, scn->qdf_dev->dev,
322 orig_nbytes, &CE_data_base);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800323 if (!data_buf) {
324 status = A_NO_MEMORY;
325 goto done;
326 }
327
328 /* Copy caller's data to allocated DMA buf */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530329 qdf_mem_copy(data_buf, data, orig_nbytes);
330 qdf_mem_dma_sync_single_for_device(scn->qdf_dev, CE_data_base,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 orig_nbytes, DMA_TO_DEVICE);
332
333 /*
334 * The address supplied by the caller is in the
335 * Target CPU virtual address space.
336 *
337 * In order to use this address with the diagnostic CE,
338 * convert it from
339 * Target CPU virtual address space
340 * to
341 * CE address space
342 */
343 A_TARGET_ACCESS_BEGIN_RET(scn);
344 ce_phy_addr = TARG_CPU_SPACE_TO_CE_SPACE(scn->mem, address);
345 A_TARGET_ACCESS_END_RET(scn);
346
347 remaining_bytes = orig_nbytes;
348 CE_data = CE_data_base;
349 while (remaining_bytes) {
350 nbytes = min(remaining_bytes, DIAG_TRANSFER_LIMIT);
351
352 { /* Set up to receive directly into Target(!) address */
353 status = ce_recv_buf_enqueue(ce_diag,
354 NULL, ce_phy_addr);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530355 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356 goto done;
357 }
358
359 {
360 /*
361 * Request CE to send caller-supplied data that
362 * was copied to bounce buffer to Target(!) address.
363 */
364 status =
365 ce_send(ce_diag, NULL,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530366 (qdf_dma_addr_t) CE_data, nbytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367 transaction_id, 0, user_flags);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530368 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369 goto done;
370 }
371
372 i = 0;
373 while (ce_completed_send_next(ce_diag, NULL, NULL, &buf,
374 &completed_nbytes, &id,
375 NULL, NULL, &toeplitz_hash_result) !=
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530376 QDF_STATUS_SUCCESS) {
377 qdf_mdelay(1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378 if (i++ > DIAG_ACCESS_CE_TIMEOUT_MS) {
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530379 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380 goto done;
381 }
382 }
383
384 if (nbytes != completed_nbytes) {
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530385 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800386 goto done;
387 }
388
389 if (buf != CE_data) {
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530390 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800391 goto done;
392 }
393
394 i = 0;
395 while (ce_completed_recv_next
396 (ce_diag, NULL, NULL, &buf,
397 &completed_nbytes, &id,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530398 &flags) != QDF_STATUS_SUCCESS) {
399 qdf_mdelay(1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800400 if (i++ > DIAG_ACCESS_CE_TIMEOUT_MS) {
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530401 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 goto done;
403 }
404 }
405
406 if (nbytes != completed_nbytes) {
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530407 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408 goto done;
409 }
410
411 if (buf != ce_phy_addr) {
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530412 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800413 goto done;
414 }
415
416 remaining_bytes -= nbytes;
417 address += nbytes;
418 CE_data += nbytes;
419 }
420
421done:
422 A_TARGET_ACCESS_UNLIKELY(scn);
423
424 if (data_buf) {
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530425 qdf_mem_free_consistent(scn->qdf_dev, scn->qdf_dev->dev,
426 orig_nbytes, data_buf, CE_data_base, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 }
428
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530429 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430 HIF_ERROR("%s failure (0x%llu)", __func__,
431 (uint64_t)ce_phy_addr);
432 }
433
434 return status;
435}
436
437/* Write 4B data to Target memory or register */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530438QDF_STATUS hif_diag_write_access(struct hif_opaque_softc *hif_ctx,
Komal Seelam5584a7c2016-02-24 19:22:48 +0530439 uint32_t address, uint32_t data)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440{
Komal Seelam644263d2016-02-22 20:45:49 +0530441 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800442
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 if (address >= DRAM_BASE_ADDRESS) {
444 /* Assume range doesn't cross this boundary */
445 uint32_t data_buf = data;
446
Komal Seelam644263d2016-02-22 20:45:49 +0530447 return hif_diag_write_mem(hif_ctx, address,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448 (uint8_t *) &data_buf,
449 sizeof(uint32_t));
450 } else {
451 A_TARGET_ACCESS_BEGIN_RET(scn);
452 A_TARGET_WRITE(scn, address, data);
453 A_TARGET_ACCESS_END_RET(scn);
454
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530455 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800456 }
457}