Luciano Coelho | 9a1a699 | 2012-05-10 12:13:06 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of wl18xx |
| 3 | * |
| 4 | * Copyright (C) 2011 Texas Instruments |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * version 2 as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 18 | * 02110-1301 USA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include <linux/module.h> |
| 23 | #include <linux/platform_device.h> |
Arik Nemtsov | 2fc28de | 2012-05-10 12:13:27 +0300 | [diff] [blame] | 24 | #include <linux/ip.h> |
Luciano Coelho | 9a1a699 | 2012-05-10 12:13:06 +0300 | [diff] [blame] | 25 | |
| 26 | #include "../wlcore/wlcore.h" |
| 27 | #include "../wlcore/debug.h" |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 28 | #include "../wlcore/io.h" |
| 29 | #include "../wlcore/acx.h" |
Arik Nemtsov | fb0f2e4 | 2012-05-10 12:13:18 +0300 | [diff] [blame] | 30 | #include "../wlcore/tx.h" |
Arik Nemtsov | 9c809f8 | 2012-05-10 12:13:23 +0300 | [diff] [blame] | 31 | #include "../wlcore/rx.h" |
| 32 | #include "../wlcore/io.h" |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 33 | #include "../wlcore/boot.h" |
Luciano Coelho | 9a1a699 | 2012-05-10 12:13:06 +0300 | [diff] [blame] | 34 | |
Luciano Coelho | 5d4a9fa | 2012-05-10 12:13:10 +0300 | [diff] [blame] | 35 | #include "reg.h" |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 36 | #include "conf.h" |
Luciano Coelho | b8422dc | 2012-05-10 12:13:26 +0300 | [diff] [blame] | 37 | #include "acx.h" |
Arik Nemtsov | 872b345 | 2012-05-10 12:13:25 +0300 | [diff] [blame] | 38 | #include "tx.h" |
Luciano Coelho | 274c66c | 2012-05-10 12:13:13 +0300 | [diff] [blame] | 39 | #include "wl18xx.h" |
Luciano Coelho | be65202 | 2012-05-10 12:13:41 +0300 | [diff] [blame] | 40 | #include "io.h" |
Luciano Coelho | 8c0ea10 | 2012-05-10 12:14:09 +0300 | [diff] [blame] | 41 | #include "debugfs.h" |
Arik Nemtsov | 1349c42 | 2012-05-10 12:13:16 +0300 | [diff] [blame] | 42 | |
Arik Nemtsov | 169da04 | 2012-05-10 12:13:28 +0300 | [diff] [blame] | 43 | #define WL18XX_RX_CHECKSUM_MASK 0x40 |
| 44 | |
Luciano Coelho | 174a730 | 2012-05-10 12:14:13 +0300 | [diff] [blame] | 45 | static char *ht_mode_param = "wide"; |
Luciano Coelho | 4b9d236 | 2012-05-10 12:13:59 +0300 | [diff] [blame] | 46 | static char *board_type_param = "hdk"; |
Luciano Coelho | e925881 | 2012-05-10 12:13:52 +0300 | [diff] [blame] | 47 | static bool dc2dc_param = false; |
| 48 | static int n_antennas_2_param = 1; |
| 49 | static int n_antennas_5_param = 1; |
Luciano Coelho | 102165c | 2012-05-10 12:13:53 +0300 | [diff] [blame] | 50 | static bool checksum_param = true; |
Luciano Coelho | 1ddbc7d | 2012-05-10 12:13:56 +0300 | [diff] [blame] | 51 | static bool enable_11a_param = true; |
Luciano Coelho | 858403a | 2012-05-10 12:14:17 +0300 | [diff] [blame] | 52 | static int low_band_component = -1; |
| 53 | static int low_band_component_type = -1; |
| 54 | static int high_band_component = -1; |
| 55 | static int high_band_component_type = -1; |
Luciano Coelho | 7b03c30 | 2012-05-10 12:14:18 +0300 | [diff] [blame^] | 56 | static int pwr_limit_reference_11_abg = -1; |
Arik Nemtsov | 3a8ddb6 | 2012-05-10 12:13:36 +0300 | [diff] [blame] | 57 | |
Arik Nemtsov | f648eab | 2012-05-10 12:13:20 +0300 | [diff] [blame] | 58 | static const u8 wl18xx_rate_to_idx_2ghz[] = { |
| 59 | /* MCS rates are used only with 11n */ |
| 60 | 15, /* WL18XX_CONF_HW_RXTX_RATE_MCS15 */ |
| 61 | 14, /* WL18XX_CONF_HW_RXTX_RATE_MCS14 */ |
| 62 | 13, /* WL18XX_CONF_HW_RXTX_RATE_MCS13 */ |
| 63 | 12, /* WL18XX_CONF_HW_RXTX_RATE_MCS12 */ |
| 64 | 11, /* WL18XX_CONF_HW_RXTX_RATE_MCS11 */ |
| 65 | 10, /* WL18XX_CONF_HW_RXTX_RATE_MCS10 */ |
| 66 | 9, /* WL18XX_CONF_HW_RXTX_RATE_MCS9 */ |
| 67 | 8, /* WL18XX_CONF_HW_RXTX_RATE_MCS8 */ |
| 68 | 7, /* WL18XX_CONF_HW_RXTX_RATE_MCS7 */ |
| 69 | 6, /* WL18XX_CONF_HW_RXTX_RATE_MCS6 */ |
| 70 | 5, /* WL18XX_CONF_HW_RXTX_RATE_MCS5 */ |
| 71 | 4, /* WL18XX_CONF_HW_RXTX_RATE_MCS4 */ |
| 72 | 3, /* WL18XX_CONF_HW_RXTX_RATE_MCS3 */ |
| 73 | 2, /* WL18XX_CONF_HW_RXTX_RATE_MCS2 */ |
| 74 | 1, /* WL18XX_CONF_HW_RXTX_RATE_MCS1 */ |
| 75 | 0, /* WL18XX_CONF_HW_RXTX_RATE_MCS0 */ |
| 76 | |
| 77 | 11, /* WL18XX_CONF_HW_RXTX_RATE_54 */ |
| 78 | 10, /* WL18XX_CONF_HW_RXTX_RATE_48 */ |
| 79 | 9, /* WL18XX_CONF_HW_RXTX_RATE_36 */ |
| 80 | 8, /* WL18XX_CONF_HW_RXTX_RATE_24 */ |
| 81 | |
| 82 | /* TI-specific rate */ |
| 83 | CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_22 */ |
| 84 | |
| 85 | 7, /* WL18XX_CONF_HW_RXTX_RATE_18 */ |
| 86 | 6, /* WL18XX_CONF_HW_RXTX_RATE_12 */ |
| 87 | 3, /* WL18XX_CONF_HW_RXTX_RATE_11 */ |
| 88 | 5, /* WL18XX_CONF_HW_RXTX_RATE_9 */ |
| 89 | 4, /* WL18XX_CONF_HW_RXTX_RATE_6 */ |
| 90 | 2, /* WL18XX_CONF_HW_RXTX_RATE_5_5 */ |
| 91 | 1, /* WL18XX_CONF_HW_RXTX_RATE_2 */ |
| 92 | 0 /* WL18XX_CONF_HW_RXTX_RATE_1 */ |
| 93 | }; |
| 94 | |
| 95 | static const u8 wl18xx_rate_to_idx_5ghz[] = { |
| 96 | /* MCS rates are used only with 11n */ |
| 97 | 15, /* WL18XX_CONF_HW_RXTX_RATE_MCS15 */ |
| 98 | 14, /* WL18XX_CONF_HW_RXTX_RATE_MCS14 */ |
| 99 | 13, /* WL18XX_CONF_HW_RXTX_RATE_MCS13 */ |
| 100 | 12, /* WL18XX_CONF_HW_RXTX_RATE_MCS12 */ |
| 101 | 11, /* WL18XX_CONF_HW_RXTX_RATE_MCS11 */ |
| 102 | 10, /* WL18XX_CONF_HW_RXTX_RATE_MCS10 */ |
| 103 | 9, /* WL18XX_CONF_HW_RXTX_RATE_MCS9 */ |
| 104 | 8, /* WL18XX_CONF_HW_RXTX_RATE_MCS8 */ |
| 105 | 7, /* WL18XX_CONF_HW_RXTX_RATE_MCS7 */ |
| 106 | 6, /* WL18XX_CONF_HW_RXTX_RATE_MCS6 */ |
| 107 | 5, /* WL18XX_CONF_HW_RXTX_RATE_MCS5 */ |
| 108 | 4, /* WL18XX_CONF_HW_RXTX_RATE_MCS4 */ |
| 109 | 3, /* WL18XX_CONF_HW_RXTX_RATE_MCS3 */ |
| 110 | 2, /* WL18XX_CONF_HW_RXTX_RATE_MCS2 */ |
| 111 | 1, /* WL18XX_CONF_HW_RXTX_RATE_MCS1 */ |
| 112 | 0, /* WL18XX_CONF_HW_RXTX_RATE_MCS0 */ |
| 113 | |
| 114 | 7, /* WL18XX_CONF_HW_RXTX_RATE_54 */ |
| 115 | 6, /* WL18XX_CONF_HW_RXTX_RATE_48 */ |
| 116 | 5, /* WL18XX_CONF_HW_RXTX_RATE_36 */ |
| 117 | 4, /* WL18XX_CONF_HW_RXTX_RATE_24 */ |
| 118 | |
| 119 | /* TI-specific rate */ |
| 120 | CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_22 */ |
| 121 | |
| 122 | 3, /* WL18XX_CONF_HW_RXTX_RATE_18 */ |
| 123 | 2, /* WL18XX_CONF_HW_RXTX_RATE_12 */ |
| 124 | CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_11 */ |
| 125 | 1, /* WL18XX_CONF_HW_RXTX_RATE_9 */ |
| 126 | 0, /* WL18XX_CONF_HW_RXTX_RATE_6 */ |
| 127 | CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_5_5 */ |
| 128 | CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_2 */ |
| 129 | CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_1 */ |
| 130 | }; |
| 131 | |
| 132 | static const u8 *wl18xx_band_rate_to_idx[] = { |
| 133 | [IEEE80211_BAND_2GHZ] = wl18xx_rate_to_idx_2ghz, |
| 134 | [IEEE80211_BAND_5GHZ] = wl18xx_rate_to_idx_5ghz |
| 135 | }; |
| 136 | |
| 137 | enum wl18xx_hw_rates { |
| 138 | WL18XX_CONF_HW_RXTX_RATE_MCS15 = 0, |
| 139 | WL18XX_CONF_HW_RXTX_RATE_MCS14, |
| 140 | WL18XX_CONF_HW_RXTX_RATE_MCS13, |
| 141 | WL18XX_CONF_HW_RXTX_RATE_MCS12, |
| 142 | WL18XX_CONF_HW_RXTX_RATE_MCS11, |
| 143 | WL18XX_CONF_HW_RXTX_RATE_MCS10, |
| 144 | WL18XX_CONF_HW_RXTX_RATE_MCS9, |
| 145 | WL18XX_CONF_HW_RXTX_RATE_MCS8, |
| 146 | WL18XX_CONF_HW_RXTX_RATE_MCS7, |
| 147 | WL18XX_CONF_HW_RXTX_RATE_MCS6, |
| 148 | WL18XX_CONF_HW_RXTX_RATE_MCS5, |
| 149 | WL18XX_CONF_HW_RXTX_RATE_MCS4, |
| 150 | WL18XX_CONF_HW_RXTX_RATE_MCS3, |
| 151 | WL18XX_CONF_HW_RXTX_RATE_MCS2, |
| 152 | WL18XX_CONF_HW_RXTX_RATE_MCS1, |
| 153 | WL18XX_CONF_HW_RXTX_RATE_MCS0, |
| 154 | WL18XX_CONF_HW_RXTX_RATE_54, |
| 155 | WL18XX_CONF_HW_RXTX_RATE_48, |
| 156 | WL18XX_CONF_HW_RXTX_RATE_36, |
| 157 | WL18XX_CONF_HW_RXTX_RATE_24, |
| 158 | WL18XX_CONF_HW_RXTX_RATE_22, |
| 159 | WL18XX_CONF_HW_RXTX_RATE_18, |
| 160 | WL18XX_CONF_HW_RXTX_RATE_12, |
| 161 | WL18XX_CONF_HW_RXTX_RATE_11, |
| 162 | WL18XX_CONF_HW_RXTX_RATE_9, |
| 163 | WL18XX_CONF_HW_RXTX_RATE_6, |
| 164 | WL18XX_CONF_HW_RXTX_RATE_5_5, |
| 165 | WL18XX_CONF_HW_RXTX_RATE_2, |
| 166 | WL18XX_CONF_HW_RXTX_RATE_1, |
| 167 | WL18XX_CONF_HW_RXTX_RATE_MAX, |
| 168 | }; |
| 169 | |
Luciano Coelho | 23ee9bf | 2012-05-10 12:13:29 +0300 | [diff] [blame] | 170 | static struct wlcore_conf wl18xx_conf = { |
| 171 | .sg = { |
| 172 | .params = { |
| 173 | [CONF_SG_ACL_BT_MASTER_MIN_BR] = 10, |
| 174 | [CONF_SG_ACL_BT_MASTER_MAX_BR] = 180, |
| 175 | [CONF_SG_ACL_BT_SLAVE_MIN_BR] = 10, |
| 176 | [CONF_SG_ACL_BT_SLAVE_MAX_BR] = 180, |
| 177 | [CONF_SG_ACL_BT_MASTER_MIN_EDR] = 10, |
| 178 | [CONF_SG_ACL_BT_MASTER_MAX_EDR] = 80, |
| 179 | [CONF_SG_ACL_BT_SLAVE_MIN_EDR] = 10, |
| 180 | [CONF_SG_ACL_BT_SLAVE_MAX_EDR] = 80, |
| 181 | [CONF_SG_ACL_WLAN_PS_MASTER_BR] = 8, |
| 182 | [CONF_SG_ACL_WLAN_PS_SLAVE_BR] = 8, |
| 183 | [CONF_SG_ACL_WLAN_PS_MASTER_EDR] = 20, |
| 184 | [CONF_SG_ACL_WLAN_PS_SLAVE_EDR] = 20, |
| 185 | [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MIN_BR] = 20, |
| 186 | [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MAX_BR] = 35, |
| 187 | [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MIN_BR] = 16, |
| 188 | [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MAX_BR] = 35, |
| 189 | [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MIN_EDR] = 32, |
| 190 | [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MAX_EDR] = 50, |
| 191 | [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MIN_EDR] = 28, |
| 192 | [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MAX_EDR] = 50, |
| 193 | [CONF_SG_ACL_ACTIVE_SCAN_WLAN_BR] = 10, |
| 194 | [CONF_SG_ACL_ACTIVE_SCAN_WLAN_EDR] = 20, |
| 195 | [CONF_SG_ACL_PASSIVE_SCAN_BT_BR] = 75, |
| 196 | [CONF_SG_ACL_PASSIVE_SCAN_WLAN_BR] = 15, |
| 197 | [CONF_SG_ACL_PASSIVE_SCAN_BT_EDR] = 27, |
| 198 | [CONF_SG_ACL_PASSIVE_SCAN_WLAN_EDR] = 17, |
| 199 | /* active scan params */ |
| 200 | [CONF_SG_AUTO_SCAN_PROBE_REQ] = 170, |
| 201 | [CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_HV3] = 50, |
| 202 | [CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_A2DP] = 100, |
| 203 | /* passive scan params */ |
| 204 | [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_A2DP_BR] = 800, |
| 205 | [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_A2DP_EDR] = 200, |
| 206 | [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_HV3] = 200, |
| 207 | /* passive scan in dual antenna params */ |
| 208 | [CONF_SG_CONSECUTIVE_HV3_IN_PASSIVE_SCAN] = 0, |
| 209 | [CONF_SG_BCN_HV3_COLLISION_THRESH_IN_PASSIVE_SCAN] = 0, |
| 210 | [CONF_SG_TX_RX_PROTECTION_BWIDTH_IN_PASSIVE_SCAN] = 0, |
| 211 | /* general params */ |
| 212 | [CONF_SG_STA_FORCE_PS_IN_BT_SCO] = 1, |
| 213 | [CONF_SG_ANTENNA_CONFIGURATION] = 0, |
| 214 | [CONF_SG_BEACON_MISS_PERCENT] = 60, |
| 215 | [CONF_SG_DHCP_TIME] = 5000, |
| 216 | [CONF_SG_RXT] = 1200, |
| 217 | [CONF_SG_TXT] = 1000, |
| 218 | [CONF_SG_ADAPTIVE_RXT_TXT] = 1, |
| 219 | [CONF_SG_GENERAL_USAGE_BIT_MAP] = 3, |
| 220 | [CONF_SG_HV3_MAX_SERVED] = 6, |
| 221 | [CONF_SG_PS_POLL_TIMEOUT] = 10, |
| 222 | [CONF_SG_UPSD_TIMEOUT] = 10, |
| 223 | [CONF_SG_CONSECUTIVE_CTS_THRESHOLD] = 2, |
| 224 | [CONF_SG_STA_RX_WINDOW_AFTER_DTIM] = 5, |
| 225 | [CONF_SG_STA_CONNECTION_PROTECTION_TIME] = 30, |
| 226 | /* AP params */ |
| 227 | [CONF_AP_BEACON_MISS_TX] = 3, |
| 228 | [CONF_AP_RX_WINDOW_AFTER_BEACON] = 10, |
| 229 | [CONF_AP_BEACON_WINDOW_INTERVAL] = 2, |
| 230 | [CONF_AP_CONNECTION_PROTECTION_TIME] = 0, |
| 231 | [CONF_AP_BT_ACL_VAL_BT_SERVE_TIME] = 25, |
| 232 | [CONF_AP_BT_ACL_VAL_WL_SERVE_TIME] = 25, |
| 233 | /* CTS Diluting params */ |
| 234 | [CONF_SG_CTS_DILUTED_BAD_RX_PACKETS_TH] = 0, |
| 235 | [CONF_SG_CTS_CHOP_IN_DUAL_ANT_SCO_MASTER] = 0, |
| 236 | }, |
| 237 | .state = CONF_SG_PROTECTIVE, |
| 238 | }, |
| 239 | .rx = { |
| 240 | .rx_msdu_life_time = 512000, |
| 241 | .packet_detection_threshold = 0, |
| 242 | .ps_poll_timeout = 15, |
| 243 | .upsd_timeout = 15, |
| 244 | .rts_threshold = IEEE80211_MAX_RTS_THRESHOLD, |
| 245 | .rx_cca_threshold = 0, |
| 246 | .irq_blk_threshold = 0xFFFF, |
| 247 | .irq_pkt_threshold = 0, |
| 248 | .irq_timeout = 600, |
| 249 | .queue_type = CONF_RX_QUEUE_TYPE_LOW_PRIORITY, |
| 250 | }, |
| 251 | .tx = { |
| 252 | .tx_energy_detection = 0, |
| 253 | .sta_rc_conf = { |
| 254 | .enabled_rates = 0, |
| 255 | .short_retry_limit = 10, |
| 256 | .long_retry_limit = 10, |
| 257 | .aflags = 0, |
| 258 | }, |
| 259 | .ac_conf_count = 4, |
| 260 | .ac_conf = { |
| 261 | [CONF_TX_AC_BE] = { |
| 262 | .ac = CONF_TX_AC_BE, |
| 263 | .cw_min = 15, |
| 264 | .cw_max = 63, |
| 265 | .aifsn = 3, |
| 266 | .tx_op_limit = 0, |
| 267 | }, |
| 268 | [CONF_TX_AC_BK] = { |
| 269 | .ac = CONF_TX_AC_BK, |
| 270 | .cw_min = 15, |
| 271 | .cw_max = 63, |
| 272 | .aifsn = 7, |
| 273 | .tx_op_limit = 0, |
| 274 | }, |
| 275 | [CONF_TX_AC_VI] = { |
| 276 | .ac = CONF_TX_AC_VI, |
| 277 | .cw_min = 15, |
| 278 | .cw_max = 63, |
| 279 | .aifsn = CONF_TX_AIFS_PIFS, |
| 280 | .tx_op_limit = 3008, |
| 281 | }, |
| 282 | [CONF_TX_AC_VO] = { |
| 283 | .ac = CONF_TX_AC_VO, |
| 284 | .cw_min = 15, |
| 285 | .cw_max = 63, |
| 286 | .aifsn = CONF_TX_AIFS_PIFS, |
| 287 | .tx_op_limit = 1504, |
| 288 | }, |
| 289 | }, |
| 290 | .max_tx_retries = 100, |
| 291 | .ap_aging_period = 300, |
| 292 | .tid_conf_count = 4, |
| 293 | .tid_conf = { |
| 294 | [CONF_TX_AC_BE] = { |
| 295 | .queue_id = CONF_TX_AC_BE, |
| 296 | .channel_type = CONF_CHANNEL_TYPE_EDCF, |
| 297 | .tsid = CONF_TX_AC_BE, |
| 298 | .ps_scheme = CONF_PS_SCHEME_LEGACY, |
| 299 | .ack_policy = CONF_ACK_POLICY_LEGACY, |
| 300 | .apsd_conf = {0, 0}, |
| 301 | }, |
| 302 | [CONF_TX_AC_BK] = { |
| 303 | .queue_id = CONF_TX_AC_BK, |
| 304 | .channel_type = CONF_CHANNEL_TYPE_EDCF, |
| 305 | .tsid = CONF_TX_AC_BK, |
| 306 | .ps_scheme = CONF_PS_SCHEME_LEGACY, |
| 307 | .ack_policy = CONF_ACK_POLICY_LEGACY, |
| 308 | .apsd_conf = {0, 0}, |
| 309 | }, |
| 310 | [CONF_TX_AC_VI] = { |
| 311 | .queue_id = CONF_TX_AC_VI, |
| 312 | .channel_type = CONF_CHANNEL_TYPE_EDCF, |
| 313 | .tsid = CONF_TX_AC_VI, |
| 314 | .ps_scheme = CONF_PS_SCHEME_LEGACY, |
| 315 | .ack_policy = CONF_ACK_POLICY_LEGACY, |
| 316 | .apsd_conf = {0, 0}, |
| 317 | }, |
| 318 | [CONF_TX_AC_VO] = { |
| 319 | .queue_id = CONF_TX_AC_VO, |
| 320 | .channel_type = CONF_CHANNEL_TYPE_EDCF, |
| 321 | .tsid = CONF_TX_AC_VO, |
| 322 | .ps_scheme = CONF_PS_SCHEME_LEGACY, |
| 323 | .ack_policy = CONF_ACK_POLICY_LEGACY, |
| 324 | .apsd_conf = {0, 0}, |
| 325 | }, |
| 326 | }, |
| 327 | .frag_threshold = IEEE80211_MAX_FRAG_THRESHOLD, |
| 328 | .tx_compl_timeout = 350, |
| 329 | .tx_compl_threshold = 10, |
| 330 | .basic_rate = CONF_HW_BIT_RATE_1MBPS, |
| 331 | .basic_rate_5 = CONF_HW_BIT_RATE_6MBPS, |
| 332 | .tmpl_short_retry_limit = 10, |
| 333 | .tmpl_long_retry_limit = 10, |
| 334 | .tx_watchdog_timeout = 5000, |
| 335 | }, |
| 336 | .conn = { |
| 337 | .wake_up_event = CONF_WAKE_UP_EVENT_DTIM, |
| 338 | .listen_interval = 1, |
| 339 | .suspend_wake_up_event = CONF_WAKE_UP_EVENT_N_DTIM, |
| 340 | .suspend_listen_interval = 3, |
| 341 | .bcn_filt_mode = CONF_BCN_FILT_MODE_ENABLED, |
| 342 | .bcn_filt_ie_count = 2, |
| 343 | .bcn_filt_ie = { |
| 344 | [0] = { |
| 345 | .ie = WLAN_EID_CHANNEL_SWITCH, |
| 346 | .rule = CONF_BCN_RULE_PASS_ON_APPEARANCE, |
| 347 | }, |
| 348 | [1] = { |
| 349 | .ie = WLAN_EID_HT_OPERATION, |
| 350 | .rule = CONF_BCN_RULE_PASS_ON_CHANGE, |
| 351 | }, |
| 352 | }, |
| 353 | .synch_fail_thold = 10, |
| 354 | .bss_lose_timeout = 100, |
| 355 | .beacon_rx_timeout = 10000, |
| 356 | .broadcast_timeout = 20000, |
| 357 | .rx_broadcast_in_ps = 1, |
| 358 | .ps_poll_threshold = 10, |
| 359 | .bet_enable = CONF_BET_MODE_ENABLE, |
| 360 | .bet_max_consecutive = 50, |
| 361 | .psm_entry_retries = 8, |
| 362 | .psm_exit_retries = 16, |
| 363 | .psm_entry_nullfunc_retries = 3, |
| 364 | .dynamic_ps_timeout = 40, |
| 365 | .forced_ps = false, |
| 366 | .keep_alive_interval = 55000, |
| 367 | .max_listen_interval = 20, |
| 368 | }, |
| 369 | .itrim = { |
| 370 | .enable = false, |
| 371 | .timeout = 50000, |
| 372 | }, |
| 373 | .pm_config = { |
| 374 | .host_clk_settling_time = 5000, |
| 375 | .host_fast_wakeup_support = false |
| 376 | }, |
| 377 | .roam_trigger = { |
| 378 | .trigger_pacing = 1, |
| 379 | .avg_weight_rssi_beacon = 20, |
| 380 | .avg_weight_rssi_data = 10, |
| 381 | .avg_weight_snr_beacon = 20, |
| 382 | .avg_weight_snr_data = 10, |
| 383 | }, |
| 384 | .scan = { |
| 385 | .min_dwell_time_active = 7500, |
| 386 | .max_dwell_time_active = 30000, |
| 387 | .min_dwell_time_passive = 100000, |
| 388 | .max_dwell_time_passive = 100000, |
| 389 | .num_probe_reqs = 2, |
| 390 | .split_scan_timeout = 50000, |
| 391 | }, |
| 392 | .sched_scan = { |
| 393 | /* |
| 394 | * Values are in TU/1000 but since sched scan FW command |
| 395 | * params are in TUs rounding up may occur. |
| 396 | */ |
| 397 | .base_dwell_time = 7500, |
| 398 | .max_dwell_time_delta = 22500, |
| 399 | /* based on 250bits per probe @1Mbps */ |
| 400 | .dwell_time_delta_per_probe = 2000, |
| 401 | /* based on 250bits per probe @6Mbps (plus a bit more) */ |
| 402 | .dwell_time_delta_per_probe_5 = 350, |
| 403 | .dwell_time_passive = 100000, |
| 404 | .dwell_time_dfs = 150000, |
| 405 | .num_probe_reqs = 2, |
| 406 | .rssi_threshold = -90, |
| 407 | .snr_threshold = 0, |
| 408 | }, |
| 409 | .ht = { |
| 410 | .rx_ba_win_size = 10, |
| 411 | .tx_ba_win_size = 10, |
| 412 | .inactivity_timeout = 10000, |
| 413 | .tx_ba_tid_bitmap = CONF_TX_BA_ENABLED_TID_BITMAP, |
| 414 | }, |
| 415 | .mem = { |
| 416 | .num_stations = 1, |
| 417 | .ssid_profiles = 1, |
| 418 | .rx_block_num = 40, |
| 419 | .tx_min_block_num = 40, |
| 420 | .dynamic_memory = 1, |
| 421 | .min_req_tx_blocks = 45, |
| 422 | .min_req_rx_blocks = 22, |
| 423 | .tx_min = 27, |
| 424 | }, |
| 425 | .fm_coex = { |
| 426 | .enable = true, |
| 427 | .swallow_period = 5, |
| 428 | .n_divider_fref_set_1 = 0xff, /* default */ |
| 429 | .n_divider_fref_set_2 = 12, |
| 430 | .m_divider_fref_set_1 = 148, |
| 431 | .m_divider_fref_set_2 = 0xffff, /* default */ |
| 432 | .coex_pll_stabilization_time = 0xffffffff, /* default */ |
| 433 | .ldo_stabilization_time = 0xffff, /* default */ |
| 434 | .fm_disturbed_band_margin = 0xff, /* default */ |
| 435 | .swallow_clk_diff = 0xff, /* default */ |
| 436 | }, |
| 437 | .rx_streaming = { |
| 438 | .duration = 150, |
| 439 | .queues = 0x1, |
| 440 | .interval = 20, |
| 441 | .always = 0, |
| 442 | }, |
| 443 | .fwlog = { |
| 444 | .mode = WL12XX_FWLOG_ON_DEMAND, |
| 445 | .mem_blocks = 2, |
| 446 | .severity = 0, |
| 447 | .timestamp = WL12XX_FWLOG_TIMESTAMP_DISABLED, |
| 448 | .output = WL12XX_FWLOG_OUTPUT_HOST, |
| 449 | .threshold = 0, |
| 450 | }, |
| 451 | .rate = { |
| 452 | .rate_retry_score = 32000, |
| 453 | .per_add = 8192, |
| 454 | .per_th1 = 2048, |
| 455 | .per_th2 = 4096, |
| 456 | .max_per = 8100, |
| 457 | .inverse_curiosity_factor = 5, |
| 458 | .tx_fail_low_th = 4, |
| 459 | .tx_fail_high_th = 10, |
| 460 | .per_alpha_shift = 4, |
| 461 | .per_add_shift = 13, |
| 462 | .per_beta1_shift = 10, |
| 463 | .per_beta2_shift = 8, |
| 464 | .rate_check_up = 2, |
| 465 | .rate_check_down = 12, |
| 466 | .rate_retry_policy = { |
| 467 | 0x00, 0x00, 0x00, 0x00, 0x00, |
| 468 | 0x00, 0x00, 0x00, 0x00, 0x00, |
| 469 | 0x00, 0x00, 0x00, |
| 470 | }, |
| 471 | }, |
| 472 | .hangover = { |
| 473 | .recover_time = 0, |
| 474 | .hangover_period = 20, |
| 475 | .dynamic_mode = 1, |
| 476 | .early_termination_mode = 1, |
| 477 | .max_period = 20, |
| 478 | .min_period = 1, |
| 479 | .increase_delta = 1, |
| 480 | .decrease_delta = 2, |
| 481 | .quiet_time = 4, |
| 482 | .increase_time = 1, |
| 483 | .window_size = 16, |
| 484 | }, |
| 485 | }; |
| 486 | |
| 487 | static struct wl18xx_priv_conf wl18xx_default_priv_conf = { |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 488 | .phy = { |
| 489 | .phy_standalone = 0x00, |
| 490 | .primary_clock_setting_time = 0x05, |
| 491 | .clock_valid_on_wake_up = 0x00, |
| 492 | .secondary_clock_setting_time = 0x05, |
| 493 | .rdl = 0x01, |
| 494 | .auto_detect = 0x00, |
| 495 | .dedicated_fem = FEM_NONE, |
| 496 | .low_band_component = COMPONENT_2_WAY_SWITCH, |
| 497 | .low_band_component_type = 0x05, |
| 498 | .high_band_component = COMPONENT_2_WAY_SWITCH, |
| 499 | .high_band_component_type = 0x09, |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 500 | .tcxo_ldo_voltage = 0x00, |
| 501 | .xtal_itrim_val = 0x04, |
| 502 | .srf_state = 0x00, |
| 503 | .io_configuration = 0x01, |
| 504 | .sdio_configuration = 0x00, |
| 505 | .settings = 0x00, |
| 506 | .enable_clpc = 0x00, |
| 507 | .enable_tx_low_pwr_on_siso_rdl = 0x00, |
| 508 | .rx_profile = 0x00, |
Luciano Coelho | 5add82e | 2012-05-10 12:14:16 +0300 | [diff] [blame] | 509 | .pwr_limit_reference_11_abg = 0xc8, |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 510 | }, |
| 511 | }; |
Luciano Coelho | 5d4a9fa | 2012-05-10 12:13:10 +0300 | [diff] [blame] | 512 | |
Luciano Coelho | 82b890c | 2012-05-10 12:13:09 +0300 | [diff] [blame] | 513 | static const struct wlcore_partition_set wl18xx_ptable[PART_TABLE_LEN] = { |
| 514 | [PART_TOP_PRCM_ELP_SOC] = { |
| 515 | .mem = { .start = 0x00A02000, .size = 0x00010000 }, |
| 516 | .reg = { .start = 0x00807000, .size = 0x00005000 }, |
| 517 | .mem2 = { .start = 0x00800000, .size = 0x0000B000 }, |
| 518 | .mem3 = { .start = 0x00000000, .size = 0x00000000 }, |
| 519 | }, |
| 520 | [PART_DOWN] = { |
| 521 | .mem = { .start = 0x00000000, .size = 0x00014000 }, |
| 522 | .reg = { .start = 0x00810000, .size = 0x0000BFFF }, |
| 523 | .mem2 = { .start = 0x00000000, .size = 0x00000000 }, |
| 524 | .mem3 = { .start = 0x00000000, .size = 0x00000000 }, |
| 525 | }, |
| 526 | [PART_BOOT] = { |
| 527 | .mem = { .start = 0x00700000, .size = 0x0000030c }, |
| 528 | .reg = { .start = 0x00802000, .size = 0x00014578 }, |
| 529 | .mem2 = { .start = 0x00B00404, .size = 0x00001000 }, |
| 530 | .mem3 = { .start = 0x00C00000, .size = 0x00000400 }, |
| 531 | }, |
| 532 | [PART_WORK] = { |
| 533 | .mem = { .start = 0x00800000, .size = 0x000050FC }, |
| 534 | .reg = { .start = 0x00B00404, .size = 0x00001000 }, |
| 535 | .mem2 = { .start = 0x00C00000, .size = 0x00000400 }, |
| 536 | .mem3 = { .start = 0x00000000, .size = 0x00000000 }, |
| 537 | }, |
| 538 | [PART_PHY_INIT] = { |
| 539 | /* TODO: use the phy_conf struct size here */ |
| 540 | .mem = { .start = 0x80926000, .size = 252 }, |
| 541 | .reg = { .start = 0x00000000, .size = 0x00000000 }, |
| 542 | .mem2 = { .start = 0x00000000, .size = 0x00000000 }, |
| 543 | .mem3 = { .start = 0x00000000, .size = 0x00000000 }, |
| 544 | }, |
| 545 | }; |
| 546 | |
Luciano Coelho | 5d4a9fa | 2012-05-10 12:13:10 +0300 | [diff] [blame] | 547 | static const int wl18xx_rtable[REG_TABLE_LEN] = { |
| 548 | [REG_ECPU_CONTROL] = WL18XX_REG_ECPU_CONTROL, |
| 549 | [REG_INTERRUPT_NO_CLEAR] = WL18XX_REG_INTERRUPT_NO_CLEAR, |
| 550 | [REG_INTERRUPT_ACK] = WL18XX_REG_INTERRUPT_ACK, |
| 551 | [REG_COMMAND_MAILBOX_PTR] = WL18XX_REG_COMMAND_MAILBOX_PTR, |
| 552 | [REG_EVENT_MAILBOX_PTR] = WL18XX_REG_EVENT_MAILBOX_PTR, |
| 553 | [REG_INTERRUPT_TRIG] = WL18XX_REG_INTERRUPT_TRIG_H, |
| 554 | [REG_INTERRUPT_MASK] = WL18XX_REG_INTERRUPT_MASK, |
Arik Nemtsov | 1c351da | 2012-05-10 12:13:39 +0300 | [diff] [blame] | 555 | [REG_PC_ON_RECOVERY] = WL18XX_SCR_PAD4, |
Luciano Coelho | 5d4a9fa | 2012-05-10 12:13:10 +0300 | [diff] [blame] | 556 | [REG_CHIP_ID_B] = WL18XX_REG_CHIP_ID_B, |
| 557 | [REG_CMD_MBOX_ADDRESS] = WL18XX_CMD_MBOX_ADDRESS, |
| 558 | |
| 559 | /* data access memory addresses, used with partition translation */ |
| 560 | [REG_SLV_MEM_DATA] = WL18XX_SLV_MEM_DATA, |
| 561 | [REG_SLV_REG_DATA] = WL18XX_SLV_REG_DATA, |
| 562 | |
| 563 | /* raw data access memory addresses */ |
| 564 | [REG_RAW_FW_STATUS_ADDR] = WL18XX_FW_STATUS_ADDR, |
| 565 | }; |
| 566 | |
Luciano Coelho | be65202 | 2012-05-10 12:13:41 +0300 | [diff] [blame] | 567 | static const struct wl18xx_clk_cfg wl18xx_clk_table[NUM_CLOCK_CONFIGS] = { |
| 568 | [CLOCK_CONFIG_16_2_M] = { 7, 104, 801, 4, true }, |
| 569 | [CLOCK_CONFIG_16_368_M] = { 9, 132, 3751, 4, true }, |
| 570 | [CLOCK_CONFIG_16_8_M] = { 7, 100, 0, 0, false }, |
| 571 | [CLOCK_CONFIG_19_2_M] = { 8, 100, 0, 0, false }, |
| 572 | [CLOCK_CONFIG_26_M] = { 13, 120, 0, 0, false }, |
| 573 | [CLOCK_CONFIG_32_736_M] = { 9, 132, 3751, 4, true }, |
| 574 | [CLOCK_CONFIG_33_6_M] = { 7, 100, 0, 0, false }, |
| 575 | [CLOCK_CONFIG_38_468_M] = { 8, 100, 0, 0, false }, |
| 576 | [CLOCK_CONFIG_52_M] = { 13, 120, 0, 0, false }, |
| 577 | }; |
| 578 | |
Luciano Coelho | 0cd6543 | 2012-05-10 12:13:11 +0300 | [diff] [blame] | 579 | /* TODO: maybe move to a new header file? */ |
| 580 | #define WL18XX_FW_NAME "ti-connectivity/wl18xx-fw.bin" |
| 581 | |
| 582 | static int wl18xx_identify_chip(struct wl1271 *wl) |
| 583 | { |
| 584 | int ret = 0; |
| 585 | |
| 586 | switch (wl->chip.id) { |
| 587 | case CHIP_ID_185x_PG10: |
| 588 | wl1271_debug(DEBUG_BOOT, "chip id 0x%x (185x PG10)", |
| 589 | wl->chip.id); |
| 590 | wl->sr_fw_name = WL18XX_FW_NAME; |
Luciano Coelho | be42aee | 2012-05-10 12:13:50 +0300 | [diff] [blame] | 591 | /* wl18xx uses the same firmware for PLT */ |
| 592 | wl->plt_fw_name = WL18XX_FW_NAME; |
Arik Nemtsov | 7cfefd1 | 2012-05-10 12:13:22 +0300 | [diff] [blame] | 593 | wl->quirks |= WLCORE_QUIRK_NO_ELP | |
Arik Nemtsov | d9fedea | 2012-05-10 12:13:40 +0300 | [diff] [blame] | 594 | WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED | |
Arik Nemtsov | 7cfefd1 | 2012-05-10 12:13:22 +0300 | [diff] [blame] | 595 | WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN; |
Luciano Coelho | 0cd6543 | 2012-05-10 12:13:11 +0300 | [diff] [blame] | 596 | |
Luciano Coelho | 7ae25da | 2012-05-10 12:14:03 +0300 | [diff] [blame] | 597 | /* PG 1.0 has some problems with MCS_13, so disable it */ |
| 598 | wl->ht_cap.mcs.rx_mask[1] &= ~BIT(5); |
| 599 | |
Luciano Coelho | 0cd6543 | 2012-05-10 12:13:11 +0300 | [diff] [blame] | 600 | /* TODO: need to blocksize alignment for RX/TX separately? */ |
| 601 | break; |
| 602 | default: |
| 603 | wl1271_warning("unsupported chip id: 0x%x", wl->chip.id); |
| 604 | ret = -ENODEV; |
| 605 | goto out; |
| 606 | } |
| 607 | |
| 608 | out: |
| 609 | return ret; |
| 610 | } |
| 611 | |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 612 | static void wl18xx_set_clk(struct wl1271 *wl) |
| 613 | { |
Luciano Coelho | be65202 | 2012-05-10 12:13:41 +0300 | [diff] [blame] | 614 | u32 clk_freq; |
Luciano Coelho | d5b5927 | 2012-05-10 12:13:38 +0300 | [diff] [blame] | 615 | |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 616 | wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]); |
Luciano Coelho | be65202 | 2012-05-10 12:13:41 +0300 | [diff] [blame] | 617 | |
| 618 | /* TODO: PG2: apparently we need to read the clk type */ |
| 619 | |
| 620 | clk_freq = wl18xx_top_reg_read(wl, PRIMARY_CLK_DETECT); |
| 621 | wl1271_debug(DEBUG_BOOT, "clock freq %d (%d, %d, %d, %d, %s)", clk_freq, |
| 622 | wl18xx_clk_table[clk_freq].n, wl18xx_clk_table[clk_freq].m, |
| 623 | wl18xx_clk_table[clk_freq].p, wl18xx_clk_table[clk_freq].q, |
| 624 | wl18xx_clk_table[clk_freq].swallow ? "swallow" : "spit"); |
| 625 | |
| 626 | wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_N, wl18xx_clk_table[clk_freq].n); |
| 627 | wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_M, wl18xx_clk_table[clk_freq].m); |
| 628 | |
| 629 | if (wl18xx_clk_table[clk_freq].swallow) { |
| 630 | /* first the 16 lower bits */ |
| 631 | wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_1, |
| 632 | wl18xx_clk_table[clk_freq].q & |
| 633 | PLLSH_WCS_PLL_Q_FACTOR_CFG_1_MASK); |
| 634 | /* then the 16 higher bits, masked out */ |
| 635 | wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_2, |
| 636 | (wl18xx_clk_table[clk_freq].q >> 16) & |
| 637 | PLLSH_WCS_PLL_Q_FACTOR_CFG_2_MASK); |
| 638 | |
| 639 | /* first the 16 lower bits */ |
| 640 | wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_1, |
| 641 | wl18xx_clk_table[clk_freq].p & |
| 642 | PLLSH_WCS_PLL_P_FACTOR_CFG_1_MASK); |
| 643 | /* then the 16 higher bits, masked out */ |
| 644 | wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_2, |
| 645 | (wl18xx_clk_table[clk_freq].p >> 16) & |
| 646 | PLLSH_WCS_PLL_P_FACTOR_CFG_2_MASK); |
| 647 | } else { |
| 648 | wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_SWALLOW_EN, |
| 649 | PLLSH_WCS_PLL_SWALLOW_EN_VAL2); |
| 650 | } |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | static void wl18xx_boot_soft_reset(struct wl1271 *wl) |
| 654 | { |
| 655 | /* disable Rx/Tx */ |
| 656 | wl1271_write32(wl, WL18XX_ENABLE, 0x0); |
| 657 | |
| 658 | /* disable auto calibration on start*/ |
| 659 | wl1271_write32(wl, WL18XX_SPARE_A2, 0xffff); |
| 660 | } |
| 661 | |
| 662 | static int wl18xx_pre_boot(struct wl1271 *wl) |
| 663 | { |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 664 | wl18xx_set_clk(wl); |
| 665 | |
| 666 | /* Continue the ELP wake up sequence */ |
| 667 | wl1271_write32(wl, WL18XX_WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL); |
| 668 | udelay(500); |
| 669 | |
| 670 | wlcore_set_partition(wl, &wl->ptable[PART_BOOT]); |
| 671 | |
| 672 | /* Disable interrupts */ |
| 673 | wlcore_write_reg(wl, REG_INTERRUPT_MASK, WL1271_ACX_INTR_ALL); |
| 674 | |
| 675 | wl18xx_boot_soft_reset(wl); |
| 676 | |
| 677 | return 0; |
| 678 | } |
| 679 | |
| 680 | static void wl18xx_pre_upload(struct wl1271 *wl) |
| 681 | { |
| 682 | u32 tmp; |
| 683 | |
| 684 | wlcore_set_partition(wl, &wl->ptable[PART_BOOT]); |
| 685 | |
| 686 | /* TODO: check if this is all needed */ |
| 687 | wl1271_write32(wl, WL18XX_EEPROMLESS_IND, WL18XX_EEPROMLESS_IND); |
| 688 | |
| 689 | tmp = wlcore_read_reg(wl, REG_CHIP_ID_B); |
| 690 | |
| 691 | wl1271_debug(DEBUG_BOOT, "chip id 0x%x", tmp); |
| 692 | |
| 693 | tmp = wl1271_read32(wl, WL18XX_SCR_PAD2); |
| 694 | } |
| 695 | |
| 696 | static void wl18xx_set_mac_and_phy(struct wl1271 *wl) |
| 697 | { |
Luciano Coelho | 23ee9bf | 2012-05-10 12:13:29 +0300 | [diff] [blame] | 698 | struct wl18xx_priv *priv = wl->priv; |
| 699 | struct wl18xx_conf_phy *phy = &priv->conf.phy; |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 700 | struct wl18xx_mac_and_phy_params params; |
| 701 | |
| 702 | memset(¶ms, 0, sizeof(params)); |
| 703 | |
Luciano Coelho | 23ee9bf | 2012-05-10 12:13:29 +0300 | [diff] [blame] | 704 | params.phy_standalone = phy->phy_standalone; |
| 705 | params.rdl = phy->rdl; |
| 706 | params.enable_clpc = phy->enable_clpc; |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 707 | params.enable_tx_low_pwr_on_siso_rdl = |
Luciano Coelho | 23ee9bf | 2012-05-10 12:13:29 +0300 | [diff] [blame] | 708 | phy->enable_tx_low_pwr_on_siso_rdl; |
| 709 | params.auto_detect = phy->auto_detect; |
| 710 | params.dedicated_fem = phy->dedicated_fem; |
| 711 | params.low_band_component = phy->low_band_component; |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 712 | params.low_band_component_type = |
Luciano Coelho | 23ee9bf | 2012-05-10 12:13:29 +0300 | [diff] [blame] | 713 | phy->low_band_component_type; |
| 714 | params.high_band_component = phy->high_band_component; |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 715 | params.high_band_component_type = |
Luciano Coelho | 23ee9bf | 2012-05-10 12:13:29 +0300 | [diff] [blame] | 716 | phy->high_band_component_type; |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 717 | params.number_of_assembled_ant2_4 = |
Luciano Coelho | e925881 | 2012-05-10 12:13:52 +0300 | [diff] [blame] | 718 | n_antennas_2_param; |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 719 | params.number_of_assembled_ant5 = |
Luciano Coelho | e925881 | 2012-05-10 12:13:52 +0300 | [diff] [blame] | 720 | n_antennas_5_param; |
| 721 | params.external_pa_dc2dc = dc2dc_param; |
Luciano Coelho | 23ee9bf | 2012-05-10 12:13:29 +0300 | [diff] [blame] | 722 | params.tcxo_ldo_voltage = phy->tcxo_ldo_voltage; |
| 723 | params.xtal_itrim_val = phy->xtal_itrim_val; |
| 724 | params.srf_state = phy->srf_state; |
| 725 | params.io_configuration = phy->io_configuration; |
| 726 | params.sdio_configuration = phy->sdio_configuration; |
| 727 | params.settings = phy->settings; |
| 728 | params.rx_profile = phy->rx_profile; |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 729 | params.primary_clock_setting_time = |
Luciano Coelho | 23ee9bf | 2012-05-10 12:13:29 +0300 | [diff] [blame] | 730 | phy->primary_clock_setting_time; |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 731 | params.clock_valid_on_wake_up = |
Luciano Coelho | 23ee9bf | 2012-05-10 12:13:29 +0300 | [diff] [blame] | 732 | phy->clock_valid_on_wake_up; |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 733 | params.secondary_clock_setting_time = |
Luciano Coelho | 23ee9bf | 2012-05-10 12:13:29 +0300 | [diff] [blame] | 734 | phy->secondary_clock_setting_time; |
Luciano Coelho | 5add82e | 2012-05-10 12:14:16 +0300 | [diff] [blame] | 735 | params.pwr_limit_reference_11_abg = |
| 736 | phy->pwr_limit_reference_11_abg; |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 737 | |
Luciano Coelho | a9c130d | 2012-05-10 12:13:37 +0300 | [diff] [blame] | 738 | params.board_type = priv->board_type; |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 739 | |
| 740 | wlcore_set_partition(wl, &wl->ptable[PART_PHY_INIT]); |
| 741 | wl1271_write(wl, WL18XX_PHY_INIT_MEM_ADDR, (u8 *)¶ms, |
| 742 | sizeof(params), false); |
| 743 | } |
| 744 | |
| 745 | static void wl18xx_enable_interrupts(struct wl1271 *wl) |
| 746 | { |
| 747 | wlcore_write_reg(wl, REG_INTERRUPT_MASK, WL1271_ACX_ALL_EVENTS_VECTOR); |
| 748 | |
| 749 | wlcore_enable_interrupts(wl); |
| 750 | wlcore_write_reg(wl, REG_INTERRUPT_MASK, |
| 751 | WL1271_ACX_INTR_ALL & ~(WL1271_INTR_MASK)); |
| 752 | } |
| 753 | |
| 754 | static int wl18xx_boot(struct wl1271 *wl) |
| 755 | { |
| 756 | int ret; |
| 757 | |
| 758 | ret = wl18xx_pre_boot(wl); |
| 759 | if (ret < 0) |
| 760 | goto out; |
| 761 | |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 762 | wl18xx_pre_upload(wl); |
| 763 | |
| 764 | ret = wlcore_boot_upload_firmware(wl); |
| 765 | if (ret < 0) |
| 766 | goto out; |
| 767 | |
| 768 | wl18xx_set_mac_and_phy(wl); |
| 769 | |
| 770 | ret = wlcore_boot_run_firmware(wl); |
| 771 | if (ret < 0) |
| 772 | goto out; |
| 773 | |
| 774 | wl18xx_enable_interrupts(wl); |
| 775 | |
| 776 | out: |
| 777 | return ret; |
| 778 | } |
| 779 | |
Luciano Coelho | 274c66c | 2012-05-10 12:13:13 +0300 | [diff] [blame] | 780 | static void wl18xx_trigger_cmd(struct wl1271 *wl, int cmd_box_addr, |
| 781 | void *buf, size_t len) |
| 782 | { |
| 783 | struct wl18xx_priv *priv = wl->priv; |
| 784 | |
| 785 | memcpy(priv->cmd_buf, buf, len); |
| 786 | memset(priv->cmd_buf + len, 0, WL18XX_CMD_MAX_SIZE - len); |
| 787 | |
| 788 | wl1271_write(wl, cmd_box_addr, priv->cmd_buf, WL18XX_CMD_MAX_SIZE, |
| 789 | false); |
| 790 | } |
| 791 | |
| 792 | static void wl18xx_ack_event(struct wl1271 *wl) |
| 793 | { |
| 794 | wlcore_write_reg(wl, REG_INTERRUPT_TRIG, WL18XX_INTR_TRIG_EVENT_ACK); |
| 795 | } |
| 796 | |
Arik Nemtsov | 624845b | 2012-05-10 12:13:17 +0300 | [diff] [blame] | 797 | static u32 wl18xx_calc_tx_blocks(struct wl1271 *wl, u32 len, u32 spare_blks) |
| 798 | { |
| 799 | u32 blk_size = WL18XX_TX_HW_BLOCK_SIZE; |
| 800 | return (len + blk_size - 1) / blk_size + spare_blks; |
| 801 | } |
| 802 | |
Arik Nemtsov | fb0f2e4 | 2012-05-10 12:13:18 +0300 | [diff] [blame] | 803 | static void |
| 804 | wl18xx_set_tx_desc_blocks(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc, |
| 805 | u32 blks, u32 spare_blks) |
| 806 | { |
| 807 | desc->wl18xx_mem.total_mem_blocks = blks; |
| 808 | desc->wl18xx_mem.reserved = 0; |
| 809 | } |
| 810 | |
Arik Nemtsov | d2361c5 | 2012-05-10 12:13:19 +0300 | [diff] [blame] | 811 | static void |
| 812 | wl18xx_set_tx_desc_data_len(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc, |
| 813 | struct sk_buff *skb) |
| 814 | { |
| 815 | desc->length = cpu_to_le16(skb->len); |
| 816 | |
| 817 | wl1271_debug(DEBUG_TX, "tx_fill_hdr: hlid: %d " |
| 818 | "len: %d life: %d mem: %d", desc->hlid, |
| 819 | le16_to_cpu(desc->length), |
| 820 | le16_to_cpu(desc->life_time), |
| 821 | desc->wl18xx_mem.total_mem_blocks); |
| 822 | } |
| 823 | |
Arik Nemtsov | 9c809f8 | 2012-05-10 12:13:23 +0300 | [diff] [blame] | 824 | static enum wl_rx_buf_align |
| 825 | wl18xx_get_rx_buf_align(struct wl1271 *wl, u32 rx_desc) |
| 826 | { |
| 827 | if (rx_desc & RX_BUF_PADDED_PAYLOAD) |
| 828 | return WLCORE_RX_BUF_PADDED; |
| 829 | |
| 830 | return WLCORE_RX_BUF_ALIGNED; |
| 831 | } |
| 832 | |
Arik Nemtsov | 30e2dd7 | 2012-05-10 12:13:24 +0300 | [diff] [blame] | 833 | static u32 wl18xx_get_rx_packet_len(struct wl1271 *wl, void *rx_data, |
| 834 | u32 data_len) |
| 835 | { |
| 836 | struct wl1271_rx_descriptor *desc = rx_data; |
| 837 | |
| 838 | /* invalid packet */ |
| 839 | if (data_len < sizeof(*desc)) |
| 840 | return 0; |
| 841 | |
| 842 | return data_len - sizeof(*desc); |
| 843 | } |
Arik Nemtsov | 9c809f8 | 2012-05-10 12:13:23 +0300 | [diff] [blame] | 844 | |
Arik Nemtsov | 872b345 | 2012-05-10 12:13:25 +0300 | [diff] [blame] | 845 | static void wl18xx_tx_immediate_completion(struct wl1271 *wl) |
| 846 | { |
| 847 | wl18xx_tx_immediate_complete(wl); |
| 848 | } |
| 849 | |
Luciano Coelho | b8422dc | 2012-05-10 12:13:26 +0300 | [diff] [blame] | 850 | static int wl18xx_hw_init(struct wl1271 *wl) |
| 851 | { |
| 852 | int ret; |
Arik Nemtsov | f2baf07 | 2012-05-10 12:13:46 +0300 | [diff] [blame] | 853 | struct wl18xx_priv *priv = wl->priv; |
Luciano Coelho | b8422dc | 2012-05-10 12:13:26 +0300 | [diff] [blame] | 854 | u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE | |
| 855 | HOST_IF_CFG_ADD_RX_ALIGNMENT; |
| 856 | |
| 857 | u32 sdio_align_size = 0; |
| 858 | |
Arik Nemtsov | f2baf07 | 2012-05-10 12:13:46 +0300 | [diff] [blame] | 859 | /* (re)init private structures. Relevant on recovery as well. */ |
| 860 | priv->last_fw_rls_idx = 0; |
| 861 | |
Luciano Coelho | b8422dc | 2012-05-10 12:13:26 +0300 | [diff] [blame] | 862 | /* Enable Tx SDIO padding */ |
| 863 | if (wl->quirks & WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN) { |
| 864 | host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK; |
| 865 | sdio_align_size = WL12XX_BUS_BLOCK_SIZE; |
| 866 | } |
| 867 | |
| 868 | /* Enable Rx SDIO padding */ |
| 869 | if (wl->quirks & WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN) { |
| 870 | host_cfg_bitmap |= HOST_IF_CFG_RX_PAD_TO_SDIO_BLK; |
| 871 | sdio_align_size = WL12XX_BUS_BLOCK_SIZE; |
| 872 | } |
| 873 | |
| 874 | ret = wl18xx_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap, |
| 875 | sdio_align_size, |
| 876 | WL18XX_TX_HW_BLOCK_SPARE, |
| 877 | WL18XX_HOST_IF_LEN_SIZE_FIELD); |
| 878 | if (ret < 0) |
| 879 | return ret; |
| 880 | |
Luciano Coelho | 102165c | 2012-05-10 12:13:53 +0300 | [diff] [blame] | 881 | if (checksum_param) { |
| 882 | ret = wl18xx_acx_set_checksum_state(wl); |
| 883 | if (ret != 0) |
| 884 | return ret; |
| 885 | } |
Arik Nemtsov | 2fc28de | 2012-05-10 12:13:27 +0300 | [diff] [blame] | 886 | |
Luciano Coelho | b8422dc | 2012-05-10 12:13:26 +0300 | [diff] [blame] | 887 | return ret; |
| 888 | } |
| 889 | |
Arik Nemtsov | 2fc28de | 2012-05-10 12:13:27 +0300 | [diff] [blame] | 890 | static void wl18xx_set_tx_desc_csum(struct wl1271 *wl, |
| 891 | struct wl1271_tx_hw_descr *desc, |
| 892 | struct sk_buff *skb) |
| 893 | { |
| 894 | u32 ip_hdr_offset; |
| 895 | struct iphdr *ip_hdr; |
| 896 | |
Luciano Coelho | 102165c | 2012-05-10 12:13:53 +0300 | [diff] [blame] | 897 | if (!checksum_param) { |
| 898 | desc->wl18xx_checksum_data = 0; |
| 899 | return; |
| 900 | } |
| 901 | |
Arik Nemtsov | 2fc28de | 2012-05-10 12:13:27 +0300 | [diff] [blame] | 902 | if (skb->ip_summed != CHECKSUM_PARTIAL) { |
| 903 | desc->wl18xx_checksum_data = 0; |
| 904 | return; |
| 905 | } |
| 906 | |
| 907 | ip_hdr_offset = skb_network_header(skb) - skb_mac_header(skb); |
| 908 | if (WARN_ON(ip_hdr_offset >= (1<<7))) { |
| 909 | desc->wl18xx_checksum_data = 0; |
| 910 | return; |
| 911 | } |
| 912 | |
| 913 | desc->wl18xx_checksum_data = ip_hdr_offset << 1; |
| 914 | |
| 915 | /* FW is interested only in the LSB of the protocol TCP=0 UDP=1 */ |
| 916 | ip_hdr = (void *)skb_network_header(skb); |
| 917 | desc->wl18xx_checksum_data |= (ip_hdr->protocol & 0x01); |
| 918 | } |
| 919 | |
Arik Nemtsov | 169da04 | 2012-05-10 12:13:28 +0300 | [diff] [blame] | 920 | static void wl18xx_set_rx_csum(struct wl1271 *wl, |
| 921 | struct wl1271_rx_descriptor *desc, |
| 922 | struct sk_buff *skb) |
| 923 | { |
| 924 | if (desc->status & WL18XX_RX_CHECKSUM_MASK) |
| 925 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 926 | } |
| 927 | |
Luciano Coelho | 7ae25da | 2012-05-10 12:14:03 +0300 | [diff] [blame] | 928 | /* |
| 929 | * TODO: instead of having these two functions to get the rate mask, |
| 930 | * we should modify the wlvif->rate_set instead |
| 931 | */ |
Arik Nemtsov | f13af34 | 2012-05-10 12:13:32 +0300 | [diff] [blame] | 932 | static u32 wl18xx_sta_get_ap_rate_mask(struct wl1271 *wl, |
| 933 | struct wl12xx_vif *wlvif) |
| 934 | { |
| 935 | u32 hw_rate_set = wlvif->rate_set; |
| 936 | |
| 937 | if (wlvif->channel_type == NL80211_CHAN_HT40MINUS || |
| 938 | wlvif->channel_type == NL80211_CHAN_HT40PLUS) { |
| 939 | wl1271_debug(DEBUG_ACX, "using wide channel rate mask"); |
| 940 | hw_rate_set |= CONF_TX_RATE_USE_WIDE_CHAN; |
| 941 | |
| 942 | /* we don't support MIMO in wide-channel mode */ |
| 943 | hw_rate_set &= ~CONF_TX_MIMO_RATES; |
| 944 | } |
| 945 | |
| 946 | return hw_rate_set; |
| 947 | } |
| 948 | |
Arik Nemtsov | ebc7e57 | 2012-05-10 12:13:34 +0300 | [diff] [blame] | 949 | static u32 wl18xx_ap_get_mimo_wide_rate_mask(struct wl1271 *wl, |
| 950 | struct wl12xx_vif *wlvif) |
| 951 | { |
Luciano Coelho | 174a730 | 2012-05-10 12:14:13 +0300 | [diff] [blame] | 952 | if ((wlvif->channel_type == NL80211_CHAN_HT40MINUS || |
| 953 | wlvif->channel_type == NL80211_CHAN_HT40PLUS) && |
| 954 | !strcmp(ht_mode_param, "wide")) { |
Arik Nemtsov | ebc7e57 | 2012-05-10 12:13:34 +0300 | [diff] [blame] | 955 | wl1271_debug(DEBUG_ACX, "using wide channel rate mask"); |
| 956 | return CONF_TX_RATE_USE_WIDE_CHAN; |
Luciano Coelho | 174a730 | 2012-05-10 12:14:13 +0300 | [diff] [blame] | 957 | } else if (!strcmp(ht_mode_param, "mimo")) { |
Arik Nemtsov | ebc7e57 | 2012-05-10 12:13:34 +0300 | [diff] [blame] | 958 | wl1271_debug(DEBUG_ACX, "using MIMO rate mask"); |
Luciano Coelho | 7ae25da | 2012-05-10 12:14:03 +0300 | [diff] [blame] | 959 | |
| 960 | /* |
| 961 | * PG 1.0 has some problems with MCS_13, so disable it |
| 962 | * |
| 963 | * TODO: instead of hacking this in here, we should |
| 964 | * make it more general and change a bit in the |
| 965 | * wlvif->rate_set instead. |
| 966 | */ |
| 967 | if (wl->chip.id == CHIP_ID_185x_PG10) |
| 968 | return CONF_TX_MIMO_RATES & ~CONF_HW_BIT_RATE_MCS_13; |
| 969 | |
Arik Nemtsov | ebc7e57 | 2012-05-10 12:13:34 +0300 | [diff] [blame] | 970 | return CONF_TX_MIMO_RATES; |
Luciano Coelho | 174a730 | 2012-05-10 12:14:13 +0300 | [diff] [blame] | 971 | } else { |
| 972 | return 0; |
Arik Nemtsov | ebc7e57 | 2012-05-10 12:13:34 +0300 | [diff] [blame] | 973 | } |
| 974 | } |
| 975 | |
Arik Nemtsov | 5495629 | 2012-05-10 12:13:44 +0300 | [diff] [blame] | 976 | static s8 wl18xx_get_pg_ver(struct wl1271 *wl) |
| 977 | { |
| 978 | u32 fuse; |
| 979 | |
| 980 | wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]); |
| 981 | |
| 982 | fuse = wl1271_read32(wl, WL18XX_REG_FUSE_DATA_1_3); |
| 983 | fuse = (fuse & WL18XX_PG_VER_MASK) >> WL18XX_PG_VER_OFFSET; |
| 984 | |
| 985 | wlcore_set_partition(wl, &wl->ptable[PART_BOOT]); |
| 986 | |
| 987 | return (s8)fuse; |
| 988 | } |
| 989 | |
Luciano Coelho | 23ee9bf | 2012-05-10 12:13:29 +0300 | [diff] [blame] | 990 | static void wl18xx_conf_init(struct wl1271 *wl) |
| 991 | { |
| 992 | struct wl18xx_priv *priv = wl->priv; |
| 993 | |
| 994 | /* apply driver default configuration */ |
| 995 | memcpy(&wl->conf, &wl18xx_conf, sizeof(wl18xx_conf)); |
| 996 | |
| 997 | /* apply default private configuration */ |
| 998 | memcpy(&priv->conf, &wl18xx_default_priv_conf, sizeof(priv->conf)); |
| 999 | } |
| 1000 | |
Luciano Coelho | be42aee | 2012-05-10 12:13:50 +0300 | [diff] [blame] | 1001 | static int wl18xx_plt_init(struct wl1271 *wl) |
| 1002 | { |
| 1003 | wl1271_write32(wl, WL18XX_SCR_PAD8, WL18XX_SCR_PAD8_PLT); |
| 1004 | |
| 1005 | return wl->ops->boot(wl); |
| 1006 | } |
| 1007 | |
Luciano Coelho | a5114d9 | 2012-05-10 12:13:55 +0300 | [diff] [blame] | 1008 | static void wl18xx_get_mac(struct wl1271 *wl) |
| 1009 | { |
| 1010 | u32 mac1, mac2; |
| 1011 | |
| 1012 | wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]); |
| 1013 | |
| 1014 | mac1 = wl1271_read32(wl, WL18XX_REG_FUSE_BD_ADDR_1); |
| 1015 | mac2 = wl1271_read32(wl, WL18XX_REG_FUSE_BD_ADDR_2); |
| 1016 | |
| 1017 | /* these are the two parts of the BD_ADDR */ |
| 1018 | wl->fuse_oui_addr = ((mac2 & 0xffff) << 8) + |
| 1019 | ((mac1 & 0xff000000) >> 24); |
| 1020 | wl->fuse_nic_addr = (mac1 & 0xffffff); |
| 1021 | |
| 1022 | wlcore_set_partition(wl, &wl->ptable[PART_DOWN]); |
| 1023 | } |
| 1024 | |
Luciano Coelho | 8c0ea10 | 2012-05-10 12:14:09 +0300 | [diff] [blame] | 1025 | static int wl18xx_debugfs_init(struct wl1271 *wl, struct dentry *rootdir) |
| 1026 | { |
| 1027 | return wl18xx_debugfs_add_files(wl, rootdir); |
| 1028 | } |
| 1029 | |
Luciano Coelho | 283e8c4 | 2012-05-10 12:14:11 +0300 | [diff] [blame] | 1030 | static int wl18xx_handle_static_data(struct wl1271 *wl, |
| 1031 | struct wl1271_static_data *static_data) |
| 1032 | { |
| 1033 | struct wl18xx_static_data_priv *static_data_priv = |
| 1034 | (struct wl18xx_static_data_priv *) static_data->priv; |
| 1035 | |
| 1036 | wl1271_info("PHY firmware version: %s", static_data_priv->phy_version); |
| 1037 | |
| 1038 | return 0; |
| 1039 | } |
| 1040 | |
Luciano Coelho | 0cd6543 | 2012-05-10 12:13:11 +0300 | [diff] [blame] | 1041 | static struct wlcore_ops wl18xx_ops = { |
Luciano Coelho | 46a1d51 | 2012-05-10 12:13:12 +0300 | [diff] [blame] | 1042 | .identify_chip = wl18xx_identify_chip, |
| 1043 | .boot = wl18xx_boot, |
Luciano Coelho | be42aee | 2012-05-10 12:13:50 +0300 | [diff] [blame] | 1044 | .plt_init = wl18xx_plt_init, |
Luciano Coelho | 274c66c | 2012-05-10 12:13:13 +0300 | [diff] [blame] | 1045 | .trigger_cmd = wl18xx_trigger_cmd, |
| 1046 | .ack_event = wl18xx_ack_event, |
Arik Nemtsov | 624845b | 2012-05-10 12:13:17 +0300 | [diff] [blame] | 1047 | .calc_tx_blocks = wl18xx_calc_tx_blocks, |
Arik Nemtsov | fb0f2e4 | 2012-05-10 12:13:18 +0300 | [diff] [blame] | 1048 | .set_tx_desc_blocks = wl18xx_set_tx_desc_blocks, |
Arik Nemtsov | d2361c5 | 2012-05-10 12:13:19 +0300 | [diff] [blame] | 1049 | .set_tx_desc_data_len = wl18xx_set_tx_desc_data_len, |
Arik Nemtsov | 9c809f8 | 2012-05-10 12:13:23 +0300 | [diff] [blame] | 1050 | .get_rx_buf_align = wl18xx_get_rx_buf_align, |
Arik Nemtsov | 30e2dd7 | 2012-05-10 12:13:24 +0300 | [diff] [blame] | 1051 | .get_rx_packet_len = wl18xx_get_rx_packet_len, |
Arik Nemtsov | 872b345 | 2012-05-10 12:13:25 +0300 | [diff] [blame] | 1052 | .tx_immediate_compl = wl18xx_tx_immediate_completion, |
| 1053 | .tx_delayed_compl = NULL, |
Luciano Coelho | b8422dc | 2012-05-10 12:13:26 +0300 | [diff] [blame] | 1054 | .hw_init = wl18xx_hw_init, |
Arik Nemtsov | 2fc28de | 2012-05-10 12:13:27 +0300 | [diff] [blame] | 1055 | .set_tx_desc_csum = wl18xx_set_tx_desc_csum, |
Arik Nemtsov | 5495629 | 2012-05-10 12:13:44 +0300 | [diff] [blame] | 1056 | .get_pg_ver = wl18xx_get_pg_ver, |
Arik Nemtsov | 169da04 | 2012-05-10 12:13:28 +0300 | [diff] [blame] | 1057 | .set_rx_csum = wl18xx_set_rx_csum, |
Arik Nemtsov | f13af34 | 2012-05-10 12:13:32 +0300 | [diff] [blame] | 1058 | .sta_get_ap_rate_mask = wl18xx_sta_get_ap_rate_mask, |
Arik Nemtsov | ebc7e57 | 2012-05-10 12:13:34 +0300 | [diff] [blame] | 1059 | .ap_get_mimo_wide_rate_mask = wl18xx_ap_get_mimo_wide_rate_mask, |
Luciano Coelho | a5114d9 | 2012-05-10 12:13:55 +0300 | [diff] [blame] | 1060 | .get_mac = wl18xx_get_mac, |
Luciano Coelho | 8c0ea10 | 2012-05-10 12:14:09 +0300 | [diff] [blame] | 1061 | .debugfs_init = wl18xx_debugfs_init, |
Luciano Coelho | 283e8c4 | 2012-05-10 12:14:11 +0300 | [diff] [blame] | 1062 | .handle_static_data = wl18xx_handle_static_data, |
Luciano Coelho | 0cd6543 | 2012-05-10 12:13:11 +0300 | [diff] [blame] | 1063 | }; |
| 1064 | |
Arik Nemtsov | 0e0f5a3 | 2012-05-10 12:13:35 +0300 | [diff] [blame] | 1065 | /* HT cap appropriate for wide channels */ |
Luciano Coelho | 8334271 | 2012-05-10 12:14:15 +0300 | [diff] [blame] | 1066 | static struct ieee80211_sta_ht_cap wl18xx_siso40_ht_cap = { |
Arik Nemtsov | 0e0f5a3 | 2012-05-10 12:13:35 +0300 | [diff] [blame] | 1067 | .cap = IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | |
| 1068 | IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_DSSSCCK40, |
| 1069 | .ht_supported = true, |
| 1070 | .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K, |
| 1071 | .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 1072 | .mcs = { |
| 1073 | .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 1074 | .rx_highest = cpu_to_le16(150), |
| 1075 | .tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 1076 | }, |
| 1077 | }; |
| 1078 | |
Luciano Coelho | 8334271 | 2012-05-10 12:14:15 +0300 | [diff] [blame] | 1079 | /* HT cap appropriate for SISO 20 */ |
| 1080 | static struct ieee80211_sta_ht_cap wl18xx_siso20_ht_cap = { |
| 1081 | .cap = IEEE80211_HT_CAP_SGI_20, |
| 1082 | .ht_supported = true, |
| 1083 | .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K, |
| 1084 | .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 1085 | .mcs = { |
| 1086 | .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 1087 | .rx_highest = cpu_to_le16(72), |
| 1088 | .tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 1089 | }, |
| 1090 | }; |
| 1091 | |
Arik Nemtsov | 3a8ddb6 | 2012-05-10 12:13:36 +0300 | [diff] [blame] | 1092 | /* HT cap appropriate for MIMO rates in 20mhz channel */ |
| 1093 | static struct ieee80211_sta_ht_cap wl18xx_mimo_ht_cap = { |
| 1094 | .cap = IEEE80211_HT_CAP_SGI_20, |
| 1095 | .ht_supported = true, |
| 1096 | .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K, |
| 1097 | .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 1098 | .mcs = { |
| 1099 | .rx_mask = { 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 1100 | .rx_highest = cpu_to_le16(144), |
| 1101 | .tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 1102 | }, |
| 1103 | }; |
| 1104 | |
Luciano Coelho | 9a1a699 | 2012-05-10 12:13:06 +0300 | [diff] [blame] | 1105 | int __devinit wl18xx_probe(struct platform_device *pdev) |
| 1106 | { |
| 1107 | struct wl1271 *wl; |
| 1108 | struct ieee80211_hw *hw; |
Arik Nemtsov | 9d1c973 | 2012-05-10 12:13:14 +0300 | [diff] [blame] | 1109 | struct wl18xx_priv *priv; |
Luciano Coelho | 9a1a699 | 2012-05-10 12:13:06 +0300 | [diff] [blame] | 1110 | |
Arik Nemtsov | 9d1c973 | 2012-05-10 12:13:14 +0300 | [diff] [blame] | 1111 | hw = wlcore_alloc_hw(sizeof(*priv)); |
Luciano Coelho | 9a1a699 | 2012-05-10 12:13:06 +0300 | [diff] [blame] | 1112 | if (IS_ERR(hw)) { |
| 1113 | wl1271_error("can't allocate hw"); |
| 1114 | return PTR_ERR(hw); |
| 1115 | } |
| 1116 | |
| 1117 | wl = hw->priv; |
Luciano Coelho | a9c130d | 2012-05-10 12:13:37 +0300 | [diff] [blame] | 1118 | priv = wl->priv; |
Luciano Coelho | 554c36b | 2012-05-10 12:13:08 +0300 | [diff] [blame] | 1119 | wl->ops = &wl18xx_ops; |
Luciano Coelho | 82b890c | 2012-05-10 12:13:09 +0300 | [diff] [blame] | 1120 | wl->ptable = wl18xx_ptable; |
Luciano Coelho | 5d4a9fa | 2012-05-10 12:13:10 +0300 | [diff] [blame] | 1121 | wl->rtable = wl18xx_rtable; |
Arik Nemtsov | cb7b5d8 | 2012-05-10 12:13:15 +0300 | [diff] [blame] | 1122 | wl->num_tx_desc = 32; |
Arik Nemtsov | 0afd04e | 2012-05-10 12:13:54 +0300 | [diff] [blame] | 1123 | wl->num_rx_desc = 16; |
Arik Nemtsov | 1349c42 | 2012-05-10 12:13:16 +0300 | [diff] [blame] | 1124 | wl->normal_tx_spare = WL18XX_TX_HW_BLOCK_SPARE; |
| 1125 | wl->gem_tx_spare = WL18XX_TX_HW_GEM_BLOCK_SPARE; |
Arik Nemtsov | f648eab | 2012-05-10 12:13:20 +0300 | [diff] [blame] | 1126 | wl->band_rate_to_idx = wl18xx_band_rate_to_idx; |
| 1127 | wl->hw_tx_rate_tbl_size = WL18XX_CONF_HW_RXTX_RATE_MAX; |
| 1128 | wl->hw_min_ht_rate = WL18XX_CONF_HW_RXTX_RATE_MCS0; |
Arik Nemtsov | 1fab39d | 2012-05-10 12:13:21 +0300 | [diff] [blame] | 1129 | wl->fw_status_priv_len = sizeof(struct wl18xx_fw_status_priv); |
Luciano Coelho | 8c0ea10 | 2012-05-10 12:14:09 +0300 | [diff] [blame] | 1130 | wl->stats.fw_stats_len = sizeof(struct wl18xx_acx_statistics); |
Luciano Coelho | 283e8c4 | 2012-05-10 12:14:11 +0300 | [diff] [blame] | 1131 | wl->static_data_priv_len = sizeof(struct wl18xx_static_data_priv); |
Luciano Coelho | 8334271 | 2012-05-10 12:14:15 +0300 | [diff] [blame] | 1132 | |
| 1133 | if (!strcmp(ht_mode_param, "wide")) { |
| 1134 | memcpy(&wl->ht_cap, &wl18xx_siso40_ht_cap, |
| 1135 | sizeof(wl18xx_siso40_ht_cap)); |
| 1136 | } else if (!strcmp(ht_mode_param, "mimo")) { |
Arik Nemtsov | 3a8ddb6 | 2012-05-10 12:13:36 +0300 | [diff] [blame] | 1137 | memcpy(&wl->ht_cap, &wl18xx_mimo_ht_cap, |
| 1138 | sizeof(wl18xx_mimo_ht_cap)); |
Luciano Coelho | 8334271 | 2012-05-10 12:14:15 +0300 | [diff] [blame] | 1139 | } else if (!strcmp(ht_mode_param, "siso20")) { |
| 1140 | memcpy(&wl->ht_cap, &wl18xx_siso20_ht_cap, |
| 1141 | sizeof(wl18xx_siso20_ht_cap)); |
| 1142 | } else { |
| 1143 | wl1271_error("invalid ht_mode '%s'", ht_mode_param); |
| 1144 | goto out_free; |
| 1145 | } |
Arik Nemtsov | 3a8ddb6 | 2012-05-10 12:13:36 +0300 | [diff] [blame] | 1146 | |
Luciano Coelho | 776f030 | 2012-05-10 12:13:58 +0300 | [diff] [blame] | 1147 | wl18xx_conf_init(wl); |
| 1148 | |
Luciano Coelho | 4b9d236 | 2012-05-10 12:13:59 +0300 | [diff] [blame] | 1149 | if (!strcmp(board_type_param, "fpga")) { |
Arik Nemtsov | 05057c0 | 2012-05-10 12:13:48 +0300 | [diff] [blame] | 1150 | priv->board_type = BOARD_TYPE_FPGA_18XX; |
| 1151 | } else if (!strcmp(board_type_param, "hdk")) { |
| 1152 | priv->board_type = BOARD_TYPE_HDK_18XX; |
Luciano Coelho | 0a1569f | 2012-05-10 12:13:51 +0300 | [diff] [blame] | 1153 | /* HACK! Just for now we hardcode HDK to 0x06 */ |
| 1154 | priv->conf.phy.low_band_component_type = 0x06; |
Arik Nemtsov | 05057c0 | 2012-05-10 12:13:48 +0300 | [diff] [blame] | 1155 | } else if (!strcmp(board_type_param, "dvp")) { |
| 1156 | priv->board_type = BOARD_TYPE_DVP_18XX; |
| 1157 | } else if (!strcmp(board_type_param, "evb")) { |
| 1158 | priv->board_type = BOARD_TYPE_EVB_18XX; |
| 1159 | } else if (!strcmp(board_type_param, "com8")) { |
| 1160 | priv->board_type = BOARD_TYPE_COM8_18XX; |
Luciano Coelho | 73d8a42 | 2012-05-10 12:14:01 +0300 | [diff] [blame] | 1161 | /* HACK! Just for now we hardcode COM8 to 0x06 */ |
| 1162 | priv->conf.phy.low_band_component_type = 0x06; |
Luciano Coelho | a9c130d | 2012-05-10 12:13:37 +0300 | [diff] [blame] | 1163 | } else { |
Arik Nemtsov | 05057c0 | 2012-05-10 12:13:48 +0300 | [diff] [blame] | 1164 | wl1271_error("invalid board type '%s'", board_type_param); |
Luciano Coelho | 8334271 | 2012-05-10 12:14:15 +0300 | [diff] [blame] | 1165 | goto out_free; |
Luciano Coelho | a9c130d | 2012-05-10 12:13:37 +0300 | [diff] [blame] | 1166 | } |
| 1167 | |
Luciano Coelho | 858403a | 2012-05-10 12:14:17 +0300 | [diff] [blame] | 1168 | /* |
| 1169 | * If the module param is not set, update it with the one from |
| 1170 | * conf. If it is set, overwrite conf with it. |
| 1171 | */ |
| 1172 | if (low_band_component == -1) |
| 1173 | low_band_component = priv->conf.phy.low_band_component; |
| 1174 | else |
| 1175 | priv->conf.phy.low_band_component = low_band_component; |
| 1176 | if (low_band_component_type == -1) |
| 1177 | low_band_component_type = |
| 1178 | priv->conf.phy.low_band_component_type; |
| 1179 | else |
| 1180 | priv->conf.phy.low_band_component_type = |
| 1181 | low_band_component_type; |
| 1182 | |
| 1183 | if (high_band_component == -1) |
| 1184 | high_band_component = priv->conf.phy.high_band_component; |
| 1185 | else |
| 1186 | priv->conf.phy.high_band_component = high_band_component; |
| 1187 | if (high_band_component_type == -1) |
| 1188 | high_band_component_type = |
| 1189 | priv->conf.phy.high_band_component_type; |
| 1190 | else |
| 1191 | priv->conf.phy.high_band_component_type = |
| 1192 | high_band_component_type; |
| 1193 | |
Luciano Coelho | 7b03c30 | 2012-05-10 12:14:18 +0300 | [diff] [blame^] | 1194 | if (pwr_limit_reference_11_abg == -1) |
| 1195 | pwr_limit_reference_11_abg = |
| 1196 | priv->conf.phy.pwr_limit_reference_11_abg; |
| 1197 | else |
| 1198 | priv->conf.phy.pwr_limit_reference_11_abg = |
| 1199 | pwr_limit_reference_11_abg; |
| 1200 | |
Luciano Coelho | 102165c | 2012-05-10 12:13:53 +0300 | [diff] [blame] | 1201 | if (!checksum_param) { |
| 1202 | wl18xx_ops.set_rx_csum = NULL; |
| 1203 | wl18xx_ops.init_vif = NULL; |
| 1204 | } |
| 1205 | |
Luciano Coelho | 1ddbc7d | 2012-05-10 12:13:56 +0300 | [diff] [blame] | 1206 | wl->enable_11a = enable_11a_param; |
| 1207 | |
Luciano Coelho | 9a1a699 | 2012-05-10 12:13:06 +0300 | [diff] [blame] | 1208 | return wlcore_probe(wl, pdev); |
Luciano Coelho | 8334271 | 2012-05-10 12:14:15 +0300 | [diff] [blame] | 1209 | |
| 1210 | out_free: |
| 1211 | wlcore_free_hw(wl); |
| 1212 | return -EINVAL; |
Luciano Coelho | 9a1a699 | 2012-05-10 12:13:06 +0300 | [diff] [blame] | 1213 | } |
| 1214 | |
| 1215 | static const struct platform_device_id wl18xx_id_table[] __devinitconst = { |
| 1216 | { "wl18xx", 0 }, |
| 1217 | { } /* Terminating Entry */ |
| 1218 | }; |
| 1219 | MODULE_DEVICE_TABLE(platform, wl18xx_id_table); |
| 1220 | |
| 1221 | static struct platform_driver wl18xx_driver = { |
| 1222 | .probe = wl18xx_probe, |
| 1223 | .remove = __devexit_p(wlcore_remove), |
| 1224 | .id_table = wl18xx_id_table, |
| 1225 | .driver = { |
| 1226 | .name = "wl18xx_driver", |
| 1227 | .owner = THIS_MODULE, |
| 1228 | } |
| 1229 | }; |
| 1230 | |
| 1231 | static int __init wl18xx_init(void) |
| 1232 | { |
| 1233 | return platform_driver_register(&wl18xx_driver); |
| 1234 | } |
| 1235 | module_init(wl18xx_init); |
| 1236 | |
| 1237 | static void __exit wl18xx_exit(void) |
| 1238 | { |
| 1239 | platform_driver_unregister(&wl18xx_driver); |
| 1240 | } |
| 1241 | module_exit(wl18xx_exit); |
| 1242 | |
Arik Nemtsov | 3a8ddb6 | 2012-05-10 12:13:36 +0300 | [diff] [blame] | 1243 | module_param_named(ht_mode, ht_mode_param, charp, S_IRUSR); |
Luciano Coelho | 8334271 | 2012-05-10 12:14:15 +0300 | [diff] [blame] | 1244 | MODULE_PARM_DESC(ht_mode, "Force HT mode: wide (default), mimo or siso20"); |
Arik Nemtsov | 3a8ddb6 | 2012-05-10 12:13:36 +0300 | [diff] [blame] | 1245 | |
Luciano Coelho | a9c130d | 2012-05-10 12:13:37 +0300 | [diff] [blame] | 1246 | module_param_named(board_type, board_type_param, charp, S_IRUSR); |
Luciano Coelho | 4b9d236 | 2012-05-10 12:13:59 +0300 | [diff] [blame] | 1247 | MODULE_PARM_DESC(board_type, "Board type: fpga, hdk (default), evb, com8 or " |
| 1248 | "dvp"); |
Luciano Coelho | a9c130d | 2012-05-10 12:13:37 +0300 | [diff] [blame] | 1249 | |
Luciano Coelho | e925881 | 2012-05-10 12:13:52 +0300 | [diff] [blame] | 1250 | module_param_named(dc2dc, dc2dc_param, bool, S_IRUSR); |
| 1251 | MODULE_PARM_DESC(dc2dc, "External DC2DC: boolean (defaults to false)"); |
| 1252 | |
| 1253 | module_param_named(n_antennas_2, n_antennas_2_param, uint, S_IRUSR); |
| 1254 | MODULE_PARM_DESC(n_antennas_2, "Number of installed 2.4GHz antennas: 1 (default) or 2"); |
| 1255 | |
| 1256 | module_param_named(n_antennas_5, n_antennas_5_param, uint, S_IRUSR); |
| 1257 | MODULE_PARM_DESC(n_antennas_5, "Number of installed 5GHz antennas: 1 (default) or 2"); |
| 1258 | |
Luciano Coelho | 102165c | 2012-05-10 12:13:53 +0300 | [diff] [blame] | 1259 | module_param_named(checksum, checksum_param, bool, S_IRUSR); |
| 1260 | MODULE_PARM_DESC(checksum, "Enable TCP checksum: boolean (defaults to true)"); |
| 1261 | |
Luciano Coelho | 1ddbc7d | 2012-05-10 12:13:56 +0300 | [diff] [blame] | 1262 | module_param_named(enable_11a, enable_11a_param, bool, S_IRUSR); |
| 1263 | MODULE_PARM_DESC(enable_11a, "Enable 11a (5GHz): boolean (defaults to true)"); |
| 1264 | |
Luciano Coelho | 858403a | 2012-05-10 12:14:17 +0300 | [diff] [blame] | 1265 | module_param(low_band_component, uint, S_IRUSR); |
| 1266 | MODULE_PARM_DESC(low_band_component, "Low band component: u8 " |
| 1267 | "(default is 0x01)"); |
| 1268 | |
| 1269 | module_param(low_band_component_type, uint, S_IRUSR); |
| 1270 | MODULE_PARM_DESC(low_band_component_type, "Low band component type: u8 " |
| 1271 | "(default is 0x05 or 0x06 depending on the board_type)"); |
| 1272 | |
| 1273 | module_param(high_band_component, uint, S_IRUSR); |
| 1274 | MODULE_PARM_DESC(high_band_component, "High band component: u8, " |
| 1275 | "(default is 0x01)"); |
| 1276 | |
| 1277 | module_param(high_band_component_type, uint, S_IRUSR); |
| 1278 | MODULE_PARM_DESC(high_band_component_type, "High band component type: u8 " |
| 1279 | "(default is 0x09)"); |
| 1280 | |
Luciano Coelho | 7b03c30 | 2012-05-10 12:14:18 +0300 | [diff] [blame^] | 1281 | module_param(pwr_limit_reference_11_abg, uint, S_IRUSR); |
| 1282 | MODULE_PARM_DESC(pwr_limit_reference_11_abg, "Power limit reference: u8 " |
| 1283 | "(default is 0xc8)"); |
| 1284 | |
Luciano Coelho | 9a1a699 | 2012-05-10 12:13:06 +0300 | [diff] [blame] | 1285 | MODULE_LICENSE("GPL v2"); |
| 1286 | MODULE_AUTHOR("Luciano Coelho <coelho@ti.com>"); |
Luciano Coelho | 0cd6543 | 2012-05-10 12:13:11 +0300 | [diff] [blame] | 1287 | MODULE_FIRMWARE(WL18XX_FW_NAME); |