Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of version 2 of the GNU General Public License as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | ******************************************************************************/ |
| 15 | |
| 16 | #include "odm_precomp.h" |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 17 | #include "usb_ops_linux.h" |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 18 | |
| 19 | static const u16 dB_Invert_Table[8][12] = { |
| 20 | {1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4}, |
| 21 | {4, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16}, |
| 22 | {18, 20, 22, 25, 28, 32, 35, 40, 45, 50, 56, 63}, |
| 23 | {71, 79, 89, 100, 112, 126, 141, 158, 178, 200, 224, 251}, |
| 24 | {282, 316, 355, 398, 447, 501, 562, 631, 708, 794, 891, 1000}, |
| 25 | {1122, 1259, 1413, 1585, 1778, 1995, 2239, 2512, 2818, 3162, 3548, 3981}, |
| 26 | {4467, 5012, 5623, 6310, 7079, 7943, 8913, 10000, 11220, 12589, 14125, 15849}, |
| 27 | {17783, 19953, 22387, 25119, 28184, 31623, 35481, 39811, 44668, 50119, 56234, 65535} |
| 28 | }; |
| 29 | |
| 30 | static u32 EDCAParam[HT_IOT_PEER_MAX][3] = { /* UL DL */ |
| 31 | {0x5ea42b, 0x5ea42b, 0x5ea42b}, /* 0:unknown AP */ |
| 32 | {0xa44f, 0x5ea44f, 0x5e431c}, /* 1:realtek AP */ |
| 33 | {0x5ea42b, 0x5ea42b, 0x5ea42b}, /* 2:unknown AP => realtek_92SE */ |
| 34 | {0x5ea32b, 0x5ea42b, 0x5e4322}, /* 3:broadcom AP */ |
| 35 | {0x5ea422, 0x00a44f, 0x00a44f}, /* 4:ralink AP */ |
| 36 | {0x5ea322, 0x00a630, 0x00a44f}, /* 5:atheros AP */ |
| 37 | {0x5e4322, 0x5e4322, 0x5e4322},/* 6:cisco AP */ |
| 38 | {0x5ea44f, 0x00a44f, 0x5ea42b}, /* 8:marvell AP */ |
| 39 | {0x5ea42b, 0x5ea42b, 0x5ea42b}, /* 10:unknown AP => 92U AP */ |
| 40 | {0x5ea42b, 0xa630, 0x5e431c}, /* 11:airgocap AP */ |
| 41 | }; |
| 42 | |
Carlos E. Garcia | 69e98df | 2015-04-24 09:40:42 -0400 | [diff] [blame] | 43 | /* EDCA Parameter for AP/ADSL by Mingzhi 2011-11-22 */ |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 44 | |
| 45 | /* Global var */ |
| 46 | u32 OFDMSwingTable23A[OFDM_TABLE_SIZE_92D] = { |
| 47 | 0x7f8001fe, /* 0, +6.0dB */ |
| 48 | 0x788001e2, /* 1, +5.5dB */ |
| 49 | 0x71c001c7, /* 2, +5.0dB */ |
| 50 | 0x6b8001ae, /* 3, +4.5dB */ |
| 51 | 0x65400195, /* 4, +4.0dB */ |
| 52 | 0x5fc0017f, /* 5, +3.5dB */ |
| 53 | 0x5a400169, /* 6, +3.0dB */ |
| 54 | 0x55400155, /* 7, +2.5dB */ |
| 55 | 0x50800142, /* 8, +2.0dB */ |
| 56 | 0x4c000130, /* 9, +1.5dB */ |
| 57 | 0x47c0011f, /* 10, +1.0dB */ |
| 58 | 0x43c0010f, /* 11, +0.5dB */ |
| 59 | 0x40000100, /* 12, +0dB */ |
| 60 | 0x3c8000f2, /* 13, -0.5dB */ |
| 61 | 0x390000e4, /* 14, -1.0dB */ |
| 62 | 0x35c000d7, /* 15, -1.5dB */ |
| 63 | 0x32c000cb, /* 16, -2.0dB */ |
| 64 | 0x300000c0, /* 17, -2.5dB */ |
| 65 | 0x2d4000b5, /* 18, -3.0dB */ |
| 66 | 0x2ac000ab, /* 19, -3.5dB */ |
| 67 | 0x288000a2, /* 20, -4.0dB */ |
| 68 | 0x26000098, /* 21, -4.5dB */ |
| 69 | 0x24000090, /* 22, -5.0dB */ |
| 70 | 0x22000088, /* 23, -5.5dB */ |
| 71 | 0x20000080, /* 24, -6.0dB */ |
| 72 | 0x1e400079, /* 25, -6.5dB */ |
| 73 | 0x1c800072, /* 26, -7.0dB */ |
| 74 | 0x1b00006c, /* 27. -7.5dB */ |
| 75 | 0x19800066, /* 28, -8.0dB */ |
| 76 | 0x18000060, /* 29, -8.5dB */ |
| 77 | 0x16c0005b, /* 30, -9.0dB */ |
| 78 | 0x15800056, /* 31, -9.5dB */ |
| 79 | 0x14400051, /* 32, -10.0dB */ |
| 80 | 0x1300004c, /* 33, -10.5dB */ |
| 81 | 0x12000048, /* 34, -11.0dB */ |
| 82 | 0x11000044, /* 35, -11.5dB */ |
| 83 | 0x10000040, /* 36, -12.0dB */ |
| 84 | 0x0f00003c,/* 37, -12.5dB */ |
| 85 | 0x0e400039,/* 38, -13.0dB */ |
| 86 | 0x0d800036,/* 39, -13.5dB */ |
| 87 | 0x0cc00033,/* 40, -14.0dB */ |
| 88 | 0x0c000030,/* 41, -14.5dB */ |
| 89 | 0x0b40002d,/* 42, -15.0dB */ |
| 90 | }; |
| 91 | |
| 92 | u8 CCKSwingTable_Ch1_Ch1323A[CCK_TABLE_SIZE][8] = { |
| 93 | {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, /* 0, +0dB */ |
| 94 | {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, /* 1, -0.5dB */ |
| 95 | {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, /* 2, -1.0dB */ |
| 96 | {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, /* 3, -1.5dB */ |
| 97 | {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, /* 4, -2.0dB */ |
| 98 | {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, /* 5, -2.5dB */ |
| 99 | {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, /* 6, -3.0dB */ |
| 100 | {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, /* 7, -3.5dB */ |
| 101 | {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, /* 8, -4.0dB */ |
| 102 | {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, /* 9, -4.5dB */ |
| 103 | {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, /* 10, -5.0dB */ |
| 104 | {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, /* 11, -5.5dB */ |
| 105 | {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, /* 12, -6.0dB */ |
| 106 | {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, /* 13, -6.5dB */ |
| 107 | {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, /* 14, -7.0dB */ |
| 108 | {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, /* 15, -7.5dB */ |
| 109 | {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, /* 16, -8.0dB */ |
| 110 | {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, /* 17, -8.5dB */ |
| 111 | {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, /* 18, -9.0dB */ |
| 112 | {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 19, -9.5dB */ |
| 113 | {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 20, -10.0dB */ |
| 114 | {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 21, -10.5dB */ |
| 115 | {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 22, -11.0dB */ |
| 116 | {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, /* 23, -11.5dB */ |
| 117 | {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, /* 24, -12.0dB */ |
| 118 | {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, /* 25, -12.5dB */ |
| 119 | {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, /* 26, -13.0dB */ |
| 120 | {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 27, -13.5dB */ |
| 121 | {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 28, -14.0dB */ |
| 122 | {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 29, -14.5dB */ |
| 123 | {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 30, -15.0dB */ |
| 124 | {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, /* 31, -15.5dB */ |
| 125 | {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01} /* 32, -16.0dB */ |
| 126 | }; |
| 127 | |
| 128 | u8 CCKSwingTable_Ch1423A[CCK_TABLE_SIZE][8] = { |
| 129 | {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, /* 0, +0dB */ |
| 130 | {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, /* 1, -0.5dB */ |
| 131 | {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, /* 2, -1.0dB */ |
| 132 | {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, /* 3, -1.5dB */ |
| 133 | {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, /* 4, -2.0dB */ |
| 134 | {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, /* 5, -2.5dB */ |
| 135 | {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, /* 6, -3.0dB */ |
| 136 | {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, /* 7, -3.5dB */ |
| 137 | {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, /* 8, -4.0dB */ |
| 138 | {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, /* 9, -4.5dB */ |
| 139 | {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, /* 10, -5.0dB */ |
| 140 | {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 11, -5.5dB */ |
| 141 | {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 12, -6.0dB */ |
| 142 | {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, /* 13, -6.5dB */ |
| 143 | {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, /* 14, -7.0dB */ |
| 144 | {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 15, -7.5dB */ |
| 145 | {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 16, -8.0dB */ |
| 146 | {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 17, -8.5dB */ |
| 147 | {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 18, -9.0dB */ |
| 148 | {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 19, -9.5dB */ |
| 149 | {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 20, -10.0dB */ |
| 150 | {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 21, -10.5dB */ |
| 151 | {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 22, -11.0dB */ |
| 152 | {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 23, -11.5dB */ |
| 153 | {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 24, -12.0dB */ |
| 154 | {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 25, -12.5dB */ |
| 155 | {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 26, -13.0dB */ |
| 156 | {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 27, -13.5dB */ |
| 157 | {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 28, -14.0dB */ |
| 158 | {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 29, -14.5dB */ |
| 159 | {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 30, -15.0dB */ |
| 160 | {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 31, -15.5dB */ |
| 161 | {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} /* 32, -16.0dB */ |
| 162 | }; |
| 163 | |
| 164 | /* Local Function predefine. */ |
| 165 | |
| 166 | /* START------------COMMON INFO RELATED--------------- */ |
| 167 | void odm_CommonInfoSelfInit23a(struct dm_odm_t *pDM_Odm); |
| 168 | |
Jes Sorensen | 91a2916 | 2014-07-21 11:24:56 +0200 | [diff] [blame] | 169 | static void odm_CommonInfoSelfUpdate(struct hal_data_8723a *pHalData); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 170 | |
| 171 | void odm_CmnInfoInit_Debug23a(struct dm_odm_t *pDM_Odm); |
| 172 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 173 | void odm_CmnInfoUpdate_Debug23a(struct dm_odm_t *pDM_Odm); |
| 174 | |
| 175 | /* START---------------DIG--------------------------- */ |
| 176 | void odm_FalseAlarmCounterStatistics23a(struct dm_odm_t *pDM_Odm); |
| 177 | |
| 178 | void odm_DIG23aInit(struct dm_odm_t *pDM_Odm); |
| 179 | |
Jes Sorensen | 1a573d2 | 2014-07-21 11:24:59 +0200 | [diff] [blame] | 180 | void odm_DIG23a(struct rtw_adapter *adapter); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 181 | |
| 182 | void odm_CCKPacketDetectionThresh23a(struct dm_odm_t *pDM_Odm); |
| 183 | /* END---------------DIG--------------------------- */ |
| 184 | |
| 185 | /* START-------BB POWER SAVE----------------------- */ |
| 186 | void odm23a_DynBBPSInit(struct dm_odm_t *pDM_Odm); |
| 187 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 188 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 189 | /* END---------BB POWER SAVE----------------------- */ |
| 190 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 191 | void odm_DynamicTxPower23aInit(struct dm_odm_t *pDM_Odm); |
| 192 | |
Jes Sorensen | 04b7466 | 2015-03-02 15:24:59 -0500 | [diff] [blame] | 193 | static void odm_RSSIMonitorCheck(struct dm_odm_t *pDM_Odm); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 194 | void odm_DynamicTxPower23a(struct dm_odm_t *pDM_Odm); |
| 195 | |
Jes Sorensen | b58298e | 2015-03-02 15:25:01 -0500 | [diff] [blame] | 196 | static void odm_RefreshRateAdaptiveMask(struct dm_odm_t *pDM_Odm); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 197 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 198 | void odm_RateAdaptiveMaskInit23a(struct dm_odm_t *pDM_Odm); |
| 199 | |
Jes Sorensen | def0c45 | 2015-03-05 14:24:36 -0500 | [diff] [blame] | 200 | static void odm_TXPowerTrackingInit(struct dm_odm_t *pDM_Odm); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 201 | |
Jes Sorensen | 4d1def6b | 2014-07-21 11:24:42 +0200 | [diff] [blame] | 202 | static void odm_EdcaTurboCheck23a(struct dm_odm_t *pDM_Odm); |
| 203 | static void ODM_EdcaTurboInit23a(struct dm_odm_t *pDM_Odm); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 204 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 205 | #define RxDefaultAnt1 0x65a9 |
| 206 | #define RxDefaultAnt2 0x569a |
| 207 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 208 | bool odm_StaDefAntSel(struct dm_odm_t *pDM_Odm, |
Melike Yurtoglu | ef37b77 | 2015-02-26 08:51:03 +0200 | [diff] [blame] | 209 | u32 OFDM_Ant1_Cnt, |
| 210 | u32 OFDM_Ant2_Cnt, |
| 211 | u32 CCK_Ant1_Cnt, |
| 212 | u32 CCK_Ant2_Cnt, |
| 213 | u8 *pDefAnt |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 214 | ); |
| 215 | |
| 216 | void odm_SetRxIdleAnt(struct dm_odm_t *pDM_Odm, |
| 217 | u8 Ant, |
Melike Yurtoglu | ef37b77 | 2015-02-26 08:51:03 +0200 | [diff] [blame] | 218 | bool bDualPath |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 219 | ); |
| 220 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 221 | /* 3 Export Interface */ |
| 222 | |
| 223 | /* 2011/09/21 MH Add to describe different team necessary resource allocate?? */ |
| 224 | void ODM23a_DMInit(struct dm_odm_t *pDM_Odm) |
| 225 | { |
| 226 | /* For all IC series */ |
| 227 | odm_CommonInfoSelfInit23a(pDM_Odm); |
| 228 | odm_CmnInfoInit_Debug23a(pDM_Odm); |
| 229 | odm_DIG23aInit(pDM_Odm); |
| 230 | odm_RateAdaptiveMaskInit23a(pDM_Odm); |
| 231 | |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 232 | odm23a_DynBBPSInit(pDM_Odm); |
| 233 | odm_DynamicTxPower23aInit(pDM_Odm); |
Jes Sorensen | def0c45 | 2015-03-05 14:24:36 -0500 | [diff] [blame] | 234 | odm_TXPowerTrackingInit(pDM_Odm); |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 235 | ODM_EdcaTurboInit23a(pDM_Odm); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | /* 2011/09/20 MH This is the entry pointer for all team to execute HW out source DM. */ |
| 239 | /* You can not add any dummy function here, be care, you can only use DM structure */ |
| 240 | /* to perform any new ODM_DM. */ |
Jes Sorensen | 1a573d2 | 2014-07-21 11:24:59 +0200 | [diff] [blame] | 241 | void ODM_DMWatchdog23a(struct rtw_adapter *adapter) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 242 | { |
Jes Sorensen | 1a573d2 | 2014-07-21 11:24:59 +0200 | [diff] [blame] | 243 | struct hal_data_8723a *pHalData = GET_HAL_DATA(adapter); |
Jes Sorensen | ec8884f | 2014-07-21 11:24:55 +0200 | [diff] [blame] | 244 | struct dm_odm_t *pDM_Odm = &pHalData->odmpriv; |
Jes Sorensen | 638847c | 2014-07-21 11:25:00 +0200 | [diff] [blame] | 245 | struct pwrctrl_priv *pwrctrlpriv = &adapter->pwrctrlpriv; |
Jes Sorensen | ec8884f | 2014-07-21 11:24:55 +0200 | [diff] [blame] | 246 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 247 | /* 2012.05.03 Luke: For all IC series */ |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 248 | odm_CmnInfoUpdate_Debug23a(pDM_Odm); |
Jes Sorensen | 91a2916 | 2014-07-21 11:24:56 +0200 | [diff] [blame] | 249 | odm_CommonInfoSelfUpdate(pHalData); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 250 | odm_FalseAlarmCounterStatistics23a(pDM_Odm); |
Jes Sorensen | 04b7466 | 2015-03-02 15:24:59 -0500 | [diff] [blame] | 251 | odm_RSSIMonitorCheck(pDM_Odm); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 252 | |
| 253 | /* 8723A or 8189ES platform */ |
| 254 | /* NeilChen--2012--08--24-- */ |
| 255 | /* Fix Leave LPS issue */ |
| 256 | if ((pDM_Odm->Adapter->pwrctrlpriv.pwr_mode != PS_MODE_ACTIVE) &&/* in LPS mode */ |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 257 | (pDM_Odm->SupportICType & ODM_RTL8723A)) { |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 258 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("----Step1: odm_DIG23a is in LPS mode\n")); |
| 259 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Step2: 8723AS is in LPS mode\n")); |
| 260 | odm_DIG23abyRSSI_LPS(pDM_Odm); |
| 261 | } else { |
Jes Sorensen | 1a573d2 | 2014-07-21 11:24:59 +0200 | [diff] [blame] | 262 | odm_DIG23a(adapter); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | odm_CCKPacketDetectionThresh23a(pDM_Odm); |
| 266 | |
Jes Sorensen | 638847c | 2014-07-21 11:25:00 +0200 | [diff] [blame] | 267 | if (pwrctrlpriv->bpower_saving) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 268 | return; |
| 269 | |
Jes Sorensen | b58298e | 2015-03-02 15:25:01 -0500 | [diff] [blame] | 270 | odm_RefreshRateAdaptiveMask(pDM_Odm); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 271 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 272 | |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 273 | odm_EdcaTurboCheck23a(pDM_Odm); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | /* */ |
| 277 | /* Init /.. Fixed HW value. Only init time. */ |
| 278 | /* */ |
| 279 | void ODM_CmnInfoInit23a(struct dm_odm_t *pDM_Odm, |
| 280 | enum odm_cmninfo CmnInfo, |
| 281 | u32 Value |
| 282 | ) |
| 283 | { |
| 284 | /* ODM_RT_TRACE(pDM_Odm,); */ |
| 285 | |
| 286 | /* */ |
| 287 | /* This section is used for init value */ |
| 288 | /* */ |
| 289 | switch (CmnInfo) { |
| 290 | /* Fixed ODM value. */ |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 291 | case ODM_CMNINFO_MP_TEST_CHIP: |
| 292 | pDM_Odm->bIsMPChip = (u8)Value; |
| 293 | break; |
| 294 | case ODM_CMNINFO_IC_TYPE: |
| 295 | pDM_Odm->SupportICType = Value; |
| 296 | break; |
| 297 | case ODM_CMNINFO_CUT_VER: |
| 298 | pDM_Odm->CutVersion = (u8)Value; |
| 299 | break; |
| 300 | case ODM_CMNINFO_FAB_VER: |
| 301 | pDM_Odm->FabVersion = (u8)Value; |
| 302 | break; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 303 | case ODM_CMNINFO_BOARD_TYPE: |
| 304 | pDM_Odm->BoardType = (u8)Value; |
| 305 | break; |
| 306 | case ODM_CMNINFO_EXT_LNA: |
| 307 | pDM_Odm->ExtLNA = (u8)Value; |
| 308 | break; |
| 309 | case ODM_CMNINFO_EXT_PA: |
| 310 | pDM_Odm->ExtPA = (u8)Value; |
| 311 | break; |
| 312 | case ODM_CMNINFO_EXT_TRSW: |
| 313 | pDM_Odm->ExtTRSW = (u8)Value; |
| 314 | break; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 315 | case ODM_CMNINFO_BINHCT_TEST: |
| 316 | pDM_Odm->bInHctTest = (bool)Value; |
| 317 | break; |
| 318 | case ODM_CMNINFO_BWIFI_TEST: |
| 319 | pDM_Odm->bWIFITest = (bool)Value; |
| 320 | break; |
| 321 | case ODM_CMNINFO_SMART_CONCURRENT: |
| 322 | pDM_Odm->bDualMacSmartConcurrent = (bool)Value; |
| 323 | break; |
| 324 | /* To remove the compiler warning, must add an empty default statement to handle the other values. */ |
| 325 | default: |
| 326 | /* do nothing */ |
| 327 | break; |
| 328 | } |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 329 | } |
| 330 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 331 | void ODM_CmnInfoPtrArrayHook23a(struct dm_odm_t *pDM_Odm, enum odm_cmninfo CmnInfo, |
| 332 | u16 Index, void *pValue) |
| 333 | { |
| 334 | /* Hook call by reference pointer. */ |
| 335 | switch (CmnInfo) { |
| 336 | /* Dynamic call by reference pointer. */ |
| 337 | case ODM_CMNINFO_STA_STATUS: |
| 338 | pDM_Odm->pODM_StaInfo[Index] = (struct sta_info *)pValue; |
| 339 | break; |
| 340 | /* To remove the compiler warning, must add an empty default statement to handle the other values. */ |
| 341 | default: |
| 342 | /* do nothing */ |
| 343 | break; |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | /* Update Band/CHannel/.. The values are dynamic but non-per-packet. */ |
| 348 | void ODM_CmnInfoUpdate23a(struct dm_odm_t *pDM_Odm, u32 CmnInfo, u64 Value) |
| 349 | { |
| 350 | /* This init variable may be changed in run time. */ |
| 351 | switch (CmnInfo) { |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 352 | case ODM_CMNINFO_WIFI_DIRECT: |
| 353 | pDM_Odm->bWIFI_Direct = (bool)Value; |
| 354 | break; |
| 355 | case ODM_CMNINFO_WIFI_DISPLAY: |
| 356 | pDM_Odm->bWIFI_Display = (bool)Value; |
| 357 | break; |
| 358 | case ODM_CMNINFO_LINK: |
| 359 | pDM_Odm->bLinked = (bool)Value; |
| 360 | break; |
| 361 | case ODM_CMNINFO_RSSI_MIN: |
| 362 | pDM_Odm->RSSI_Min = (u8)Value; |
| 363 | break; |
| 364 | case ODM_CMNINFO_DBG_COMP: |
| 365 | pDM_Odm->DebugComponents = Value; |
| 366 | break; |
| 367 | case ODM_CMNINFO_DBG_LEVEL: |
| 368 | pDM_Odm->DebugLevel = (u32)Value; |
| 369 | break; |
| 370 | case ODM_CMNINFO_RA_THRESHOLD_HIGH: |
| 371 | pDM_Odm->RateAdaptive.HighRSSIThresh = (u8)Value; |
| 372 | break; |
| 373 | case ODM_CMNINFO_RA_THRESHOLD_LOW: |
| 374 | pDM_Odm->RateAdaptive.LowRSSIThresh = (u8)Value; |
| 375 | break; |
| 376 | } |
| 377 | |
| 378 | } |
| 379 | |
Jes Sorensen | 3f9cb6a | 2015-03-05 14:24:48 -0500 | [diff] [blame] | 380 | void odm_CommonInfoSelfInit23a(struct dm_odm_t *pDM_Odm) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 381 | { |
Jes Sorensen | 3f9cb6a | 2015-03-05 14:24:48 -0500 | [diff] [blame] | 382 | u32 val32; |
| 383 | |
| 384 | val32 = rtl8723au_read32(pDM_Odm->Adapter, rFPGA0_XA_HSSIParameter2); |
| 385 | if (val32 & BIT(9)) |
| 386 | pDM_Odm->bCckHighPower = true; |
| 387 | else |
| 388 | pDM_Odm->bCckHighPower = false; |
Edward Lipinsky | 95829dc | 2015-04-18 09:35:19 -0700 | [diff] [blame] | 389 | |
Jes Sorensen | 36cf7c7 | 2014-07-21 11:25:04 +0200 | [diff] [blame] | 390 | pDM_Odm->RFPathRxEnable = |
Jes Sorensen | 3f9cb6a | 2015-03-05 14:24:48 -0500 | [diff] [blame] | 391 | rtl8723au_read32(pDM_Odm->Adapter, rOFDM0_TRxPathEnable) & 0x0F; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 392 | |
| 393 | ODM_InitDebugSetting23a(pDM_Odm); |
| 394 | } |
| 395 | |
Jes Sorensen | 91a2916 | 2014-07-21 11:24:56 +0200 | [diff] [blame] | 396 | static void odm_CommonInfoSelfUpdate(struct hal_data_8723a *pHalData) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 397 | { |
Jes Sorensen | 91a2916 | 2014-07-21 11:24:56 +0200 | [diff] [blame] | 398 | struct dm_odm_t *pDM_Odm = &pHalData->odmpriv; |
| 399 | struct sta_info *pEntry; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 400 | u8 EntryCnt = 0; |
| 401 | u8 i; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 402 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 403 | for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { |
| 404 | pEntry = pDM_Odm->pODM_StaInfo[i]; |
Jes Sorensen | 2e8d47e | 2014-07-17 22:59:57 +0200 | [diff] [blame] | 405 | if (pEntry) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 406 | EntryCnt++; |
| 407 | } |
| 408 | if (EntryCnt == 1) |
| 409 | pDM_Odm->bOneEntryOnly = true; |
| 410 | else |
| 411 | pDM_Odm->bOneEntryOnly = false; |
| 412 | } |
| 413 | |
| 414 | void odm_CmnInfoInit_Debug23a(struct dm_odm_t *pDM_Odm) |
| 415 | { |
| 416 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoInit_Debug23a ==>\n")); |
| 417 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportAbility = 0x%x\n", pDM_Odm->SupportAbility)); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 418 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportICType = 0x%x\n", pDM_Odm->SupportICType)); |
| 419 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("CutVersion =%d\n", pDM_Odm->CutVersion)); |
| 420 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("FabVersion =%d\n", pDM_Odm->FabVersion)); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 421 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("BoardType =%d\n", pDM_Odm->BoardType)); |
| 422 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtLNA =%d\n", pDM_Odm->ExtLNA)); |
| 423 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtPA =%d\n", pDM_Odm->ExtPA)); |
| 424 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtTRSW =%d\n", pDM_Odm->ExtTRSW)); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 425 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bInHctTest =%d\n", pDM_Odm->bInHctTest)); |
| 426 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFITest =%d\n", pDM_Odm->bWIFITest)); |
| 427 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bDualMacSmartConcurrent =%d\n", pDM_Odm->bDualMacSmartConcurrent)); |
| 428 | |
| 429 | } |
| 430 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 431 | void odm_CmnInfoUpdate_Debug23a(struct dm_odm_t *pDM_Odm) |
| 432 | { |
| 433 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoUpdate_Debug23a ==>\n")); |
| 434 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFI_Direct =%d\n", pDM_Odm->bWIFI_Direct)); |
| 435 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFI_Display =%d\n", pDM_Odm->bWIFI_Display)); |
| 436 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bLinked =%d\n", pDM_Odm->bLinked)); |
| 437 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RSSI_Min =%d\n", pDM_Odm->RSSI_Min)); |
| 438 | } |
| 439 | |
Jes Sorensen | c335da5 | 2015-03-02 15:25:02 -0500 | [diff] [blame] | 440 | void ODM_Write_DIG23a(struct dm_odm_t *pDM_Odm, u8 CurrentIGI) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 441 | { |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 442 | struct rtw_adapter *adapter = pDM_Odm->Adapter; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 443 | struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable; |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 444 | u32 val32; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 445 | |
| 446 | if (pDM_DigTable->CurIGValue != CurrentIGI) { |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 447 | val32 = rtl8723au_read32(adapter, ODM_REG_IGI_A_11N); |
| 448 | val32 &= ~ODM_BIT_IGI_11N; |
| 449 | val32 |= CurrentIGI; |
| 450 | rtl8723au_write32(adapter, ODM_REG_IGI_A_11N, val32); |
Jes Sorensen | c335da5 | 2015-03-02 15:25:02 -0500 | [diff] [blame] | 451 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, |
| 452 | ("CurrentIGI(0x%02x). \n", CurrentIGI)); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 453 | pDM_DigTable->CurIGValue = CurrentIGI; |
| 454 | } |
| 455 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, |
| 456 | ("ODM_Write_DIG23a():CurrentIGI = 0x%x \n", CurrentIGI)); |
| 457 | } |
| 458 | |
| 459 | /* Need LPS mode for CE platform --2012--08--24--- */ |
| 460 | /* 8723AS/8189ES */ |
| 461 | void odm_DIG23abyRSSI_LPS(struct dm_odm_t *pDM_Odm) |
| 462 | { |
| 463 | struct rtw_adapter *pAdapter = pDM_Odm->Adapter; |
| 464 | struct false_alarm_stats *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; |
| 465 | u8 RSSI_Lower = DM_DIG_MIN_NIC; /* 0x1E or 0x1C */ |
| 466 | u8 bFwCurrentInPSMode = false; |
| 467 | u8 CurrentIGI = pDM_Odm->RSSI_Min; |
| 468 | |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 469 | if (!(pDM_Odm->SupportICType & ODM_RTL8723A)) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 470 | return; |
| 471 | |
| 472 | CurrentIGI = CurrentIGI+RSSI_OFFSET_DIG; |
| 473 | bFwCurrentInPSMode = pAdapter->pwrctrlpriv.bFwCurrentInPSMode; |
| 474 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 475 | /* Using FW PS mode to make IGI */ |
| 476 | if (bFwCurrentInPSMode) { |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 477 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, |
| 478 | ("---Neil---odm_DIG23a is in LPS mode\n")); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 479 | /* Adjust by FA in LPS MODE */ |
| 480 | if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2_LPS) |
| 481 | CurrentIGI = CurrentIGI+2; |
| 482 | else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1_LPS) |
| 483 | CurrentIGI = CurrentIGI+1; |
| 484 | else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0_LPS) |
| 485 | CurrentIGI = CurrentIGI-1; |
| 486 | } else { |
| 487 | CurrentIGI = RSSI_Lower; |
| 488 | } |
| 489 | |
| 490 | /* Lower bound checking */ |
| 491 | |
| 492 | /* RSSI Lower bound check */ |
| 493 | if ((pDM_Odm->RSSI_Min-10) > DM_DIG_MIN_NIC) |
| 494 | RSSI_Lower = (pDM_Odm->RSSI_Min-10); |
| 495 | else |
| 496 | RSSI_Lower = DM_DIG_MIN_NIC; |
| 497 | |
| 498 | /* Upper and Lower Bound checking */ |
| 499 | if (CurrentIGI > DM_DIG_MAX_NIC) |
| 500 | CurrentIGI = DM_DIG_MAX_NIC; |
| 501 | else if (CurrentIGI < RSSI_Lower) |
| 502 | CurrentIGI = RSSI_Lower; |
| 503 | |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 504 | ODM_Write_DIG23a(pDM_Odm, CurrentIGI); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | void odm_DIG23aInit(struct dm_odm_t *pDM_Odm) |
| 508 | { |
| 509 | struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable; |
Jes Sorensen | 3f9cb6a | 2015-03-05 14:24:48 -0500 | [diff] [blame] | 510 | u32 val32; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 511 | |
Jes Sorensen | 3f9cb6a | 2015-03-05 14:24:48 -0500 | [diff] [blame] | 512 | val32 = rtl8723au_read32(pDM_Odm->Adapter, ODM_REG_IGI_A_11N); |
| 513 | pDM_DigTable->CurIGValue = val32 & ODM_BIT_IGI_11N; |
| 514 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 515 | pDM_DigTable->RssiLowThresh = DM_DIG_THRESH_LOW; |
| 516 | pDM_DigTable->RssiHighThresh = DM_DIG_THRESH_HIGH; |
| 517 | pDM_DigTable->FALowThresh = DM_FALSEALARM_THRESH_LOW; |
| 518 | pDM_DigTable->FAHighThresh = DM_FALSEALARM_THRESH_HIGH; |
| 519 | if (pDM_Odm->BoardType == ODM_BOARD_HIGHPWR) { |
| 520 | pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; |
| 521 | pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC; |
| 522 | } else { |
| 523 | pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; |
| 524 | pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC; |
| 525 | } |
| 526 | pDM_DigTable->BackoffVal = DM_DIG_BACKOFF_DEFAULT; |
| 527 | pDM_DigTable->BackoffVal_range_max = DM_DIG_BACKOFF_MAX; |
| 528 | pDM_DigTable->BackoffVal_range_min = DM_DIG_BACKOFF_MIN; |
| 529 | pDM_DigTable->PreCCK_CCAThres = 0xFF; |
| 530 | pDM_DigTable->CurCCK_CCAThres = 0x83; |
| 531 | pDM_DigTable->ForbiddenIGI = DM_DIG_MIN_NIC; |
| 532 | pDM_DigTable->LargeFAHit = 0; |
| 533 | pDM_DigTable->Recover_cnt = 0; |
| 534 | pDM_DigTable->DIG_Dynamic_MIN_0 = DM_DIG_MIN_NIC; |
| 535 | pDM_DigTable->DIG_Dynamic_MIN_1 = DM_DIG_MIN_NIC; |
| 536 | pDM_DigTable->bMediaConnect_0 = false; |
| 537 | pDM_DigTable->bMediaConnect_1 = false; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 538 | } |
| 539 | |
Jes Sorensen | 1a573d2 | 2014-07-21 11:24:59 +0200 | [diff] [blame] | 540 | void odm_DIG23a(struct rtw_adapter *adapter) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 541 | { |
Jes Sorensen | 1a573d2 | 2014-07-21 11:24:59 +0200 | [diff] [blame] | 542 | struct hal_data_8723a *pHalData = GET_HAL_DATA(adapter); |
| 543 | struct dm_odm_t *pDM_Odm = &pHalData->odmpriv; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 544 | struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable; |
| 545 | struct false_alarm_stats *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; |
| 546 | u8 DIG_Dynamic_MIN; |
| 547 | u8 DIG_MaxOfMin; |
| 548 | bool FirstConnect, FirstDisConnect; |
| 549 | u8 dm_dig_max, dm_dig_min; |
| 550 | u8 CurrentIGI = pDM_DigTable->CurIGValue; |
| 551 | |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 552 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, |
| 553 | ("odm_DIG23a() ==>\n")); |
Jes Sorensen | 1a573d2 | 2014-07-21 11:24:59 +0200 | [diff] [blame] | 554 | if (adapter->mlmepriv.bScanInProcess) { |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 555 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, |
| 556 | ("odm_DIG23a() Return: In Scan Progress \n")); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 557 | return; |
| 558 | } |
| 559 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 560 | DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; |
| 561 | FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 562 | FirstDisConnect = (!pDM_Odm->bLinked) && |
| 563 | (pDM_DigTable->bMediaConnect_0); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 564 | |
| 565 | /* 1 Boundary Decision */ |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 566 | if ((pDM_Odm->SupportICType & ODM_RTL8723A) && |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 567 | (pDM_Odm->BoardType == ODM_BOARD_HIGHPWR || pDM_Odm->ExtLNA)) { |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 568 | dm_dig_max = DM_DIG_MAX_NIC_HP; |
| 569 | dm_dig_min = DM_DIG_MIN_NIC_HP; |
| 570 | DIG_MaxOfMin = DM_DIG_MAX_AP_HP; |
| 571 | } else { |
| 572 | dm_dig_max = DM_DIG_MAX_NIC; |
| 573 | dm_dig_min = DM_DIG_MIN_NIC; |
| 574 | DIG_MaxOfMin = DM_DIG_MAX_AP; |
| 575 | } |
| 576 | |
| 577 | if (pDM_Odm->bLinked) { |
| 578 | /* 2 8723A Series, offset need to be 10 */ |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 579 | if (pDM_Odm->SupportICType == ODM_RTL8723A) { |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 580 | /* 2 Upper Bound */ |
| 581 | if ((pDM_Odm->RSSI_Min + 10) > DM_DIG_MAX_NIC) |
| 582 | pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; |
| 583 | else if ((pDM_Odm->RSSI_Min + 10) < DM_DIG_MIN_NIC) |
| 584 | pDM_DigTable->rx_gain_range_max = DM_DIG_MIN_NIC; |
| 585 | else |
| 586 | pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + 10; |
| 587 | |
| 588 | /* 2 If BT is Concurrent, need to set Lower Bound */ |
| 589 | DIG_Dynamic_MIN = DM_DIG_MIN_NIC; |
| 590 | } else { |
| 591 | /* 2 Modify DIG upper bound */ |
| 592 | if ((pDM_Odm->RSSI_Min + 20) > dm_dig_max) |
| 593 | pDM_DigTable->rx_gain_range_max = dm_dig_max; |
| 594 | else if ((pDM_Odm->RSSI_Min + 20) < dm_dig_min) |
| 595 | pDM_DigTable->rx_gain_range_max = dm_dig_min; |
| 596 | else |
| 597 | pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + 20; |
| 598 | |
| 599 | /* 2 Modify DIG lower bound */ |
| 600 | if (pDM_Odm->bOneEntryOnly) { |
| 601 | if (pDM_Odm->RSSI_Min < dm_dig_min) |
| 602 | DIG_Dynamic_MIN = dm_dig_min; |
| 603 | else if (pDM_Odm->RSSI_Min > DIG_MaxOfMin) |
| 604 | DIG_Dynamic_MIN = DIG_MaxOfMin; |
| 605 | else |
| 606 | DIG_Dynamic_MIN = pDM_Odm->RSSI_Min; |
| 607 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, |
| 608 | ("odm_DIG23a() : bOneEntryOnly = true, DIG_Dynamic_MIN = 0x%x\n", |
| 609 | DIG_Dynamic_MIN)); |
| 610 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, |
| 611 | ("odm_DIG23a() : pDM_Odm->RSSI_Min =%d\n", |
| 612 | pDM_Odm->RSSI_Min)); |
| 613 | } else { |
| 614 | DIG_Dynamic_MIN = dm_dig_min; |
| 615 | } |
| 616 | } |
| 617 | } else { |
| 618 | pDM_DigTable->rx_gain_range_max = dm_dig_max; |
| 619 | DIG_Dynamic_MIN = dm_dig_min; |
| 620 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG23a() : No Link\n")); |
| 621 | } |
| 622 | |
| 623 | /* 1 Modify DIG lower bound, deal with abnormally large false alarm */ |
| 624 | if (pFalseAlmCnt->Cnt_all > 10000) { |
| 625 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, |
| 626 | ("dm_DIG(): Abnornally false alarm case. \n")); |
| 627 | |
| 628 | if (pDM_DigTable->LargeFAHit != 3) |
| 629 | pDM_DigTable->LargeFAHit++; |
| 630 | if (pDM_DigTable->ForbiddenIGI < CurrentIGI) { |
| 631 | pDM_DigTable->ForbiddenIGI = CurrentIGI; |
| 632 | pDM_DigTable->LargeFAHit = 1; |
| 633 | } |
| 634 | |
| 635 | if (pDM_DigTable->LargeFAHit >= 3) { |
| 636 | if ((pDM_DigTable->ForbiddenIGI+1) > pDM_DigTable->rx_gain_range_max) |
| 637 | pDM_DigTable->rx_gain_range_min = pDM_DigTable->rx_gain_range_max; |
| 638 | else |
| 639 | pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1); |
| 640 | pDM_DigTable->Recover_cnt = 3600; /* 3600 = 2hr */ |
| 641 | } |
| 642 | } else { |
| 643 | /* Recovery mechanism for IGI lower bound */ |
| 644 | if (pDM_DigTable->Recover_cnt != 0) { |
| 645 | pDM_DigTable->Recover_cnt--; |
| 646 | } else { |
| 647 | if (pDM_DigTable->LargeFAHit < 3) { |
| 648 | if ((pDM_DigTable->ForbiddenIGI - 1) < DIG_Dynamic_MIN) { |
| 649 | pDM_DigTable->ForbiddenIGI = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ |
| 650 | pDM_DigTable->rx_gain_range_min = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ |
| 651 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, |
| 652 | ("odm_DIG23a(): Normal Case: At Lower Bound\n")); |
| 653 | } else { |
| 654 | pDM_DigTable->ForbiddenIGI--; |
| 655 | pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1); |
| 656 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, |
| 657 | ("odm_DIG23a(): Normal Case: Approach Lower Bound\n")); |
| 658 | } |
| 659 | } else { |
| 660 | pDM_DigTable->LargeFAHit = 0; |
| 661 | } |
| 662 | } |
| 663 | } |
| 664 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG23a(): pDM_DigTable->LargeFAHit =%d\n", pDM_DigTable->LargeFAHit)); |
| 665 | |
| 666 | /* 1 Adjust initial gain by false alarm */ |
| 667 | if (pDM_Odm->bLinked) { |
| 668 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG23a(): DIG AfterLink\n")); |
| 669 | if (FirstConnect) { |
| 670 | CurrentIGI = pDM_Odm->RSSI_Min; |
| 671 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("DIG: First Connect\n")); |
| 672 | } else { |
| 673 | if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2) |
| 674 | CurrentIGI = CurrentIGI + 4;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */ |
| 675 | else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1) |
| 676 | CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */ |
| 677 | else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0) |
| 678 | CurrentIGI = CurrentIGI - 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue-1; */ |
| 679 | } |
| 680 | } else { |
| 681 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG23a(): DIG BeforeLink\n")); |
| 682 | if (FirstDisConnect) { |
| 683 | CurrentIGI = pDM_DigTable->rx_gain_range_min; |
| 684 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG23a(): First DisConnect \n")); |
| 685 | } else { |
| 686 | /* 2012.03.30 LukeLee: enable DIG before link but with very high thresholds */ |
| 687 | if (pFalseAlmCnt->Cnt_all > 10000) |
| 688 | CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */ |
| 689 | else if (pFalseAlmCnt->Cnt_all > 8000) |
| 690 | CurrentIGI = CurrentIGI + 1;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */ |
| 691 | else if (pFalseAlmCnt->Cnt_all < 500) |
| 692 | CurrentIGI = CurrentIGI - 1;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue-1; */ |
| 693 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG23a(): England DIG \n")); |
| 694 | } |
| 695 | } |
| 696 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG23a(): DIG End Adjust IGI\n")); |
| 697 | /* 1 Check initial gain by upper/lower bound */ |
| 698 | if (CurrentIGI > pDM_DigTable->rx_gain_range_max) |
| 699 | CurrentIGI = pDM_DigTable->rx_gain_range_max; |
| 700 | if (CurrentIGI < pDM_DigTable->rx_gain_range_min) |
| 701 | CurrentIGI = pDM_DigTable->rx_gain_range_min; |
| 702 | |
| 703 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG23a(): rx_gain_range_max = 0x%x, rx_gain_range_min = 0x%x\n", |
| 704 | pDM_DigTable->rx_gain_range_max, pDM_DigTable->rx_gain_range_min)); |
| 705 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG23a(): TotalFA =%d\n", pFalseAlmCnt->Cnt_all)); |
| 706 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG23a(): CurIGValue = 0x%x\n", CurrentIGI)); |
| 707 | |
| 708 | /* 2 High power RSSI threshold */ |
| 709 | |
| 710 | ODM_Write_DIG23a(pDM_Odm, CurrentIGI);/* ODM_Write_DIG23a(pDM_Odm, pDM_DigTable->CurIGValue); */ |
| 711 | pDM_DigTable->bMediaConnect_0 = pDM_Odm->bLinked; |
| 712 | pDM_DigTable->DIG_Dynamic_MIN_0 = DIG_Dynamic_MIN; |
| 713 | } |
| 714 | |
| 715 | /* 3 ============================================================ */ |
| 716 | /* 3 FASLE ALARM CHECK */ |
| 717 | /* 3 ============================================================ */ |
| 718 | |
| 719 | void odm_FalseAlarmCounterStatistics23a(struct dm_odm_t *pDM_Odm) |
| 720 | { |
Jes Sorensen | a39bd1f | 2015-03-05 14:24:42 -0500 | [diff] [blame] | 721 | struct rtw_adapter *adapter = pDM_Odm->Adapter; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 722 | struct false_alarm_stats *FalseAlmCnt = &pDM_Odm->FalseAlmCnt; |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 723 | u32 ret_value, val32; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 724 | |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 725 | /* hold ofdm counter */ |
Jes Sorensen | a39bd1f | 2015-03-05 14:24:42 -0500 | [diff] [blame] | 726 | /* hold page C counter */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 727 | val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_HOLDC_11N); |
| 728 | val32 |= BIT(31); |
| 729 | rtl8723au_write32(adapter, ODM_REG_OFDM_FA_HOLDC_11N, val32); |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 730 | /* hold page D counter */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 731 | val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_RSTD_11N); |
| 732 | val32 |= BIT(31); |
| 733 | rtl8723au_write32(adapter, ODM_REG_OFDM_FA_RSTD_11N, val32); |
Jes Sorensen | a39bd1f | 2015-03-05 14:24:42 -0500 | [diff] [blame] | 734 | ret_value = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_TYPE1_11N); |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 735 | FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0xffff); |
Aya Mahfouz | e1bc88f | 2015-03-04 07:34:07 +0200 | [diff] [blame] | 736 | FalseAlmCnt->Cnt_SB_Search_fail = (ret_value & 0xffff0000)>>16; |
Jes Sorensen | a39bd1f | 2015-03-05 14:24:42 -0500 | [diff] [blame] | 737 | ret_value = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_TYPE2_11N); |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 738 | FalseAlmCnt->Cnt_OFDM_CCA = (ret_value&0xffff); |
Aya Mahfouz | e1bc88f | 2015-03-04 07:34:07 +0200 | [diff] [blame] | 739 | FalseAlmCnt->Cnt_Parity_Fail = (ret_value & 0xffff0000)>>16; |
Jes Sorensen | a39bd1f | 2015-03-05 14:24:42 -0500 | [diff] [blame] | 740 | ret_value = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_TYPE3_11N); |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 741 | FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff); |
Aya Mahfouz | e1bc88f | 2015-03-04 07:34:07 +0200 | [diff] [blame] | 742 | FalseAlmCnt->Cnt_Crc8_fail = (ret_value & 0xffff0000)>>16; |
Jes Sorensen | a39bd1f | 2015-03-05 14:24:42 -0500 | [diff] [blame] | 743 | ret_value = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_TYPE4_11N); |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 744 | FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 745 | |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 746 | FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + |
| 747 | FalseAlmCnt->Cnt_Rate_Illegal + |
| 748 | FalseAlmCnt->Cnt_Crc8_fail + |
| 749 | FalseAlmCnt->Cnt_Mcs_fail + |
| 750 | FalseAlmCnt->Cnt_Fast_Fsync + |
| 751 | FalseAlmCnt->Cnt_SB_Search_fail; |
| 752 | /* hold cck counter */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 753 | val32 = rtl8723au_read32(adapter, ODM_REG_CCK_FA_RST_11N); |
| 754 | val32 |= (BIT(12) | BIT(14)); |
| 755 | rtl8723au_write32(adapter, ODM_REG_CCK_FA_RST_11N, val32); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 756 | |
Jes Sorensen | 3f9cb6a | 2015-03-05 14:24:48 -0500 | [diff] [blame] | 757 | ret_value = rtl8723au_read32(adapter, ODM_REG_CCK_FA_LSB_11N) & 0xff; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 758 | FalseAlmCnt->Cnt_Cck_fail = ret_value; |
Jes Sorensen | 3f9cb6a | 2015-03-05 14:24:48 -0500 | [diff] [blame] | 759 | ret_value = rtl8723au_read32(adapter, ODM_REG_CCK_FA_MSB_11N) >> 16; |
| 760 | FalseAlmCnt->Cnt_Cck_fail += (ret_value & 0xff00); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 761 | |
Jes Sorensen | a39bd1f | 2015-03-05 14:24:42 -0500 | [diff] [blame] | 762 | ret_value = rtl8723au_read32(adapter, ODM_REG_CCK_CCA_CNT_11N); |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 763 | FalseAlmCnt->Cnt_CCK_CCA = |
| 764 | ((ret_value&0xFF)<<8) | ((ret_value&0xFF00)>>8); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 765 | |
| 766 | FalseAlmCnt->Cnt_all = (FalseAlmCnt->Cnt_Fast_Fsync + |
| 767 | FalseAlmCnt->Cnt_SB_Search_fail + |
| 768 | FalseAlmCnt->Cnt_Parity_Fail + |
| 769 | FalseAlmCnt->Cnt_Rate_Illegal + |
| 770 | FalseAlmCnt->Cnt_Crc8_fail + |
| 771 | FalseAlmCnt->Cnt_Mcs_fail + |
| 772 | FalseAlmCnt->Cnt_Cck_fail); |
| 773 | |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 774 | FalseAlmCnt->Cnt_CCA_all = |
| 775 | FalseAlmCnt->Cnt_OFDM_CCA + FalseAlmCnt->Cnt_CCK_CCA; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 776 | |
| 777 | if (pDM_Odm->SupportICType >= ODM_RTL8723A) { |
| 778 | /* reset false alarm counter registers */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 779 | val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_RSTC_11N); |
| 780 | val32 |= BIT(31); |
| 781 | rtl8723au_write32(adapter, ODM_REG_OFDM_FA_RSTC_11N, val32); |
| 782 | val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_RSTC_11N); |
| 783 | val32 &= ~BIT(31); |
| 784 | rtl8723au_write32(adapter, ODM_REG_OFDM_FA_RSTC_11N, val32); |
Jes Sorensen | 18f576f | 2015-03-22 19:09:42 -0400 | [diff] [blame] | 785 | |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 786 | val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_RSTD_11N); |
| 787 | val32 |= BIT(27); |
| 788 | rtl8723au_write32(adapter, ODM_REG_OFDM_FA_RSTD_11N, val32); |
| 789 | val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_RSTD_11N); |
| 790 | val32 &= ~BIT(27); |
| 791 | rtl8723au_write32(adapter, ODM_REG_OFDM_FA_RSTD_11N, val32); |
| 792 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 793 | /* update ofdm counter */ |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 794 | /* update page C counter */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 795 | val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_HOLDC_11N); |
| 796 | val32 &= ~BIT(31); |
| 797 | rtl8723au_write32(adapter, ODM_REG_OFDM_FA_HOLDC_11N, val32); |
| 798 | |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 799 | /* update page D counter */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 800 | val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_RSTD_11N); |
| 801 | val32 &= ~BIT(31); |
| 802 | rtl8723au_write32(adapter, ODM_REG_OFDM_FA_RSTD_11N, val32); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 803 | |
| 804 | /* reset CCK CCA counter */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 805 | val32 = rtl8723au_read32(adapter, ODM_REG_CCK_FA_RST_11N); |
| 806 | val32 &= ~(BIT(12) | BIT(13) | BIT(14) | BIT(15)); |
| 807 | rtl8723au_write32(adapter, ODM_REG_CCK_FA_RST_11N, val32); |
| 808 | |
| 809 | val32 = rtl8723au_read32(adapter, ODM_REG_CCK_FA_RST_11N); |
| 810 | val32 |= (BIT(13) | BIT(15)); |
| 811 | rtl8723au_write32(adapter, ODM_REG_CCK_FA_RST_11N, val32); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 812 | } |
| 813 | |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 814 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, |
| 815 | ("Enter odm_FalseAlarmCounterStatistics23a\n")); |
| 816 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, |
| 817 | ("Cnt_Fast_Fsync =%d, Cnt_SB_Search_fail =%d\n", |
| 818 | FalseAlmCnt->Cnt_Fast_Fsync, |
| 819 | FalseAlmCnt->Cnt_SB_Search_fail)); |
| 820 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, |
| 821 | ("Cnt_Parity_Fail =%d, Cnt_Rate_Illegal =%d\n", |
| 822 | FalseAlmCnt->Cnt_Parity_Fail, |
| 823 | FalseAlmCnt->Cnt_Rate_Illegal)); |
| 824 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, |
| 825 | ("Cnt_Crc8_fail =%d, Cnt_Mcs_fail =%d\n", |
| 826 | FalseAlmCnt->Cnt_Crc8_fail, FalseAlmCnt->Cnt_Mcs_fail)); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 827 | |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 828 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, |
| 829 | ("Cnt_Cck_fail =%d\n", FalseAlmCnt->Cnt_Cck_fail)); |
| 830 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, |
| 831 | ("Cnt_Ofdm_fail =%d\n", FalseAlmCnt->Cnt_Ofdm_fail)); |
| 832 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, |
| 833 | ("Total False Alarm =%d\n", FalseAlmCnt->Cnt_all)); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 834 | } |
| 835 | |
| 836 | /* 3 ============================================================ */ |
| 837 | /* 3 CCK Packet Detect Threshold */ |
| 838 | /* 3 ============================================================ */ |
| 839 | |
| 840 | void odm_CCKPacketDetectionThresh23a(struct dm_odm_t *pDM_Odm) |
| 841 | { |
| 842 | struct false_alarm_stats *FalseAlmCnt = &pDM_Odm->FalseAlmCnt; |
| 843 | u8 CurCCK_CCAThres; |
| 844 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 845 | if (pDM_Odm->ExtLNA) |
| 846 | return; |
| 847 | |
| 848 | if (pDM_Odm->bLinked) { |
| 849 | if (pDM_Odm->RSSI_Min > 25) { |
| 850 | CurCCK_CCAThres = 0xcd; |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 851 | } else if (pDM_Odm->RSSI_Min <= 25 && pDM_Odm->RSSI_Min > 10) { |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 852 | CurCCK_CCAThres = 0x83; |
| 853 | } else { |
| 854 | if (FalseAlmCnt->Cnt_Cck_fail > 1000) |
| 855 | CurCCK_CCAThres = 0x83; |
| 856 | else |
| 857 | CurCCK_CCAThres = 0x40; |
| 858 | } |
| 859 | } else { |
| 860 | if (FalseAlmCnt->Cnt_Cck_fail > 1000) |
| 861 | CurCCK_CCAThres = 0x83; |
| 862 | else |
| 863 | CurCCK_CCAThres = 0x40; |
| 864 | } |
| 865 | |
| 866 | ODM_Write_CCK_CCA_Thres23a(pDM_Odm, CurCCK_CCAThres); |
| 867 | } |
| 868 | |
| 869 | void ODM_Write_CCK_CCA_Thres23a(struct dm_odm_t *pDM_Odm, u8 CurCCK_CCAThres) |
| 870 | { |
| 871 | struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable; |
| 872 | |
| 873 | if (pDM_DigTable->CurCCK_CCAThres != CurCCK_CCAThres) |
Jes Sorensen | 4f092cc | 2015-03-05 14:24:45 -0500 | [diff] [blame] | 874 | rtl8723au_write8(pDM_Odm->Adapter, ODM_REG(CCK_CCA, pDM_Odm), |
| 875 | CurCCK_CCAThres); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 876 | pDM_DigTable->PreCCK_CCAThres = pDM_DigTable->CurCCK_CCAThres; |
| 877 | pDM_DigTable->CurCCK_CCAThres = CurCCK_CCAThres; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 878 | } |
| 879 | |
| 880 | /* 3 ============================================================ */ |
| 881 | /* 3 BB Power Save */ |
| 882 | /* 3 ============================================================ */ |
| 883 | void odm23a_DynBBPSInit(struct dm_odm_t *pDM_Odm) |
| 884 | { |
| 885 | struct dynamic_pwr_sav *pDM_PSTable = &pDM_Odm->DM_PSTable; |
| 886 | |
| 887 | pDM_PSTable->PreCCAState = CCA_MAX; |
| 888 | pDM_PSTable->CurCCAState = CCA_MAX; |
| 889 | pDM_PSTable->PreRFState = RF_MAX; |
| 890 | pDM_PSTable->CurRFState = RF_MAX; |
| 891 | pDM_PSTable->Rssi_val_min = 0; |
| 892 | pDM_PSTable->initialize = 0; |
| 893 | } |
| 894 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 895 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 896 | void ODM_RF_Saving23a(struct dm_odm_t *pDM_Odm, u8 bForceInNormal) |
| 897 | { |
| 898 | struct dynamic_pwr_sav *pDM_PSTable = &pDM_Odm->DM_PSTable; |
Jes Sorensen | a39bd1f | 2015-03-05 14:24:42 -0500 | [diff] [blame] | 899 | struct rtw_adapter *adapter = pDM_Odm->Adapter; |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 900 | u32 val32; |
Anjana Sasindran | 9d55c814 | 2014-12-04 19:20:30 +0530 | [diff] [blame] | 901 | u8 Rssi_Up_bound = 30; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 902 | u8 Rssi_Low_bound = 25; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 903 | if (pDM_PSTable->initialize == 0) { |
| 904 | |
Jes Sorensen | a39bd1f | 2015-03-05 14:24:42 -0500 | [diff] [blame] | 905 | pDM_PSTable->Reg874 = |
Jes Sorensen | 6725e52 | 2015-03-05 14:24:50 -0500 | [diff] [blame] | 906 | rtl8723au_read32(adapter, 0x874) & 0x1CC000; |
Jes Sorensen | fc8b7c8 | 2014-05-16 10:03:50 +0200 | [diff] [blame] | 907 | pDM_PSTable->RegC70 = |
Jes Sorensen | 6725e52 | 2015-03-05 14:24:50 -0500 | [diff] [blame] | 908 | rtl8723au_read32(adapter, 0xc70) & BIT(3); |
Jes Sorensen | a39bd1f | 2015-03-05 14:24:42 -0500 | [diff] [blame] | 909 | pDM_PSTable->Reg85C = |
Jes Sorensen | 6725e52 | 2015-03-05 14:24:50 -0500 | [diff] [blame] | 910 | rtl8723au_read32(adapter, 0x85c) & 0xFF000000; |
| 911 | pDM_PSTable->RegA74 = rtl8723au_read32(adapter, 0xa74) & 0xF000; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 912 | pDM_PSTable->initialize = 1; |
| 913 | } |
| 914 | |
| 915 | if (!bForceInNormal) { |
| 916 | if (pDM_Odm->RSSI_Min != 0xFF) { |
| 917 | if (pDM_PSTable->PreRFState == RF_Normal) { |
| 918 | if (pDM_Odm->RSSI_Min >= Rssi_Up_bound) |
| 919 | pDM_PSTable->CurRFState = RF_Save; |
| 920 | else |
| 921 | pDM_PSTable->CurRFState = RF_Normal; |
| 922 | } else { |
| 923 | if (pDM_Odm->RSSI_Min <= Rssi_Low_bound) |
| 924 | pDM_PSTable->CurRFState = RF_Normal; |
| 925 | else |
| 926 | pDM_PSTable->CurRFState = RF_Save; |
| 927 | } |
| 928 | } else { |
| 929 | pDM_PSTable->CurRFState = RF_MAX; |
| 930 | } |
| 931 | } else { |
| 932 | pDM_PSTable->CurRFState = RF_Normal; |
| 933 | } |
| 934 | |
| 935 | if (pDM_PSTable->PreRFState != pDM_PSTable->CurRFState) { |
| 936 | if (pDM_PSTable->CurRFState == RF_Save) { |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 937 | /* <tynli_note> 8723 RSSI report will be wrong. |
| 938 | * Set 0x874[5]= 1 when enter BB power saving mode. */ |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 939 | /* Suggested by SD3 Yu-Nan. 2011.01.20. */ |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 940 | /* Reg874[5]= 1b'1 */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 941 | if (pDM_Odm->SupportICType == ODM_RTL8723A) { |
| 942 | val32 = rtl8723au_read32(adapter, 0x874); |
| 943 | val32 |= BIT(5); |
| 944 | rtl8723au_write32(adapter, 0x874, val32); |
| 945 | } |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 946 | /* Reg874[20:18]= 3'b010 */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 947 | val32 = rtl8723au_read32(adapter, 0x874); |
| 948 | val32 &= ~(BIT(18) | BIT(20)); |
| 949 | val32 |= BIT(19); |
| 950 | rtl8723au_write32(adapter, 0x874, val32); |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 951 | /* RegC70[3]= 1'b0 */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 952 | val32 = rtl8723au_read32(adapter, 0xc70); |
| 953 | val32 &= ~BIT(3); |
| 954 | rtl8723au_write32(adapter, 0xc70, val32); |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 955 | /* Reg85C[31:24]= 0x63 */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 956 | val32 = rtl8723au_read32(adapter, 0x85c); |
| 957 | val32 &= 0x00ffffff; |
| 958 | val32 |= 0x63000000; |
| 959 | rtl8723au_write32(adapter, 0x85c, val32); |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 960 | /* Reg874[15:14]= 2'b10 */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 961 | val32 = rtl8723au_read32(adapter, 0x874); |
| 962 | val32 &= ~BIT(14); |
| 963 | val32 |= BIT(15); |
| 964 | rtl8723au_write32(adapter, 0x874, val32); |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 965 | /* RegA75[7:4]= 0x3 */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 966 | val32 = rtl8723au_read32(adapter, 0xa74); |
| 967 | val32 &= ~(BIT(14) | BIT(15)); |
| 968 | val32 |= (BIT(12) | BIT(13)); |
| 969 | rtl8723au_write32(adapter, 0xa74, val32); |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 970 | /* Reg818[28]= 1'b0 */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 971 | val32 = rtl8723au_read32(adapter, 0x818); |
| 972 | val32 &= ~BIT(28); |
| 973 | rtl8723au_write32(adapter, 0x818, val32); |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 974 | /* Reg818[28]= 1'b1 */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 975 | val32 = rtl8723au_read32(adapter, 0x818); |
| 976 | val32 |= BIT(28); |
| 977 | rtl8723au_write32(adapter, 0x818, val32); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 978 | } else { |
Jes Sorensen | 6725e52 | 2015-03-05 14:24:50 -0500 | [diff] [blame] | 979 | val32 = rtl8723au_read32(adapter, 0x874); |
| 980 | val32 |= pDM_PSTable->Reg874; |
| 981 | rtl8723au_write32(adapter, 0x874, val32); |
Joglekar Tejas | edeafb9 | 2015-06-20 12:46:16 +0000 | [diff] [blame] | 982 | |
Jes Sorensen | 6725e52 | 2015-03-05 14:24:50 -0500 | [diff] [blame] | 983 | val32 = rtl8723au_read32(adapter, 0xc70); |
| 984 | val32 |= pDM_PSTable->RegC70; |
| 985 | rtl8723au_write32(adapter, 0xc70, val32); |
| 986 | |
| 987 | val32 = rtl8723au_read32(adapter, 0x85c); |
| 988 | val32 |= pDM_PSTable->Reg85C; |
| 989 | rtl8723au_write32(adapter, 0x85c, val32); |
| 990 | |
| 991 | val32 = rtl8723au_read32(adapter, 0xa74); |
| 992 | val32 |= pDM_PSTable->RegA74; |
| 993 | rtl8723au_write32(adapter, 0xa74, val32); |
| 994 | |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 995 | val32 = rtl8723au_read32(adapter, 0x818); |
| 996 | val32 &= ~BIT(28); |
| 997 | rtl8723au_write32(adapter, 0x818, val32); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 998 | |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 999 | /* Reg874[5]= 1b'0 */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 1000 | if (pDM_Odm->SupportICType == ODM_RTL8723A) { |
| 1001 | val32 = rtl8723au_read32(adapter, 0x874); |
| 1002 | val32 &= ~BIT(5); |
| 1003 | rtl8723au_write32(adapter, 0x874, val32); |
| 1004 | } |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1005 | } |
| 1006 | pDM_PSTable->PreRFState = pDM_PSTable->CurRFState; |
| 1007 | } |
| 1008 | } |
| 1009 | |
| 1010 | /* 3 ============================================================ */ |
| 1011 | /* 3 RATR MASK */ |
| 1012 | /* 3 ============================================================ */ |
| 1013 | /* 3 ============================================================ */ |
| 1014 | /* 3 Rate Adaptive */ |
| 1015 | /* 3 ============================================================ */ |
| 1016 | |
| 1017 | void odm_RateAdaptiveMaskInit23a(struct dm_odm_t *pDM_Odm) |
| 1018 | { |
| 1019 | struct odm_rate_adapt *pOdmRA = &pDM_Odm->RateAdaptive; |
| 1020 | |
| 1021 | pOdmRA->Type = DM_Type_ByDriver; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1022 | |
| 1023 | pOdmRA->RATRState = DM_RATR_STA_INIT; |
| 1024 | pOdmRA->HighRSSIThresh = 50; |
| 1025 | pOdmRA->LowRSSIThresh = 20; |
| 1026 | } |
| 1027 | |
Jes Sorensen | 301fc63 | 2014-07-21 11:24:57 +0200 | [diff] [blame] | 1028 | u32 ODM_Get_Rate_Bitmap23a(struct hal_data_8723a *pHalData, u32 macid, |
| 1029 | u32 ra_mask, u8 rssi_level) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1030 | { |
Jes Sorensen | 301fc63 | 2014-07-21 11:24:57 +0200 | [diff] [blame] | 1031 | struct dm_odm_t *pDM_Odm = &pHalData->odmpriv; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1032 | struct sta_info *pEntry; |
| 1033 | u32 rate_bitmap = 0x0fffffff; |
| 1034 | u8 WirelessMode; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1035 | |
| 1036 | pEntry = pDM_Odm->pODM_StaInfo[macid]; |
Jes Sorensen | 2e8d47e | 2014-07-17 22:59:57 +0200 | [diff] [blame] | 1037 | if (!pEntry) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1038 | return ra_mask; |
| 1039 | |
| 1040 | WirelessMode = pEntry->wireless_mode; |
| 1041 | |
| 1042 | switch (WirelessMode) { |
| 1043 | case ODM_WM_B: |
| 1044 | if (ra_mask & 0x0000000c) /* 11M or 5.5M enable */ |
| 1045 | rate_bitmap = 0x0000000d; |
| 1046 | else |
| 1047 | rate_bitmap = 0x0000000f; |
| 1048 | break; |
| 1049 | case (ODM_WM_A|ODM_WM_G): |
| 1050 | if (rssi_level == DM_RATR_STA_HIGH) |
| 1051 | rate_bitmap = 0x00000f00; |
| 1052 | else |
| 1053 | rate_bitmap = 0x00000ff0; |
| 1054 | break; |
| 1055 | case (ODM_WM_B|ODM_WM_G): |
| 1056 | if (rssi_level == DM_RATR_STA_HIGH) |
| 1057 | rate_bitmap = 0x00000f00; |
| 1058 | else if (rssi_level == DM_RATR_STA_MIDDLE) |
| 1059 | rate_bitmap = 0x00000ff0; |
| 1060 | else |
| 1061 | rate_bitmap = 0x00000ff5; |
| 1062 | break; |
| 1063 | case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G): |
| 1064 | case (ODM_WM_A|ODM_WM_B|ODM_WM_G|ODM_WM_N24G): |
Jes Sorensen | 1629046 | 2015-02-27 15:45:30 -0500 | [diff] [blame] | 1065 | if (pHalData->rf_type == RF_1T2R || |
| 1066 | pHalData->rf_type == RF_1T1R) { |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1067 | if (rssi_level == DM_RATR_STA_HIGH) { |
| 1068 | rate_bitmap = 0x000f0000; |
| 1069 | } else if (rssi_level == DM_RATR_STA_MIDDLE) { |
| 1070 | rate_bitmap = 0x000ff000; |
| 1071 | } else { |
Jes Sorensen | 301fc63 | 2014-07-21 11:24:57 +0200 | [diff] [blame] | 1072 | if (pHalData->CurrentChannelBW == |
| 1073 | HT_CHANNEL_WIDTH_40) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1074 | rate_bitmap = 0x000ff015; |
| 1075 | else |
| 1076 | rate_bitmap = 0x000ff005; |
| 1077 | } |
| 1078 | } else { |
| 1079 | if (rssi_level == DM_RATR_STA_HIGH) { |
| 1080 | rate_bitmap = 0x0f8f0000; |
| 1081 | } else if (rssi_level == DM_RATR_STA_MIDDLE) { |
| 1082 | rate_bitmap = 0x0f8ff000; |
| 1083 | } else { |
Jes Sorensen | 301fc63 | 2014-07-21 11:24:57 +0200 | [diff] [blame] | 1084 | if (pHalData->CurrentChannelBW == |
| 1085 | HT_CHANNEL_WIDTH_40) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1086 | rate_bitmap = 0x0f8ff015; |
| 1087 | else |
| 1088 | rate_bitmap = 0x0f8ff005; |
| 1089 | } |
| 1090 | } |
| 1091 | break; |
| 1092 | default: |
| 1093 | /* case WIRELESS_11_24N: */ |
| 1094 | /* case WIRELESS_11_5N: */ |
Jes Sorensen | 1629046 | 2015-02-27 15:45:30 -0500 | [diff] [blame] | 1095 | if (pHalData->rf_type == RF_1T2R) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1096 | rate_bitmap = 0x000fffff; |
| 1097 | else |
| 1098 | rate_bitmap = 0x0fffffff; |
| 1099 | break; |
| 1100 | } |
| 1101 | |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1102 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, |
| 1103 | (" ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x \n", |
| 1104 | rssi_level, WirelessMode, rate_bitmap)); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1105 | |
| 1106 | return rate_bitmap; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1107 | } |
| 1108 | |
| 1109 | /*----------------------------------------------------------------------------- |
Jes Sorensen | b58298e | 2015-03-02 15:25:01 -0500 | [diff] [blame] | 1110 | * Function: odm_RefreshRateAdaptiveMask() |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1111 | * |
| 1112 | * Overview: Update rate table mask according to rssi |
| 1113 | * |
| 1114 | * Input: NONE |
| 1115 | * |
| 1116 | * Output: NONE |
| 1117 | * |
| 1118 | * Return: NONE |
| 1119 | * |
| 1120 | * Revised History: |
| 1121 | *When Who Remark |
| 1122 | *05/27/2009 hpfan Create Version 0. |
| 1123 | * |
| 1124 | *---------------------------------------------------------------------------*/ |
Jes Sorensen | b58298e | 2015-03-02 15:25:01 -0500 | [diff] [blame] | 1125 | static void odm_RefreshRateAdaptiveMask(struct dm_odm_t *pDM_Odm) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1126 | { |
Jes Sorensen | b58298e | 2015-03-02 15:25:01 -0500 | [diff] [blame] | 1127 | struct rtw_adapter *pAdapter = pDM_Odm->Adapter; |
| 1128 | u32 smoothed; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1129 | u8 i; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1130 | |
| 1131 | if (pAdapter->bDriverStopped) { |
| 1132 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, |
Jes Sorensen | 79afea1 | 2015-03-02 15:24:39 -0500 | [diff] [blame] | 1133 | ("<---- %s: driver is going to unload\n", |
| 1134 | __func__)); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1135 | return; |
| 1136 | } |
| 1137 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1138 | for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { |
| 1139 | struct sta_info *pstat = pDM_Odm->pODM_StaInfo[i]; |
Jes Sorensen | 2e8d47e | 2014-07-17 22:59:57 +0200 | [diff] [blame] | 1140 | if (pstat) { |
Jes Sorensen | b58298e | 2015-03-02 15:25:01 -0500 | [diff] [blame] | 1141 | smoothed = pstat->rssi_stat.UndecoratedSmoothedPWDB; |
| 1142 | if (ODM_RAStateCheck23a(pDM_Odm, smoothed, false, |
| 1143 | &pstat->rssi_level)) { |
| 1144 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, |
| 1145 | ODM_DBG_LOUD, |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1146 | ("RSSI:%d, RSSI_LEVEL:%d\n", |
Jes Sorensen | b58298e | 2015-03-02 15:25:01 -0500 | [diff] [blame] | 1147 | smoothed, |
| 1148 | pstat->rssi_level)); |
| 1149 | rtw_hal_update_ra_mask23a(pstat, |
| 1150 | pstat->rssi_level); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1151 | } |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1152 | } |
| 1153 | } |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1154 | } |
| 1155 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1156 | /* Return Value: bool */ |
| 1157 | /* - true: RATRState is changed. */ |
| 1158 | bool ODM_RAStateCheck23a(struct dm_odm_t *pDM_Odm, s32 RSSI, bool bForceUpdate, |
| 1159 | u8 *pRATRState) |
| 1160 | { |
| 1161 | struct odm_rate_adapt *pRA = &pDM_Odm->RateAdaptive; |
| 1162 | const u8 GoUpGap = 5; |
| 1163 | u8 HighRSSIThreshForRA = pRA->HighRSSIThresh; |
| 1164 | u8 LowRSSIThreshForRA = pRA->LowRSSIThresh; |
| 1165 | u8 RATRState; |
| 1166 | |
| 1167 | /* Threshold Adjustment: */ |
| 1168 | /* when RSSI state trends to go up one or two levels, make sure RSSI is high enough. */ |
| 1169 | /* Here GoUpGap is added to solve the boundary's level alternation issue. */ |
| 1170 | switch (*pRATRState) { |
| 1171 | case DM_RATR_STA_INIT: |
| 1172 | case DM_RATR_STA_HIGH: |
| 1173 | break; |
| 1174 | case DM_RATR_STA_MIDDLE: |
| 1175 | HighRSSIThreshForRA += GoUpGap; |
| 1176 | break; |
| 1177 | case DM_RATR_STA_LOW: |
| 1178 | HighRSSIThreshForRA += GoUpGap; |
| 1179 | LowRSSIThreshForRA += GoUpGap; |
| 1180 | break; |
| 1181 | default: |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1182 | ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !", |
| 1183 | *pRATRState)); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1184 | break; |
| 1185 | } |
| 1186 | |
| 1187 | /* Decide RATRState by RSSI. */ |
| 1188 | if (RSSI > HighRSSIThreshForRA) |
| 1189 | RATRState = DM_RATR_STA_HIGH; |
| 1190 | else if (RSSI > LowRSSIThreshForRA) |
| 1191 | RATRState = DM_RATR_STA_MIDDLE; |
| 1192 | else |
| 1193 | RATRState = DM_RATR_STA_LOW; |
| 1194 | |
| 1195 | if (*pRATRState != RATRState || bForceUpdate) { |
| 1196 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, |
| 1197 | ("RSSI Level %d -> %d\n", *pRATRState, RATRState)); |
| 1198 | *pRATRState = RATRState; |
| 1199 | return true; |
| 1200 | } |
| 1201 | return false; |
| 1202 | } |
| 1203 | |
| 1204 | /* 3 ============================================================ */ |
| 1205 | /* 3 Dynamic Tx Power */ |
| 1206 | /* 3 ============================================================ */ |
| 1207 | |
| 1208 | void odm_DynamicTxPower23aInit(struct dm_odm_t *pDM_Odm) |
| 1209 | { |
| 1210 | struct rtw_adapter *Adapter = pDM_Odm->Adapter; |
| 1211 | struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); |
| 1212 | struct dm_priv *pdmpriv = &pHalData->dmpriv; |
| 1213 | |
Jes Sorensen | 13b2beb | 2014-05-16 10:05:13 +0200 | [diff] [blame] | 1214 | /* |
| 1215 | * This is never changed, so we should be able to clean up the |
| 1216 | * code checking for different values in rtl8723a_rf6052.c |
| 1217 | */ |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1218 | pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; |
| 1219 | } |
| 1220 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1221 | static void |
Jes Sorensen | 0305d27 | 2015-03-02 15:25:00 -0500 | [diff] [blame] | 1222 | FindMinimumRSSI(struct rtw_adapter *pAdapter) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1223 | { |
| 1224 | struct hal_data_8723a *pHalData = GET_HAL_DATA(pAdapter); |
| 1225 | struct dm_priv *pdmpriv = &pHalData->dmpriv; |
| 1226 | struct dm_odm_t *pDM_Odm = &pHalData->odmpriv; |
| 1227 | |
| 1228 | /* 1 1.Determine the minimum RSSI */ |
| 1229 | |
Jes Sorensen | 0305d27 | 2015-03-02 15:25:00 -0500 | [diff] [blame] | 1230 | if (!pDM_Odm->bLinked && !pdmpriv->EntryMinUndecoratedSmoothedPWDB) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1231 | pdmpriv->MinUndecoratedPWDBForDM = 0; |
| 1232 | else |
Jes Sorensen | 0305d27 | 2015-03-02 15:25:00 -0500 | [diff] [blame] | 1233 | pdmpriv->MinUndecoratedPWDBForDM = |
| 1234 | pdmpriv->EntryMinUndecoratedSmoothedPWDB; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1235 | } |
| 1236 | |
Jes Sorensen | 04b7466 | 2015-03-02 15:24:59 -0500 | [diff] [blame] | 1237 | static void odm_RSSIMonitorCheck(struct dm_odm_t *pDM_Odm) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1238 | { |
| 1239 | struct rtw_adapter *Adapter = pDM_Odm->Adapter; |
| 1240 | struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); |
| 1241 | struct dm_priv *pdmpriv = &pHalData->dmpriv; |
Jes Sorensen | 04b7466 | 2015-03-02 15:24:59 -0500 | [diff] [blame] | 1242 | int i; |
| 1243 | int MaxDB = 0, MinDB = 0xff; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1244 | u8 sta_cnt = 0; |
Jes Sorensen | 04b7466 | 2015-03-02 15:24:59 -0500 | [diff] [blame] | 1245 | u32 tmpdb; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1246 | u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */ |
| 1247 | struct sta_info *psta; |
| 1248 | |
| 1249 | if (!pDM_Odm->bLinked) |
| 1250 | return; |
| 1251 | |
| 1252 | for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { |
| 1253 | psta = pDM_Odm->pODM_StaInfo[i]; |
Jes Sorensen | 2e8d47e | 2014-07-17 22:59:57 +0200 | [diff] [blame] | 1254 | if (psta) { |
Jes Sorensen | 04b7466 | 2015-03-02 15:24:59 -0500 | [diff] [blame] | 1255 | if (psta->rssi_stat.UndecoratedSmoothedPWDB < MinDB) |
| 1256 | MinDB = psta->rssi_stat.UndecoratedSmoothedPWDB; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1257 | |
Jes Sorensen | 04b7466 | 2015-03-02 15:24:59 -0500 | [diff] [blame] | 1258 | if (psta->rssi_stat.UndecoratedSmoothedPWDB > MaxDB) |
| 1259 | MaxDB = psta->rssi_stat.UndecoratedSmoothedPWDB; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1260 | |
Jes Sorensen | 04b7466 | 2015-03-02 15:24:59 -0500 | [diff] [blame] | 1261 | if (psta->rssi_stat.UndecoratedSmoothedPWDB != -1) { |
| 1262 | tmpdb = psta->rssi_stat.UndecoratedSmoothedPWDB; |
| 1263 | PWDB_rssi[sta_cnt++] = psta->mac_id | |
| 1264 | (tmpdb << 16); |
| 1265 | } |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | for (i = 0; i < sta_cnt; i++) { |
Jes Sorensen | 04b7466 | 2015-03-02 15:24:59 -0500 | [diff] [blame] | 1270 | if (PWDB_rssi[i] != (0)) |
Anatoly Stepanov | 485b099 | 2015-12-17 16:47:36 +0300 | [diff] [blame] | 1271 | rtl8723a_set_rssi_cmd(Adapter, PWDB_rssi[i]); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1272 | } |
| 1273 | |
Jes Sorensen | 04b7466 | 2015-03-02 15:24:59 -0500 | [diff] [blame] | 1274 | pdmpriv->EntryMaxUndecoratedSmoothedPWDB = MaxDB; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1275 | |
Jes Sorensen | 04b7466 | 2015-03-02 15:24:59 -0500 | [diff] [blame] | 1276 | if (MinDB != 0xff) /* If associated entry is found */ |
| 1277 | pdmpriv->EntryMinUndecoratedSmoothedPWDB = MinDB; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1278 | else |
| 1279 | pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0; |
| 1280 | |
| 1281 | FindMinimumRSSI(Adapter);/* get pdmpriv->MinUndecoratedPWDBForDM */ |
| 1282 | |
Jes Sorensen | 04b7466 | 2015-03-02 15:24:59 -0500 | [diff] [blame] | 1283 | ODM_CmnInfoUpdate23a(&pHalData->odmpriv, ODM_CMNINFO_RSSI_MIN, |
| 1284 | pdmpriv->MinUndecoratedPWDBForDM); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1285 | } |
| 1286 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1287 | /* endif */ |
| 1288 | /* 3 ============================================================ */ |
| 1289 | /* 3 Tx Power Tracking */ |
| 1290 | /* 3 ============================================================ */ |
| 1291 | |
Jes Sorensen | def0c45 | 2015-03-05 14:24:36 -0500 | [diff] [blame] | 1292 | static void odm_TXPowerTrackingInit(struct dm_odm_t *pDM_Odm) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1293 | { |
| 1294 | struct rtw_adapter *Adapter = pDM_Odm->Adapter; |
| 1295 | struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); |
| 1296 | struct dm_priv *pdmpriv = &pHalData->dmpriv; |
| 1297 | |
| 1298 | pdmpriv->bTXPowerTracking = true; |
| 1299 | pdmpriv->TXPowercount = 0; |
| 1300 | pdmpriv->bTXPowerTrackingInit = false; |
| 1301 | pdmpriv->TxPowerTrackControl = true; |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1302 | MSG_8723A("pdmpriv->TxPowerTrackControl = %d\n", |
| 1303 | pdmpriv->TxPowerTrackControl); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1304 | |
| 1305 | pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true; |
| 1306 | } |
| 1307 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1308 | /* EDCA Turbo */ |
Jes Sorensen | 4d1def6b | 2014-07-21 11:24:42 +0200 | [diff] [blame] | 1309 | static void ODM_EdcaTurboInit23a(struct dm_odm_t *pDM_Odm) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1310 | { |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1311 | struct rtw_adapter *Adapter = pDM_Odm->Adapter; |
Anjana Sasindran | 0dc4872 | 2014-12-04 18:11:13 +0530 | [diff] [blame] | 1312 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1313 | pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1314 | Adapter->recvpriv.bIsAnyNonBEPkts = false; |
| 1315 | |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1316 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, |
| 1317 | ("Orginial VO PARAM: 0x%x\n", |
Jes Sorensen | 53de994 | 2015-03-05 14:24:47 -0500 | [diff] [blame] | 1318 | rtl8723au_read32(Adapter, ODM_EDCA_VO_PARAM))); |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1319 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, |
| 1320 | ("Orginial VI PARAM: 0x%x\n", |
Jes Sorensen | 53de994 | 2015-03-05 14:24:47 -0500 | [diff] [blame] | 1321 | rtl8723au_read32(Adapter, ODM_EDCA_VI_PARAM))); |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1322 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, |
| 1323 | ("Orginial BE PARAM: 0x%x\n", |
Jes Sorensen | 53de994 | 2015-03-05 14:24:47 -0500 | [diff] [blame] | 1324 | rtl8723au_read32(Adapter, ODM_EDCA_BE_PARAM))); |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1325 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, |
| 1326 | ("Orginial BK PARAM: 0x%x\n", |
Jes Sorensen | 53de994 | 2015-03-05 14:24:47 -0500 | [diff] [blame] | 1327 | rtl8723au_read32(Adapter, ODM_EDCA_BK_PARAM))); |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1328 | } |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1329 | |
Jes Sorensen | 4d1def6b | 2014-07-21 11:24:42 +0200 | [diff] [blame] | 1330 | static void odm_EdcaTurboCheck23a(struct dm_odm_t *pDM_Odm) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1331 | { |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1332 | struct rtw_adapter *Adapter = pDM_Odm->Adapter; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1333 | struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); |
| 1334 | struct xmit_priv *pxmitpriv = &Adapter->xmitpriv; |
| 1335 | struct recv_priv *precvpriv = &Adapter->recvpriv; |
| 1336 | struct registry_priv *pregpriv = &Adapter->registrypriv; |
| 1337 | struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; |
| 1338 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
Jes Sorensen | 9ea3b82 | 2014-07-21 11:24:41 +0200 | [diff] [blame] | 1339 | u32 trafficIndex; |
| 1340 | u32 edca_param; |
Jes Sorensen | 4b4431c | 2015-03-02 15:24:37 -0500 | [diff] [blame] | 1341 | u64 cur_tx_bytes; |
| 1342 | u64 cur_rx_bytes; |
Jes Sorensen | 9ea3b82 | 2014-07-21 11:24:41 +0200 | [diff] [blame] | 1343 | |
| 1344 | /* For AP/ADSL use struct rtl8723a_priv * */ |
| 1345 | /* For CE/NIC use struct rtw_adapter * */ |
| 1346 | |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1347 | /* |
| 1348 | * 2011/09/29 MH In HW integration first stage, we provide 4 |
| 1349 | * different handle to operate at the same time. In the stage2/3, |
| 1350 | * we need to prive universal interface and merge all HW dynamic |
| 1351 | * mechanism. |
| 1352 | */ |
Jes Sorensen | 9ea3b82 | 2014-07-21 11:24:41 +0200 | [diff] [blame] | 1353 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1354 | if ((pregpriv->wifi_spec == 1))/* (pmlmeinfo->HT_enable == 0)) */ |
| 1355 | goto dm_CheckEdcaTurbo_EXIT; |
| 1356 | |
| 1357 | if (pmlmeinfo->assoc_AP_vendor >= HT_IOT_PEER_MAX) |
| 1358 | goto dm_CheckEdcaTurbo_EXIT; |
| 1359 | |
Jes Sorensen | dddeff3 | 2014-05-25 22:43:37 +0200 | [diff] [blame] | 1360 | if (rtl8723a_BT_disable_EDCA_turbo(Adapter)) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1361 | goto dm_CheckEdcaTurbo_EXIT; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1362 | |
| 1363 | /* Check if the status needs to be changed. */ |
Jes Sorensen | daa656b | 2015-03-02 15:24:36 -0500 | [diff] [blame] | 1364 | if (!precvpriv->bIsAnyNonBEPkts) { |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1365 | cur_tx_bytes = pxmitpriv->tx_bytes - pxmitpriv->last_tx_bytes; |
| 1366 | cur_rx_bytes = precvpriv->rx_bytes - precvpriv->last_rx_bytes; |
| 1367 | |
| 1368 | /* traffic, TX or RX */ |
| 1369 | if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK) || |
| 1370 | (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS)) { |
| 1371 | if (cur_tx_bytes > (cur_rx_bytes << 2)) { |
| 1372 | /* Uplink TP is present. */ |
| 1373 | trafficIndex = UP_LINK; |
| 1374 | } else { /* Balance TP is present. */ |
| 1375 | trafficIndex = DOWN_LINK; |
| 1376 | } |
| 1377 | } else { |
| 1378 | if (cur_rx_bytes > (cur_tx_bytes << 2)) { |
| 1379 | /* Downlink TP is present. */ |
| 1380 | trafficIndex = DOWN_LINK; |
| 1381 | } else { /* Balance TP is present. */ |
| 1382 | trafficIndex = UP_LINK; |
| 1383 | } |
| 1384 | } |
| 1385 | |
| 1386 | if ((pDM_Odm->DM_EDCA_Table.prv_traffic_idx != trafficIndex) || |
| 1387 | (!pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA)) { |
| 1388 | if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_CISCO) && |
| 1389 | (pmlmeext->cur_wireless_mode & WIRELESS_11_24N)) |
| 1390 | edca_param = EDCAParam[pmlmeinfo->assoc_AP_vendor][trafficIndex]; |
| 1391 | else |
| 1392 | edca_param = EDCAParam[HT_IOT_PEER_UNKNOWN][trafficIndex]; |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 1393 | rtl8723au_write32(Adapter, REG_EDCA_BE_PARAM, |
| 1394 | edca_param); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1395 | |
| 1396 | pDM_Odm->DM_EDCA_Table.prv_traffic_idx = trafficIndex; |
| 1397 | } |
| 1398 | |
| 1399 | pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = true; |
| 1400 | } else { |
| 1401 | /* Turn Off EDCA turbo here. */ |
| 1402 | /* Restore original EDCA according to the declaration of AP. */ |
| 1403 | if (pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA) { |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 1404 | rtl8723au_write32(Adapter, REG_EDCA_BE_PARAM, |
| 1405 | pHalData->AcParam_BE); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1406 | pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false; |
| 1407 | } |
| 1408 | } |
| 1409 | |
| 1410 | dm_CheckEdcaTurbo_EXIT: |
| 1411 | /* Set variables for next time. */ |
| 1412 | precvpriv->bIsAnyNonBEPkts = false; |
| 1413 | pxmitpriv->last_tx_bytes = pxmitpriv->tx_bytes; |
| 1414 | precvpriv->last_rx_bytes = precvpriv->rx_bytes; |
| 1415 | } |
| 1416 | |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1417 | u32 GetPSDData(struct dm_odm_t *pDM_Odm, unsigned int point, |
| 1418 | u8 initial_gain_psd) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1419 | { |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1420 | struct rtw_adapter *adapter = pDM_Odm->Adapter; |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 1421 | u32 psd_report, val32; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1422 | |
| 1423 | /* Set DCO frequency index, offset = (40MHz/SamplePts)*point */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 1424 | val32 = rtl8723au_read32(adapter, 0x808); |
| 1425 | val32 &= ~0x3ff; |
| 1426 | val32 |= (point & 0x3ff); |
| 1427 | rtl8723au_write32(adapter, 0x808, val32); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1428 | |
| 1429 | /* Start PSD calculation, Reg808[22]= 0->1 */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 1430 | val32 = rtl8723au_read32(adapter, 0x808); |
| 1431 | val32 |= BIT(22); |
| 1432 | rtl8723au_write32(adapter, 0x808, val32); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1433 | /* Need to wait for HW PSD report */ |
| 1434 | udelay(30); |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 1435 | val32 = rtl8723au_read32(adapter, 0x808); |
| 1436 | val32 &= ~BIT(22); |
| 1437 | rtl8723au_write32(adapter, 0x808, val32); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1438 | /* Read PSD report, Reg8B4[15:0] */ |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1439 | psd_report = rtl8723au_read32(adapter, 0x8B4) & 0x0000FFFF; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1440 | |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1441 | psd_report = (u32)(ConvertTo_dB23a(psd_report)) + |
| 1442 | (u32)(initial_gain_psd-0x1c); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1443 | |
| 1444 | return psd_report; |
| 1445 | } |
| 1446 | |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1447 | u32 ConvertTo_dB23a(u32 Value) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1448 | { |
| 1449 | u8 i; |
| 1450 | u8 j; |
| 1451 | u32 dB; |
| 1452 | |
| 1453 | Value = Value & 0xFFFF; |
| 1454 | |
| 1455 | for (i = 0; i < 8; i++) { |
| 1456 | if (Value <= dB_Invert_Table[i][11]) |
| 1457 | break; |
| 1458 | } |
| 1459 | |
| 1460 | if (i >= 8) |
| 1461 | return 96; /* maximum 96 dB */ |
| 1462 | |
| 1463 | for (j = 0; j < 12; j++) { |
| 1464 | if (Value <= dB_Invert_Table[i][j]) |
| 1465 | break; |
| 1466 | } |
| 1467 | |
| 1468 | dB = i*12 + j + 1; |
| 1469 | |
| 1470 | return dB; |
| 1471 | } |
| 1472 | |
| 1473 | /* */ |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1474 | /* Description: */ |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1475 | /* Set Single/Dual Antenna default setting for products that do not |
| 1476 | * do detection in advance. */ |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1477 | /* */ |
| 1478 | /* Added by Joseph, 2012.03.22 */ |
| 1479 | /* */ |
| 1480 | void ODM_SingleDualAntennaDefaultSetting(struct dm_odm_t *pDM_Odm) |
| 1481 | { |
| 1482 | struct sw_ant_sw *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; |
Anjana Sasindran | 0dc4872 | 2014-12-04 18:11:13 +0530 | [diff] [blame] | 1483 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1484 | pDM_SWAT_Table->ANTA_ON = true; |
| 1485 | pDM_SWAT_Table->ANTB_ON = true; |
| 1486 | } |
| 1487 | |
| 1488 | /* 2 8723A ANT DETECT */ |
| 1489 | |
Jes Sorensen | 8cba07d | 2015-03-02 15:24:49 -0500 | [diff] [blame] | 1490 | static void odm_PHY_SaveAFERegisters(struct dm_odm_t *pDM_Odm, u32 *AFEReg, |
| 1491 | u32 *AFEBackup, u32 RegisterNum) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1492 | { |
| 1493 | u32 i; |
| 1494 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1495 | for (i = 0 ; i < RegisterNum ; i++) |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1496 | AFEBackup[i] = rtl8723au_read32(pDM_Odm->Adapter, AFEReg[i]); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1497 | } |
| 1498 | |
| 1499 | static void odm_PHY_ReloadAFERegisters(struct dm_odm_t *pDM_Odm, u32 *AFEReg, |
| 1500 | u32 *AFEBackup, u32 RegiesterNum) |
| 1501 | { |
| 1502 | u32 i; |
| 1503 | |
| 1504 | for (i = 0 ; i < RegiesterNum; i++) |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1505 | rtl8723au_write32(pDM_Odm->Adapter, AFEReg[i], AFEBackup[i]); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1506 | } |
| 1507 | |
| 1508 | /* 2 8723A ANT DETECT */ |
| 1509 | /* Description: */ |
| 1510 | /* Implement IQK single tone for RF DPK loopback and BB PSD scanning. */ |
| 1511 | /* This function is cooperated with BB team Neil. */ |
| 1512 | bool ODM_SingleDualAntennaDetection(struct dm_odm_t *pDM_Odm, u8 mode) |
| 1513 | { |
| 1514 | struct sw_ant_sw *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1515 | struct rtw_adapter *adapter = pDM_Odm->Adapter; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1516 | u32 CurrentChannel, RfLoopReg; |
| 1517 | u8 n; |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 1518 | u32 Reg88c, Regc08, Reg874, Regc50, val32; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1519 | u8 initial_gain = 0x5a; |
| 1520 | u32 PSD_report_tmp; |
| 1521 | u32 AntA_report = 0x0, AntB_report = 0x0, AntO_report = 0x0; |
| 1522 | bool bResult = true; |
| 1523 | u32 AFE_Backup[16]; |
| 1524 | u32 AFE_REG_8723A[16] = { |
| 1525 | rRx_Wait_CCA, rTx_CCK_RFON, |
| 1526 | rTx_CCK_BBON, rTx_OFDM_RFON, |
| 1527 | rTx_OFDM_BBON, rTx_To_Rx, |
| 1528 | rTx_To_Tx, rRx_CCK, |
| 1529 | rRx_OFDM, rRx_Wait_RIFS, |
| 1530 | rRx_TO_Rx, rStandby, |
| 1531 | rSleep, rPMPD_ANAEN, |
| 1532 | rFPGA0_XCD_SwitchControl, rBlue_Tooth}; |
| 1533 | |
Jes Sorensen | 344af82 | 2014-07-17 22:59:55 +0200 | [diff] [blame] | 1534 | if (!(pDM_Odm->SupportICType & ODM_RTL8723A)) |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1535 | return bResult; |
| 1536 | |
| 1537 | if (!(pDM_Odm->SupportAbility&ODM_BB_ANT_DIV)) |
| 1538 | return bResult; |
| 1539 | /* 1 Backup Current RF/BB Settings */ |
| 1540 | |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1541 | CurrentChannel = ODM_GetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL, |
| 1542 | bRFRegOffsetMask); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1543 | RfLoopReg = ODM_GetRFReg(pDM_Odm, RF_PATH_A, 0x00, bRFRegOffsetMask); |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1544 | /* change to Antenna A */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 1545 | val32 = rtl8723au_read32(adapter, rFPGA0_XA_RFInterfaceOE); |
| 1546 | val32 &= ~0x300; |
| 1547 | val32 |= 0x100; /* Enable antenna A */ |
| 1548 | rtl8723au_write32(adapter, rFPGA0_XA_RFInterfaceOE, val32); |
| 1549 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1550 | /* Step 1: USE IQK to transmitter single tone */ |
| 1551 | |
| 1552 | udelay(10); |
| 1553 | |
| 1554 | /* Store A Path Register 88c, c08, 874, c50 */ |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1555 | Reg88c = rtl8723au_read32(adapter, rFPGA0_AnalogParameter4); |
| 1556 | Regc08 = rtl8723au_read32(adapter, rOFDM0_TRMuxPar); |
| 1557 | Reg874 = rtl8723au_read32(adapter, rFPGA0_XCD_RFInterfaceSW); |
| 1558 | Regc50 = rtl8723au_read32(adapter, rOFDM0_XAAGCCore1); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1559 | |
| 1560 | /* Store AFE Registers */ |
| 1561 | odm_PHY_SaveAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16); |
| 1562 | |
| 1563 | /* Set PSD 128 pts */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 1564 | val32 = rtl8723au_read32(adapter, rFPGA0_PSDFunction); |
| 1565 | val32 &= ~(BIT(14) | BIT(15)); |
| 1566 | rtl8723au_write32(adapter, rFPGA0_PSDFunction, val32); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1567 | |
| 1568 | /* To SET CH1 to do */ |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1569 | ODM_SetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask, 0x01); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1570 | |
| 1571 | /* AFE all on step */ |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1572 | rtl8723au_write32(adapter, rRx_Wait_CCA, 0x6FDB25A4); |
| 1573 | rtl8723au_write32(adapter, rTx_CCK_RFON, 0x6FDB25A4); |
| 1574 | rtl8723au_write32(adapter, rTx_CCK_BBON, 0x6FDB25A4); |
| 1575 | rtl8723au_write32(adapter, rTx_OFDM_RFON, 0x6FDB25A4); |
| 1576 | rtl8723au_write32(adapter, rTx_OFDM_BBON, 0x6FDB25A4); |
| 1577 | rtl8723au_write32(adapter, rTx_To_Rx, 0x6FDB25A4); |
| 1578 | rtl8723au_write32(adapter, rTx_To_Tx, 0x6FDB25A4); |
| 1579 | rtl8723au_write32(adapter, rRx_CCK, 0x6FDB25A4); |
| 1580 | rtl8723au_write32(adapter, rRx_OFDM, 0x6FDB25A4); |
| 1581 | rtl8723au_write32(adapter, rRx_Wait_RIFS, 0x6FDB25A4); |
| 1582 | rtl8723au_write32(adapter, rRx_TO_Rx, 0x6FDB25A4); |
| 1583 | rtl8723au_write32(adapter, rStandby, 0x6FDB25A4); |
| 1584 | rtl8723au_write32(adapter, rSleep, 0x6FDB25A4); |
| 1585 | rtl8723au_write32(adapter, rPMPD_ANAEN, 0x6FDB25A4); |
| 1586 | rtl8723au_write32(adapter, rFPGA0_XCD_SwitchControl, 0x6FDB25A4); |
| 1587 | rtl8723au_write32(adapter, rBlue_Tooth, 0x6FDB25A4); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1588 | |
| 1589 | /* 3 wire Disable */ |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1590 | rtl8723au_write32(adapter, rFPGA0_AnalogParameter4, 0xCCF000C0); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1591 | |
| 1592 | /* BB IQK Setting */ |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1593 | rtl8723au_write32(adapter, rOFDM0_TRMuxPar, 0x000800E4); |
| 1594 | rtl8723au_write32(adapter, rFPGA0_XCD_RFInterfaceSW, 0x22208000); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1595 | |
| 1596 | /* IQK setting tone@ 4.34Mhz */ |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1597 | rtl8723au_write32(adapter, rTx_IQK_Tone_A, 0x10008C1C); |
| 1598 | rtl8723au_write32(adapter, rTx_IQK, 0x01007c00); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1599 | |
| 1600 | /* Page B init */ |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1601 | rtl8723au_write32(adapter, rConfig_AntA, 0x00080000); |
| 1602 | rtl8723au_write32(adapter, rConfig_AntA, 0x0f600000); |
| 1603 | rtl8723au_write32(adapter, rRx_IQK, 0x01004800); |
| 1604 | rtl8723au_write32(adapter, rRx_IQK_Tone_A, 0x10008c1f); |
| 1605 | rtl8723au_write32(adapter, rTx_IQK_PI_A, 0x82150008); |
| 1606 | rtl8723au_write32(adapter, rRx_IQK_PI_A, 0x28150008); |
| 1607 | rtl8723au_write32(adapter, rIQK_AGC_Rsp, 0x001028d0); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1608 | |
| 1609 | /* RF loop Setting */ |
| 1610 | ODM_SetRFReg(pDM_Odm, RF_PATH_A, 0x0, 0xFFFFF, 0x50008); |
| 1611 | |
| 1612 | /* IQK Single tone start */ |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1613 | rtl8723au_write32(adapter, rFPGA0_IQK, 0x80800000); |
| 1614 | rtl8723au_write32(adapter, rIQK_AGC_Pts, 0xf8000000); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1615 | udelay(1000); |
| 1616 | PSD_report_tmp = 0x0; |
| 1617 | |
| 1618 | for (n = 0; n < 2; n++) { |
| 1619 | PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain); |
| 1620 | if (PSD_report_tmp > AntA_report) |
| 1621 | AntA_report = PSD_report_tmp; |
| 1622 | } |
| 1623 | |
| 1624 | PSD_report_tmp = 0x0; |
| 1625 | |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 1626 | val32 = rtl8723au_read32(adapter, rFPGA0_XA_RFInterfaceOE); |
| 1627 | val32 &= ~0x300; |
| 1628 | val32 |= 0x200; /* Enable antenna B */ |
| 1629 | rtl8723au_write32(adapter, rFPGA0_XA_RFInterfaceOE, val32); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1630 | udelay(10); |
| 1631 | |
| 1632 | for (n = 0; n < 2; n++) { |
| 1633 | PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain); |
| 1634 | if (PSD_report_tmp > AntB_report) |
| 1635 | AntB_report = PSD_report_tmp; |
| 1636 | } |
| 1637 | |
| 1638 | /* change to open case */ |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1639 | /* change to Ant A and B all open case */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 1640 | val32 = rtl8723au_read32(adapter, rFPGA0_XA_RFInterfaceOE); |
| 1641 | val32 &= ~0x300; |
| 1642 | rtl8723au_write32(adapter, rFPGA0_XA_RFInterfaceOE, val32); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1643 | udelay(10); |
| 1644 | |
| 1645 | for (n = 0; n < 2; n++) { |
| 1646 | PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain); |
| 1647 | if (PSD_report_tmp > AntO_report) |
| 1648 | AntO_report = PSD_report_tmp; |
| 1649 | } |
| 1650 | |
| 1651 | /* Close IQK Single Tone function */ |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1652 | rtl8723au_write32(adapter, rFPGA0_IQK, 0x00000000); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1653 | PSD_report_tmp = 0x0; |
| 1654 | |
| 1655 | /* 1 Return to antanna A */ |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 1656 | val32 = rtl8723au_read32(adapter, rFPGA0_XA_RFInterfaceOE); |
| 1657 | val32 &= ~0x300; |
| 1658 | val32 |= 0x100; /* Enable antenna A */ |
| 1659 | rtl8723au_write32(adapter, rFPGA0_XA_RFInterfaceOE, val32); |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1660 | rtl8723au_write32(adapter, rFPGA0_AnalogParameter4, Reg88c); |
| 1661 | rtl8723au_write32(adapter, rOFDM0_TRMuxPar, Regc08); |
| 1662 | rtl8723au_write32(adapter, rFPGA0_XCD_RFInterfaceSW, Reg874); |
Jes Sorensen | 2635f19 | 2015-03-05 14:24:49 -0500 | [diff] [blame] | 1663 | val32 = rtl8723au_read32(adapter, rOFDM0_XAAGCCore1); |
| 1664 | val32 &= ~0x7f; |
| 1665 | val32 |= 0x40; |
| 1666 | rtl8723au_write32(adapter, rOFDM0_XAAGCCore1, val32); |
| 1667 | |
Jes Sorensen | bfd83bb | 2015-03-05 14:24:37 -0500 | [diff] [blame] | 1668 | rtl8723au_write32(adapter, rOFDM0_XAAGCCore1, Regc50); |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1669 | ODM_SetRFReg(pDM_Odm, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, |
| 1670 | CurrentChannel); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1671 | ODM_SetRFReg(pDM_Odm, RF_PATH_A, 0x00, bRFRegOffsetMask, RfLoopReg); |
| 1672 | |
| 1673 | /* Reload AFE Registers */ |
| 1674 | odm_PHY_ReloadAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16); |
| 1675 | |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1676 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, |
| 1677 | ("psd_report_A[%d]= %d \n", 2416, AntA_report)); |
| 1678 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, |
| 1679 | ("psd_report_B[%d]= %d \n", 2416, AntB_report)); |
| 1680 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, |
| 1681 | ("psd_report_O[%d]= %d \n", 2416, AntO_report)); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1682 | |
| 1683 | /* 2 Test Ant B based on Ant A is ON */ |
| 1684 | if (mode == ANTTESTB) { |
| 1685 | if (AntA_report >= 100) { |
| 1686 | if (AntB_report > (AntA_report+1)) { |
| 1687 | pDM_SWAT_Table->ANTB_ON = false; |
| 1688 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna A\n")); |
| 1689 | } else { |
| 1690 | pDM_SWAT_Table->ANTB_ON = true; |
| 1691 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Dual Antenna is A and B\n")); |
| 1692 | } |
| 1693 | } else { |
| 1694 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Need to check again\n")); |
| 1695 | pDM_SWAT_Table->ANTB_ON = false; /* Set Antenna B off as default */ |
| 1696 | bResult = false; |
| 1697 | } |
| 1698 | } else if (mode == ANTTESTALL) { |
| 1699 | /* 2 Test Ant A and B based on DPDT Open */ |
| 1700 | if ((AntO_report >= 100) & (AntO_report < 118)) { |
| 1701 | if (AntA_report > (AntO_report+1)) { |
| 1702 | pDM_SWAT_Table->ANTA_ON = false; |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1703 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, |
| 1704 | ODM_DBG_LOUD, ("Ant A is OFF")); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1705 | } else { |
| 1706 | pDM_SWAT_Table->ANTA_ON = true; |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1707 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, |
| 1708 | ODM_DBG_LOUD, ("Ant A is ON")); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1709 | } |
| 1710 | |
| 1711 | if (AntB_report > (AntO_report+2)) { |
| 1712 | pDM_SWAT_Table->ANTB_ON = false; |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1713 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, |
| 1714 | ODM_DBG_LOUD, ("Ant B is OFF")); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1715 | } else { |
| 1716 | pDM_SWAT_Table->ANTB_ON = true; |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1717 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, |
| 1718 | ODM_DBG_LOUD, ("Ant B is ON")); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1719 | } |
| 1720 | } |
| 1721 | } else { |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1722 | ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, |
| 1723 | ("ODM_SingleDualAntennaDetection(): Need to check again\n")); |
| 1724 | /* Set Antenna A on as default */ |
| 1725 | pDM_SWAT_Table->ANTA_ON = true; |
| 1726 | /* Set Antenna B off as default */ |
| 1727 | pDM_SWAT_Table->ANTB_ON = false; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1728 | bResult = false; |
| 1729 | } |
Jes Sorensen | fe6e019 | 2015-03-02 15:25:03 -0500 | [diff] [blame] | 1730 | |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 1731 | return bResult; |
| 1732 | } |