Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of wl1271 |
| 3 | * |
| 4 | * Copyright (C) 2009 Nokia Corporation |
| 5 | * |
| 6 | * Contact: Luciano Coelho <luciano.coelho@nokia.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License |
| 10 | * version 2 as published by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 20 | * 02110-1301 USA |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <linux/kernel.h> |
| 25 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 26 | #include <linux/slab.h> |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 27 | |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 28 | #include "init.h" |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 29 | #include "wl12xx_80211.h" |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 30 | #include "acx.h" |
| 31 | #include "cmd.h" |
| 32 | #include "reg.h" |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 33 | #include "tx.h" |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 34 | #include "io.h" |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 35 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 36 | int wl1271_init_templates_config(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 37 | { |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 38 | int ret, i; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 39 | |
| 40 | /* send empty templates for fw memory reservation */ |
| 41 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, NULL, |
Eliad Peller | 154037d | 2011-08-14 13:17:12 +0300 | [diff] [blame] | 42 | WL1271_CMD_TEMPL_DFLT_SIZE, |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 43 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 44 | if (ret < 0) |
| 45 | return ret; |
| 46 | |
Juuso Oikarinen | 11eb542 | 2010-08-24 06:28:03 +0300 | [diff] [blame] | 47 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5, |
Eliad Peller | 154037d | 2011-08-14 13:17:12 +0300 | [diff] [blame] | 48 | NULL, WL1271_CMD_TEMPL_DFLT_SIZE, 0, |
Juuso Oikarinen | 11eb542 | 2010-08-24 06:28:03 +0300 | [diff] [blame] | 49 | WL1271_RATE_AUTOMATIC); |
| 50 | if (ret < 0) |
| 51 | return ret; |
Teemu Paasikivi | abb0b3b | 2009-10-13 12:47:50 +0300 | [diff] [blame] | 52 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 53 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL, |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 54 | sizeof(struct wl12xx_null_data_template), |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 55 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 56 | if (ret < 0) |
| 57 | return ret; |
| 58 | |
| 59 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, NULL, |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 60 | sizeof(struct wl12xx_ps_poll_template), |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 61 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 62 | if (ret < 0) |
| 63 | return ret; |
| 64 | |
| 65 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL, |
| 66 | sizeof |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 67 | (struct wl12xx_qos_null_data_template), |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 68 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 69 | if (ret < 0) |
| 70 | return ret; |
| 71 | |
| 72 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE, NULL, |
Eliad Peller | 154037d | 2011-08-14 13:17:12 +0300 | [diff] [blame] | 73 | WL1271_CMD_TEMPL_DFLT_SIZE, |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 74 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 75 | if (ret < 0) |
| 76 | return ret; |
| 77 | |
| 78 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, NULL, |
Eliad Peller | 154037d | 2011-08-14 13:17:12 +0300 | [diff] [blame] | 79 | WL1271_CMD_TEMPL_DFLT_SIZE, |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 80 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 81 | if (ret < 0) |
| 82 | return ret; |
| 83 | |
Eliad Peller | c531277 | 2010-12-09 11:31:27 +0200 | [diff] [blame] | 84 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_ARP_RSP, NULL, |
| 85 | sizeof |
| 86 | (struct wl12xx_arp_rsp_template), |
| 87 | 0, WL1271_RATE_AUTOMATIC); |
| 88 | if (ret < 0) |
| 89 | return ret; |
| 90 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 91 | /* |
| 92 | * Put very large empty placeholders for all templates. These |
| 93 | * reserve memory for later. |
| 94 | */ |
| 95 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL, |
| 96 | WL1271_CMD_TEMPL_MAX_SIZE, |
| 97 | 0, WL1271_RATE_AUTOMATIC); |
| 98 | if (ret < 0) |
| 99 | return ret; |
| 100 | |
| 101 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL, |
| 102 | WL1271_CMD_TEMPL_MAX_SIZE, |
| 103 | 0, WL1271_RATE_AUTOMATIC); |
| 104 | if (ret < 0) |
| 105 | return ret; |
| 106 | |
| 107 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL, |
| 108 | sizeof |
| 109 | (struct wl12xx_disconn_template), |
| 110 | 0, WL1271_RATE_AUTOMATIC); |
| 111 | if (ret < 0) |
| 112 | return ret; |
| 113 | |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 114 | for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { |
| 115 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL, |
Eliad Peller | 154037d | 2011-08-14 13:17:12 +0300 | [diff] [blame] | 116 | WL1271_CMD_TEMPL_DFLT_SIZE, i, |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 117 | WL1271_RATE_AUTOMATIC); |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 118 | if (ret < 0) |
| 119 | return ret; |
| 120 | } |
| 121 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 122 | return 0; |
| 123 | } |
| 124 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 125 | static int wl1271_ap_init_deauth_template(struct wl1271 *wl, |
| 126 | struct wl12xx_vif *wlvif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 127 | { |
| 128 | struct wl12xx_disconn_template *tmpl; |
| 129 | int ret; |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 130 | u32 rate; |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 131 | |
| 132 | tmpl = kzalloc(sizeof(*tmpl), GFP_KERNEL); |
| 133 | if (!tmpl) { |
| 134 | ret = -ENOMEM; |
| 135 | goto out; |
| 136 | } |
| 137 | |
| 138 | tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 139 | IEEE80211_STYPE_DEAUTH); |
| 140 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 141 | rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 142 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 143 | tmpl, sizeof(*tmpl), 0, rate); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 144 | |
| 145 | out: |
| 146 | kfree(tmpl); |
| 147 | return ret; |
| 148 | } |
| 149 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 150 | static int wl1271_ap_init_null_template(struct wl1271 *wl, |
| 151 | struct ieee80211_vif *vif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 152 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 153 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 154 | struct ieee80211_hdr_3addr *nullfunc; |
| 155 | int ret; |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 156 | u32 rate; |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 157 | |
| 158 | nullfunc = kzalloc(sizeof(*nullfunc), GFP_KERNEL); |
| 159 | if (!nullfunc) { |
| 160 | ret = -ENOMEM; |
| 161 | goto out; |
| 162 | } |
| 163 | |
| 164 | nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | |
| 165 | IEEE80211_STYPE_NULLFUNC | |
| 166 | IEEE80211_FCTL_FROMDS); |
| 167 | |
| 168 | /* nullfunc->addr1 is filled by FW */ |
| 169 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 170 | memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); |
| 171 | memcpy(nullfunc->addr3, vif->addr, ETH_ALEN); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 172 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 173 | rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 174 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc, |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 175 | sizeof(*nullfunc), 0, rate); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 176 | |
| 177 | out: |
| 178 | kfree(nullfunc); |
| 179 | return ret; |
| 180 | } |
| 181 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 182 | static int wl1271_ap_init_qos_null_template(struct wl1271 *wl, |
| 183 | struct ieee80211_vif *vif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 184 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 185 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 186 | struct ieee80211_qos_hdr *qosnull; |
| 187 | int ret; |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 188 | u32 rate; |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 189 | |
| 190 | qosnull = kzalloc(sizeof(*qosnull), GFP_KERNEL); |
| 191 | if (!qosnull) { |
| 192 | ret = -ENOMEM; |
| 193 | goto out; |
| 194 | } |
| 195 | |
| 196 | qosnull->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | |
| 197 | IEEE80211_STYPE_QOS_NULLFUNC | |
| 198 | IEEE80211_FCTL_FROMDS); |
| 199 | |
| 200 | /* qosnull->addr1 is filled by FW */ |
| 201 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 202 | memcpy(qosnull->addr2, vif->addr, ETH_ALEN); |
| 203 | memcpy(qosnull->addr3, vif->addr, ETH_ALEN); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 204 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 205 | rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 206 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull, |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 207 | sizeof(*qosnull), 0, rate); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 208 | |
| 209 | out: |
| 210 | kfree(qosnull); |
| 211 | return ret; |
| 212 | } |
| 213 | |
Eliad Peller | 08c1d1c | 2011-08-14 13:17:04 +0300 | [diff] [blame] | 214 | static int wl12xx_init_rx_config(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 215 | { |
| 216 | int ret; |
| 217 | |
Juuso Oikarinen | 8793f9b | 2009-10-13 12:47:40 +0300 | [diff] [blame] | 218 | ret = wl1271_acx_rx_msdu_life_time(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 219 | if (ret < 0) |
| 220 | return ret; |
| 221 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 222 | return 0; |
| 223 | } |
| 224 | |
Luciano Coelho | 12419cc | 2010-02-18 13:25:44 +0200 | [diff] [blame] | 225 | int wl1271_init_phy_config(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 226 | { |
| 227 | int ret; |
| 228 | |
| 229 | ret = wl1271_acx_pd_threshold(wl); |
| 230 | if (ret < 0) |
| 231 | return ret; |
| 232 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 233 | return 0; |
| 234 | } |
| 235 | |
| 236 | static int wl12xx_init_phy_vif_config(struct wl1271 *wl) |
| 237 | { |
| 238 | int ret; |
| 239 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 240 | ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME); |
| 241 | if (ret < 0) |
| 242 | return ret; |
| 243 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 244 | ret = wl1271_acx_service_period_timeout(wl); |
| 245 | if (ret < 0) |
| 246 | return ret; |
| 247 | |
Arik Nemtsov | 5f704d1 | 2011-04-18 14:15:21 +0300 | [diff] [blame] | 248 | ret = wl1271_acx_rts_threshold(wl, wl->hw->wiphy->rts_threshold); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 249 | if (ret < 0) |
| 250 | return ret; |
| 251 | |
| 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | static int wl1271_init_beacon_filter(struct wl1271 *wl) |
| 256 | { |
| 257 | int ret; |
| 258 | |
Juuso Oikarinen | 1922167 | 2009-10-08 21:56:35 +0300 | [diff] [blame] | 259 | /* disable beacon filtering at this stage */ |
| 260 | ret = wl1271_acx_beacon_filter_opt(wl, false); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 261 | if (ret < 0) |
| 262 | return ret; |
| 263 | |
| 264 | ret = wl1271_acx_beacon_filter_table(wl); |
| 265 | if (ret < 0) |
| 266 | return ret; |
| 267 | |
| 268 | return 0; |
| 269 | } |
| 270 | |
Luciano Coelho | 12419cc | 2010-02-18 13:25:44 +0200 | [diff] [blame] | 271 | int wl1271_init_pta(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 272 | { |
| 273 | int ret; |
| 274 | |
Eliad Peller | 3be4112 | 2011-08-14 13:17:19 +0300 | [diff] [blame] | 275 | ret = wl12xx_acx_sg_cfg(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 276 | if (ret < 0) |
| 277 | return ret; |
| 278 | |
Juuso Oikarinen | 7fc3a86 | 2010-03-18 12:26:32 +0200 | [diff] [blame] | 279 | ret = wl1271_acx_sg_enable(wl, wl->sg_enabled); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 280 | if (ret < 0) |
| 281 | return ret; |
| 282 | |
| 283 | return 0; |
| 284 | } |
| 285 | |
Luciano Coelho | 12419cc | 2010-02-18 13:25:44 +0200 | [diff] [blame] | 286 | int wl1271_init_energy_detection(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 287 | { |
| 288 | int ret; |
| 289 | |
| 290 | ret = wl1271_acx_cca_threshold(wl); |
| 291 | if (ret < 0) |
| 292 | return ret; |
| 293 | |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | static int wl1271_init_beacon_broadcast(struct wl1271 *wl) |
| 298 | { |
| 299 | int ret; |
| 300 | |
| 301 | ret = wl1271_acx_bcn_dtim_options(wl); |
| 302 | if (ret < 0) |
| 303 | return ret; |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 308 | static int wl12xx_init_fwlog(struct wl1271 *wl) |
| 309 | { |
| 310 | int ret; |
| 311 | |
| 312 | if (wl->quirks & WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED) |
| 313 | return 0; |
| 314 | |
| 315 | ret = wl12xx_cmd_config_fwlog(wl); |
| 316 | if (ret < 0) |
| 317 | return ret; |
| 318 | |
| 319 | return 0; |
| 320 | } |
| 321 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 322 | /* generic sta initialization (non vif-specific) */ |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 323 | static int wl1271_sta_hw_init(struct wl1271 *wl) |
| 324 | { |
| 325 | int ret; |
| 326 | |
Shahar Levi | 49d750ca | 2011-03-06 16:32:09 +0200 | [diff] [blame] | 327 | if (wl->chip.id != CHIP_ID_1283_PG20) { |
| 328 | ret = wl1271_cmd_ext_radio_parms(wl); |
| 329 | if (ret < 0) |
| 330 | return ret; |
| 331 | } |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 332 | |
Eliad Peller | c8bde24 | 2011-02-02 09:59:35 +0200 | [diff] [blame] | 333 | /* PS config */ |
| 334 | ret = wl1271_acx_config_ps(wl); |
| 335 | if (ret < 0) |
| 336 | return ret; |
| 337 | |
Shahar Levi | ff86843 | 2011-04-11 15:41:46 +0300 | [diff] [blame] | 338 | /* FM WLAN coexistence */ |
| 339 | ret = wl1271_acx_fm_coex(wl); |
| 340 | if (ret < 0) |
| 341 | return ret; |
| 342 | |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 343 | /* Configure for ELP power saving */ |
| 344 | ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP); |
| 345 | if (ret < 0) |
| 346 | return ret; |
| 347 | |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 348 | ret = wl1271_acx_sta_rate_policies(wl); |
| 349 | if (ret < 0) |
| 350 | return ret; |
| 351 | |
| 352 | return 0; |
| 353 | } |
| 354 | |
| 355 | static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl) |
| 356 | { |
| 357 | int ret, i; |
| 358 | |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 359 | /* disable all keep-alive templates */ |
| 360 | for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { |
| 361 | ret = wl1271_acx_keep_alive_config(wl, i, |
| 362 | ACX_KEEP_ALIVE_TPL_INVALID); |
| 363 | if (ret < 0) |
| 364 | return ret; |
| 365 | } |
| 366 | |
| 367 | /* disable the keep-alive feature */ |
| 368 | ret = wl1271_acx_keep_alive_mode(wl, false); |
| 369 | if (ret < 0) |
| 370 | return ret; |
| 371 | |
| 372 | return 0; |
| 373 | } |
| 374 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 375 | /* generic ap initialization (non vif-specific) */ |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 376 | static int wl1271_ap_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 377 | { |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 378 | int ret; |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 379 | |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 380 | /* Configure for power always on */ |
| 381 | ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM); |
| 382 | if (ret < 0) |
| 383 | return ret; |
| 384 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 385 | ret = wl1271_init_ap_rates(wl, wlvif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 386 | if (ret < 0) |
| 387 | return ret; |
| 388 | |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 389 | return 0; |
| 390 | } |
| 391 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 392 | int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 393 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 394 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 395 | int ret; |
| 396 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 397 | ret = wl1271_ap_init_deauth_template(wl, wlvif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 398 | if (ret < 0) |
| 399 | return ret; |
| 400 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 401 | ret = wl1271_ap_init_null_template(wl, vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 402 | if (ret < 0) |
| 403 | return ret; |
| 404 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 405 | ret = wl1271_ap_init_qos_null_template(wl, vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 406 | if (ret < 0) |
| 407 | return ret; |
| 408 | |
Arik Nemtsov | 521a4a2 | 2011-04-18 14:15:22 +0300 | [diff] [blame] | 409 | /* |
| 410 | * when operating as AP we want to receive external beacons for |
| 411 | * configuring ERP protection. |
| 412 | */ |
Eliad Peller | f42bd2c | 2011-08-14 13:17:13 +0300 | [diff] [blame] | 413 | ret = wl1271_acx_beacon_filter_opt(wl, false); |
Arik Nemtsov | 521a4a2 | 2011-04-18 14:15:22 +0300 | [diff] [blame] | 414 | if (ret < 0) |
| 415 | return ret; |
| 416 | |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 417 | return 0; |
| 418 | } |
| 419 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 420 | static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl, |
| 421 | struct ieee80211_vif *vif) |
Arik Nemtsov | c45a85b | 2011-04-18 14:15:26 +0300 | [diff] [blame] | 422 | { |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 423 | return wl1271_ap_init_templates(wl, vif); |
Arik Nemtsov | c45a85b | 2011-04-18 14:15:26 +0300 | [diff] [blame] | 424 | } |
| 425 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 426 | int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 427 | { |
| 428 | int i, ret; |
| 429 | struct conf_tx_rate_class rc; |
| 430 | u32 supported_rates; |
| 431 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 432 | wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", |
| 433 | wlvif->basic_rate_set); |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 434 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 435 | if (wlvif->basic_rate_set == 0) |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 436 | return -EINVAL; |
| 437 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 438 | rc.enabled_rates = wlvif->basic_rate_set; |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 439 | rc.long_retry_limit = 10; |
| 440 | rc.short_retry_limit = 10; |
| 441 | rc.aflags = 0; |
| 442 | ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_MGMT_RATE); |
| 443 | if (ret < 0) |
| 444 | return ret; |
| 445 | |
| 446 | /* use the min basic rate for AP broadcast/multicast */ |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 447 | rc.enabled_rates = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 448 | rc.short_retry_limit = 10; |
| 449 | rc.long_retry_limit = 10; |
| 450 | rc.aflags = 0; |
| 451 | ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_BCST_RATE); |
| 452 | if (ret < 0) |
| 453 | return ret; |
| 454 | |
| 455 | /* |
| 456 | * If the basic rates contain OFDM rates, use OFDM only |
| 457 | * rates for unicast TX as well. Else use all supported rates. |
| 458 | */ |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 459 | if ((wlvif->basic_rate_set & CONF_TX_OFDM_RATES)) |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 460 | supported_rates = CONF_TX_OFDM_RATES; |
| 461 | else |
| 462 | supported_rates = CONF_TX_AP_ENABLED_RATES; |
| 463 | |
Arik Nemtsov | 1a8adb6 | 2011-08-14 13:17:29 +0300 | [diff] [blame] | 464 | /* unconditionally enable HT rates */ |
| 465 | supported_rates |= CONF_TX_MCS_RATES; |
| 466 | |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 467 | /* configure unicast TX rate classes */ |
| 468 | for (i = 0; i < wl->conf.tx.ac_conf_count; i++) { |
| 469 | rc.enabled_rates = supported_rates; |
| 470 | rc.short_retry_limit = 10; |
| 471 | rc.long_retry_limit = 10; |
| 472 | rc.aflags = 0; |
| 473 | ret = wl1271_acx_ap_rate_policy(wl, &rc, i); |
| 474 | if (ret < 0) |
| 475 | return ret; |
| 476 | } |
| 477 | |
| 478 | return 0; |
| 479 | } |
| 480 | |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 481 | static int wl1271_set_ba_policies(struct wl1271 *wl) |
| 482 | { |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 483 | /* Reset the BA RX indicators */ |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 484 | wl->ba_rx_bitmap = 0; |
Shahar Levi | 70559a0 | 2011-05-22 16:10:22 +0300 | [diff] [blame] | 485 | wl->ba_allowed = true; |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 486 | wl->ba_rx_session_count = 0; |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 487 | |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 488 | /* BA is supported in STA/AP modes */ |
| 489 | if (wl->bss_type != BSS_TYPE_AP_BSS && |
| 490 | wl->bss_type != BSS_TYPE_STA_BSS) { |
| 491 | wl->ba_support = false; |
| 492 | return 0; |
| 493 | } |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 494 | |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 495 | wl->ba_support = true; |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 496 | |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 497 | /* 802.11n initiator BA session setting */ |
| 498 | return wl12xx_acx_set_ba_initiator_policy(wl); |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 499 | } |
| 500 | |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 501 | int wl1271_chip_specific_init(struct wl1271 *wl) |
| 502 | { |
| 503 | int ret = 0; |
| 504 | |
| 505 | if (wl->chip.id == CHIP_ID_1283_PG20) { |
| 506 | u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE; |
| 507 | |
Ido Yariv | 0da13da | 2011-03-31 10:06:58 +0200 | [diff] [blame] | 508 | if (wl->quirks & WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT) |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 509 | /* Enable SDIO padding */ |
| 510 | host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK; |
| 511 | |
| 512 | /* Must be before wl1271_acx_init_mem_config() */ |
| 513 | ret = wl1271_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap); |
| 514 | if (ret < 0) |
| 515 | goto out; |
| 516 | } |
| 517 | out: |
| 518 | return ret; |
| 519 | } |
| 520 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 521 | /* vif-specifc initialization */ |
| 522 | static int wl12xx_init_sta_role(struct wl1271 *wl, struct ieee80211_vif *vif) |
| 523 | { |
| 524 | int ret; |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 525 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 526 | ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0); |
| 527 | if (ret < 0) |
| 528 | return ret; |
| 529 | |
| 530 | /* Initialize connection monitoring thresholds */ |
| 531 | ret = wl1271_acx_conn_monit_params(wl, false); |
| 532 | if (ret < 0) |
| 533 | return ret; |
| 534 | |
| 535 | /* Beacon filtering */ |
| 536 | ret = wl1271_init_beacon_filter(wl); |
| 537 | if (ret < 0) |
| 538 | return ret; |
| 539 | |
| 540 | /* Beacons and broadcast settings */ |
| 541 | ret = wl1271_init_beacon_broadcast(wl); |
| 542 | if (ret < 0) |
| 543 | return ret; |
| 544 | |
| 545 | /* Configure rssi/snr averaging weights */ |
| 546 | ret = wl1271_acx_rssi_snr_avg_weights(wl); |
| 547 | if (ret < 0) |
| 548 | return ret; |
| 549 | |
| 550 | return 0; |
| 551 | } |
| 552 | |
| 553 | /* vif-specific intialization */ |
| 554 | static int wl12xx_init_ap_role(struct wl1271 *wl, struct ieee80211_vif *vif) |
| 555 | { |
| 556 | int ret; |
| 557 | |
| 558 | ret = wl1271_acx_ap_max_tx_retry(wl); |
| 559 | if (ret < 0) |
| 560 | return ret; |
| 561 | |
| 562 | /* initialize Tx power */ |
| 563 | ret = wl1271_acx_tx_power(wl, wl->power_level); |
| 564 | if (ret < 0) |
| 565 | return ret; |
| 566 | |
| 567 | return 0; |
| 568 | } |
| 569 | |
| 570 | int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 571 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 572 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Kalle Valo | 243eeb5 | 2010-02-18 13:25:39 +0200 | [diff] [blame] | 573 | struct conf_tx_ac_category *conf_ac; |
Kalle Valo | f2054df | 2010-02-18 13:25:40 +0200 | [diff] [blame] | 574 | struct conf_tx_tid *conf_tid; |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 575 | bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 576 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 577 | int ret, i; |
| 578 | |
| 579 | /* Mode specific init */ |
| 580 | if (is_ap) { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame^] | 581 | ret = wl1271_ap_hw_init(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 582 | if (ret < 0) |
| 583 | return ret; |
| 584 | |
| 585 | ret = wl12xx_init_ap_role(wl, vif); |
| 586 | if (ret < 0) |
| 587 | return ret; |
| 588 | } else { |
| 589 | ret = wl1271_sta_hw_init(wl); |
| 590 | if (ret < 0) |
| 591 | return ret; |
| 592 | |
| 593 | ret = wl12xx_init_sta_role(wl, vif); |
| 594 | if (ret < 0) |
| 595 | return ret; |
| 596 | } |
| 597 | |
| 598 | wl12xx_init_phy_vif_config(wl); |
| 599 | |
| 600 | /* Default TID/AC configuration */ |
| 601 | BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count); |
| 602 | for (i = 0; i < wl->conf.tx.tid_conf_count; i++) { |
| 603 | conf_ac = &wl->conf.tx.ac_conf[i]; |
| 604 | ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min, |
| 605 | conf_ac->cw_max, conf_ac->aifsn, |
| 606 | conf_ac->tx_op_limit); |
| 607 | if (ret < 0) |
| 608 | return ret; |
| 609 | |
| 610 | conf_tid = &wl->conf.tx.tid_conf[i]; |
| 611 | ret = wl1271_acx_tid_cfg(wl, |
| 612 | conf_tid->queue_id, |
| 613 | conf_tid->channel_type, |
| 614 | conf_tid->tsid, |
| 615 | conf_tid->ps_scheme, |
| 616 | conf_tid->ack_policy, |
| 617 | conf_tid->apsd_conf[0], |
| 618 | conf_tid->apsd_conf[1]); |
| 619 | if (ret < 0) |
| 620 | return ret; |
| 621 | } |
| 622 | |
| 623 | /* Configure HW encryption */ |
| 624 | ret = wl1271_acx_feature_cfg(wl); |
| 625 | if (ret < 0) |
| 626 | return ret; |
| 627 | |
| 628 | /* Mode specific init - post mem init */ |
| 629 | if (is_ap) |
| 630 | ret = wl1271_ap_hw_init_post_mem(wl, vif); |
| 631 | else |
| 632 | ret = wl1271_sta_hw_init_post_mem(wl); |
| 633 | |
| 634 | if (ret < 0) |
| 635 | return ret; |
| 636 | |
| 637 | /* Configure initiator BA sessions policies */ |
| 638 | ret = wl1271_set_ba_policies(wl); |
| 639 | if (ret < 0) |
| 640 | return ret; |
| 641 | |
| 642 | return 0; |
| 643 | } |
| 644 | |
| 645 | int wl1271_hw_init(struct wl1271 *wl) |
| 646 | { |
| 647 | int ret; |
| 648 | |
Shahar Levi | 49d750ca | 2011-03-06 16:32:09 +0200 | [diff] [blame] | 649 | if (wl->chip.id == CHIP_ID_1283_PG20) |
| 650 | ret = wl128x_cmd_general_parms(wl); |
| 651 | else |
| 652 | ret = wl1271_cmd_general_parms(wl); |
Luciano Coelho | 4a90406 | 2009-11-23 23:22:18 +0200 | [diff] [blame] | 653 | if (ret < 0) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 654 | return ret; |
| 655 | |
Shahar Levi | 49d750ca | 2011-03-06 16:32:09 +0200 | [diff] [blame] | 656 | if (wl->chip.id == CHIP_ID_1283_PG20) |
| 657 | ret = wl128x_cmd_radio_parms(wl); |
| 658 | else |
| 659 | ret = wl1271_cmd_radio_parms(wl); |
Luciano Coelho | 4a90406 | 2009-11-23 23:22:18 +0200 | [diff] [blame] | 660 | if (ret < 0) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 661 | return ret; |
| 662 | |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 663 | /* Chip-specific init */ |
| 664 | ret = wl1271_chip_specific_init(wl); |
| 665 | if (ret < 0) |
| 666 | return ret; |
| 667 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 668 | /* Init templates */ |
| 669 | ret = wl1271_init_templates_config(wl); |
| 670 | if (ret < 0) |
| 671 | return ret; |
Juuso Oikarinen | 644a486 | 2010-10-05 13:11:56 +0200 | [diff] [blame] | 672 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 673 | ret = wl12xx_acx_mem_cfg(wl); |
| 674 | if (ret < 0) |
| 675 | return ret; |
| 676 | |
| 677 | /* Configure the FW logger */ |
| 678 | ret = wl12xx_init_fwlog(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 679 | if (ret < 0) |
| 680 | return ret; |
| 681 | |
Arik Nemtsov | 801f870 | 2011-04-18 14:15:20 +0300 | [diff] [blame] | 682 | /* Bluetooth WLAN coexistence */ |
| 683 | ret = wl1271_init_pta(wl); |
| 684 | if (ret < 0) |
| 685 | return ret; |
| 686 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 687 | /* Default memory configuration */ |
| 688 | ret = wl1271_acx_init_mem_config(wl); |
| 689 | if (ret < 0) |
| 690 | return ret; |
| 691 | |
| 692 | /* RX config */ |
Eliad Peller | 08c1d1c | 2011-08-14 13:17:04 +0300 | [diff] [blame] | 693 | ret = wl12xx_init_rx_config(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 694 | if (ret < 0) |
| 695 | goto out_free_memmap; |
| 696 | |
| 697 | /* PHY layer config */ |
| 698 | ret = wl1271_init_phy_config(wl); |
| 699 | if (ret < 0) |
| 700 | goto out_free_memmap; |
| 701 | |
Luciano Coelho | 6e92b41 | 2009-12-11 15:40:50 +0200 | [diff] [blame] | 702 | ret = wl1271_acx_dco_itrim_params(wl); |
| 703 | if (ret < 0) |
| 704 | goto out_free_memmap; |
| 705 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 706 | /* Configure TX patch complete interrupt behavior */ |
| 707 | ret = wl1271_acx_tx_config_options(wl); |
| 708 | if (ret < 0) |
| 709 | goto out_free_memmap; |
| 710 | |
| 711 | /* RX complete interrupt pacing */ |
| 712 | ret = wl1271_acx_init_rx_interrupt(wl); |
| 713 | if (ret < 0) |
| 714 | goto out_free_memmap; |
| 715 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 716 | /* Energy detection */ |
| 717 | ret = wl1271_init_energy_detection(wl); |
| 718 | if (ret < 0) |
| 719 | goto out_free_memmap; |
| 720 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 721 | /* Default fragmentation threshold */ |
Arik Nemtsov | 5f704d1 | 2011-04-18 14:15:21 +0300 | [diff] [blame] | 722 | ret = wl1271_acx_frag_threshold(wl, wl->hw->wiphy->frag_threshold); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 723 | if (ret < 0) |
| 724 | goto out_free_memmap; |
| 725 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 726 | /* Enable data path */ |
Luciano Coelho | 9421089 | 2009-12-11 15:40:55 +0200 | [diff] [blame] | 727 | ret = wl1271_cmd_data_path(wl, 1); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 728 | if (ret < 0) |
| 729 | goto out_free_memmap; |
| 730 | |
Juuso Oikarinen | 38ad2d8 | 2009-12-11 15:41:08 +0200 | [diff] [blame] | 731 | /* configure PM */ |
| 732 | ret = wl1271_acx_pm_config(wl); |
| 733 | if (ret < 0) |
| 734 | goto out_free_memmap; |
| 735 | |
Eliad Peller | fa6ad9f | 2011-08-14 13:17:14 +0300 | [diff] [blame] | 736 | ret = wl12xx_acx_set_rate_mgmt_params(wl); |
| 737 | if (ret < 0) |
| 738 | goto out_free_memmap; |
| 739 | |
Eliad Peller | 9487775 | 2011-08-28 15:11:56 +0300 | [diff] [blame] | 740 | /* configure hangover */ |
| 741 | ret = wl12xx_acx_config_hangover(wl); |
| 742 | if (ret < 0) |
| 743 | goto out_free_memmap; |
| 744 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 745 | return 0; |
| 746 | |
| 747 | out_free_memmap: |
| 748 | kfree(wl->target_mem_map); |
Juuso Oikarinen | 3441523 | 2009-10-08 21:56:33 +0300 | [diff] [blame] | 749 | wl->target_mem_map = NULL; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 750 | |
| 751 | return ret; |
| 752 | } |