blob: 3709235dc24d70b123575f04bacb03fc84786b12 [file] [log] [blame]
Poddar, Siddarthef1f3022016-05-10 20:10:43 +05301/*
2 * Copyright (c) 2014-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#include "ol_if_athvar.h"
29#include "targaddrs.h"
30#include "ol_cfg.h"
31#include "i_ar6320v2_regtable.h"
32#include "ol_fw.h"
33#ifdef HIF_PCI
34#include "ce_reg.h"
35#endif
36#if defined(HIF_SDIO)
37#include "regtable_sdio.h"
38#endif
39#if defined(CONFIG_CNSS)
40#include <net/cnss.h>
41#endif
42#include "i_bmi.h"
43
44#ifdef CONFIG_DISABLE_SLEEP_BMI_OPTION
45static inline void ol_sdio_disable_sleep(struct ol_context *ol_ctx)
46{
47 uint32_t value;
48
49 BMI_ERR("prevent ROME from sleeping");
50 bmi_read_soc_register(MBOX_BASE_ADDRESS + LOCAL_SCRATCH_OFFSET,
51 /* this address should be 0x80C0 for ROME*/
52 &value,
53 ol_ctx);
54
55 value |= SOC_OPTION_SLEEP_DISABLE;
56
57 bmi_write_soc_register(MBOX_BASE_ADDRESS + LOCAL_SCRATCH_OFFSET,
58 value,
59 ol_ctx);
60}
61
62#else
63static inline void ol_sdio_disable_sleep(struct ol_context *ol_ctx)
64{
65}
66
67#endif
68
69/*Setting SDIO block size, mbox ISR yield limit for SDIO based HIF*/
70static
71QDF_STATUS ol_sdio_extra_initialization(struct ol_context *ol_ctx)
72{
73
74 QDF_STATUS status;
75 uint32_t param;
76 uint32_t blocksizes[HTC_MAILBOX_NUM_MAX];
77 uint32_t MboxIsrYieldValue = 99;
78 struct hif_opaque_softc *scn = ol_ctx->scn;
79 struct hif_target_info *tgt_info = hif_get_target_info_handle(scn);
80 uint32_t target_type = tgt_info->target_type;
81
82 /* get the block sizes */
83 status = hif_get_config_item(scn,
84 HIF_DEVICE_GET_MBOX_BLOCK_SIZE,
85 blocksizes, sizeof(blocksizes));
86 if (status != EOK) {
87 BMI_ERR("Failed to get block size info from HIF layer");
88 goto exit;
89 }
90 /* note: we actually get the block size for mailbox 1,
91 * for SDIO the block size on mailbox 0 is artificially
92 * set to 1 must be a power of 2 */
93 qdf_assert((blocksizes[1] & (blocksizes[1] - 1)) == 0);
94
95 /* set the host interest area for the block size */
96 status = bmi_write_memory(hif_hia_item_address(target_type,
97 offsetof(struct host_interest_s,
98 hi_mbox_io_block_sz)),
99 (uint8_t *)&blocksizes[1],
100 4,
101 ol_ctx);
102
103 if (status != EOK) {
104 BMI_ERR("BMIWriteMemory for IO block size failed");
105 goto exit;
106 }
107
108 if (MboxIsrYieldValue != 0) {
109 /* set the host for the mbox ISR yield limit */
110 status =
111 bmi_write_memory(hif_hia_item_address(target_type,
112 offsetof(struct host_interest_s,
113 hi_mbox_isr_yield_limit)),
114 (uint8_t *)&MboxIsrYieldValue,
115 4,
116 ol_ctx);
117
118 if (status != EOK) {
119 BMI_ERR("BMI write for yield limit failed\n");
120 goto exit;
121 }
122 }
123 ol_sdio_disable_sleep(ol_ctx);
124 status = bmi_read_memory(hif_hia_item_address(target_type,
125 offsetof(struct host_interest_s,
126 hi_acs_flags)),
127 (uint8_t *)&param,
128 4,
129 ol_ctx);
130 if (status != EOK) {
131 BMI_ERR("BMIReadMemory for hi_acs_flags failed");
132 goto exit;
133 }
134
135 param |= (HI_ACS_FLAGS_SDIO_SWAP_MAILBOX_SET|
136 HI_ACS_FLAGS_SDIO_REDUCE_TX_COMPL_SET|
137 HI_ACS_FLAGS_ALT_DATA_CREDIT_SIZE);
138
139 bmi_write_memory(hif_hia_item_address(target_type,
140 offsetof(struct host_interest_s,
141 hi_acs_flags)),
142 (uint8_t *)&param, 4, ol_ctx);
143exit:
144 return status;
145}
146
147QDF_STATUS ol_extra_initialization(struct ol_context *ol_ctx)
148{
149 struct hif_opaque_softc *scn = ol_ctx->scn;
150
151 if (hif_get_bus_type(scn) == QDF_BUS_TYPE_SDIO)
152 return ol_sdio_extra_initialization(ol_ctx);
153
154 return QDF_STATUS_SUCCESS;
155}
156
157void ol_target_ready(struct hif_opaque_softc *scn, void *cfg_ctx)
158{
159 uint32_t value = 0;
160 QDF_STATUS status = QDF_STATUS_SUCCESS;
161 struct hif_target_info *tgt_info = hif_get_target_info_handle(scn);
162 uint32_t target_type = tgt_info->target_type;
163
164 if (hif_get_bus_type(scn) != QDF_BUS_TYPE_SDIO)
165 return;
166 status = hif_diag_read_mem(scn,
167 hif_hia_item_address(target_type,
168 offsetof(struct host_interest_s, hi_acs_flags)),
169 (uint8_t *)&value, sizeof(u_int32_t));
170
171 if (status != QDF_STATUS_SUCCESS) {
172 BMI_ERR("HIFDiagReadMem failed");
173 return;
174 }
175
176 if (value & HI_ACS_FLAGS_SDIO_SWAP_MAILBOX_FW_ACK) {
177 BMI_ERR("MAILBOX SWAP Service is enabled!");
178 hif_set_mailbox_swap(scn);
179 }
180
181 if (value & HI_ACS_FLAGS_SDIO_REDUCE_TX_COMPL_FW_ACK)
182 BMI_ERR("Reduced Tx Complete service is enabled!");
183}