Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 15 | * |
| 16 | * File: card.c |
| 17 | * Purpose: Provide functions to setup NIC operation mode |
| 18 | * Functions: |
Malcolm Priestley | 1a79294 | 2014-05-30 16:27:46 +0100 | [diff] [blame] | 19 | * vnt_set_rspinf - Set RSPINF |
Malcolm Priestley | c7ee9ee | 2014-05-30 16:27:44 +0100 | [diff] [blame] | 20 | * vnt_update_ifs - Update slotTime,SIFS,DIFS, and EIFS |
Malcolm Priestley | 47203c4 | 2014-05-30 16:27:45 +0100 | [diff] [blame] | 21 | * vnt_update_top_rates - Update BasicTopRate |
Malcolm Priestley | 9a2cffd | 2014-05-30 16:27:47 +0100 | [diff] [blame] | 22 | * vnt_add_basic_rate - Add to BasicRateSet |
Malcolm Priestley | cfa4d8d | 2014-05-30 16:27:48 +0100 | [diff] [blame] | 23 | * vnt_ofdm_min_rate - Check if any OFDM rate is in BasicRateSet |
Malcolm Priestley | ecbc0a1 | 2014-05-30 16:27:50 +0100 | [diff] [blame] | 24 | * vnt_get_tsf_offset - Calculate TSFOffset |
Malcolm Priestley | 4a9f4c6 | 2014-05-30 23:22:47 +0100 | [diff] [blame] | 25 | * vnt_get_current_tsf - Read Current NIC TSF counter |
Malcolm Priestley | 75ef1b51 | 2014-05-30 23:22:49 +0100 | [diff] [blame] | 26 | * vnt_get_next_tbtt - Calculate Next Beacon TSF counter |
Malcolm Priestley | 6964cd1 | 2014-05-30 23:22:50 +0100 | [diff] [blame] | 27 | * vnt_reset_next_tbtt - Set NIC Beacon time |
Malcolm Priestley | 88ec2f7 | 2014-05-30 23:22:51 +0100 | [diff] [blame] | 28 | * vnt_update_next_tbtt - Sync. NIC Beacon time |
Malcolm Priestley | fa26e0b | 2014-05-30 23:22:52 +0100 | [diff] [blame] | 29 | * vnt_radio_power_off - Turn Off NIC Radio Power |
Malcolm Priestley | 8a5e6c8 | 2014-05-30 23:22:53 +0100 | [diff] [blame] | 30 | * vnt_radio_power_on - Turn On NIC Radio Power |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 31 | * |
| 32 | * Revision History: |
| 33 | * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec. |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 34 | * 08-26-2003 Kyle Hsu: Modify the definition type of dwIoBase. |
Malcolm Priestley | c7ee9ee | 2014-05-30 16:27:44 +0100 | [diff] [blame] | 35 | * 09-01-2003 Bryan YC Fan: Add vnt_update_ifs(). |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 36 | * |
| 37 | */ |
| 38 | |
Malcolm Priestley | dd0a774 | 2012-12-10 21:59:10 +0000 | [diff] [blame] | 39 | #include "device.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 40 | #include "card.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 41 | #include "baseband.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 42 | #include "mac.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 43 | #include "desc.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 44 | #include "rf.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 45 | #include "power.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 46 | #include "key.h" |
Malcolm Priestley | 62c8526 | 2014-05-26 13:59:07 +0100 | [diff] [blame] | 47 | #include "usbpipe.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 48 | |
Rithvik Patibandla | e7c8565 | 2016-06-17 09:26:47 +0530 | [diff] [blame] | 49 | /* const u16 cw_rxbcntsf_off[MAX_RATE] = |
Rithvik Patibandla | b01a5d7 | 2016-06-12 01:38:58 +0530 | [diff] [blame] | 50 | * {17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3}; |
| 51 | */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 52 | |
Rithvik Patibandla | e7c8565 | 2016-06-17 09:26:47 +0530 | [diff] [blame] | 53 | static const u16 cw_rxbcntsf_off[MAX_RATE] = { |
Peter Senna Tschudin | 42b138d | 2014-07-15 23:23:26 +0200 | [diff] [blame] | 54 | 192, 96, 34, 17, 34, 23, 17, 11, 8, 5, 4, 3 |
| 55 | }; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 56 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 57 | /* |
| 58 | * Description: Set NIC media channel |
| 59 | * |
| 60 | * Parameters: |
| 61 | * In: |
| 62 | * pDevice - The adapter to be set |
Malcolm Priestley | 7387f43 | 2013-12-12 23:33:08 +0000 | [diff] [blame] | 63 | * connection_channel - Channel to be set |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 64 | * Out: |
| 65 | * none |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 66 | */ |
Malcolm Priestley | 084fc8f | 2014-05-30 16:27:40 +0100 | [diff] [blame] | 67 | void vnt_set_channel(struct vnt_private *priv, u32 connection_channel) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 68 | { |
Malcolm Priestley | 04f2ff1 | 2014-07-05 19:24:25 +0100 | [diff] [blame] | 69 | if (connection_channel > CB_MAX_CHANNEL || !connection_channel) |
| 70 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 71 | |
Malcolm Priestley | 7387f43 | 2013-12-12 23:33:08 +0000 | [diff] [blame] | 72 | /* clear NAV */ |
Malcolm Priestley | 3695753 | 2014-05-31 11:50:42 +0100 | [diff] [blame] | 73 | vnt_mac_reg_bits_on(priv, MAC_REG_MACCR, MACCR_CLRNAV); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 74 | |
Malcolm Priestley | 7387f43 | 2013-12-12 23:33:08 +0000 | [diff] [blame] | 75 | /* Set Channel[7] = 0 to tell H/W channel is changing now. */ |
Malcolm Priestley | a9bed1d | 2014-05-31 11:50:41 +0100 | [diff] [blame] | 76 | vnt_mac_reg_bits_off(priv, MAC_REG_CHANNEL, 0xb0); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 77 | |
Gustavo A. R. Silva | 733b3b0 | 2015-01-11 16:35:54 -0600 | [diff] [blame] | 78 | vnt_control_out(priv, MESSAGE_TYPE_SELECT_CHANNEL, |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 79 | connection_channel, 0, 0, NULL); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 80 | |
Malcolm Priestley | 285d58c | 2014-05-26 13:59:03 +0100 | [diff] [blame] | 81 | vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, MAC_REG_CHANNEL, |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 82 | (u8)(connection_channel | 0x80)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | /* |
| 86 | * Description: Get CCK mode basic rate |
| 87 | * |
| 88 | * Parameters: |
| 89 | * In: |
Malcolm Priestley | 3d2988c | 2014-05-25 21:36:23 +0100 | [diff] [blame] | 90 | * priv - The adapter to be set |
| 91 | * rate_idx - Receiving data rate |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 92 | * Out: |
| 93 | * none |
| 94 | * |
| 95 | * Return Value: response Control frame rate |
| 96 | * |
| 97 | */ |
Malcolm Priestley | 073d02e | 2014-05-30 16:27:41 +0100 | [diff] [blame] | 98 | static u16 vnt_get_cck_rate(struct vnt_private *priv, u16 rate_idx) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 99 | { |
Malcolm Priestley | 3d2988c | 2014-05-25 21:36:23 +0100 | [diff] [blame] | 100 | u16 ui = rate_idx; |
Malcolm Priestley | dd0a774 | 2012-12-10 21:59:10 +0000 | [diff] [blame] | 101 | |
| 102 | while (ui > RATE_1M) { |
Malcolm Priestley | 93a7355 | 2014-07-20 15:33:13 +0100 | [diff] [blame] | 103 | if (priv->basic_rates & (1 << ui)) |
Malcolm Priestley | dd0a774 | 2012-12-10 21:59:10 +0000 | [diff] [blame] | 104 | return ui; |
| 105 | ui--; |
| 106 | } |
| 107 | |
| 108 | return RATE_1M; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | /* |
| 112 | * Description: Get OFDM mode basic rate |
| 113 | * |
| 114 | * Parameters: |
| 115 | * In: |
Malcolm Priestley | a5a7c43 | 2014-05-25 21:36:22 +0100 | [diff] [blame] | 116 | * priv - The adapter to be set |
| 117 | * rate_idx - Receiving data rate |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 118 | * Out: |
| 119 | * none |
| 120 | * |
| 121 | * Return Value: response Control frame rate |
| 122 | * |
| 123 | */ |
Malcolm Priestley | 15fa7ce | 2014-05-30 16:27:42 +0100 | [diff] [blame] | 124 | static u16 vnt_get_ofdm_rate(struct vnt_private *priv, u16 rate_idx) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 125 | { |
Malcolm Priestley | a5a7c43 | 2014-05-25 21:36:22 +0100 | [diff] [blame] | 126 | u16 ui = rate_idx; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 127 | |
Malcolm Priestley | 842e3ecc | 2014-05-25 21:36:24 +0100 | [diff] [blame] | 128 | dev_dbg(&priv->usb->dev, "%s basic rate: %d\n", |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 129 | __func__, priv->basic_rates); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 130 | |
Malcolm Priestley | cfa4d8d | 2014-05-30 16:27:48 +0100 | [diff] [blame] | 131 | if (!vnt_ofdm_min_rate(priv)) { |
Malcolm Priestley | 842e3ecc | 2014-05-25 21:36:24 +0100 | [diff] [blame] | 132 | dev_dbg(&priv->usb->dev, "%s (NO OFDM) %d\n", |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 133 | __func__, rate_idx); |
Malcolm Priestley | a5a7c43 | 2014-05-25 21:36:22 +0100 | [diff] [blame] | 134 | if (rate_idx > RATE_24M) |
| 135 | rate_idx = RATE_24M; |
| 136 | return rate_idx; |
Malcolm Priestley | dd0a774 | 2012-12-10 21:59:10 +0000 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | while (ui > RATE_11M) { |
Malcolm Priestley | 93a7355 | 2014-07-20 15:33:13 +0100 | [diff] [blame] | 140 | if (priv->basic_rates & (1 << ui)) { |
Malcolm Priestley | 842e3ecc | 2014-05-25 21:36:24 +0100 | [diff] [blame] | 141 | dev_dbg(&priv->usb->dev, "%s rate: %d\n", |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 142 | __func__, ui); |
Malcolm Priestley | dd0a774 | 2012-12-10 21:59:10 +0000 | [diff] [blame] | 143 | return ui; |
| 144 | } |
| 145 | ui--; |
| 146 | } |
| 147 | |
Malcolm Priestley | 842e3ecc | 2014-05-25 21:36:24 +0100 | [diff] [blame] | 148 | dev_dbg(&priv->usb->dev, "%s basic rate: 24M\n", __func__); |
Malcolm Priestley | dd0a774 | 2012-12-10 21:59:10 +0000 | [diff] [blame] | 149 | |
| 150 | return RATE_24M; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | /* |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 154 | * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode. |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 155 | * |
| 156 | * Parameters: |
Malcolm Priestley | 3605f84 | 2014-05-23 18:00:15 +0100 | [diff] [blame] | 157 | * In: |
| 158 | * rate - Tx Rate |
| 159 | * bb_type - Tx Packet type |
| 160 | * Out: |
| 161 | * tx_rate - pointer to RSPINF TxRate field |
| 162 | * rsv_time- pointer to RSPINF RsvTime field |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 163 | * |
| 164 | * Return Value: none |
| 165 | * |
| 166 | */ |
Malcolm Priestley | c9a0487 | 2014-05-30 16:27:43 +0100 | [diff] [blame] | 167 | static void vnt_calculate_ofdm_rate(u16 rate, u8 bb_type, |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 168 | u8 *tx_rate, u8 *rsv_time) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 169 | { |
Malcolm Priestley | 3605f84 | 2014-05-23 18:00:15 +0100 | [diff] [blame] | 170 | switch (rate) { |
| 171 | case RATE_6M: |
| 172 | if (bb_type == BB_TYPE_11A) { |
| 173 | *tx_rate = 0x9b; |
| 174 | *rsv_time = 24; |
| 175 | } else { |
| 176 | *tx_rate = 0x8b; |
| 177 | *rsv_time = 30; |
| 178 | } |
| 179 | break; |
| 180 | case RATE_9M: |
| 181 | if (bb_type == BB_TYPE_11A) { |
| 182 | *tx_rate = 0x9f; |
| 183 | *rsv_time = 16; |
| 184 | } else { |
| 185 | *tx_rate = 0x8f; |
| 186 | *rsv_time = 22; |
| 187 | } |
| 188 | break; |
| 189 | case RATE_12M: |
| 190 | if (bb_type == BB_TYPE_11A) { |
| 191 | *tx_rate = 0x9a; |
| 192 | *rsv_time = 12; |
| 193 | } else { |
| 194 | *tx_rate = 0x8a; |
| 195 | *rsv_time = 18; |
| 196 | } |
| 197 | break; |
| 198 | case RATE_18M: |
| 199 | if (bb_type == BB_TYPE_11A) { |
| 200 | *tx_rate = 0x9e; |
| 201 | *rsv_time = 8; |
| 202 | } else { |
| 203 | *tx_rate = 0x8e; |
| 204 | *rsv_time = 14; |
| 205 | } |
| 206 | break; |
| 207 | case RATE_36M: |
| 208 | if (bb_type == BB_TYPE_11A) { |
| 209 | *tx_rate = 0x9d; |
| 210 | *rsv_time = 4; |
| 211 | } else { |
| 212 | *tx_rate = 0x8d; |
| 213 | *rsv_time = 10; |
| 214 | } |
| 215 | break; |
| 216 | case RATE_48M: |
| 217 | if (bb_type == BB_TYPE_11A) { |
| 218 | *tx_rate = 0x98; |
| 219 | *rsv_time = 4; |
| 220 | } else { |
| 221 | *tx_rate = 0x88; |
Malcolm Priestley | fd4859f | 2014-05-24 14:37:10 +0100 | [diff] [blame] | 222 | *rsv_time = 10; |
Malcolm Priestley | 3605f84 | 2014-05-23 18:00:15 +0100 | [diff] [blame] | 223 | } |
| 224 | break; |
| 225 | case RATE_54M: |
| 226 | if (bb_type == BB_TYPE_11A) { |
| 227 | *tx_rate = 0x9c; |
| 228 | *rsv_time = 4; |
| 229 | } else { |
| 230 | *tx_rate = 0x8c; |
| 231 | *rsv_time = 10; |
| 232 | } |
| 233 | break; |
| 234 | case RATE_24M: |
| 235 | default: |
| 236 | if (bb_type == BB_TYPE_11A) { |
| 237 | *tx_rate = 0x99; |
| 238 | *rsv_time = 8; |
| 239 | } else { |
| 240 | *tx_rate = 0x89; |
| 241 | *rsv_time = 14; |
| 242 | } |
| 243 | break; |
| 244 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | /* |
| 248 | * Description: Set RSPINF |
| 249 | * |
| 250 | * Parameters: |
| 251 | * In: |
| 252 | * pDevice - The adapter to be set |
| 253 | * Out: |
| 254 | * none |
| 255 | * |
| 256 | * Return Value: None. |
| 257 | * |
| 258 | */ |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 259 | |
Malcolm Priestley | 1a79294 | 2014-05-30 16:27:46 +0100 | [diff] [blame] | 260 | void vnt_set_rspinf(struct vnt_private *priv, u8 bb_type) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 261 | { |
Malcolm Priestley | aed387c | 2013-08-20 22:52:30 +0100 | [diff] [blame] | 262 | struct vnt_phy_field phy[4]; |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 263 | u8 tx_rate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */ |
| 264 | u8 rsv_time[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 265 | u8 data[34]; |
Malcolm Priestley | dd0a774 | 2012-12-10 21:59:10 +0000 | [diff] [blame] | 266 | int i; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 267 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 268 | /*RSPINF_b_1*/ |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 269 | vnt_get_phy_field(priv, 14, vnt_get_cck_rate(priv, RATE_1M), |
| 270 | PK_TYPE_11B, &phy[0]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 271 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 272 | /*RSPINF_b_2*/ |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 273 | vnt_get_phy_field(priv, 14, vnt_get_cck_rate(priv, RATE_2M), |
| 274 | PK_TYPE_11B, &phy[1]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 275 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 276 | /*RSPINF_b_5*/ |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 277 | vnt_get_phy_field(priv, 14, vnt_get_cck_rate(priv, RATE_5M), |
| 278 | PK_TYPE_11B, &phy[2]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 279 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 280 | /*RSPINF_b_11*/ |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 281 | vnt_get_phy_field(priv, 14, vnt_get_cck_rate(priv, RATE_11M), |
| 282 | PK_TYPE_11B, &phy[3]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 283 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 284 | /*RSPINF_a_6*/ |
Malcolm Priestley | c9a0487 | 2014-05-30 16:27:43 +0100 | [diff] [blame] | 285 | vnt_calculate_ofdm_rate(RATE_6M, bb_type, &tx_rate[0], &rsv_time[0]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 286 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 287 | /*RSPINF_a_9*/ |
Malcolm Priestley | c9a0487 | 2014-05-30 16:27:43 +0100 | [diff] [blame] | 288 | vnt_calculate_ofdm_rate(RATE_9M, bb_type, &tx_rate[1], &rsv_time[1]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 289 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 290 | /*RSPINF_a_12*/ |
Malcolm Priestley | c9a0487 | 2014-05-30 16:27:43 +0100 | [diff] [blame] | 291 | vnt_calculate_ofdm_rate(RATE_12M, bb_type, &tx_rate[2], &rsv_time[2]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 292 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 293 | /*RSPINF_a_18*/ |
Malcolm Priestley | c9a0487 | 2014-05-30 16:27:43 +0100 | [diff] [blame] | 294 | vnt_calculate_ofdm_rate(RATE_18M, bb_type, &tx_rate[3], &rsv_time[3]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 295 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 296 | /*RSPINF_a_24*/ |
Malcolm Priestley | c9a0487 | 2014-05-30 16:27:43 +0100 | [diff] [blame] | 297 | vnt_calculate_ofdm_rate(RATE_24M, bb_type, &tx_rate[4], &rsv_time[4]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 298 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 299 | /*RSPINF_a_36*/ |
Malcolm Priestley | c9a0487 | 2014-05-30 16:27:43 +0100 | [diff] [blame] | 300 | vnt_calculate_ofdm_rate(vnt_get_ofdm_rate(priv, RATE_36M), |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 301 | bb_type, &tx_rate[5], &rsv_time[5]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 302 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 303 | /*RSPINF_a_48*/ |
Malcolm Priestley | c9a0487 | 2014-05-30 16:27:43 +0100 | [diff] [blame] | 304 | vnt_calculate_ofdm_rate(vnt_get_ofdm_rate(priv, RATE_48M), |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 305 | bb_type, &tx_rate[6], &rsv_time[6]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 306 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 307 | /*RSPINF_a_54*/ |
Malcolm Priestley | c9a0487 | 2014-05-30 16:27:43 +0100 | [diff] [blame] | 308 | vnt_calculate_ofdm_rate(vnt_get_ofdm_rate(priv, RATE_54M), |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 309 | bb_type, &tx_rate[7], &rsv_time[7]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 310 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 311 | /*RSPINF_a_72*/ |
Malcolm Priestley | c9a0487 | 2014-05-30 16:27:43 +0100 | [diff] [blame] | 312 | vnt_calculate_ofdm_rate(vnt_get_ofdm_rate(priv, RATE_54M), |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 313 | bb_type, &tx_rate[8], &rsv_time[8]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 314 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 315 | put_unaligned(phy[0].len, (u16 *)&data[0]); |
| 316 | data[2] = phy[0].signal; |
| 317 | data[3] = phy[0].service; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 318 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 319 | put_unaligned(phy[1].len, (u16 *)&data[4]); |
| 320 | data[6] = phy[1].signal; |
| 321 | data[7] = phy[1].service; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 322 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 323 | put_unaligned(phy[2].len, (u16 *)&data[8]); |
| 324 | data[10] = phy[2].signal; |
| 325 | data[11] = phy[2].service; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 326 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 327 | put_unaligned(phy[3].len, (u16 *)&data[12]); |
| 328 | data[14] = phy[3].signal; |
| 329 | data[15] = phy[3].service; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 330 | |
Malcolm Priestley | 652d0f0 | 2014-05-23 18:00:16 +0100 | [diff] [blame] | 331 | for (i = 0; i < 9; i++) { |
| 332 | data[16 + i * 2] = tx_rate[i]; |
| 333 | data[16 + i * 2 + 1] = rsv_time[i]; |
| 334 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 335 | |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 336 | vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_RSPINF_B_1, |
| 337 | MESSAGE_REQUEST_MACREG, 34, &data[0]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | /* |
| 341 | * Description: Update IFS |
| 342 | * |
| 343 | * Parameters: |
| 344 | * In: |
Malcolm Priestley | 5ebc46d | 2014-05-23 18:00:17 +0100 | [diff] [blame] | 345 | * priv - The adapter to be set |
| 346 | * Out: |
| 347 | * none |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 348 | * |
| 349 | * Return Value: None. |
| 350 | * |
| 351 | */ |
Malcolm Priestley | c7ee9ee | 2014-05-30 16:27:44 +0100 | [diff] [blame] | 352 | void vnt_update_ifs(struct vnt_private *priv) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 353 | { |
Malcolm Priestley | 5ebc46d | 2014-05-23 18:00:17 +0100 | [diff] [blame] | 354 | u8 max_min = 0; |
| 355 | u8 data[4]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 356 | |
Malcolm Priestley | e12471d | 2014-07-20 15:33:12 +0100 | [diff] [blame] | 357 | if (priv->packet_type == PK_TYPE_11A) { |
Malcolm Priestley | ff5fee2 | 2014-07-19 12:30:18 +0100 | [diff] [blame] | 358 | priv->slot = C_SLOT_SHORT; |
| 359 | priv->sifs = C_SIFS_A; |
| 360 | priv->difs = C_SIFS_A + 2 * C_SLOT_SHORT; |
Malcolm Priestley | 5ebc46d | 2014-05-23 18:00:17 +0100 | [diff] [blame] | 361 | max_min = 4; |
Malcolm Priestley | e12471d | 2014-07-20 15:33:12 +0100 | [diff] [blame] | 362 | } else if (priv->packet_type == PK_TYPE_11B) { |
Malcolm Priestley | ff5fee2 | 2014-07-19 12:30:18 +0100 | [diff] [blame] | 363 | priv->slot = C_SLOT_LONG; |
| 364 | priv->sifs = C_SIFS_BG; |
| 365 | priv->difs = C_SIFS_BG + 2 * C_SLOT_LONG; |
Malcolm Priestley | 5ebc46d | 2014-05-23 18:00:17 +0100 | [diff] [blame] | 366 | max_min = 5; |
| 367 | } else {/* PK_TYPE_11GA & PK_TYPE_11GB */ |
Malcolm Priestley | 5ebc46d | 2014-05-23 18:00:17 +0100 | [diff] [blame] | 368 | bool ofdm_rate = false; |
| 369 | unsigned int ii = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 370 | |
Malcolm Priestley | ff5fee2 | 2014-07-19 12:30:18 +0100 | [diff] [blame] | 371 | priv->sifs = C_SIFS_BG; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 372 | |
Malcolm Priestley | a641c9e | 2014-07-20 15:33:21 +0100 | [diff] [blame] | 373 | if (priv->short_slot_time) |
Malcolm Priestley | ff5fee2 | 2014-07-19 12:30:18 +0100 | [diff] [blame] | 374 | priv->slot = C_SLOT_SHORT; |
Malcolm Priestley | 5ebc46d | 2014-05-23 18:00:17 +0100 | [diff] [blame] | 375 | else |
Malcolm Priestley | ff5fee2 | 2014-07-19 12:30:18 +0100 | [diff] [blame] | 376 | priv->slot = C_SLOT_LONG; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 377 | |
Malcolm Priestley | ff5fee2 | 2014-07-19 12:30:18 +0100 | [diff] [blame] | 378 | priv->difs = C_SIFS_BG + 2 * priv->slot; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 379 | |
Malcolm Priestley | ee61fde | 2014-06-25 21:14:28 +0100 | [diff] [blame] | 380 | for (ii = RATE_54M; ii >= RATE_6M; ii--) { |
Malcolm Priestley | 93a7355 | 2014-07-20 15:33:13 +0100 | [diff] [blame] | 381 | if (priv->basic_rates & ((u32)(0x1 << ii))) { |
Malcolm Priestley | 5ebc46d | 2014-05-23 18:00:17 +0100 | [diff] [blame] | 382 | ofdm_rate = true; |
| 383 | break; |
| 384 | } |
| 385 | } |
| 386 | |
Abdul Hussain | 5699c0f | 2015-06-16 05:43:16 +0000 | [diff] [blame] | 387 | if (ofdm_rate) |
Malcolm Priestley | 5ebc46d | 2014-05-23 18:00:17 +0100 | [diff] [blame] | 388 | max_min = 4; |
Malcolm Priestley | 995c91e | 2014-07-19 12:30:17 +0100 | [diff] [blame] | 389 | else |
Malcolm Priestley | 5ebc46d | 2014-05-23 18:00:17 +0100 | [diff] [blame] | 390 | max_min = 5; |
Malcolm Priestley | 5ebc46d | 2014-05-23 18:00:17 +0100 | [diff] [blame] | 391 | } |
| 392 | |
Malcolm Priestley | ff5fee2 | 2014-07-19 12:30:18 +0100 | [diff] [blame] | 393 | priv->eifs = C_EIFS; |
Malcolm Priestley | 5ebc46d | 2014-05-23 18:00:17 +0100 | [diff] [blame] | 394 | |
Malcolm Priestley | 6242eca | 2014-07-19 12:30:07 +0100 | [diff] [blame] | 395 | switch (priv->rf_type) { |
Malcolm Priestley | 9fe109c | 2014-07-06 23:19:48 +0100 | [diff] [blame] | 396 | case RF_VT3226D0: |
Malcolm Priestley | 65df77e | 2014-07-20 15:33:11 +0100 | [diff] [blame] | 397 | if (priv->bb_type != BB_TYPE_11B) { |
Malcolm Priestley | ff5fee2 | 2014-07-19 12:30:18 +0100 | [diff] [blame] | 398 | priv->sifs -= 1; |
| 399 | priv->difs -= 1; |
Malcolm Priestley | 9fe109c | 2014-07-06 23:19:48 +0100 | [diff] [blame] | 400 | break; |
| 401 | } |
| 402 | case RF_AIROHA7230: |
| 403 | case RF_AL2230: |
| 404 | case RF_AL2230S: |
Malcolm Priestley | 65df77e | 2014-07-20 15:33:11 +0100 | [diff] [blame] | 405 | if (priv->bb_type != BB_TYPE_11B) |
Malcolm Priestley | 9fe109c | 2014-07-06 23:19:48 +0100 | [diff] [blame] | 406 | break; |
| 407 | case RF_RFMD2959: |
| 408 | case RF_VT3226: |
| 409 | case RF_VT3342A0: |
Malcolm Priestley | ff5fee2 | 2014-07-19 12:30:18 +0100 | [diff] [blame] | 410 | priv->sifs -= 3; |
| 411 | priv->difs -= 3; |
Malcolm Priestley | 9fe109c | 2014-07-06 23:19:48 +0100 | [diff] [blame] | 412 | break; |
| 413 | case RF_MAXIM2829: |
Malcolm Priestley | 65df77e | 2014-07-20 15:33:11 +0100 | [diff] [blame] | 414 | if (priv->bb_type == BB_TYPE_11A) { |
Malcolm Priestley | ff5fee2 | 2014-07-19 12:30:18 +0100 | [diff] [blame] | 415 | priv->sifs -= 5; |
| 416 | priv->difs -= 5; |
Malcolm Priestley | 9fe109c | 2014-07-06 23:19:48 +0100 | [diff] [blame] | 417 | } else { |
Malcolm Priestley | ff5fee2 | 2014-07-19 12:30:18 +0100 | [diff] [blame] | 418 | priv->sifs -= 2; |
| 419 | priv->difs -= 2; |
Malcolm Priestley | 9fe109c | 2014-07-06 23:19:48 +0100 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | break; |
| 423 | } |
| 424 | |
Malcolm Priestley | ff5fee2 | 2014-07-19 12:30:18 +0100 | [diff] [blame] | 425 | data[0] = (u8)priv->sifs; |
| 426 | data[1] = (u8)priv->difs; |
| 427 | data[2] = (u8)priv->eifs; |
| 428 | data[3] = (u8)priv->slot; |
Malcolm Priestley | 5ebc46d | 2014-05-23 18:00:17 +0100 | [diff] [blame] | 429 | |
Malcolm Priestley | 1390b02 | 2014-05-26 13:59:01 +0100 | [diff] [blame] | 430 | vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_SIFS, |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 431 | MESSAGE_REQUEST_MACREG, 4, &data[0]); |
Malcolm Priestley | 5ebc46d | 2014-05-23 18:00:17 +0100 | [diff] [blame] | 432 | |
| 433 | max_min |= 0xa0; |
| 434 | |
Malcolm Priestley | 1390b02 | 2014-05-26 13:59:01 +0100 | [diff] [blame] | 435 | vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_CWMAXMIN0, |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 436 | MESSAGE_REQUEST_MACREG, 1, &max_min); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 437 | } |
| 438 | |
Malcolm Priestley | 47203c4 | 2014-05-30 16:27:45 +0100 | [diff] [blame] | 439 | void vnt_update_top_rates(struct vnt_private *priv) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 440 | { |
Malcolm Priestley | dcce9e0 | 2014-05-23 18:00:18 +0100 | [diff] [blame] | 441 | u8 top_ofdm = RATE_24M, top_cck = RATE_1M; |
| 442 | u8 i; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 443 | |
Malcolm Priestley | dcce9e0 | 2014-05-23 18:00:18 +0100 | [diff] [blame] | 444 | /*Determines the highest basic rate.*/ |
| 445 | for (i = RATE_54M; i >= RATE_6M; i--) { |
Malcolm Priestley | 93a7355 | 2014-07-20 15:33:13 +0100 | [diff] [blame] | 446 | if (priv->basic_rates & (u16)(1 << i)) { |
Malcolm Priestley | dcce9e0 | 2014-05-23 18:00:18 +0100 | [diff] [blame] | 447 | top_ofdm = i; |
| 448 | break; |
| 449 | } |
| 450 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 451 | |
Malcolm Priestley | 3c8a5b2 | 2014-07-20 15:33:14 +0100 | [diff] [blame] | 452 | priv->top_ofdm_basic_rate = top_ofdm; |
Malcolm Priestley | dcce9e0 | 2014-05-23 18:00:18 +0100 | [diff] [blame] | 453 | |
| 454 | for (i = RATE_11M;; i--) { |
Malcolm Priestley | 93a7355 | 2014-07-20 15:33:13 +0100 | [diff] [blame] | 455 | if (priv->basic_rates & (u16)(1 << i)) { |
Malcolm Priestley | dcce9e0 | 2014-05-23 18:00:18 +0100 | [diff] [blame] | 456 | top_cck = i; |
| 457 | break; |
| 458 | } |
| 459 | if (i == RATE_1M) |
| 460 | break; |
| 461 | } |
| 462 | |
Malcolm Priestley | d80bf43 | 2014-07-20 15:33:15 +0100 | [diff] [blame] | 463 | priv->top_cck_basic_rate = top_cck; |
Peter Senna Tschudin | 42b138d | 2014-07-15 23:23:26 +0200 | [diff] [blame] | 464 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 465 | |
Malcolm Priestley | cfa4d8d | 2014-05-30 16:27:48 +0100 | [diff] [blame] | 466 | int vnt_ofdm_min_rate(struct vnt_private *priv) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 467 | { |
Malcolm Priestley | dd0a774 | 2012-12-10 21:59:10 +0000 | [diff] [blame] | 468 | int ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 469 | |
Malcolm Priestley | de0eb9e | 2014-05-24 14:36:58 +0100 | [diff] [blame] | 470 | for (ii = RATE_54M; ii >= RATE_6M; ii--) { |
Amitoj Kaur Chawla | 574dddc | 2015-10-16 22:12:35 +0530 | [diff] [blame] | 471 | if ((priv->basic_rates) & ((u16)BIT(ii))) |
Malcolm Priestley | de0eb9e | 2014-05-24 14:36:58 +0100 | [diff] [blame] | 472 | return true; |
| 473 | } |
| 474 | |
| 475 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 476 | } |
| 477 | |
Malcolm Priestley | e809c96 | 2014-05-30 16:27:49 +0100 | [diff] [blame] | 478 | u8 vnt_get_pkt_type(struct vnt_private *priv) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 479 | { |
Malcolm Priestley | 65df77e | 2014-07-20 15:33:11 +0100 | [diff] [blame] | 480 | if (priv->bb_type == BB_TYPE_11A || priv->bb_type == BB_TYPE_11B) |
| 481 | return (u8)priv->bb_type; |
Malcolm Priestley | cfa4d8d | 2014-05-30 16:27:48 +0100 | [diff] [blame] | 482 | else if (vnt_ofdm_min_rate(priv)) |
Malcolm Priestley | 1f44238 | 2014-05-24 14:36:59 +0100 | [diff] [blame] | 483 | return PK_TYPE_11GA; |
Tapasweni Pathak | 3e46587 | 2014-09-22 17:02:20 +0530 | [diff] [blame] | 484 | return PK_TYPE_11GB; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 485 | } |
| 486 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 487 | /* |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 488 | * Description: Calculate TSF offset of two TSF input |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 489 | * Get TSF Offset from RxBCN's TSF and local TSF |
| 490 | * |
| 491 | * Parameters: |
| 492 | * In: |
Malcolm Priestley | 3fd2a69 | 2014-05-24 14:37:00 +0100 | [diff] [blame] | 493 | * rx_rate - rx rate. |
| 494 | * tsf1 - Rx BCN's TSF |
| 495 | * tsf2 - Local TSF |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 496 | * Out: |
| 497 | * none |
| 498 | * |
| 499 | * Return Value: TSF Offset value |
| 500 | * |
| 501 | */ |
Malcolm Priestley | ecbc0a1 | 2014-05-30 16:27:50 +0100 | [diff] [blame] | 502 | u64 vnt_get_tsf_offset(u8 rx_rate, u64 tsf1, u64 tsf2) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 503 | { |
Malcolm Priestley | 3fd2a69 | 2014-05-24 14:37:00 +0100 | [diff] [blame] | 504 | u64 tsf_offset = 0; |
Amitoj Kaur Chawla | 4b1443a | 2015-10-15 13:47:00 +0530 | [diff] [blame] | 505 | u16 rx_bcn_offset; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 506 | |
Rithvik Patibandla | e7c8565 | 2016-06-17 09:26:47 +0530 | [diff] [blame] | 507 | rx_bcn_offset = cw_rxbcntsf_off[rx_rate % MAX_RATE]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 508 | |
Malcolm Priestley | 3fd2a69 | 2014-05-24 14:37:00 +0100 | [diff] [blame] | 509 | tsf2 += (u64)rx_bcn_offset; |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 510 | |
Malcolm Priestley | 3fd2a69 | 2014-05-24 14:37:00 +0100 | [diff] [blame] | 511 | tsf_offset = tsf1 - tsf2; |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 512 | |
Malcolm Priestley | 3fd2a69 | 2014-05-24 14:37:00 +0100 | [diff] [blame] | 513 | return tsf_offset; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 514 | } |
| 515 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 516 | /* |
| 517 | * Description: Sync. TSF counter to BSS |
| 518 | * Get TSF offset and write to HW |
| 519 | * |
| 520 | * Parameters: |
| 521 | * In: |
Malcolm Priestley | 302361d | 2014-05-24 14:37:01 +0100 | [diff] [blame] | 522 | * priv - The adapter to be sync. |
| 523 | * time_stamp - Rx BCN's TSF |
| 524 | * local_tsf - Local TSF |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 525 | * Out: |
| 526 | * none |
| 527 | * |
| 528 | * Return Value: none |
| 529 | * |
| 530 | */ |
Malcolm Priestley | 14c68c5 | 2014-05-30 16:27:51 +0100 | [diff] [blame] | 531 | void vnt_adjust_tsf(struct vnt_private *priv, u8 rx_rate, |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 532 | u64 time_stamp, u64 local_tsf) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 533 | { |
Malcolm Priestley | 302361d | 2014-05-24 14:37:01 +0100 | [diff] [blame] | 534 | u64 tsf_offset = 0; |
| 535 | u8 data[8]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 536 | |
Malcolm Priestley | ecbc0a1 | 2014-05-30 16:27:50 +0100 | [diff] [blame] | 537 | tsf_offset = vnt_get_tsf_offset(rx_rate, time_stamp, local_tsf); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 538 | |
Malcolm Priestley | 302361d | 2014-05-24 14:37:01 +0100 | [diff] [blame] | 539 | data[0] = (u8)tsf_offset; |
| 540 | data[1] = (u8)(tsf_offset >> 8); |
| 541 | data[2] = (u8)(tsf_offset >> 16); |
| 542 | data[3] = (u8)(tsf_offset >> 24); |
| 543 | data[4] = (u8)(tsf_offset >> 32); |
| 544 | data[5] = (u8)(tsf_offset >> 40); |
| 545 | data[6] = (u8)(tsf_offset >> 48); |
| 546 | data[7] = (u8)(tsf_offset >> 56); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 547 | |
Malcolm Priestley | 1390b02 | 2014-05-26 13:59:01 +0100 | [diff] [blame] | 548 | vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 549 | MESSAGE_REQUEST_TSF, 0, 8, data); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 550 | } |
Rithvik Patibandla | 6d898d6 | 2016-06-17 09:23:42 +0530 | [diff] [blame] | 551 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 552 | /* |
| 553 | * Description: Read NIC TSF counter |
| 554 | * Get local TSF counter |
| 555 | * |
| 556 | * Parameters: |
| 557 | * In: |
Malcolm Priestley | 2092dfa | 2014-05-24 14:37:02 +0100 | [diff] [blame] | 558 | * priv - The adapter to be read |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 559 | * Out: |
Malcolm Priestley | 2092dfa | 2014-05-24 14:37:02 +0100 | [diff] [blame] | 560 | * current_tsf - Current TSF counter |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 561 | * |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 562 | * Return Value: true if success; otherwise false |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 563 | * |
| 564 | */ |
Malcolm Priestley | 4a9f4c6 | 2014-05-30 23:22:47 +0100 | [diff] [blame] | 565 | bool vnt_get_current_tsf(struct vnt_private *priv, u64 *current_tsf) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 566 | { |
Malcolm Priestley | 113f0b9 | 2014-07-19 12:30:13 +0100 | [diff] [blame] | 567 | *current_tsf = priv->current_tsf; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 568 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 569 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 570 | } |
| 571 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 572 | /* |
| 573 | * Description: Clear NIC TSF counter |
| 574 | * Clear local TSF counter |
| 575 | * |
| 576 | * Parameters: |
| 577 | * In: |
Malcolm Priestley | e151e47 | 2014-05-24 14:37:03 +0100 | [diff] [blame] | 578 | * priv - The adapter to be read |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 579 | * |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 580 | * Return Value: true if success; otherwise false |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 581 | * |
| 582 | */ |
Malcolm Priestley | dba066e | 2014-05-30 23:22:48 +0100 | [diff] [blame] | 583 | bool vnt_clear_current_tsf(struct vnt_private *priv) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 584 | { |
Malcolm Priestley | 3695753 | 2014-05-31 11:50:42 +0100 | [diff] [blame] | 585 | vnt_mac_reg_bits_on(priv, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 586 | |
Malcolm Priestley | 113f0b9 | 2014-07-19 12:30:13 +0100 | [diff] [blame] | 587 | priv->current_tsf = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 588 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 589 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | /* |
| 593 | * Description: Read NIC TSF counter |
| 594 | * Get NEXTTBTT from adjusted TSF and Beacon Interval |
| 595 | * |
| 596 | * Parameters: |
| 597 | * In: |
Malcolm Priestley | 5f4dfb6 | 2014-05-24 14:37:04 +0100 | [diff] [blame] | 598 | * tsf - Current TSF counter |
| 599 | * beacon_interval - Beacon Interval |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 600 | * Out: |
Malcolm Priestley | 5f4dfb6 | 2014-05-24 14:37:04 +0100 | [diff] [blame] | 601 | * tsf - Current TSF counter |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 602 | * |
| 603 | * Return Value: TSF value of next Beacon |
| 604 | * |
| 605 | */ |
Malcolm Priestley | 75ef1b51 | 2014-05-30 23:22:49 +0100 | [diff] [blame] | 606 | u64 vnt_get_next_tbtt(u64 tsf, u16 beacon_interval) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 607 | { |
Malcolm Priestley | 5f4dfb6 | 2014-05-24 14:37:04 +0100 | [diff] [blame] | 608 | u32 beacon_int; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 609 | |
Malcolm Priestley | 5f4dfb6 | 2014-05-24 14:37:04 +0100 | [diff] [blame] | 610 | beacon_int = beacon_interval * 1024; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 611 | |
Malcolm Priestley | 6e28024 | 2014-01-01 19:20:40 +0000 | [diff] [blame] | 612 | /* Next TBTT = |
| 613 | * ((local_current_TSF / beacon_interval) + 1) * beacon_interval |
| 614 | */ |
Malcolm Priestley | 5f4dfb6 | 2014-05-24 14:37:04 +0100 | [diff] [blame] | 615 | if (beacon_int) { |
| 616 | do_div(tsf, beacon_int); |
| 617 | tsf += 1; |
| 618 | tsf *= beacon_int; |
Malcolm Priestley | 6e28024 | 2014-01-01 19:20:40 +0000 | [diff] [blame] | 619 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 620 | |
Malcolm Priestley | 5f4dfb6 | 2014-05-24 14:37:04 +0100 | [diff] [blame] | 621 | return tsf; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 622 | } |
| 623 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 624 | /* |
| 625 | * Description: Set NIC TSF counter for first Beacon time |
| 626 | * Get NEXTTBTT from adjusted TSF and Beacon Interval |
| 627 | * |
| 628 | * Parameters: |
| 629 | * In: |
| 630 | * dwIoBase - IO Base |
Malcolm Priestley | 414475f | 2014-05-24 14:37:05 +0100 | [diff] [blame] | 631 | * beacon_interval - Beacon Interval |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 632 | * Out: |
| 633 | * none |
| 634 | * |
| 635 | * Return Value: none |
| 636 | * |
| 637 | */ |
Malcolm Priestley | 6964cd1 | 2014-05-30 23:22:50 +0100 | [diff] [blame] | 638 | void vnt_reset_next_tbtt(struct vnt_private *priv, u16 beacon_interval) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 639 | { |
Malcolm Priestley | 414475f | 2014-05-24 14:37:05 +0100 | [diff] [blame] | 640 | u64 next_tbtt = 0; |
| 641 | u8 data[8]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 642 | |
Malcolm Priestley | dba066e | 2014-05-30 23:22:48 +0100 | [diff] [blame] | 643 | vnt_clear_current_tsf(priv); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 644 | |
Malcolm Priestley | 75ef1b51 | 2014-05-30 23:22:49 +0100 | [diff] [blame] | 645 | next_tbtt = vnt_get_next_tbtt(next_tbtt, beacon_interval); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 646 | |
Malcolm Priestley | 414475f | 2014-05-24 14:37:05 +0100 | [diff] [blame] | 647 | data[0] = (u8)next_tbtt; |
| 648 | data[1] = (u8)(next_tbtt >> 8); |
| 649 | data[2] = (u8)(next_tbtt >> 16); |
| 650 | data[3] = (u8)(next_tbtt >> 24); |
| 651 | data[4] = (u8)(next_tbtt >> 32); |
| 652 | data[5] = (u8)(next_tbtt >> 40); |
| 653 | data[6] = (u8)(next_tbtt >> 48); |
| 654 | data[7] = (u8)(next_tbtt >> 56); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 655 | |
Malcolm Priestley | 1390b02 | 2014-05-26 13:59:01 +0100 | [diff] [blame] | 656 | vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 657 | MESSAGE_REQUEST_TBTT, 0, 8, data); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 658 | } |
| 659 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 660 | /* |
| 661 | * Description: Sync NIC TSF counter for Beacon time |
| 662 | * Get NEXTTBTT and write to HW |
| 663 | * |
| 664 | * Parameters: |
| 665 | * In: |
Malcolm Priestley | 8b515de | 2014-05-24 14:37:06 +0100 | [diff] [blame] | 666 | * priv - The adapter to be set |
| 667 | * tsf - Current TSF counter |
| 668 | * beacon_interval - Beacon Interval |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 669 | * Out: |
| 670 | * none |
| 671 | * |
| 672 | * Return Value: none |
| 673 | * |
| 674 | */ |
Malcolm Priestley | 88ec2f7 | 2014-05-30 23:22:51 +0100 | [diff] [blame] | 675 | void vnt_update_next_tbtt(struct vnt_private *priv, u64 tsf, |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 676 | u16 beacon_interval) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 677 | { |
Malcolm Priestley | 8b515de | 2014-05-24 14:37:06 +0100 | [diff] [blame] | 678 | u8 data[8]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 679 | |
Malcolm Priestley | 75ef1b51 | 2014-05-30 23:22:49 +0100 | [diff] [blame] | 680 | tsf = vnt_get_next_tbtt(tsf, beacon_interval); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 681 | |
Malcolm Priestley | 8b515de | 2014-05-24 14:37:06 +0100 | [diff] [blame] | 682 | data[0] = (u8)tsf; |
| 683 | data[1] = (u8)(tsf >> 8); |
| 684 | data[2] = (u8)(tsf >> 16); |
| 685 | data[3] = (u8)(tsf >> 24); |
| 686 | data[4] = (u8)(tsf >> 32); |
| 687 | data[5] = (u8)(tsf >> 40); |
| 688 | data[6] = (u8)(tsf >> 48); |
| 689 | data[7] = (u8)(tsf >> 56); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 690 | |
Malcolm Priestley | 1390b02 | 2014-05-26 13:59:01 +0100 | [diff] [blame] | 691 | vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, |
Peter Senna Tschudin | 42b138d | 2014-07-15 23:23:26 +0200 | [diff] [blame] | 692 | MESSAGE_REQUEST_TBTT, 0, 8, data); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 693 | |
Malcolm Priestley | 842e3ecc | 2014-05-25 21:36:24 +0100 | [diff] [blame] | 694 | dev_dbg(&priv->usb->dev, "%s TBTT: %8llx\n", __func__, tsf); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | /* |
| 698 | * Description: Turn off Radio power |
| 699 | * |
| 700 | * Parameters: |
| 701 | * In: |
Malcolm Priestley | 07deb71 | 2014-05-24 14:37:07 +0100 | [diff] [blame] | 702 | * priv - The adapter to be turned off |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 703 | * Out: |
| 704 | * none |
| 705 | * |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 706 | * Return Value: true if success; otherwise false |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 707 | * |
| 708 | */ |
Malcolm Priestley | fa26e0b | 2014-05-30 23:22:52 +0100 | [diff] [blame] | 709 | int vnt_radio_power_off(struct vnt_private *priv) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 710 | { |
Malcolm Priestley | 07deb71 | 2014-05-24 14:37:07 +0100 | [diff] [blame] | 711 | int ret = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 712 | |
Malcolm Priestley | 6242eca | 2014-07-19 12:30:07 +0100 | [diff] [blame] | 713 | switch (priv->rf_type) { |
Malcolm Priestley | 07deb71 | 2014-05-24 14:37:07 +0100 | [diff] [blame] | 714 | case RF_AL2230: |
| 715 | case RF_AL2230S: |
| 716 | case RF_AIROHA7230: |
| 717 | case RF_VT3226: |
| 718 | case RF_VT3226D0: |
| 719 | case RF_VT3342A0: |
Malcolm Priestley | a9bed1d | 2014-05-31 11:50:41 +0100 | [diff] [blame] | 720 | vnt_mac_reg_bits_off(priv, MAC_REG_SOFTPWRCTL, |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 721 | (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); |
Malcolm Priestley | 07deb71 | 2014-05-24 14:37:07 +0100 | [diff] [blame] | 722 | break; |
| 723 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 724 | |
Malcolm Priestley | a9bed1d | 2014-05-31 11:50:41 +0100 | [diff] [blame] | 725 | vnt_mac_reg_bits_off(priv, MAC_REG_HOSTCR, HOSTCR_RXON); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 726 | |
Malcolm Priestley | e8e072d | 2014-07-16 22:21:56 +0100 | [diff] [blame] | 727 | vnt_set_deep_sleep(priv); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 728 | |
Malcolm Priestley | d7f2d8f | 2014-07-18 23:00:54 +0100 | [diff] [blame] | 729 | vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL1, GPIO3_INTMD); |
| 730 | |
Malcolm Priestley | 07deb71 | 2014-05-24 14:37:07 +0100 | [diff] [blame] | 731 | return ret; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 732 | } |
| 733 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 734 | /* |
| 735 | * Description: Turn on Radio power |
| 736 | * |
| 737 | * Parameters: |
| 738 | * In: |
Malcolm Priestley | f320314 | 2014-05-24 14:37:08 +0100 | [diff] [blame] | 739 | * priv - The adapter to be turned on |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 740 | * Out: |
| 741 | * none |
| 742 | * |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 743 | * Return Value: true if success; otherwise false |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 744 | * |
| 745 | */ |
Malcolm Priestley | 8a5e6c8 | 2014-05-30 23:22:53 +0100 | [diff] [blame] | 746 | int vnt_radio_power_on(struct vnt_private *priv) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 747 | { |
Malcolm Priestley | f320314 | 2014-05-24 14:37:08 +0100 | [diff] [blame] | 748 | int ret = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 749 | |
Malcolm Priestley | 0e95175 | 2014-07-16 22:21:57 +0100 | [diff] [blame] | 750 | vnt_exit_deep_sleep(priv); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 751 | |
Malcolm Priestley | 3695753 | 2014-05-31 11:50:42 +0100 | [diff] [blame] | 752 | vnt_mac_reg_bits_on(priv, MAC_REG_HOSTCR, HOSTCR_RXON); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 753 | |
Malcolm Priestley | 6242eca | 2014-07-19 12:30:07 +0100 | [diff] [blame] | 754 | switch (priv->rf_type) { |
Malcolm Priestley | f320314 | 2014-05-24 14:37:08 +0100 | [diff] [blame] | 755 | case RF_AL2230: |
| 756 | case RF_AL2230S: |
| 757 | case RF_AIROHA7230: |
| 758 | case RF_VT3226: |
| 759 | case RF_VT3226D0: |
| 760 | case RF_VT3342A0: |
Malcolm Priestley | 3695753 | 2014-05-31 11:50:42 +0100 | [diff] [blame] | 761 | vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL, |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 762 | (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); |
Malcolm Priestley | f320314 | 2014-05-24 14:37:08 +0100 | [diff] [blame] | 763 | break; |
| 764 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 765 | |
Malcolm Priestley | d7f2d8f | 2014-07-18 23:00:54 +0100 | [diff] [blame] | 766 | vnt_mac_reg_bits_off(priv, MAC_REG_GPIOCTL1, GPIO3_INTMD); |
| 767 | |
Malcolm Priestley | f320314 | 2014-05-24 14:37:08 +0100 | [diff] [blame] | 768 | return ret; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 769 | } |
| 770 | |
Malcolm Priestley | bc240f5 | 2014-05-30 23:22:54 +0100 | [diff] [blame] | 771 | void vnt_set_bss_mode(struct vnt_private *priv) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 772 | { |
Malcolm Priestley | 65df77e | 2014-07-20 15:33:11 +0100 | [diff] [blame] | 773 | if (priv->rf_type == RF_AIROHA7230 && priv->bb_type == BB_TYPE_11A) |
Malcolm Priestley | 05089fb | 2014-05-31 11:50:38 +0100 | [diff] [blame] | 774 | vnt_mac_set_bb_type(priv, BB_TYPE_11G); |
Malcolm Priestley | 1efb8fa | 2014-05-24 14:37:09 +0100 | [diff] [blame] | 775 | else |
Malcolm Priestley | 65df77e | 2014-07-20 15:33:11 +0100 | [diff] [blame] | 776 | vnt_mac_set_bb_type(priv, priv->bb_type); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 777 | |
Malcolm Priestley | e12471d | 2014-07-20 15:33:12 +0100 | [diff] [blame] | 778 | priv->packet_type = vnt_get_pkt_type(priv); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 779 | |
Malcolm Priestley | 65df77e | 2014-07-20 15:33:11 +0100 | [diff] [blame] | 780 | if (priv->bb_type == BB_TYPE_11A) |
Malcolm Priestley | 285d58c | 2014-05-26 13:59:03 +0100 | [diff] [blame] | 781 | vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x03); |
Malcolm Priestley | 65df77e | 2014-07-20 15:33:11 +0100 | [diff] [blame] | 782 | else if (priv->bb_type == BB_TYPE_11B) |
Malcolm Priestley | 285d58c | 2014-05-26 13:59:03 +0100 | [diff] [blame] | 783 | vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x02); |
Malcolm Priestley | 65df77e | 2014-07-20 15:33:11 +0100 | [diff] [blame] | 784 | else if (priv->bb_type == BB_TYPE_11G) |
Malcolm Priestley | 285d58c | 2014-05-26 13:59:03 +0100 | [diff] [blame] | 785 | vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x08); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 786 | |
Malcolm Priestley | c7ee9ee | 2014-05-30 16:27:44 +0100 | [diff] [blame] | 787 | vnt_update_ifs(priv); |
Malcolm Priestley | 65df77e | 2014-07-20 15:33:11 +0100 | [diff] [blame] | 788 | vnt_set_rspinf(priv, (u8)priv->bb_type); |
Malcolm Priestley | 1efb8fa | 2014-05-24 14:37:09 +0100 | [diff] [blame] | 789 | |
Malcolm Priestley | 65df77e | 2014-07-20 15:33:11 +0100 | [diff] [blame] | 790 | if (priv->bb_type == BB_TYPE_11A) { |
Malcolm Priestley | 6242eca | 2014-07-19 12:30:07 +0100 | [diff] [blame] | 791 | if (priv->rf_type == RF_AIROHA7230) { |
Malcolm Priestley | c37cbd3 | 2014-07-20 15:33:25 +0100 | [diff] [blame] | 792 | priv->bb_vga[0] = 0x20; |
Malcolm Priestley | 1efb8fa | 2014-05-24 14:37:09 +0100 | [diff] [blame] | 793 | |
Malcolm Priestley | 285d58c | 2014-05-26 13:59:03 +0100 | [diff] [blame] | 794 | vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 795 | 0xe7, priv->bb_vga[0]); |
Malcolm Priestley | 1efb8fa | 2014-05-24 14:37:09 +0100 | [diff] [blame] | 796 | } |
| 797 | |
Malcolm Priestley | c37cbd3 | 2014-07-20 15:33:25 +0100 | [diff] [blame] | 798 | priv->bb_vga[2] = 0x10; |
| 799 | priv->bb_vga[3] = 0x10; |
Malcolm Priestley | 1efb8fa | 2014-05-24 14:37:09 +0100 | [diff] [blame] | 800 | } else { |
Malcolm Priestley | 6242eca | 2014-07-19 12:30:07 +0100 | [diff] [blame] | 801 | if (priv->rf_type == RF_AIROHA7230) { |
Malcolm Priestley | c37cbd3 | 2014-07-20 15:33:25 +0100 | [diff] [blame] | 802 | priv->bb_vga[0] = 0x1c; |
Malcolm Priestley | 1efb8fa | 2014-05-24 14:37:09 +0100 | [diff] [blame] | 803 | |
Malcolm Priestley | 285d58c | 2014-05-26 13:59:03 +0100 | [diff] [blame] | 804 | vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, |
Rithvik Patibandla | a9f47a4 | 2016-06-17 09:57:31 +0530 | [diff] [blame] | 805 | 0xe7, priv->bb_vga[0]); |
Malcolm Priestley | 1efb8fa | 2014-05-24 14:37:09 +0100 | [diff] [blame] | 806 | } |
| 807 | |
Malcolm Priestley | c37cbd3 | 2014-07-20 15:33:25 +0100 | [diff] [blame] | 808 | priv->bb_vga[2] = 0x0; |
| 809 | priv->bb_vga[3] = 0x0; |
Malcolm Priestley | 1efb8fa | 2014-05-24 14:37:09 +0100 | [diff] [blame] | 810 | } |
Malcolm Priestley | d358477 | 2014-06-28 23:55:45 +0100 | [diff] [blame] | 811 | |
Malcolm Priestley | c37cbd3 | 2014-07-20 15:33:25 +0100 | [diff] [blame] | 812 | vnt_set_vga_gain_offset(priv, priv->bb_vga[0]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 813 | } |