Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************* |
| 3 | * Ralink Tech Inc. |
| 4 | * 5F., No.36, Taiyuan St., Jhubei City, |
| 5 | * Hsinchu County 302, |
| 6 | * Taiwan, R.O.C. |
| 7 | * |
| 8 | * (c) Copyright 2002-2007, Ralink Technology, Inc. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify * |
| 11 | * it under the terms of the GNU General Public License as published by * |
| 12 | * the Free Software Foundation; either version 2 of the License, or * |
| 13 | * (at your option) any later version. * |
| 14 | * * |
| 15 | * This program is distributed in the hope that it will be useful, * |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 18 | * GNU General Public License for more details. * |
| 19 | * * |
| 20 | * You should have received a copy of the GNU General Public License * |
| 21 | * along with this program; if not, write to the * |
| 22 | * Free Software Foundation, Inc., * |
| 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 24 | * * |
| 25 | ************************************************************************* |
| 26 | |
| 27 | Module Name: |
| 28 | rtmp_init.c |
| 29 | |
| 30 | Abstract: |
| 31 | Miniport generic portion header file |
| 32 | |
| 33 | Revision History: |
| 34 | Who When What |
| 35 | -------- ---------- ---------------------------------------------- |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 36 | */ |
| 37 | #include "../rt_config.h" |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 38 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 39 | u8 BIT8[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 40 | char *CipherName[] = |
| 41 | { "none", "wep64", "wep128", "TKIP", "AES", "CKIP64", "CKIP128" }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 42 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 43 | /* */ |
| 44 | /* BBP register initialization set */ |
| 45 | /* */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 46 | struct rt_reg_pair BBPRegTable[] = { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 47 | {BBP_R65, 0x2C}, /* fix rssi issue */ |
| 48 | {BBP_R66, 0x38}, /* Also set this default value to pAd->BbpTuning.R66CurrentValue at initial */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 49 | {BBP_R69, 0x12}, |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 50 | {BBP_R70, 0xa}, /* BBP_R70 will change to 0x8 in ApStartUp and LinkUp for rt2860C, otherwise value is 0xa */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 51 | {BBP_R73, 0x10}, |
| 52 | {BBP_R81, 0x37}, |
| 53 | {BBP_R82, 0x62}, |
| 54 | {BBP_R83, 0x6A}, |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 55 | {BBP_R84, 0x99}, /* 0x19 is for rt2860E and after. This is for extension channel overlapping IOT. 0x99 is for rt2860D and before */ |
| 56 | {BBP_R86, 0x00}, /* middle range issue, Rory @2008-01-28 */ |
| 57 | {BBP_R91, 0x04}, /* middle range issue, Rory @2008-01-28 */ |
| 58 | {BBP_R92, 0x00}, /* middle range issue, Rory @2008-01-28 */ |
| 59 | {BBP_R103, 0x00}, /* near range high-power issue, requested from Gary @2008-0528 */ |
| 60 | {BBP_R105, 0x05}, /* 0x05 is for rt2860E to turn on FEQ control. It is safe for rt2860D and before, because Bit 7:2 are reserved in rt2860D and before. */ |
| 61 | {BBP_R106, 0x35}, /* for ShortGI throughput */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 62 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 63 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 64 | #define NUM_BBP_REG_PARMS (sizeof(BBPRegTable) / sizeof(struct rt_reg_pair)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 65 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 66 | /* */ |
| 67 | /* ASIC register initialization sets */ |
| 68 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 69 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 70 | struct rt_rtmp_reg_pair MACRegTable[] = { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 71 | #if defined(HW_BEACON_OFFSET) && (HW_BEACON_OFFSET == 0x200) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 72 | {BCN_OFFSET0, 0xf8f0e8e0}, /* 0x3800(e0), 0x3A00(e8), 0x3C00(f0), 0x3E00(f8), 512B for each beacon */ |
| 73 | {BCN_OFFSET1, 0x6f77d0c8}, /* 0x3200(c8), 0x3400(d0), 0x1DC0(77), 0x1BC0(6f), 512B for each beacon */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 74 | #elif defined(HW_BEACON_OFFSET) && (HW_BEACON_OFFSET == 0x100) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 75 | {BCN_OFFSET0, 0xece8e4e0}, /* 0x3800, 0x3A00, 0x3C00, 0x3E00, 512B for each beacon */ |
| 76 | {BCN_OFFSET1, 0xfcf8f4f0}, /* 0x3800, 0x3A00, 0x3C00, 0x3E00, 512B for each beacon */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 77 | #else |
Sebastian Dalfuß | 06aea99 | 2009-11-07 17:31:12 +0100 | [diff] [blame] | 78 | #error You must re-calculate new value for BCN_OFFSET0 & BCN_OFFSET1 in MACRegTable[]! |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 79 | #endif /* HW_BEACON_OFFSET // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 80 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 81 | {LEGACY_BASIC_RATE, 0x0000013f}, /* Basic rate set bitmap */ |
| 82 | {HT_BASIC_RATE, 0x00008003}, /* Basic HT rate set , 20M, MCS=3, MM. Format is the same as in TXWI. */ |
| 83 | {MAC_SYS_CTRL, 0x00}, /* 0x1004, , default Disable RX */ |
| 84 | {RX_FILTR_CFG, 0x17f97}, /*0x1400 , RX filter control, */ |
| 85 | {BKOFF_SLOT_CFG, 0x209}, /* default set short slot time, CC_DELAY_TIME should be 2 */ |
| 86 | /*{TX_SW_CFG0, 0x40a06}, // Gary,2006-08-23 */ |
| 87 | {TX_SW_CFG0, 0x0}, /* Gary,2008-05-21 for CWC test */ |
| 88 | {TX_SW_CFG1, 0x80606}, /* Gary,2006-08-23 */ |
| 89 | {TX_LINK_CFG, 0x1020}, /* Gary,2006-08-23 */ |
| 90 | /*{TX_TIMEOUT_CFG, 0x00182090}, // CCK has some problem. So increase timieout value. 2006-10-09// MArvek RT */ |
| 91 | {TX_TIMEOUT_CFG, 0x000a2090}, /* CCK has some problem. So increase timieout value. 2006-10-09// MArvek RT , Modify for 2860E ,2007-08-01 */ |
| 92 | {MAX_LEN_CFG, MAX_AGGREGATION_SIZE | 0x00001000}, /* 0x3018, MAX frame length. Max PSDU = 16kbytes. */ |
| 93 | {LED_CFG, 0x7f031e46}, /* Gary, 2006-08-23 */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 94 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 95 | {PBF_MAX_PCNT, 0x1F3FBF9F}, /*0x1F3f7f9f}, //Jan, 2006/04/20 */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 96 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 97 | {TX_RTY_CFG, 0x47d01f0f}, /* Jan, 2006/11/16, Set TxWI->ACK =0 in Probe Rsp Modify for 2860E ,2007-08-03 */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 98 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 99 | {AUTO_RSP_CFG, 0x00000013}, /* Initial Auto_Responder, because QA will turn off Auto-Responder */ |
| 100 | {CCK_PROT_CFG, 0x05740003 /*0x01740003 */ }, /* Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled. */ |
| 101 | {OFDM_PROT_CFG, 0x05740003 /*0x01740003 */ }, /* Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 102 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 103 | {PBF_CFG, 0xf40006}, /* Only enable Queue 2 */ |
| 104 | {MM40_PROT_CFG, 0x3F44084}, /* Initial Auto_Responder, because QA will turn off Auto-Responder */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 105 | {WPDMA_GLO_CFG, 0x00000030}, |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 106 | #endif /* RTMP_MAC_USB // */ |
| 107 | {GF20_PROT_CFG, 0x01744004}, /* set 19:18 --> Short NAV for MIMO PS */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 108 | {GF40_PROT_CFG, 0x03F44084}, |
| 109 | {MM20_PROT_CFG, 0x01744004}, |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 110 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 111 | {MM40_PROT_CFG, 0x03F54084}, |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 112 | #endif /* RTMP_MAC_PCI // */ |
| 113 | {TXOP_CTRL_CFG, 0x0000583f, /*0x0000243f *//*0x000024bf */ }, /*Extension channel backoff. */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 114 | {TX_RTS_CFG, 0x00092b20}, |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 115 | {EXP_ACK_TIME, 0x002400ca}, /* default value */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 116 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 117 | {TXOP_HLDR_ET, 0x00000002}, |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 118 | |
| 119 | /* Jerry comments 2008/01/16: we use SIFS = 10us in CCK defaultly, but it seems that 10us |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 120 | is too small for INTEL 2200bg card, so in MBSS mode, the delta time between beacon0 |
| 121 | and beacon1 is SIFS (10us), so if INTEL 2200bg card connects to BSS0, the ping |
| 122 | will always lost. So we change the SIFS of CCK from 10us to 16us. */ |
| 123 | {XIFS_TIME_CFG, 0x33a41010}, |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 124 | {PWR_PIN_CFG, 0x00000003}, /* patch for 2880-E */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 125 | }; |
| 126 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 127 | struct rt_rtmp_reg_pair STAMACRegTable[] = { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 128 | {WMM_AIFSN_CFG, 0x00002273}, |
| 129 | {WMM_CWMIN_CFG, 0x00002344}, |
| 130 | {WMM_CWMAX_CFG, 0x000034aa}, |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 131 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 132 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 133 | #define NUM_MAC_REG_PARMS (sizeof(MACRegTable) / sizeof(struct rt_rtmp_reg_pair)) |
| 134 | #define NUM_STA_MAC_REG_PARMS (sizeof(STAMACRegTable) / sizeof(struct rt_rtmp_reg_pair)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 135 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 136 | /* |
| 137 | ======================================================================== |
| 138 | |
| 139 | Routine Description: |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 140 | Allocate struct rt_rtmp_adapter data block and do some initialization |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 141 | |
| 142 | Arguments: |
| 143 | Adapter Pointer to our adapter |
| 144 | |
| 145 | Return Value: |
| 146 | NDIS_STATUS_SUCCESS |
| 147 | NDIS_STATUS_FAILURE |
| 148 | |
| 149 | IRQL = PASSIVE_LEVEL |
| 150 | |
| 151 | Note: |
| 152 | |
| 153 | ======================================================================== |
| 154 | */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 155 | int RTMPAllocAdapterBlock(void *handle, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 156 | struct rt_rtmp_adapter * * ppAdapter) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 157 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 158 | struct rt_rtmp_adapter *pAd; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 159 | int Status; |
| 160 | int index; |
| 161 | u8 *pBeaconBuf = NULL; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 162 | |
| 163 | DBGPRINT(RT_DEBUG_TRACE, ("--> RTMPAllocAdapterBlock\n")); |
| 164 | |
| 165 | *ppAdapter = NULL; |
| 166 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 167 | do { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 168 | /* Allocate struct rt_rtmp_adapter memory block */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 169 | pBeaconBuf = kmalloc(MAX_BEACON_SIZE, MEM_ALLOC_FLAG); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 170 | if (pBeaconBuf == NULL) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 171 | Status = NDIS_STATUS_FAILURE; |
| 172 | DBGPRINT_ERR(("Failed to allocate memory - BeaconBuf!\n")); |
| 173 | break; |
| 174 | } |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 175 | NdisZeroMemory(pBeaconBuf, MAX_BEACON_SIZE); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 176 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 177 | Status = AdapterBlockAllocateMemory(handle, (void **) & pAd); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 178 | if (Status != NDIS_STATUS_SUCCESS) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 179 | DBGPRINT_ERR(("Failed to allocate memory - ADAPTER\n")); |
| 180 | break; |
| 181 | } |
| 182 | pAd->BeaconBuf = pBeaconBuf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 183 | DBGPRINT(RT_DEBUG_OFF, |
Sebastian Dalfuß | d6dbc01 | 2009-11-06 14:49:28 +0100 | [diff] [blame] | 184 | ("=== pAd = %p, size = %d ===\n", pAd, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 185 | (u32)sizeof(struct rt_rtmp_adapter))); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 186 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 187 | /* Init spin locks */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 188 | NdisAllocateSpinLock(&pAd->MgmtRingLock); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 189 | #ifdef RTMP_MAC_PCI |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 190 | NdisAllocateSpinLock(&pAd->RxRingLock); |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 191 | #ifdef RT3090 |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 192 | NdisAllocateSpinLock(&pAd->McuCmdLock); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 193 | #endif /* RT3090 // */ |
| 194 | #endif /* RTMP_MAC_PCI // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 195 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 196 | for (index = 0; index < NUM_OF_TX_RING; index++) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 197 | NdisAllocateSpinLock(&pAd->TxSwQueueLock[index]); |
| 198 | NdisAllocateSpinLock(&pAd->DeQueueLock[index]); |
| 199 | pAd->DeQueueRunning[index] = FALSE; |
| 200 | } |
| 201 | |
| 202 | NdisAllocateSpinLock(&pAd->irq_lock); |
| 203 | |
| 204 | } while (FALSE); |
| 205 | |
| 206 | if ((Status != NDIS_STATUS_SUCCESS) && (pBeaconBuf)) |
| 207 | kfree(pBeaconBuf); |
| 208 | |
| 209 | *ppAdapter = pAd; |
| 210 | |
| 211 | DBGPRINT_S(Status, ("<-- RTMPAllocAdapterBlock, Status=%x\n", Status)); |
| 212 | return Status; |
| 213 | } |
| 214 | |
| 215 | /* |
| 216 | ======================================================================== |
| 217 | |
| 218 | Routine Description: |
| 219 | Read initial Tx power per MCS and BW from EEPROM |
| 220 | |
| 221 | Arguments: |
| 222 | Adapter Pointer to our adapter |
| 223 | |
| 224 | Return Value: |
| 225 | None |
| 226 | |
| 227 | IRQL = PASSIVE_LEVEL |
| 228 | |
| 229 | Note: |
| 230 | |
| 231 | ======================================================================== |
| 232 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 233 | void RTMPReadTxPwrPerRate(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 234 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 235 | unsigned long data, Adata, Gdata; |
| 236 | u16 i, value, value2; |
| 237 | int Apwrdelta, Gpwrdelta; |
| 238 | u8 t1, t2, t3, t4; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 239 | BOOLEAN bApwrdeltaMinus = TRUE, bGpwrdeltaMinus = TRUE; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 240 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 241 | /* */ |
| 242 | /* Get power delta for 20MHz and 40MHz. */ |
| 243 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 244 | DBGPRINT(RT_DEBUG_TRACE, ("Txpower per Rate\n")); |
| 245 | RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_DELTA, value2); |
| 246 | Apwrdelta = 0; |
| 247 | Gpwrdelta = 0; |
| 248 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 249 | if ((value2 & 0xff) != 0xff) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 250 | if ((value2 & 0x80)) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 251 | Gpwrdelta = (value2 & 0xf); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 252 | |
| 253 | if ((value2 & 0x40)) |
| 254 | bGpwrdeltaMinus = FALSE; |
| 255 | else |
| 256 | bGpwrdeltaMinus = TRUE; |
| 257 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 258 | if ((value2 & 0xff00) != 0xff00) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 259 | if ((value2 & 0x8000)) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 260 | Apwrdelta = ((value2 & 0xf00) >> 8); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 261 | |
| 262 | if ((value2 & 0x4000)) |
| 263 | bApwrdeltaMinus = FALSE; |
| 264 | else |
| 265 | bApwrdeltaMinus = TRUE; |
| 266 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 267 | DBGPRINT(RT_DEBUG_TRACE, |
| 268 | ("Gpwrdelta = %x, Apwrdelta = %x .\n", Gpwrdelta, Apwrdelta)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 269 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 270 | /* */ |
| 271 | /* Get Txpower per MCS for 20MHz in 2.4G. */ |
| 272 | /* */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 273 | for (i = 0; i < 5; i++) { |
| 274 | RT28xx_EEPROM_READ16(pAd, |
| 275 | EEPROM_TXPOWER_BYRATE_20MHZ_2_4G + i * 4, |
| 276 | value); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 277 | data = value; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 278 | if (bApwrdeltaMinus == FALSE) { |
| 279 | t1 = (value & 0xf) + (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 280 | if (t1 > 0xf) |
| 281 | t1 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 282 | t2 = ((value & 0xf0) >> 4) + (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 283 | if (t2 > 0xf) |
| 284 | t2 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 285 | t3 = ((value & 0xf00) >> 8) + (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 286 | if (t3 > 0xf) |
| 287 | t3 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 288 | t4 = ((value & 0xf000) >> 12) + (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 289 | if (t4 > 0xf) |
| 290 | t4 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 291 | } else { |
| 292 | if ((value & 0xf) > Apwrdelta) |
| 293 | t1 = (value & 0xf) - (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 294 | else |
| 295 | t1 = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 296 | if (((value & 0xf0) >> 4) > Apwrdelta) |
| 297 | t2 = ((value & 0xf0) >> 4) - (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 298 | else |
| 299 | t2 = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 300 | if (((value & 0xf00) >> 8) > Apwrdelta) |
| 301 | t3 = ((value & 0xf00) >> 8) - (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 302 | else |
| 303 | t3 = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 304 | if (((value & 0xf000) >> 12) > Apwrdelta) |
| 305 | t4 = ((value & 0xf000) >> 12) - (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 306 | else |
| 307 | t4 = 0; |
| 308 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 309 | Adata = t1 + (t2 << 4) + (t3 << 8) + (t4 << 12); |
| 310 | if (bGpwrdeltaMinus == FALSE) { |
| 311 | t1 = (value & 0xf) + (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 312 | if (t1 > 0xf) |
| 313 | t1 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 314 | t2 = ((value & 0xf0) >> 4) + (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 315 | if (t2 > 0xf) |
| 316 | t2 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 317 | t3 = ((value & 0xf00) >> 8) + (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 318 | if (t3 > 0xf) |
| 319 | t3 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 320 | t4 = ((value & 0xf000) >> 12) + (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 321 | if (t4 > 0xf) |
| 322 | t4 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 323 | } else { |
| 324 | if ((value & 0xf) > Gpwrdelta) |
| 325 | t1 = (value & 0xf) - (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 326 | else |
| 327 | t1 = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 328 | if (((value & 0xf0) >> 4) > Gpwrdelta) |
| 329 | t2 = ((value & 0xf0) >> 4) - (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 330 | else |
| 331 | t2 = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 332 | if (((value & 0xf00) >> 8) > Gpwrdelta) |
| 333 | t3 = ((value & 0xf00) >> 8) - (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 334 | else |
| 335 | t3 = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 336 | if (((value & 0xf000) >> 12) > Gpwrdelta) |
| 337 | t4 = ((value & 0xf000) >> 12) - (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 338 | else |
| 339 | t4 = 0; |
| 340 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 341 | Gdata = t1 + (t2 << 4) + (t3 << 8) + (t4 << 12); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 342 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 343 | RT28xx_EEPROM_READ16(pAd, |
| 344 | EEPROM_TXPOWER_BYRATE_20MHZ_2_4G + i * 4 + |
| 345 | 2, value); |
| 346 | if (bApwrdeltaMinus == FALSE) { |
| 347 | t1 = (value & 0xf) + (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 348 | if (t1 > 0xf) |
| 349 | t1 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 350 | t2 = ((value & 0xf0) >> 4) + (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 351 | if (t2 > 0xf) |
| 352 | t2 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 353 | t3 = ((value & 0xf00) >> 8) + (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 354 | if (t3 > 0xf) |
| 355 | t3 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 356 | t4 = ((value & 0xf000) >> 12) + (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 357 | if (t4 > 0xf) |
| 358 | t4 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 359 | } else { |
| 360 | if ((value & 0xf) > Apwrdelta) |
| 361 | t1 = (value & 0xf) - (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 362 | else |
| 363 | t1 = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 364 | if (((value & 0xf0) >> 4) > Apwrdelta) |
| 365 | t2 = ((value & 0xf0) >> 4) - (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 366 | else |
| 367 | t2 = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 368 | if (((value & 0xf00) >> 8) > Apwrdelta) |
| 369 | t3 = ((value & 0xf00) >> 8) - (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 370 | else |
| 371 | t3 = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 372 | if (((value & 0xf000) >> 12) > Apwrdelta) |
| 373 | t4 = ((value & 0xf000) >> 12) - (Apwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 374 | else |
| 375 | t4 = 0; |
| 376 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 377 | Adata |= ((t1 << 16) + (t2 << 20) + (t3 << 24) + (t4 << 28)); |
| 378 | if (bGpwrdeltaMinus == FALSE) { |
| 379 | t1 = (value & 0xf) + (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 380 | if (t1 > 0xf) |
| 381 | t1 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 382 | t2 = ((value & 0xf0) >> 4) + (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 383 | if (t2 > 0xf) |
| 384 | t2 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 385 | t3 = ((value & 0xf00) >> 8) + (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 386 | if (t3 > 0xf) |
| 387 | t3 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 388 | t4 = ((value & 0xf000) >> 12) + (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 389 | if (t4 > 0xf) |
| 390 | t4 = 0xf; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 391 | } else { |
| 392 | if ((value & 0xf) > Gpwrdelta) |
| 393 | t1 = (value & 0xf) - (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 394 | else |
| 395 | t1 = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 396 | if (((value & 0xf0) >> 4) > Gpwrdelta) |
| 397 | t2 = ((value & 0xf0) >> 4) - (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 398 | else |
| 399 | t2 = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 400 | if (((value & 0xf00) >> 8) > Gpwrdelta) |
| 401 | t3 = ((value & 0xf00) >> 8) - (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 402 | else |
| 403 | t3 = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 404 | if (((value & 0xf000) >> 12) > Gpwrdelta) |
| 405 | t4 = ((value & 0xf000) >> 12) - (Gpwrdelta); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 406 | else |
| 407 | t4 = 0; |
| 408 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 409 | Gdata |= ((t1 << 16) + (t2 << 20) + (t3 << 24) + (t4 << 28)); |
| 410 | data |= (value << 16); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 411 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 412 | /* For 20M/40M Power Delta issue */ |
| 413 | pAd->Tx20MPwrCfgABand[i] = data; |
| 414 | pAd->Tx20MPwrCfgGBand[i] = data; |
| 415 | pAd->Tx40MPwrCfgABand[i] = Adata; |
| 416 | pAd->Tx40MPwrCfgGBand[i] = Gdata; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 417 | |
| 418 | if (data != 0xffffffff) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 419 | RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i * 4, data); |
| 420 | DBGPRINT_RAW(RT_DEBUG_TRACE, |
| 421 | ("20MHz BW, 2.4G band-%lx, Adata = %lx, Gdata = %lx \n", |
| 422 | data, Adata, Gdata)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 423 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 424 | } |
| 425 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 426 | /* |
| 427 | ======================================================================== |
| 428 | |
| 429 | Routine Description: |
| 430 | Read initial channel power parameters from EEPROM |
| 431 | |
| 432 | Arguments: |
| 433 | Adapter Pointer to our adapter |
| 434 | |
| 435 | Return Value: |
| 436 | None |
| 437 | |
| 438 | IRQL = PASSIVE_LEVEL |
| 439 | |
| 440 | Note: |
| 441 | |
| 442 | ======================================================================== |
| 443 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 444 | void RTMPReadChannelPwr(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 445 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 446 | u8 i, choffset; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 447 | EEPROM_TX_PWR_STRUC Power; |
| 448 | EEPROM_TX_PWR_STRUC Power2; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 449 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 450 | /* Read Tx power value for all channels */ |
| 451 | /* Value from 1 - 0x7f. Default value is 24. */ |
| 452 | /* Power value : 2.4G 0x00 (0) ~ 0x1F (31) */ |
| 453 | /* : 5.5G 0xF9 (-7) ~ 0x0F (15) */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 454 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 455 | /* 0. 11b/g, ch1 - ch 14 */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 456 | for (i = 0; i < 7; i++) { |
| 457 | RT28xx_EEPROM_READ16(pAd, EEPROM_G_TX_PWR_OFFSET + i * 2, |
| 458 | Power.word); |
| 459 | RT28xx_EEPROM_READ16(pAd, EEPROM_G_TX2_PWR_OFFSET + i * 2, |
| 460 | Power2.word); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 461 | pAd->TxPower[i * 2].Channel = i * 2 + 1; |
| 462 | pAd->TxPower[i * 2 + 1].Channel = i * 2 + 2; |
| 463 | |
| 464 | if ((Power.field.Byte0 > 31) || (Power.field.Byte0 < 0)) |
| 465 | pAd->TxPower[i * 2].Power = DEFAULT_RF_TX_POWER; |
| 466 | else |
| 467 | pAd->TxPower[i * 2].Power = Power.field.Byte0; |
| 468 | |
| 469 | if ((Power.field.Byte1 > 31) || (Power.field.Byte1 < 0)) |
| 470 | pAd->TxPower[i * 2 + 1].Power = DEFAULT_RF_TX_POWER; |
| 471 | else |
| 472 | pAd->TxPower[i * 2 + 1].Power = Power.field.Byte1; |
| 473 | |
| 474 | if ((Power2.field.Byte0 > 31) || (Power2.field.Byte0 < 0)) |
| 475 | pAd->TxPower[i * 2].Power2 = DEFAULT_RF_TX_POWER; |
| 476 | else |
| 477 | pAd->TxPower[i * 2].Power2 = Power2.field.Byte0; |
| 478 | |
| 479 | if ((Power2.field.Byte1 > 31) || (Power2.field.Byte1 < 0)) |
| 480 | pAd->TxPower[i * 2 + 1].Power2 = DEFAULT_RF_TX_POWER; |
| 481 | else |
| 482 | pAd->TxPower[i * 2 + 1].Power2 = Power2.field.Byte1; |
| 483 | } |
| 484 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 485 | /* 1. U-NII lower/middle band: 36, 38, 40; 44, 46, 48; 52, 54, 56; 60, 62, 64 (including central frequency in BW 40MHz) */ |
| 486 | /* 1.1 Fill up channel */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 487 | choffset = 14; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 488 | for (i = 0; i < 4; i++) { |
| 489 | pAd->TxPower[3 * i + choffset + 0].Channel = 36 + i * 8 + 0; |
| 490 | pAd->TxPower[3 * i + choffset + 0].Power = DEFAULT_RF_TX_POWER; |
| 491 | pAd->TxPower[3 * i + choffset + 0].Power2 = DEFAULT_RF_TX_POWER; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 492 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 493 | pAd->TxPower[3 * i + choffset + 1].Channel = 36 + i * 8 + 2; |
| 494 | pAd->TxPower[3 * i + choffset + 1].Power = DEFAULT_RF_TX_POWER; |
| 495 | pAd->TxPower[3 * i + choffset + 1].Power2 = DEFAULT_RF_TX_POWER; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 496 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 497 | pAd->TxPower[3 * i + choffset + 2].Channel = 36 + i * 8 + 4; |
| 498 | pAd->TxPower[3 * i + choffset + 2].Power = DEFAULT_RF_TX_POWER; |
| 499 | pAd->TxPower[3 * i + choffset + 2].Power2 = DEFAULT_RF_TX_POWER; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 500 | } |
| 501 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 502 | /* 1.2 Fill up power */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 503 | for (i = 0; i < 6; i++) { |
| 504 | RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + i * 2, |
| 505 | Power.word); |
| 506 | RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + i * 2, |
| 507 | Power2.word); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 508 | |
| 509 | if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7)) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 510 | pAd->TxPower[i * 2 + choffset + 0].Power = |
| 511 | Power.field.Byte0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 512 | |
| 513 | if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7)) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 514 | pAd->TxPower[i * 2 + choffset + 1].Power = |
| 515 | Power.field.Byte1; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 516 | |
| 517 | if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7)) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 518 | pAd->TxPower[i * 2 + choffset + 0].Power2 = |
| 519 | Power2.field.Byte0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 520 | |
| 521 | if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7)) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 522 | pAd->TxPower[i * 2 + choffset + 1].Power2 = |
| 523 | Power2.field.Byte1; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 524 | } |
| 525 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 526 | /* 2. HipperLAN 2 100, 102 ,104; 108, 110, 112; 116, 118, 120; 124, 126, 128; 132, 134, 136; 140 (including central frequency in BW 40MHz) */ |
| 527 | /* 2.1 Fill up channel */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 528 | choffset = 14 + 12; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 529 | for (i = 0; i < 5; i++) { |
| 530 | pAd->TxPower[3 * i + choffset + 0].Channel = 100 + i * 8 + 0; |
| 531 | pAd->TxPower[3 * i + choffset + 0].Power = DEFAULT_RF_TX_POWER; |
| 532 | pAd->TxPower[3 * i + choffset + 0].Power2 = DEFAULT_RF_TX_POWER; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 533 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 534 | pAd->TxPower[3 * i + choffset + 1].Channel = 100 + i * 8 + 2; |
| 535 | pAd->TxPower[3 * i + choffset + 1].Power = DEFAULT_RF_TX_POWER; |
| 536 | pAd->TxPower[3 * i + choffset + 1].Power2 = DEFAULT_RF_TX_POWER; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 537 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 538 | pAd->TxPower[3 * i + choffset + 2].Channel = 100 + i * 8 + 4; |
| 539 | pAd->TxPower[3 * i + choffset + 2].Power = DEFAULT_RF_TX_POWER; |
| 540 | pAd->TxPower[3 * i + choffset + 2].Power2 = DEFAULT_RF_TX_POWER; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 541 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 542 | pAd->TxPower[3 * 5 + choffset + 0].Channel = 140; |
| 543 | pAd->TxPower[3 * 5 + choffset + 0].Power = DEFAULT_RF_TX_POWER; |
| 544 | pAd->TxPower[3 * 5 + choffset + 0].Power2 = DEFAULT_RF_TX_POWER; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 545 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 546 | /* 2.2 Fill up power */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 547 | for (i = 0; i < 8; i++) { |
| 548 | RT28xx_EEPROM_READ16(pAd, |
| 549 | EEPROM_A_TX_PWR_OFFSET + (choffset - 14) + |
| 550 | i * 2, Power.word); |
| 551 | RT28xx_EEPROM_READ16(pAd, |
| 552 | EEPROM_A_TX2_PWR_OFFSET + (choffset - 14) + |
| 553 | i * 2, Power2.word); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 554 | |
| 555 | if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7)) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 556 | pAd->TxPower[i * 2 + choffset + 0].Power = |
| 557 | Power.field.Byte0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 558 | |
| 559 | if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7)) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 560 | pAd->TxPower[i * 2 + choffset + 1].Power = |
| 561 | Power.field.Byte1; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 562 | |
| 563 | if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7)) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 564 | pAd->TxPower[i * 2 + choffset + 0].Power2 = |
| 565 | Power2.field.Byte0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 566 | |
| 567 | if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7)) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 568 | pAd->TxPower[i * 2 + choffset + 1].Power2 = |
| 569 | Power2.field.Byte1; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 570 | } |
| 571 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 572 | /* 3. U-NII upper band: 149, 151, 153; 157, 159, 161; 165, 167, 169; 171, 173 (including central frequency in BW 40MHz) */ |
| 573 | /* 3.1 Fill up channel */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 574 | choffset = 14 + 12 + 16; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 575 | /*for (i = 0; i < 2; i++) */ |
| 576 | for (i = 0; i < 3; i++) { |
| 577 | pAd->TxPower[3 * i + choffset + 0].Channel = 149 + i * 8 + 0; |
| 578 | pAd->TxPower[3 * i + choffset + 0].Power = DEFAULT_RF_TX_POWER; |
| 579 | pAd->TxPower[3 * i + choffset + 0].Power2 = DEFAULT_RF_TX_POWER; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 580 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 581 | pAd->TxPower[3 * i + choffset + 1].Channel = 149 + i * 8 + 2; |
| 582 | pAd->TxPower[3 * i + choffset + 1].Power = DEFAULT_RF_TX_POWER; |
| 583 | pAd->TxPower[3 * i + choffset + 1].Power2 = DEFAULT_RF_TX_POWER; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 584 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 585 | pAd->TxPower[3 * i + choffset + 2].Channel = 149 + i * 8 + 4; |
| 586 | pAd->TxPower[3 * i + choffset + 2].Power = DEFAULT_RF_TX_POWER; |
| 587 | pAd->TxPower[3 * i + choffset + 2].Power2 = DEFAULT_RF_TX_POWER; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 588 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 589 | pAd->TxPower[3 * 3 + choffset + 0].Channel = 171; |
| 590 | pAd->TxPower[3 * 3 + choffset + 0].Power = DEFAULT_RF_TX_POWER; |
| 591 | pAd->TxPower[3 * 3 + choffset + 0].Power2 = DEFAULT_RF_TX_POWER; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 592 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 593 | pAd->TxPower[3 * 3 + choffset + 1].Channel = 173; |
| 594 | pAd->TxPower[3 * 3 + choffset + 1].Power = DEFAULT_RF_TX_POWER; |
| 595 | pAd->TxPower[3 * 3 + choffset + 1].Power2 = DEFAULT_RF_TX_POWER; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 596 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 597 | /* 3.2 Fill up power */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 598 | /*for (i = 0; i < 4; i++) */ |
| 599 | for (i = 0; i < 6; i++) { |
| 600 | RT28xx_EEPROM_READ16(pAd, |
| 601 | EEPROM_A_TX_PWR_OFFSET + (choffset - 14) + |
| 602 | i * 2, Power.word); |
| 603 | RT28xx_EEPROM_READ16(pAd, |
| 604 | EEPROM_A_TX2_PWR_OFFSET + (choffset - 14) + |
| 605 | i * 2, Power2.word); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 606 | |
| 607 | if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7)) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 608 | pAd->TxPower[i * 2 + choffset + 0].Power = |
| 609 | Power.field.Byte0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 610 | |
| 611 | if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7)) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 612 | pAd->TxPower[i * 2 + choffset + 1].Power = |
| 613 | Power.field.Byte1; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 614 | |
| 615 | if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7)) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 616 | pAd->TxPower[i * 2 + choffset + 0].Power2 = |
| 617 | Power2.field.Byte0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 618 | |
| 619 | if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7)) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 620 | pAd->TxPower[i * 2 + choffset + 1].Power2 = |
| 621 | Power2.field.Byte1; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 622 | } |
| 623 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 624 | /* 4. Print and Debug */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 625 | /*choffset = 14 + 12 + 16 + 7; */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 626 | choffset = 14 + 12 + 16 + 11; |
| 627 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | /* |
| 631 | ======================================================================== |
| 632 | |
| 633 | Routine Description: |
| 634 | Read the following from the registry |
| 635 | 1. All the parameters |
| 636 | 2. NetworkAddres |
| 637 | |
| 638 | Arguments: |
| 639 | Adapter Pointer to our adapter |
| 640 | WrapperConfigurationContext For use by NdisOpenConfiguration |
| 641 | |
| 642 | Return Value: |
| 643 | NDIS_STATUS_SUCCESS |
| 644 | NDIS_STATUS_FAILURE |
| 645 | NDIS_STATUS_RESOURCES |
| 646 | |
| 647 | IRQL = PASSIVE_LEVEL |
| 648 | |
| 649 | Note: |
| 650 | |
| 651 | ======================================================================== |
| 652 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 653 | int NICReadRegParameters(struct rt_rtmp_adapter *pAd, |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 654 | void *WrapperConfigurationContext) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 655 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 656 | int Status = NDIS_STATUS_SUCCESS; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 657 | DBGPRINT_S(Status, ("<-- NICReadRegParameters, Status=%x\n", Status)); |
| 658 | return Status; |
| 659 | } |
| 660 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 661 | /* |
| 662 | ======================================================================== |
| 663 | |
| 664 | Routine Description: |
| 665 | Read initial parameters from EEPROM |
| 666 | |
| 667 | Arguments: |
| 668 | Adapter Pointer to our adapter |
| 669 | |
| 670 | Return Value: |
| 671 | None |
| 672 | |
| 673 | IRQL = PASSIVE_LEVEL |
| 674 | |
| 675 | Note: |
| 676 | |
| 677 | ======================================================================== |
| 678 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 679 | void NICReadEEPROMParameters(struct rt_rtmp_adapter *pAd, u8 *mac_addr) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 680 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 681 | u32 data = 0; |
| 682 | u16 i, value, value2; |
| 683 | u8 TmpPhy; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 684 | EEPROM_TX_PWR_STRUC Power; |
| 685 | EEPROM_VERSION_STRUC Version; |
| 686 | EEPROM_ANTENNA_STRUC Antenna; |
| 687 | EEPROM_NIC_CONFIG2_STRUC NicConfig2; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 688 | |
| 689 | DBGPRINT(RT_DEBUG_TRACE, ("--> NICReadEEPROMParameters\n")); |
| 690 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 691 | if (pAd->chipOps.eeinit) |
| 692 | pAd->chipOps.eeinit(pAd); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 693 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 694 | /* Init EEPROM Address Number, before access EEPROM; if 93c46, EEPROMAddressNum=6, else if 93c66, EEPROMAddressNum=8 */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 695 | RTMP_IO_READ32(pAd, E2PROM_CSR, &data); |
| 696 | DBGPRINT(RT_DEBUG_TRACE, ("--> E2PROM_CSR = 0x%x\n", data)); |
| 697 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 698 | if ((data & 0x30) == 0) |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 699 | pAd->EEPROMAddressNum = 6; /* 93C46 */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 700 | else if ((data & 0x30) == 0x10) |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 701 | pAd->EEPROMAddressNum = 8; /* 93C66 */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 702 | else |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 703 | pAd->EEPROMAddressNum = 8; /* 93C86 */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 704 | DBGPRINT(RT_DEBUG_TRACE, |
| 705 | ("--> EEPROMAddressNum = %d\n", pAd->EEPROMAddressNum)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 706 | |
Uwe Kleine-König | 9b0131c | 2010-09-01 15:40:25 +0200 | [diff] [blame^] | 707 | /* RT2860 MAC no longer auto load MAC address from E2PROM. Driver has to initialize */ |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 708 | /* MAC address registers according to E2PROM setting */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 709 | if (mac_addr == NULL || |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 710 | strlen((char *)mac_addr) != 17 || |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 711 | mac_addr[2] != ':' || mac_addr[5] != ':' || mac_addr[8] != ':' || |
| 712 | mac_addr[11] != ':' || mac_addr[14] != ':') { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 713 | u16 Addr01, Addr23, Addr45; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 714 | |
| 715 | RT28xx_EEPROM_READ16(pAd, 0x04, Addr01); |
| 716 | RT28xx_EEPROM_READ16(pAd, 0x06, Addr23); |
| 717 | RT28xx_EEPROM_READ16(pAd, 0x08, Addr45); |
| 718 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 719 | pAd->PermanentAddress[0] = (u8)(Addr01 & 0xff); |
| 720 | pAd->PermanentAddress[1] = (u8)(Addr01 >> 8); |
| 721 | pAd->PermanentAddress[2] = (u8)(Addr23 & 0xff); |
| 722 | pAd->PermanentAddress[3] = (u8)(Addr23 >> 8); |
| 723 | pAd->PermanentAddress[4] = (u8)(Addr45 & 0xff); |
| 724 | pAd->PermanentAddress[5] = (u8)(Addr45 >> 8); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 725 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 726 | DBGPRINT(RT_DEBUG_TRACE, |
| 727 | ("Initialize MAC Address from E2PROM \n")); |
| 728 | } else { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 729 | int j; |
| 730 | char *macptr; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 731 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 732 | macptr = (char *)mac_addr; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 733 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 734 | for (j = 0; j < MAC_ADDR_LEN; j++) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 735 | AtoH(macptr, &pAd->PermanentAddress[j], 1); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 736 | macptr = macptr + 3; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 737 | } |
| 738 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 739 | DBGPRINT(RT_DEBUG_TRACE, |
| 740 | ("Initialize MAC Address from module parameter \n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 741 | } |
| 742 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 743 | { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 744 | /*more conveninet to test mbssid, so ap's bssid &0xf1 */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 745 | if (pAd->PermanentAddress[0] == 0xff) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 746 | pAd->PermanentAddress[0] = RandomByte(pAd) & 0xf8; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 747 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 748 | /*if (pAd->PermanentAddress[5] == 0xff) */ |
| 749 | /* pAd->PermanentAddress[5] = RandomByte(pAd)&0xf8; */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 750 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 751 | DBGPRINT_RAW(RT_DEBUG_TRACE, |
| 752 | ("E2PROM MAC: =%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 753 | pAd->PermanentAddress[0], |
| 754 | pAd->PermanentAddress[1], |
| 755 | pAd->PermanentAddress[2], |
| 756 | pAd->PermanentAddress[3], |
| 757 | pAd->PermanentAddress[4], |
| 758 | pAd->PermanentAddress[5])); |
| 759 | if (pAd->bLocalAdminMAC == FALSE) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 760 | MAC_DW0_STRUC csr2; |
| 761 | MAC_DW1_STRUC csr3; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 762 | COPY_MAC_ADDR(pAd->CurrentAddress, |
| 763 | pAd->PermanentAddress); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 764 | csr2.field.Byte0 = pAd->CurrentAddress[0]; |
| 765 | csr2.field.Byte1 = pAd->CurrentAddress[1]; |
| 766 | csr2.field.Byte2 = pAd->CurrentAddress[2]; |
| 767 | csr2.field.Byte3 = pAd->CurrentAddress[3]; |
| 768 | RTMP_IO_WRITE32(pAd, MAC_ADDR_DW0, csr2.word); |
| 769 | csr3.word = 0; |
| 770 | csr3.field.Byte4 = pAd->CurrentAddress[4]; |
| 771 | csr3.field.Byte5 = pAd->CurrentAddress[5]; |
| 772 | csr3.field.U2MeMask = 0xff; |
| 773 | RTMP_IO_WRITE32(pAd, MAC_ADDR_DW1, csr3.word); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 774 | DBGPRINT_RAW(RT_DEBUG_TRACE, |
| 775 | ("E2PROM MAC: =%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 776 | PRINT_MAC(pAd->PermanentAddress))); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 777 | } |
| 778 | } |
| 779 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 780 | /* if not return early. cause fail at emulation. */ |
| 781 | /* Init the channel number for TX channel power */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 782 | RTMPReadChannelPwr(pAd); |
| 783 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 784 | /* if E2PROM version mismatch with driver's expectation, then skip */ |
| 785 | /* all subsequent E2RPOM retieval and set a system error bit to notify GUI */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 786 | RT28xx_EEPROM_READ16(pAd, EEPROM_VERSION_OFFSET, Version.word); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 787 | pAd->EepromVersion = |
| 788 | Version.field.Version + Version.field.FaeReleaseNumber * 256; |
| 789 | DBGPRINT(RT_DEBUG_TRACE, |
| 790 | ("E2PROM: Version = %d, FAE release #%d\n", |
| 791 | Version.field.Version, Version.field.FaeReleaseNumber)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 792 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 793 | if (Version.field.Version > VALID_EEPROM_VERSION) { |
| 794 | DBGPRINT_ERR(("E2PROM: WRONG VERSION 0x%x, should be %d\n", |
| 795 | Version.field.Version, VALID_EEPROM_VERSION)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 796 | /*pAd->SystemErrorBitmap |= 0x00000001; |
| 797 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 798 | // hard-code default value when no proper E2PROM installed |
| 799 | pAd->bAutoTxAgcA = FALSE; |
| 800 | pAd->bAutoTxAgcG = FALSE; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 801 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 802 | // Default the channel power |
| 803 | for (i = 0; i < MAX_NUM_OF_CHANNELS; i++) |
| 804 | pAd->TxPower[i].Power = DEFAULT_RF_TX_POWER; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 805 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 806 | // Default the channel power |
| 807 | for (i = 0; i < MAX_NUM_OF_11JCHANNELS; i++) |
| 808 | pAd->TxPower11J[i].Power = DEFAULT_RF_TX_POWER; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 809 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 810 | for(i = 0; i < NUM_EEPROM_BBP_PARMS; i++) |
| 811 | pAd->EEPROMDefaultValue[i] = 0xffff; |
| 812 | return; */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 813 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 814 | /* Read BBP default value from EEPROM and store to array(EEPROMDefaultValue) in pAd */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 815 | RT28xx_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET, value); |
| 816 | pAd->EEPROMDefaultValue[0] = value; |
| 817 | |
| 818 | RT28xx_EEPROM_READ16(pAd, EEPROM_NIC2_OFFSET, value); |
| 819 | pAd->EEPROMDefaultValue[1] = value; |
| 820 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 821 | RT28xx_EEPROM_READ16(pAd, 0x38, value); /* Country Region */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 822 | pAd->EEPROMDefaultValue[2] = value; |
| 823 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 824 | for (i = 0; i < 8; i++) { |
| 825 | RT28xx_EEPROM_READ16(pAd, EEPROM_BBP_BASE_OFFSET + i * 2, |
| 826 | value); |
| 827 | pAd->EEPROMDefaultValue[i + 3] = value; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 828 | } |
| 829 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 830 | /* We have to parse NIC configuration 0 at here. */ |
| 831 | /* If TSSI did not have preloaded value, it should reset the TxAutoAgc to false */ |
| 832 | /* Therefore, we have to read TxAutoAgc control beforehand. */ |
| 833 | /* Read Tx AGC control bit */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 834 | Antenna.word = pAd->EEPROMDefaultValue[0]; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 835 | if (Antenna.word == 0xFFFF) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 836 | #ifdef RT30xx |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 837 | if (IS_RT3090(pAd) || IS_RT3390(pAd)) { |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 838 | Antenna.word = 0; |
| 839 | Antenna.field.RfIcType = RFIC_3020; |
| 840 | Antenna.field.TxPath = 1; |
| 841 | Antenna.field.RxPath = 1; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 842 | } else |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 843 | #endif /* RT30xx // */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 844 | { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 845 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 846 | Antenna.word = 0; |
| 847 | Antenna.field.RfIcType = RFIC_2820; |
| 848 | Antenna.field.TxPath = 1; |
| 849 | Antenna.field.RxPath = 2; |
| 850 | DBGPRINT(RT_DEBUG_WARN, |
| 851 | ("E2PROM error, hard code as 0x%04x\n", |
| 852 | Antenna.word)); |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 853 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 854 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 855 | /* Choose the desired Tx&Rx stream. */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 856 | if ((pAd->CommonCfg.TxStream == 0) |
| 857 | || (pAd->CommonCfg.TxStream > Antenna.field.TxPath)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 858 | pAd->CommonCfg.TxStream = Antenna.field.TxPath; |
| 859 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 860 | if ((pAd->CommonCfg.RxStream == 0) |
| 861 | || (pAd->CommonCfg.RxStream > Antenna.field.RxPath)) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 862 | pAd->CommonCfg.RxStream = Antenna.field.RxPath; |
| 863 | |
| 864 | if ((pAd->MACVersion < RALINK_2883_VERSION) && |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 865 | (pAd->CommonCfg.RxStream > 2)) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 866 | /* only 2 Rx streams for RT2860 series */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 867 | pAd->CommonCfg.RxStream = 2; |
| 868 | } |
| 869 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 870 | /* 3*3 */ |
| 871 | /* read value from EEPROM and set them to CSR174 ~ 177 in chain0 ~ chain2 */ |
| 872 | /* yet implement */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 873 | for (i = 0; i < 3; i++) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 874 | } |
| 875 | |
| 876 | NicConfig2.word = pAd->EEPROMDefaultValue[1]; |
| 877 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 878 | { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 879 | if ((NicConfig2.word & 0x00ff) == 0xff) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 880 | NicConfig2.word &= 0xff00; |
| 881 | } |
| 882 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 883 | if ((NicConfig2.word >> 8) == 0xff) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 884 | NicConfig2.word &= 0x00ff; |
| 885 | } |
| 886 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 887 | |
| 888 | if (NicConfig2.field.DynamicTxAgcControl == 1) |
| 889 | pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = TRUE; |
| 890 | else |
| 891 | pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = FALSE; |
| 892 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 893 | DBGPRINT_RAW(RT_DEBUG_TRACE, |
| 894 | ("NICReadEEPROMParameters: RxPath = %d, TxPath = %d\n", |
| 895 | Antenna.field.RxPath, Antenna.field.TxPath)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 896 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 897 | /* Save the antenna for future use */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 898 | pAd->Antenna.word = Antenna.word; |
| 899 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 900 | /* Set the RfICType here, then we can initialize RFIC related operation callbacks */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 901 | pAd->Mlme.RealRxPath = (u8)Antenna.field.RxPath; |
| 902 | pAd->RfIcType = (u8)Antenna.field.RfIcType; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 903 | |
| 904 | #ifdef RTMP_RF_RW_SUPPORT |
| 905 | RtmpChipOpsRFHook(pAd); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 906 | #endif /* RTMP_RF_RW_SUPPORT // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 907 | |
| 908 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 909 | sprintf((char *)pAd->nickname, "RT2860STA"); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 910 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 911 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 912 | /* */ |
| 913 | /* Reset PhyMode if we don't support 802.11a */ |
| 914 | /* Only RFIC_2850 & RFIC_2750 support 802.11a */ |
| 915 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 916 | if ((Antenna.field.RfIcType != RFIC_2850) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 917 | && (Antenna.field.RfIcType != RFIC_2750) |
| 918 | && (Antenna.field.RfIcType != RFIC_3052)) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 919 | if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED) || |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 920 | (pAd->CommonCfg.PhyMode == PHY_11A)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 921 | pAd->CommonCfg.PhyMode = PHY_11BG_MIXED; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 922 | else if ((pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) || |
| 923 | (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED) || |
| 924 | (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED) || |
| 925 | (pAd->CommonCfg.PhyMode == PHY_11N_5G)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 926 | pAd->CommonCfg.PhyMode = PHY_11BGN_MIXED; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 927 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 928 | /* Read TSSI reference and TSSI boundary for temperature compensation. This is ugly */ |
| 929 | /* 0. 11b/g */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 930 | { |
| 931 | /* these are tempature reference value (0x00 ~ 0xFE) |
| 932 | ex: 0x00 0x15 0x25 0x45 0x88 0xA0 0xB5 0xD0 0xF0 |
| 933 | TssiPlusBoundaryG [4] [3] [2] [1] [0] (smaller) + |
| 934 | TssiMinusBoundaryG[0] [1] [2] [3] [4] (larger) */ |
| 935 | RT28xx_EEPROM_READ16(pAd, 0x6E, Power.word); |
| 936 | pAd->TssiMinusBoundaryG[4] = Power.field.Byte0; |
| 937 | pAd->TssiMinusBoundaryG[3] = Power.field.Byte1; |
| 938 | RT28xx_EEPROM_READ16(pAd, 0x70, Power.word); |
| 939 | pAd->TssiMinusBoundaryG[2] = Power.field.Byte0; |
| 940 | pAd->TssiMinusBoundaryG[1] = Power.field.Byte1; |
| 941 | RT28xx_EEPROM_READ16(pAd, 0x72, Power.word); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 942 | pAd->TssiRefG = Power.field.Byte0; /* reference value [0] */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 943 | pAd->TssiPlusBoundaryG[1] = Power.field.Byte1; |
| 944 | RT28xx_EEPROM_READ16(pAd, 0x74, Power.word); |
| 945 | pAd->TssiPlusBoundaryG[2] = Power.field.Byte0; |
| 946 | pAd->TssiPlusBoundaryG[3] = Power.field.Byte1; |
| 947 | RT28xx_EEPROM_READ16(pAd, 0x76, Power.word); |
| 948 | pAd->TssiPlusBoundaryG[4] = Power.field.Byte0; |
| 949 | pAd->TxAgcStepG = Power.field.Byte1; |
| 950 | pAd->TxAgcCompensateG = 0; |
| 951 | pAd->TssiMinusBoundaryG[0] = pAd->TssiRefG; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 952 | pAd->TssiPlusBoundaryG[0] = pAd->TssiRefG; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 953 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 954 | /* Disable TxAgc if the based value is not right */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 955 | if (pAd->TssiRefG == 0xff) |
| 956 | pAd->bAutoTxAgcG = FALSE; |
| 957 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 958 | DBGPRINT(RT_DEBUG_TRACE, |
| 959 | ("E2PROM: G Tssi[-4 .. +4] = %d %d %d %d - %d -%d %d %d %d, step=%d, tuning=%d\n", |
| 960 | pAd->TssiMinusBoundaryG[4], |
| 961 | pAd->TssiMinusBoundaryG[3], |
| 962 | pAd->TssiMinusBoundaryG[2], |
| 963 | pAd->TssiMinusBoundaryG[1], pAd->TssiRefG, |
| 964 | pAd->TssiPlusBoundaryG[1], pAd->TssiPlusBoundaryG[2], |
| 965 | pAd->TssiPlusBoundaryG[3], pAd->TssiPlusBoundaryG[4], |
| 966 | pAd->TxAgcStepG, pAd->bAutoTxAgcG)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 967 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 968 | /* 1. 11a */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 969 | { |
| 970 | RT28xx_EEPROM_READ16(pAd, 0xD4, Power.word); |
| 971 | pAd->TssiMinusBoundaryA[4] = Power.field.Byte0; |
| 972 | pAd->TssiMinusBoundaryA[3] = Power.field.Byte1; |
| 973 | RT28xx_EEPROM_READ16(pAd, 0xD6, Power.word); |
| 974 | pAd->TssiMinusBoundaryA[2] = Power.field.Byte0; |
| 975 | pAd->TssiMinusBoundaryA[1] = Power.field.Byte1; |
| 976 | RT28xx_EEPROM_READ16(pAd, 0xD8, Power.word); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 977 | pAd->TssiRefA = Power.field.Byte0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 978 | pAd->TssiPlusBoundaryA[1] = Power.field.Byte1; |
| 979 | RT28xx_EEPROM_READ16(pAd, 0xDA, Power.word); |
| 980 | pAd->TssiPlusBoundaryA[2] = Power.field.Byte0; |
| 981 | pAd->TssiPlusBoundaryA[3] = Power.field.Byte1; |
| 982 | RT28xx_EEPROM_READ16(pAd, 0xDC, Power.word); |
| 983 | pAd->TssiPlusBoundaryA[4] = Power.field.Byte0; |
| 984 | pAd->TxAgcStepA = Power.field.Byte1; |
| 985 | pAd->TxAgcCompensateA = 0; |
| 986 | pAd->TssiMinusBoundaryA[0] = pAd->TssiRefA; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 987 | pAd->TssiPlusBoundaryA[0] = pAd->TssiRefA; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 988 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 989 | /* Disable TxAgc if the based value is not right */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 990 | if (pAd->TssiRefA == 0xff) |
| 991 | pAd->bAutoTxAgcA = FALSE; |
| 992 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 993 | DBGPRINT(RT_DEBUG_TRACE, |
| 994 | ("E2PROM: A Tssi[-4 .. +4] = %d %d %d %d - %d -%d %d %d %d, step=%d, tuning=%d\n", |
| 995 | pAd->TssiMinusBoundaryA[4], |
| 996 | pAd->TssiMinusBoundaryA[3], |
| 997 | pAd->TssiMinusBoundaryA[2], |
| 998 | pAd->TssiMinusBoundaryA[1], pAd->TssiRefA, |
| 999 | pAd->TssiPlusBoundaryA[1], pAd->TssiPlusBoundaryA[2], |
| 1000 | pAd->TssiPlusBoundaryA[3], pAd->TssiPlusBoundaryA[4], |
| 1001 | pAd->TxAgcStepA, pAd->bAutoTxAgcA)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1002 | } |
| 1003 | pAd->BbpRssiToDbmDelta = 0x0; |
| 1004 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1005 | /* Read frequency offset setting for RF */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1006 | RT28xx_EEPROM_READ16(pAd, EEPROM_FREQ_OFFSET, value); |
| 1007 | if ((value & 0x00FF) != 0x00FF) |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1008 | pAd->RfFreqOffset = (unsigned long)(value & 0x00FF); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1009 | else |
| 1010 | pAd->RfFreqOffset = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1011 | DBGPRINT(RT_DEBUG_TRACE, |
| 1012 | ("E2PROM: RF FreqOffset=0x%lx \n", pAd->RfFreqOffset)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1013 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1014 | /*CountryRegion byte offset (38h) */ |
| 1015 | value = pAd->EEPROMDefaultValue[2] >> 8; /* 2.4G band */ |
| 1016 | value2 = pAd->EEPROMDefaultValue[2] & 0x00FF; /* 5G band */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1017 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1018 | if ((value <= REGION_MAXIMUM_BG_BAND) |
| 1019 | && (value2 <= REGION_MAXIMUM_A_BAND)) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1020 | pAd->CommonCfg.CountryRegion = ((u8)value) | 0x80; |
| 1021 | pAd->CommonCfg.CountryRegionForABand = ((u8)value2) | 0x80; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1022 | TmpPhy = pAd->CommonCfg.PhyMode; |
| 1023 | pAd->CommonCfg.PhyMode = 0xff; |
| 1024 | RTMPSetPhyMode(pAd, TmpPhy); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1025 | SetCommonHT(pAd); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1026 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1027 | /* */ |
| 1028 | /* Get RSSI Offset on EEPROM 0x9Ah & 0x9Ch. */ |
| 1029 | /* The valid value are (-10 ~ 10) */ |
| 1030 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1031 | RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET, value); |
| 1032 | pAd->BGRssiOffset0 = value & 0x00ff; |
| 1033 | pAd->BGRssiOffset1 = (value >> 8); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1034 | RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET + 2, value); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1035 | pAd->BGRssiOffset2 = value & 0x00ff; |
| 1036 | pAd->ALNAGain1 = (value >> 8); |
| 1037 | RT28xx_EEPROM_READ16(pAd, EEPROM_LNA_OFFSET, value); |
| 1038 | pAd->BLNAGain = value & 0x00ff; |
| 1039 | pAd->ALNAGain0 = (value >> 8); |
| 1040 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1041 | /* Validate 11b/g RSSI_0 offset. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1042 | if ((pAd->BGRssiOffset0 < -10) || (pAd->BGRssiOffset0 > 10)) |
| 1043 | pAd->BGRssiOffset0 = 0; |
| 1044 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1045 | /* Validate 11b/g RSSI_1 offset. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1046 | if ((pAd->BGRssiOffset1 < -10) || (pAd->BGRssiOffset1 > 10)) |
| 1047 | pAd->BGRssiOffset1 = 0; |
| 1048 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1049 | /* Validate 11b/g RSSI_2 offset. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1050 | if ((pAd->BGRssiOffset2 < -10) || (pAd->BGRssiOffset2 > 10)) |
| 1051 | pAd->BGRssiOffset2 = 0; |
| 1052 | |
| 1053 | RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_A_OFFSET, value); |
| 1054 | pAd->ARssiOffset0 = value & 0x00ff; |
| 1055 | pAd->ARssiOffset1 = (value >> 8); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1056 | RT28xx_EEPROM_READ16(pAd, (EEPROM_RSSI_A_OFFSET + 2), value); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1057 | pAd->ARssiOffset2 = value & 0x00ff; |
| 1058 | pAd->ALNAGain2 = (value >> 8); |
| 1059 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1060 | if (((u8)pAd->ALNAGain1 == 0xFF) || (pAd->ALNAGain1 == 0x00)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1061 | pAd->ALNAGain1 = pAd->ALNAGain0; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1062 | if (((u8)pAd->ALNAGain2 == 0xFF) || (pAd->ALNAGain2 == 0x00)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1063 | pAd->ALNAGain2 = pAd->ALNAGain0; |
| 1064 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1065 | /* Validate 11a RSSI_0 offset. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1066 | if ((pAd->ARssiOffset0 < -10) || (pAd->ARssiOffset0 > 10)) |
| 1067 | pAd->ARssiOffset0 = 0; |
| 1068 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1069 | /* Validate 11a RSSI_1 offset. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1070 | if ((pAd->ARssiOffset1 < -10) || (pAd->ARssiOffset1 > 10)) |
| 1071 | pAd->ARssiOffset1 = 0; |
| 1072 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1073 | /*Validate 11a RSSI_2 offset. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1074 | if ((pAd->ARssiOffset2 < -10) || (pAd->ARssiOffset2 > 10)) |
| 1075 | pAd->ARssiOffset2 = 0; |
| 1076 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1077 | #ifdef RT30xx |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1078 | /* */ |
| 1079 | /* Get TX mixer gain setting */ |
| 1080 | /* 0xff are invalid value */ |
| 1081 | /* Note: RT30xX default value is 0x00 and will program to RF_R17 only when this value is not zero. */ |
| 1082 | /* RT359X default value is 0x02 */ |
| 1083 | /* */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1084 | if (IS_RT30xx(pAd) || IS_RT3572(pAd)) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1085 | RT28xx_EEPROM_READ16(pAd, EEPROM_TXMIXER_GAIN_2_4G, value); |
| 1086 | pAd->TxMixerGain24G = 0; |
| 1087 | value &= 0x00ff; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1088 | if (value != 0xff) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1089 | value &= 0x07; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1090 | pAd->TxMixerGain24G = (u8)value; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1091 | } |
| 1092 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1093 | #endif /* RT30xx // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1094 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1095 | /* */ |
| 1096 | /* Get LED Setting. */ |
| 1097 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1098 | RT28xx_EEPROM_READ16(pAd, 0x3a, value); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1099 | pAd->LedCntl.word = (value >> 8); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1100 | RT28xx_EEPROM_READ16(pAd, EEPROM_LED1_OFFSET, value); |
| 1101 | pAd->Led1 = value; |
| 1102 | RT28xx_EEPROM_READ16(pAd, EEPROM_LED2_OFFSET, value); |
| 1103 | pAd->Led2 = value; |
| 1104 | RT28xx_EEPROM_READ16(pAd, EEPROM_LED3_OFFSET, value); |
| 1105 | pAd->Led3 = value; |
| 1106 | |
| 1107 | RTMPReadTxPwrPerRate(pAd); |
| 1108 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1109 | #ifdef RT30xx |
| 1110 | #ifdef RTMP_EFUSE_SUPPORT |
| 1111 | RtmpEfuseSupportCheck(pAd); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1112 | #endif /* RTMP_EFUSE_SUPPORT // */ |
| 1113 | #endif /* RT30xx // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1114 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1115 | DBGPRINT(RT_DEBUG_TRACE, ("<-- NICReadEEPROMParameters\n")); |
| 1116 | } |
| 1117 | |
| 1118 | /* |
| 1119 | ======================================================================== |
| 1120 | |
| 1121 | Routine Description: |
| 1122 | Set default value from EEPROM |
| 1123 | |
| 1124 | Arguments: |
| 1125 | Adapter Pointer to our adapter |
| 1126 | |
| 1127 | Return Value: |
| 1128 | None |
| 1129 | |
| 1130 | IRQL = PASSIVE_LEVEL |
| 1131 | |
| 1132 | Note: |
| 1133 | |
| 1134 | ======================================================================== |
| 1135 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1136 | void NICInitAsicFromEEPROM(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1137 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1138 | u32 data = 0; |
| 1139 | u8 BBPR1 = 0; |
| 1140 | u16 i; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1141 | /* EEPROM_ANTENNA_STRUC Antenna; */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1142 | EEPROM_NIC_CONFIG2_STRUC NicConfig2; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1143 | u8 BBPR3 = 0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1144 | |
| 1145 | DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitAsicFromEEPROM\n")); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1146 | for (i = 3; i < NUM_EEPROM_BBP_PARMS; i++) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1147 | u8 BbpRegIdx, BbpValue; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1148 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1149 | if ((pAd->EEPROMDefaultValue[i] != 0xFFFF) |
| 1150 | && (pAd->EEPROMDefaultValue[i] != 0)) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1151 | BbpRegIdx = (u8)(pAd->EEPROMDefaultValue[i] >> 8); |
| 1152 | BbpValue = (u8)(pAd->EEPROMDefaultValue[i] & 0xff); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1153 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BbpRegIdx, BbpValue); |
| 1154 | } |
| 1155 | } |
| 1156 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1157 | NicConfig2.word = pAd->EEPROMDefaultValue[1]; |
| 1158 | |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1159 | { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1160 | if ((NicConfig2.word & 0x00ff) == 0xff) { |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1161 | NicConfig2.word &= 0xff00; |
| 1162 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1163 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1164 | if ((NicConfig2.word >> 8) == 0xff) { |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1165 | NicConfig2.word &= 0x00ff; |
| 1166 | } |
| 1167 | } |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1168 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1169 | /* Save the antenna for future use */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1170 | pAd->NicConfig2.word = NicConfig2.word; |
| 1171 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1172 | #ifdef RT30xx |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1173 | /* set default antenna as main */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1174 | if (pAd->RfIcType == RFIC_3020) |
| 1175 | AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1176 | #endif /* RT30xx // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1177 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1178 | /* */ |
| 1179 | /* Send LED Setting to MCU. */ |
| 1180 | /* */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1181 | if (pAd->LedCntl.word == 0xFF) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1182 | pAd->LedCntl.word = 0x01; |
| 1183 | pAd->Led1 = 0x5555; |
| 1184 | pAd->Led2 = 0x2221; |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1185 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1186 | #ifdef RTMP_MAC_PCI |
| 1187 | pAd->Led3 = 0xA9F8; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1188 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1189 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1190 | pAd->Led3 = 0x5627; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1191 | #endif /* RTMP_MAC_USB // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1192 | } |
| 1193 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1194 | AsicSendCommandToMcu(pAd, 0x52, 0xff, (u8)pAd->Led1, |
| 1195 | (u8)(pAd->Led1 >> 8)); |
| 1196 | AsicSendCommandToMcu(pAd, 0x53, 0xff, (u8)pAd->Led2, |
| 1197 | (u8)(pAd->Led2 >> 8)); |
| 1198 | AsicSendCommandToMcu(pAd, 0x54, 0xff, (u8)pAd->Led3, |
| 1199 | (u8)(pAd->Led3 >> 8)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1200 | AsicSendCommandToMcu(pAd, 0x51, 0xff, 0, pAd->LedCntl.field.Polarity); |
| 1201 | |
| 1202 | pAd->LedIndicatorStrength = 0xFF; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1203 | RTMPSetSignalLED(pAd, -100); /* Force signal strength Led to be turned off, before link up */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1204 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1205 | { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1206 | /* Read Hardware controlled Radio state enable bit */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1207 | if (NicConfig2.field.HardwareRadioControl == 1) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1208 | pAd->StaCfg.bHardwareRadio = TRUE; |
| 1209 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1210 | /* Read GPIO pin2 as Hardware controlled radio state */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1211 | RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &data); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1212 | if ((data & 0x04) == 0) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1213 | pAd->StaCfg.bHwRadio = FALSE; |
| 1214 | pAd->StaCfg.bRadio = FALSE; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1215 | /* RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x00001818); */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1216 | RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF); |
| 1217 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1218 | } else |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1219 | pAd->StaCfg.bHardwareRadio = FALSE; |
| 1220 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1221 | if (pAd->StaCfg.bRadio == FALSE) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1222 | RTMPSetLED(pAd, LED_RADIO_OFF); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1223 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1224 | RTMPSetLED(pAd, LED_RADIO_ON); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1225 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1226 | #ifdef RT3090 |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1227 | AsicSendCommandToMcu(pAd, 0x30, PowerRadioOffCID, 0xff, |
| 1228 | 0x02); |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1229 | AsicCheckCommanOk(pAd, PowerRadioOffCID); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1230 | #endif /* RT3090 // */ |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1231 | #ifndef RT3090 |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1232 | AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1233 | #endif /* RT3090 // */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1234 | AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, |
| 1235 | 0x00); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1236 | /* 2-1. wait command ok. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1237 | AsicCheckCommanOk(pAd, PowerWakeCID); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1238 | #endif /* RTMP_MAC_PCI // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1239 | } |
| 1240 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1241 | |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1242 | #ifdef RTMP_MAC_PCI |
| 1243 | #ifdef RT30xx |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1244 | if (IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1245 | struct rt_rtmp_chip_op *pChipOps = &pAd->chipOps; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1246 | if (pChipOps->AsicReverseRfFromSleepMode) |
| 1247 | pChipOps->AsicReverseRfFromSleepMode(pAd); |
| 1248 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1249 | /* 3090 MCU Wakeup command needs more time to be stable. */ |
| 1250 | /* Before stable, don't issue other MCU command to prevent from firmware error. */ |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1251 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1252 | if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) |
| 1253 | && IS_VERSION_AFTER_F(pAd) |
| 1254 | && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3) |
| 1255 | && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)) { |
| 1256 | DBGPRINT(RT_DEBUG_TRACE, ("%s, release Mcu Lock\n", __func__)); |
| 1257 | RTMP_SEM_LOCK(&pAd->McuCmdLock); |
| 1258 | pAd->brt30xxBanMcuCmd = FALSE; |
| 1259 | RTMP_SEM_UNLOCK(&pAd->McuCmdLock); |
| 1260 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1261 | #endif /* RT30xx // */ |
| 1262 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1263 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1264 | /* Turn off patching for cardbus controller */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1265 | if (NicConfig2.field.CardbusAcceleration == 1) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1266 | /* pAd->bTest1 = TRUE; */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1267 | } |
| 1268 | |
| 1269 | if (NicConfig2.field.DynamicTxAgcControl == 1) |
| 1270 | pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = TRUE; |
| 1271 | else |
| 1272 | pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = FALSE; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1273 | /* */ |
| 1274 | /* Since BBP has been progamed, to make sure BBP setting will be */ |
Sebastian Dalfuß | 06aea99 | 2009-11-07 17:31:12 +0100 | [diff] [blame] | 1275 | /* upate inside of AsicAntennaSelect, so reset to UNKNOWN_BAND! */ |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1276 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1277 | pAd->CommonCfg.BandState = UNKNOWN_BAND; |
| 1278 | |
| 1279 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3); |
| 1280 | BBPR3 &= (~0x18); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1281 | if (pAd->Antenna.field.RxPath == 3) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1282 | BBPR3 |= (0x10); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1283 | } else if (pAd->Antenna.field.RxPath == 2) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1284 | BBPR3 |= (0x8); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1285 | } else if (pAd->Antenna.field.RxPath == 1) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1286 | BBPR3 |= (0x0); |
| 1287 | } |
| 1288 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3); |
| 1289 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1290 | { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1291 | /* Handle the difference when 1T */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1292 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BBPR1); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1293 | if (pAd->Antenna.field.TxPath == 1) { |
| 1294 | BBPR1 &= (~0x18); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1295 | } |
| 1296 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BBPR1); |
| 1297 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1298 | DBGPRINT(RT_DEBUG_TRACE, |
| 1299 | ("Use Hw Radio Control Pin=%d; if used Pin=%d;\n", |
| 1300 | pAd->CommonCfg.bHardwareRadio, |
| 1301 | pAd->CommonCfg.bHardwareRadio)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1302 | } |
Bartlomiej Zolnierkiewicz | 6a28a69a | 2009-04-26 16:05:46 +0200 | [diff] [blame] | 1303 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1304 | #ifdef RTMP_MAC_USB |
| 1305 | #ifdef RT30xx |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1306 | /* update registers from EEPROM for RT3071 or later(3572/3592). */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1307 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1308 | if (IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1309 | u8 RegIdx, RegValue; |
| 1310 | u16 value; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1311 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1312 | /* after RT3071, write BBP from EEPROM 0xF0 to 0x102 */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1313 | for (i = 0xF0; i <= 0x102; i = i + 2) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1314 | value = 0xFFFF; |
| 1315 | RT28xx_EEPROM_READ16(pAd, i, value); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1316 | if ((value != 0xFFFF) && (value != 0)) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1317 | RegIdx = (u8)(value >> 8); |
| 1318 | RegValue = (u8)(value & 0xff); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1319 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, RegIdx, |
| 1320 | RegValue); |
| 1321 | DBGPRINT(RT_DEBUG_TRACE, |
| 1322 | ("Update BBP Registers from EEPROM(0x%0x), BBP(0x%x) = 0x%x\n", |
| 1323 | i, RegIdx, RegValue)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1324 | } |
| 1325 | } |
| 1326 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1327 | /* after RT3071, write RF from EEPROM 0x104 to 0x116 */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1328 | for (i = 0x104; i <= 0x116; i = i + 2) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1329 | value = 0xFFFF; |
| 1330 | RT28xx_EEPROM_READ16(pAd, i, value); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1331 | if ((value != 0xFFFF) && (value != 0)) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1332 | RegIdx = (u8)(value >> 8); |
| 1333 | RegValue = (u8)(value & 0xff); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1334 | RT30xxWriteRFRegister(pAd, RegIdx, RegValue); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1335 | DBGPRINT(RT_DEBUG_TRACE, |
| 1336 | ("Update RF Registers from EEPROM0x%x), BBP(0x%x) = 0x%x\n", |
| 1337 | i, RegIdx, RegValue)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1338 | } |
| 1339 | } |
| 1340 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1341 | #endif /* RT30xx // */ |
| 1342 | #endif /* RTMP_MAC_USB // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1343 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1344 | DBGPRINT(RT_DEBUG_TRACE, |
| 1345 | ("TxPath = %d, RxPath = %d, RFIC=%d, Polar+LED mode=%x\n", |
| 1346 | pAd->Antenna.field.TxPath, pAd->Antenna.field.RxPath, |
| 1347 | pAd->RfIcType, pAd->LedCntl.word)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1348 | DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitAsicFromEEPROM\n")); |
| 1349 | } |
| 1350 | |
| 1351 | /* |
| 1352 | ======================================================================== |
| 1353 | |
| 1354 | Routine Description: |
| 1355 | Initialize NIC hardware |
| 1356 | |
| 1357 | Arguments: |
| 1358 | Adapter Pointer to our adapter |
| 1359 | |
| 1360 | Return Value: |
| 1361 | None |
| 1362 | |
| 1363 | IRQL = PASSIVE_LEVEL |
| 1364 | |
| 1365 | Note: |
| 1366 | |
| 1367 | ======================================================================== |
| 1368 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1369 | int NICInitializeAdapter(struct rt_rtmp_adapter *pAd, IN BOOLEAN bHardReset) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1370 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1371 | int Status = NDIS_STATUS_SUCCESS; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1372 | WPDMA_GLO_CFG_STRUC GloCfg; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1373 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1374 | u32 Value; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1375 | DELAY_INT_CFG_STRUC IntCfg; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1376 | #endif /* RTMP_MAC_PCI // */ |
| 1377 | /* INT_MASK_CSR_STRUC IntMask; */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1378 | unsigned long i = 0, j = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1379 | AC_TXOP_CSR0_STRUC csr0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1380 | |
| 1381 | DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitializeAdapter\n")); |
| 1382 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1383 | /* 3. Set DMA global configuration except TX_DMA_EN and RX_DMA_EN bits: */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1384 | retry: |
| 1385 | i = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1386 | do { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1387 | RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1388 | if ((GloCfg.field.TxDMABusy == 0) |
| 1389 | && (GloCfg.field.RxDMABusy == 0)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1390 | break; |
| 1391 | |
| 1392 | RTMPusecDelay(1000); |
| 1393 | i++; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1394 | } while (i < 100); |
| 1395 | DBGPRINT(RT_DEBUG_TRACE, |
| 1396 | ("<== DMA offset 0x208 = 0x%x\n", GloCfg.word)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1397 | GloCfg.word &= 0xff0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1398 | GloCfg.field.EnTXWriteBackDDONE = 1; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1399 | RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word); |
| 1400 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1401 | /* Record HW Beacon offset */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1402 | pAd->BeaconOffset[0] = HW_BEACON_BASE0; |
| 1403 | pAd->BeaconOffset[1] = HW_BEACON_BASE1; |
| 1404 | pAd->BeaconOffset[2] = HW_BEACON_BASE2; |
| 1405 | pAd->BeaconOffset[3] = HW_BEACON_BASE3; |
| 1406 | pAd->BeaconOffset[4] = HW_BEACON_BASE4; |
| 1407 | pAd->BeaconOffset[5] = HW_BEACON_BASE5; |
| 1408 | pAd->BeaconOffset[6] = HW_BEACON_BASE6; |
| 1409 | pAd->BeaconOffset[7] = HW_BEACON_BASE7; |
| 1410 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1411 | /* */ |
| 1412 | /* write all shared Ring's base address into ASIC */ |
| 1413 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1414 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1415 | /* asic simulation sequence put this ahead before loading firmware. */ |
| 1416 | /* pbf hardware reset */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1417 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1418 | RTMP_IO_WRITE32(pAd, WPDMA_RST_IDX, 0x1003f); /* 0x10000 for reset rx, 0x3f resets all 6 tx rings. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1419 | RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0xe1f); |
| 1420 | RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0xe00); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1421 | #endif /* RTMP_MAC_PCI // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1422 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1423 | /* Initialze ASIC for TX & Rx operation */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1424 | if (NICInitializeAsic(pAd, bHardReset) != NDIS_STATUS_SUCCESS) { |
| 1425 | if (j++ == 0) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1426 | NICLoadFirmware(pAd); |
| 1427 | goto retry; |
| 1428 | } |
| 1429 | return NDIS_STATUS_FAILURE; |
| 1430 | } |
| 1431 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1432 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1433 | /* Write AC_BK base address register */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1434 | Value = |
| 1435 | RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_BK].Cell[0].AllocPa); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1436 | RTMP_IO_WRITE32(pAd, TX_BASE_PTR1, Value); |
| 1437 | DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR1 : 0x%x\n", Value)); |
| 1438 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1439 | /* Write AC_BE base address register */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1440 | Value = |
| 1441 | RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_BE].Cell[0].AllocPa); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1442 | RTMP_IO_WRITE32(pAd, TX_BASE_PTR0, Value); |
| 1443 | DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR0 : 0x%x\n", Value)); |
| 1444 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1445 | /* Write AC_VI base address register */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1446 | Value = |
| 1447 | RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_VI].Cell[0].AllocPa); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1448 | RTMP_IO_WRITE32(pAd, TX_BASE_PTR2, Value); |
| 1449 | DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR2 : 0x%x\n", Value)); |
| 1450 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1451 | /* Write AC_VO base address register */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1452 | Value = |
| 1453 | RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_VO].Cell[0].AllocPa); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1454 | RTMP_IO_WRITE32(pAd, TX_BASE_PTR3, Value); |
| 1455 | DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR3 : 0x%x\n", Value)); |
| 1456 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1457 | /* Write MGMT_BASE_CSR register */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1458 | Value = RTMP_GetPhysicalAddressLow(pAd->MgmtRing.Cell[0].AllocPa); |
| 1459 | RTMP_IO_WRITE32(pAd, TX_BASE_PTR5, Value); |
| 1460 | DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR5 : 0x%x\n", Value)); |
| 1461 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1462 | /* Write RX_BASE_CSR register */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1463 | Value = RTMP_GetPhysicalAddressLow(pAd->RxRing.Cell[0].AllocPa); |
| 1464 | RTMP_IO_WRITE32(pAd, RX_BASE_PTR, Value); |
| 1465 | DBGPRINT(RT_DEBUG_TRACE, ("--> RX_BASE_PTR : 0x%x\n", Value)); |
| 1466 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1467 | /* Init RX Ring index pointer */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1468 | pAd->RxRing.RxSwReadIdx = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1469 | pAd->RxRing.RxCpuIdx = RX_RING_SIZE - 1; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1470 | RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RxCpuIdx); |
| 1471 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1472 | /* Init TX rings index pointer */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1473 | { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1474 | for (i = 0; i < NUM_OF_TX_RING; i++) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1475 | pAd->TxRing[i].TxSwFreeIdx = 0; |
| 1476 | pAd->TxRing[i].TxCpuIdx = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1477 | RTMP_IO_WRITE32(pAd, (TX_CTX_IDX0 + i * 0x10), |
| 1478 | pAd->TxRing[i].TxCpuIdx); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1479 | } |
| 1480 | } |
| 1481 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1482 | /* init MGMT ring index pointer */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1483 | pAd->MgmtRing.TxSwFreeIdx = 0; |
| 1484 | pAd->MgmtRing.TxCpuIdx = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1485 | RTMP_IO_WRITE32(pAd, TX_MGMTCTX_IDX, pAd->MgmtRing.TxCpuIdx); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1486 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1487 | /* */ |
| 1488 | /* set each Ring's SIZE into ASIC. Descriptor Size is fixed by design. */ |
| 1489 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1490 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1491 | /* Write TX_RING_CSR0 register */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1492 | Value = TX_RING_SIZE; |
| 1493 | RTMP_IO_WRITE32(pAd, TX_MAX_CNT0, Value); |
| 1494 | RTMP_IO_WRITE32(pAd, TX_MAX_CNT1, Value); |
| 1495 | RTMP_IO_WRITE32(pAd, TX_MAX_CNT2, Value); |
| 1496 | RTMP_IO_WRITE32(pAd, TX_MAX_CNT3, Value); |
| 1497 | RTMP_IO_WRITE32(pAd, TX_MAX_CNT4, Value); |
| 1498 | Value = MGMT_RING_SIZE; |
| 1499 | RTMP_IO_WRITE32(pAd, TX_MGMTMAX_CNT, Value); |
| 1500 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1501 | /* Write RX_RING_CSR register */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1502 | Value = RX_RING_SIZE; |
| 1503 | RTMP_IO_WRITE32(pAd, RX_MAX_CNT, Value); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1504 | #endif /* RTMP_MAC_PCI // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1505 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1506 | /* WMM parameter */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1507 | csr0.word = 0; |
| 1508 | RTMP_IO_WRITE32(pAd, WMM_TXOP0_CFG, csr0.word); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1509 | if (pAd->CommonCfg.PhyMode == PHY_11B) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1510 | csr0.field.Ac0Txop = 192; /* AC_VI: 192*32us ~= 6ms */ |
| 1511 | csr0.field.Ac1Txop = 96; /* AC_VO: 96*32us ~= 3ms */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1512 | } else { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1513 | csr0.field.Ac0Txop = 96; /* AC_VI: 96*32us ~= 3ms */ |
| 1514 | csr0.field.Ac1Txop = 48; /* AC_VO: 48*32us ~= 1.5ms */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1515 | } |
| 1516 | RTMP_IO_WRITE32(pAd, WMM_TXOP1_CFG, csr0.word); |
| 1517 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1518 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1519 | /* 3. Set DMA global configuration except TX_DMA_EN and RX_DMA_EN bits: */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1520 | i = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1521 | do { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1522 | RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1523 | if ((GloCfg.field.TxDMABusy == 0) |
| 1524 | && (GloCfg.field.RxDMABusy == 0)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1525 | break; |
| 1526 | |
| 1527 | RTMPusecDelay(1000); |
| 1528 | i++; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1529 | } while (i < 100); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1530 | |
| 1531 | GloCfg.word &= 0xff0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1532 | GloCfg.field.EnTXWriteBackDDONE = 1; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1533 | RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word); |
| 1534 | |
| 1535 | IntCfg.word = 0; |
| 1536 | RTMP_IO_WRITE32(pAd, DELAY_INT_CFG, IntCfg.word); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1537 | #endif /* RTMP_MAC_PCI // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1538 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1539 | /* reset action */ |
| 1540 | /* Load firmware */ |
| 1541 | /* Status = NICLoadFirmware(pAd); */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1542 | |
| 1543 | DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitializeAdapter\n")); |
| 1544 | return Status; |
| 1545 | } |
| 1546 | |
| 1547 | /* |
| 1548 | ======================================================================== |
| 1549 | |
| 1550 | Routine Description: |
| 1551 | Initialize ASIC |
| 1552 | |
| 1553 | Arguments: |
| 1554 | Adapter Pointer to our adapter |
| 1555 | |
| 1556 | Return Value: |
| 1557 | None |
| 1558 | |
| 1559 | IRQL = PASSIVE_LEVEL |
| 1560 | |
| 1561 | Note: |
| 1562 | |
| 1563 | ======================================================================== |
| 1564 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1565 | int NICInitializeAsic(struct rt_rtmp_adapter *pAd, IN BOOLEAN bHardReset) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1566 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1567 | unsigned long Index = 0; |
| 1568 | u8 R0 = 0xff; |
| 1569 | u32 MacCsr12 = 0, Counter = 0; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1570 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1571 | u32 MacCsr0 = 0; |
| 1572 | int Status; |
| 1573 | u8 Value = 0xff; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1574 | #endif /* RTMP_MAC_USB // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1575 | #ifdef RT30xx |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1576 | u8 bbpreg = 0; |
| 1577 | u8 RFValue = 0; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1578 | #endif /* RT30xx // */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1579 | u16 KeyIdx; |
| 1580 | int i, apidx; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1581 | |
| 1582 | DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitializeAsic\n")); |
| 1583 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1584 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1585 | RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x3); /* To fix driver disable/enable hang issue when radio off */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1586 | if (bHardReset == TRUE) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1587 | RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x3); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1588 | } else |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1589 | RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x1); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1590 | |
| 1591 | RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1592 | /* Initialize MAC register to default value */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1593 | for (Index = 0; Index < NUM_MAC_REG_PARMS; Index++) { |
| 1594 | RTMP_IO_WRITE32(pAd, MACRegTable[Index].Register, |
| 1595 | MACRegTable[Index].Value); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1596 | } |
| 1597 | |
| 1598 | { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1599 | for (Index = 0; Index < NUM_STA_MAC_REG_PARMS; Index++) { |
| 1600 | RTMP_IO_WRITE32(pAd, STAMACRegTable[Index].Register, |
| 1601 | STAMACRegTable[Index].Value); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1602 | } |
| 1603 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1604 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1605 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1606 | /* */ |
| 1607 | /* Make sure MAC gets ready after NICLoadFirmware(). */ |
| 1608 | /* */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1609 | Index = 0; |
| 1610 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1611 | /*To avoid hang-on issue when interface up in kernel 2.4, */ |
| 1612 | /*we use a local variable "MacCsr0" instead of using "pAd->MACVersion" directly. */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1613 | do { |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1614 | RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0); |
| 1615 | |
| 1616 | if ((MacCsr0 != 0x00) && (MacCsr0 != 0xFFFFFFFF)) |
| 1617 | break; |
| 1618 | |
| 1619 | RTMPusecDelay(10); |
| 1620 | } while (Index++ < 100); |
| 1621 | |
| 1622 | pAd->MACVersion = MacCsr0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1623 | DBGPRINT(RT_DEBUG_TRACE, |
| 1624 | ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion)); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1625 | /* turn on bit13 (set to zero) after rt2860D. This is to solve high-current issue. */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1626 | RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &MacCsr12); |
| 1627 | MacCsr12 &= (~0x2000); |
| 1628 | RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, MacCsr12); |
| 1629 | |
| 1630 | RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x3); |
| 1631 | RTMP_IO_WRITE32(pAd, USB_DMA_CFG, 0x0); |
| 1632 | Status = RTUSBVenderReset(pAd); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1633 | |
| 1634 | RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0); |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1635 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1636 | /* Initialize MAC register to default value */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1637 | for (Index = 0; Index < NUM_MAC_REG_PARMS; Index++) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1638 | #ifdef RT30xx |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1639 | if ((MACRegTable[Index].Register == TX_SW_CFG0) |
| 1640 | && (IS_RT3070(pAd) || IS_RT3071(pAd) || IS_RT3572(pAd) |
| 1641 | || IS_RT3090(pAd) || IS_RT3390(pAd))) { |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1642 | MACRegTable[Index].Value = 0x00000400; |
| 1643 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1644 | #endif /* RT30xx // */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1645 | RTMP_IO_WRITE32(pAd, (u16)MACRegTable[Index].Register, |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1646 | MACRegTable[Index].Value); |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1647 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1648 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1649 | { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1650 | for (Index = 0; Index < NUM_STA_MAC_REG_PARMS; Index++) { |
| 1651 | RTMP_IO_WRITE32(pAd, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1652 | (u16)STAMACRegTable[Index].Register, |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1653 | STAMACRegTable[Index].Value); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1654 | } |
| 1655 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1656 | #endif /* RTMP_MAC_USB // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1657 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1658 | #ifdef RT30xx |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1659 | /* Initialize RT3070 serial MAC registers which is different from RT2870 serial */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1660 | if (IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) { |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1661 | RTMP_IO_WRITE32(pAd, TX_SW_CFG1, 0); |
| 1662 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1663 | /* RT3071 version E has fixed this issue */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1664 | if ((pAd->MACVersion & 0xffff) < 0x0211) { |
| 1665 | if (pAd->NicConfig2.field.DACTestBit == 1) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1666 | RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x2C); /* To fix throughput drop drastically */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1667 | } else { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1668 | RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x0F); /* To fix throughput drop drastically */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1669 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1670 | } else { |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1671 | RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x0); |
| 1672 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1673 | } else if (IS_RT3070(pAd)) { |
| 1674 | if (((pAd->MACVersion & 0xffff) < 0x0201)) { |
| 1675 | RTMP_IO_WRITE32(pAd, TX_SW_CFG1, 0); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1676 | RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x2C); /* To fix throughput drop drastically */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1677 | } else { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1678 | RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0); |
| 1679 | } |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1680 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1681 | #endif /* RT30xx // */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1682 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1683 | /* */ |
| 1684 | /* Before program BBP, we need to wait BBP/RF get wake up. */ |
| 1685 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1686 | Index = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1687 | do { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1688 | RTMP_IO_READ32(pAd, MAC_STATUS_CFG, &MacCsr12); |
| 1689 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1690 | if ((MacCsr12 & 0x03) == 0) /* if BB.RF is stable */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1691 | break; |
| 1692 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1693 | DBGPRINT(RT_DEBUG_TRACE, |
| 1694 | ("Check MAC_STATUS_CFG = Busy = %x\n", MacCsr12)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1695 | RTMPusecDelay(1000); |
| 1696 | } while (Index++ < 100); |
| 1697 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1698 | /* The commands to firmware should be after these commands, these commands will init firmware */ |
| 1699 | /* PCI and USB are not the same because PCI driver needs to wait for PCI bus ready */ |
| 1700 | RTMP_IO_WRITE32(pAd, H2M_BBP_AGENT, 0); /* initialize BBP R/W access agent */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1701 | RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, 0); |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1702 | #ifdef RT3090 |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1703 | /*2008/11/28:KH add to fix the dead rf frequency offset bug<-- */ |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1704 | AsicSendCommandToMcu(pAd, 0x72, 0, 0, 0); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1705 | /*2008/11/28:KH add to fix the dead rf frequency offset bug--> */ |
| 1706 | #endif /* RT3090 // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1707 | RTMPusecDelay(1000); |
| 1708 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1709 | /* Read BBP register, make sure BBP is up and running before write new data */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1710 | Index = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1711 | do { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1712 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R0, &R0); |
| 1713 | DBGPRINT(RT_DEBUG_TRACE, ("BBP version = %x\n", R0)); |
| 1714 | } while ((++Index < 20) && ((R0 == 0xff) || (R0 == 0x00))); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1715 | /*ASSERT(Index < 20); //this will cause BSOD on Check-build driver */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1716 | |
| 1717 | if ((R0 == 0xff) || (R0 == 0x00)) |
| 1718 | return NDIS_STATUS_FAILURE; |
| 1719 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1720 | /* Initialize BBP register to default value */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1721 | for (Index = 0; Index < NUM_BBP_REG_PARMS; Index++) { |
| 1722 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBPRegTable[Index].Register, |
| 1723 | BBPRegTable[Index].Value); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1724 | } |
| 1725 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1726 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1727 | /* TODO: shiang, check MACVersion, currently, rbus-based chip use this. */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1728 | if (pAd->MACVersion == 0x28720200) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1729 | /*u8 value; */ |
| 1730 | unsigned long value2; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1731 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1732 | /*disable MLD by Bruce 20080704 */ |
| 1733 | /*BBP_IO_READ8_BY_REG_ID(pAd, BBP_R105, &value); */ |
| 1734 | /*BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R105, value | 4); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1735 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1736 | /*Maximum PSDU length from 16K to 32K bytes */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1737 | RTMP_IO_READ32(pAd, MAX_LEN_CFG, &value2); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1738 | value2 &= ~(0x3 << 12); |
| 1739 | value2 |= (0x2 << 12); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1740 | RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, value2); |
| 1741 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1742 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1743 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1744 | /* for rt2860E and after, init BBP_R84 with 0x19. This is for extension channel overlapping IOT. */ |
| 1745 | /* RT3090 should not program BBP R84 to 0x19, otherwise TX will block. */ |
| 1746 | /*3070/71/72,3090,3090A( are included in RT30xx),3572,3390 */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1747 | if (((pAd->MACVersion & 0xffff) != 0x0101) |
| 1748 | && !(IS_RT30xx(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))) |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1749 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R84, 0x19); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1750 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1751 | #ifdef RT30xx |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1752 | /* add by johnli, RF power sequence setup */ |
| 1753 | if (IS_RT30xx(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) { /*update for RT3070/71/72/90/91/92,3572,3390. */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1754 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R79, 0x13); |
| 1755 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R80, 0x05); |
| 1756 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R81, 0x33); |
| 1757 | } |
| 1758 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1759 | if (IS_RT3090(pAd) || IS_RT3390(pAd)) /* RT309x, RT3071/72 */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1760 | { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1761 | /* enable DC filter */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1762 | if ((pAd->MACVersion & 0xffff) >= 0x0211) { |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1763 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R103, 0xc0); |
| 1764 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1765 | /* improve power consumption */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1766 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R138, &bbpreg); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1767 | if (pAd->Antenna.field.TxPath == 1) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1768 | /* turn off tx DAC_1 */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1769 | bbpreg = (bbpreg | 0x20); |
| 1770 | } |
| 1771 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1772 | if (pAd->Antenna.field.RxPath == 1) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1773 | /* turn off tx ADC_1 */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1774 | bbpreg &= (~0x2); |
| 1775 | } |
| 1776 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R138, bbpreg); |
| 1777 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1778 | /* improve power consumption in RT3071 Ver.E */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1779 | if ((pAd->MACVersion & 0xffff) >= 0x0211) { |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1780 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R31, &bbpreg); |
| 1781 | bbpreg &= (~0x3); |
| 1782 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R31, bbpreg); |
| 1783 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1784 | } else if (IS_RT3070(pAd)) { |
| 1785 | if ((pAd->MACVersion & 0xffff) >= 0x0201) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1786 | /* enable DC filter */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1787 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R103, 0xc0); |
| 1788 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1789 | /* improve power consumption in RT3070 Ver.F */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1790 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R31, &bbpreg); |
| 1791 | bbpreg &= (~0x3); |
| 1792 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R31, bbpreg); |
| 1793 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1794 | /* TX_LO1_en, RF R17 register Bit 3 to 0 */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1795 | RT30xxReadRFRegister(pAd, RF_R17, &RFValue); |
| 1796 | RFValue &= (~0x08); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1797 | /* to fix rx long range issue */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1798 | if (pAd->NicConfig2.field.ExternalLNAForG == 0) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1799 | RFValue |= 0x20; |
| 1800 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1801 | /* set RF_R17_bit[2:0] equal to EEPROM setting at 0x48h */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1802 | if (pAd->TxMixerGain24G >= 1) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1803 | RFValue &= (~0x7); /* clean bit [2:0] */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1804 | RFValue |= pAd->TxMixerGain24G; |
| 1805 | } |
| 1806 | RT30xxWriteRFRegister(pAd, RF_R17, RFValue); |
| 1807 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1808 | /* end johnli */ |
| 1809 | #endif /* RT30xx // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1810 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1811 | if (pAd->MACVersion == 0x28600100) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1812 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16); |
| 1813 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x12); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1814 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1815 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1816 | if (pAd->MACVersion >= RALINK_2880E_VERSION && pAd->MACVersion < RALINK_3070_VERSION) /* 3*3 */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1817 | { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1818 | /* enlarge MAX_LEN_CFG */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1819 | u32 csr; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1820 | RTMP_IO_READ32(pAd, MAX_LEN_CFG, &csr); |
| 1821 | csr &= 0xFFF; |
| 1822 | csr |= 0x2000; |
| 1823 | RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, csr); |
| 1824 | } |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1825 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1826 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1827 | u8 MAC_Value[] = |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1828 | { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0 }; |
| 1829 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1830 | /*Initialize WCID table */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1831 | Value = 0xff; |
| 1832 | for (Index = 0; Index < 254; Index++) { |
| 1833 | RTUSBMultiWrite(pAd, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1834 | (u16)(MAC_WCID_BASE + Index * 8), |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1835 | MAC_Value, 8); |
| 1836 | } |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1837 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1838 | #endif /* RTMP_MAC_USB // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1839 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1840 | /* Add radio off control */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1841 | { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1842 | if (pAd->StaCfg.bRadio == FALSE) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1843 | /* RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x00001818); */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1844 | RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF); |
| 1845 | DBGPRINT(RT_DEBUG_TRACE, ("Set Radio Off\n")); |
| 1846 | } |
| 1847 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1848 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1849 | /* Clear raw counters */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1850 | RTMP_IO_READ32(pAd, RX_STA_CNT0, &Counter); |
| 1851 | RTMP_IO_READ32(pAd, RX_STA_CNT1, &Counter); |
| 1852 | RTMP_IO_READ32(pAd, RX_STA_CNT2, &Counter); |
| 1853 | RTMP_IO_READ32(pAd, TX_STA_CNT0, &Counter); |
| 1854 | RTMP_IO_READ32(pAd, TX_STA_CNT1, &Counter); |
| 1855 | RTMP_IO_READ32(pAd, TX_STA_CNT2, &Counter); |
| 1856 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1857 | /* ASIC will keep garbage value after boot */ |
| 1858 | /* Clear all shared key table when initial */ |
| 1859 | /* This routine can be ignored in radio-ON/OFF operation. */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1860 | if (bHardReset) { |
| 1861 | for (KeyIdx = 0; KeyIdx < 4; KeyIdx++) { |
| 1862 | RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE + 4 * KeyIdx, |
| 1863 | 0); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1864 | } |
| 1865 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1866 | /* Clear all pairwise key table when initial */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1867 | for (KeyIdx = 0; KeyIdx < 256; KeyIdx++) { |
| 1868 | RTMP_IO_WRITE32(pAd, |
| 1869 | MAC_WCID_ATTRIBUTE_BASE + |
| 1870 | (KeyIdx * HW_WCID_ATTRI_SIZE), 1); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1871 | } |
| 1872 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1873 | /* assert HOST ready bit */ |
| 1874 | /* RTMP_IO_WRITE32(pAd, MAC_CSR1, 0x0); // 2004-09-14 asked by Mark */ |
| 1875 | /* RTMP_IO_WRITE32(pAd, MAC_CSR1, 0x4); */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1876 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1877 | /* It isn't necessary to clear this space when not hard reset. */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1878 | if (bHardReset == TRUE) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1879 | /* clear all on-chip BEACON frame space */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1880 | for (apidx = 0; apidx < HW_BEACON_MAX_COUNT; apidx++) { |
| 1881 | for (i = 0; i < HW_BEACON_OFFSET >> 2; i += 4) |
| 1882 | RTMP_IO_WRITE32(pAd, |
| 1883 | pAd->BeaconOffset[apidx] + i, |
| 1884 | 0x00); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1885 | } |
| 1886 | } |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1887 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1888 | AsicDisableSync(pAd); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1889 | /* Clear raw counters */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1890 | RTMP_IO_READ32(pAd, RX_STA_CNT0, &Counter); |
| 1891 | RTMP_IO_READ32(pAd, RX_STA_CNT1, &Counter); |
| 1892 | RTMP_IO_READ32(pAd, RX_STA_CNT2, &Counter); |
| 1893 | RTMP_IO_READ32(pAd, TX_STA_CNT0, &Counter); |
| 1894 | RTMP_IO_READ32(pAd, TX_STA_CNT1, &Counter); |
| 1895 | RTMP_IO_READ32(pAd, TX_STA_CNT2, &Counter); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1896 | /* Default PCI clock cycle per ms is different as default setting, which is based on PCI. */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1897 | RTMP_IO_READ32(pAd, USB_CYC_CFG, &Counter); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1898 | Counter &= 0xffffff00; |
| 1899 | Counter |= 0x000001e; |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 1900 | RTMP_IO_WRITE32(pAd, USB_CYC_CFG, Counter); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1901 | #endif /* RTMP_MAC_USB // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1902 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1903 | { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1904 | /* for rt2860E and after, init TXOP_CTRL_CFG with 0x583f. This is for extension channel overlapping IOT. */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1905 | if ((pAd->MACVersion & 0xffff) != 0x0101) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1906 | RTMP_IO_WRITE32(pAd, TXOP_CTRL_CFG, 0x583f); |
| 1907 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1908 | |
| 1909 | DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitializeAsic\n")); |
| 1910 | return NDIS_STATUS_SUCCESS; |
| 1911 | } |
| 1912 | |
| 1913 | /* |
| 1914 | ======================================================================== |
| 1915 | |
| 1916 | Routine Description: |
| 1917 | Reset NIC Asics |
| 1918 | |
| 1919 | Arguments: |
| 1920 | Adapter Pointer to our adapter |
| 1921 | |
| 1922 | Return Value: |
| 1923 | None |
| 1924 | |
| 1925 | IRQL = PASSIVE_LEVEL |
| 1926 | |
| 1927 | Note: |
| 1928 | Reset NIC to initial state AS IS system boot up time. |
| 1929 | |
| 1930 | ======================================================================== |
| 1931 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1932 | void NICIssueReset(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1933 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1934 | u32 Value = 0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1935 | DBGPRINT(RT_DEBUG_TRACE, ("--> NICIssueReset\n")); |
| 1936 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1937 | /* Abort Tx, prevent ASIC from writing to Host memory */ |
| 1938 | /*RTMP_IO_WRITE32(pAd, TX_CNTL_CSR, 0x001f0000); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1939 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1940 | /* Disable Rx, register value supposed will remain after reset */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1941 | RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value); |
| 1942 | Value &= (0xfffffff3); |
| 1943 | RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value); |
| 1944 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1945 | /* Issue reset and clear from reset state */ |
| 1946 | RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x03); /* 2004-09-17 change from 0x01 */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1947 | RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x00); |
| 1948 | |
| 1949 | DBGPRINT(RT_DEBUG_TRACE, ("<-- NICIssueReset\n")); |
| 1950 | } |
| 1951 | |
| 1952 | /* |
| 1953 | ======================================================================== |
| 1954 | |
| 1955 | Routine Description: |
| 1956 | Check ASIC registers and find any reason the system might hang |
| 1957 | |
| 1958 | Arguments: |
| 1959 | Adapter Pointer to our adapter |
| 1960 | |
| 1961 | Return Value: |
| 1962 | None |
| 1963 | |
| 1964 | IRQL = DISPATCH_LEVEL |
| 1965 | |
| 1966 | ======================================================================== |
| 1967 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1968 | BOOLEAN NICCheckForHang(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1969 | { |
| 1970 | return (FALSE); |
| 1971 | } |
| 1972 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1973 | void NICUpdateFifoStaCounters(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1974 | { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1975 | TX_STA_FIFO_STRUC StaFifo; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1976 | struct rt_mac_table_entry *pEntry; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1977 | u8 i = 0; |
| 1978 | u8 pid = 0, wcid = 0; |
| 1979 | char reTry; |
| 1980 | u8 succMCS; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1981 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1982 | do { |
| 1983 | RTMP_IO_READ32(pAd, TX_STA_FIFO, &StaFifo.word); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1984 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1985 | if (StaFifo.field.bValid == 0) |
| 1986 | break; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1987 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1988 | wcid = (u8)StaFifo.field.wcid; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1989 | |
| 1990 | /* ignore NoACK and MGMT frame use 0xFF as WCID */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1991 | if ((StaFifo.field.TxAckRequired == 0) |
| 1992 | || (wcid >= MAX_LEN_OF_MAC_TABLE)) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1993 | i++; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1994 | continue; |
| 1995 | } |
| 1996 | |
| 1997 | /* PID store Tx MCS Rate */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1998 | pid = (u8)StaFifo.field.PidType; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1999 | |
| 2000 | pEntry = &pAd->MacTab.Content[wcid]; |
| 2001 | |
| 2002 | pEntry->DebugFIFOCount++; |
| 2003 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2004 | if (StaFifo.field.TxBF) /* 3*3 */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2005 | pEntry->TxBFCount++; |
| 2006 | |
| 2007 | if (!StaFifo.field.TxSuccess) { |
| 2008 | pEntry->FIFOCount++; |
| 2009 | pEntry->OneSecTxFailCount++; |
| 2010 | |
| 2011 | if (pEntry->FIFOCount >= 1) { |
| 2012 | DBGPRINT(RT_DEBUG_TRACE, ("#")); |
| 2013 | pEntry->NoBADataCountDown = 64; |
| 2014 | |
| 2015 | if (pEntry->PsMode == PWR_ACTIVE) { |
| 2016 | int tid; |
| 2017 | for (tid = 0; tid < NUM_OF_TID; tid++) { |
| 2018 | BAOriSessionTearDown(pAd, |
| 2019 | pEntry-> |
| 2020 | Aid, tid, |
| 2021 | FALSE, |
| 2022 | FALSE); |
| 2023 | } |
| 2024 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2025 | /* Update the continuous transmission counter except PS mode */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2026 | pEntry->ContinueTxFailCnt++; |
| 2027 | } else { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2028 | /* Clear the FIFOCount when sta in Power Save mode. Basically we assume */ |
| 2029 | /* this tx error happened due to sta just go to sleep. */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2030 | pEntry->FIFOCount = 0; |
| 2031 | pEntry->ContinueTxFailCnt = 0; |
| 2032 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2033 | /*pEntry->FIFOCount = 0; */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2034 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2035 | /*pEntry->bSendBAR = TRUE; */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2036 | } else { |
| 2037 | if ((pEntry->PsMode != PWR_SAVE) |
| 2038 | && (pEntry->NoBADataCountDown > 0)) { |
| 2039 | pEntry->NoBADataCountDown--; |
| 2040 | if (pEntry->NoBADataCountDown == 0) { |
| 2041 | DBGPRINT(RT_DEBUG_TRACE, ("@\n")); |
| 2042 | } |
| 2043 | } |
| 2044 | |
| 2045 | pEntry->FIFOCount = 0; |
| 2046 | pEntry->OneSecTxNoRetryOkCount++; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2047 | /* update NoDataIdleCount when sucessful send packet to STA. */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2048 | pEntry->NoDataIdleCount = 0; |
| 2049 | pEntry->ContinueTxFailCnt = 0; |
| 2050 | } |
| 2051 | |
| 2052 | succMCS = StaFifo.field.SuccessRate & 0x7F; |
| 2053 | |
| 2054 | reTry = pid - succMCS; |
| 2055 | |
| 2056 | if (StaFifo.field.TxSuccess) { |
| 2057 | pEntry->TXMCSExpected[pid]++; |
| 2058 | if (pid == succMCS) { |
| 2059 | pEntry->TXMCSSuccessful[pid]++; |
| 2060 | } else { |
| 2061 | pEntry->TXMCSAutoFallBack[pid][succMCS]++; |
| 2062 | } |
| 2063 | } else { |
| 2064 | pEntry->TXMCSFailed[pid]++; |
| 2065 | } |
| 2066 | |
| 2067 | if (reTry > 0) { |
| 2068 | if ((pid >= 12) && succMCS <= 7) { |
| 2069 | reTry -= 4; |
| 2070 | } |
| 2071 | pEntry->OneSecTxRetryOkCount += reTry; |
| 2072 | } |
| 2073 | |
| 2074 | i++; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2075 | /* ASIC store 16 stack */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2076 | } while (i < (2 * TX_RING_SIZE)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2077 | |
| 2078 | } |
| 2079 | |
| 2080 | /* |
| 2081 | ======================================================================== |
| 2082 | |
| 2083 | Routine Description: |
| 2084 | Read statistical counters from hardware registers and record them |
| 2085 | in software variables for later on query |
| 2086 | |
| 2087 | Arguments: |
| 2088 | pAd Pointer to our adapter |
| 2089 | |
| 2090 | Return Value: |
| 2091 | None |
| 2092 | |
| 2093 | IRQL = DISPATCH_LEVEL |
| 2094 | |
| 2095 | ======================================================================== |
| 2096 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2097 | void NICUpdateRawCounters(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2098 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2099 | u32 OldValue; /*, Value2; */ |
| 2100 | /*unsigned long PageSum, OneSecTransmitCount; */ |
| 2101 | /*unsigned long TxErrorRatio, Retry, Fail; */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2102 | RX_STA_CNT0_STRUC RxStaCnt0; |
| 2103 | RX_STA_CNT1_STRUC RxStaCnt1; |
| 2104 | RX_STA_CNT2_STRUC RxStaCnt2; |
| 2105 | TX_STA_CNT0_STRUC TxStaCnt0; |
| 2106 | TX_STA_CNT1_STRUC StaTx1; |
| 2107 | TX_STA_CNT2_STRUC StaTx2; |
| 2108 | TX_AGG_CNT_STRUC TxAggCnt; |
| 2109 | TX_AGG_CNT0_STRUC TxAggCnt0; |
| 2110 | TX_AGG_CNT1_STRUC TxAggCnt1; |
| 2111 | TX_AGG_CNT2_STRUC TxAggCnt2; |
| 2112 | TX_AGG_CNT3_STRUC TxAggCnt3; |
| 2113 | TX_AGG_CNT4_STRUC TxAggCnt4; |
| 2114 | TX_AGG_CNT5_STRUC TxAggCnt5; |
| 2115 | TX_AGG_CNT6_STRUC TxAggCnt6; |
| 2116 | TX_AGG_CNT7_STRUC TxAggCnt7; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2117 | struct rt_counter_ralink *pRalinkCounters; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2118 | |
| 2119 | pRalinkCounters = &pAd->RalinkCounters; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2120 | |
| 2121 | RTMP_IO_READ32(pAd, RX_STA_CNT0, &RxStaCnt0.word); |
| 2122 | RTMP_IO_READ32(pAd, RX_STA_CNT2, &RxStaCnt2.word); |
| 2123 | |
| 2124 | { |
| 2125 | RTMP_IO_READ32(pAd, RX_STA_CNT1, &RxStaCnt1.word); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2126 | /* Update RX PLCP error counter */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2127 | pAd->PrivateInfo.PhyRxErrCnt += RxStaCnt1.field.PlcpErr; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2128 | /* Update False CCA counter */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2129 | pAd->RalinkCounters.OneSecFalseCCACnt += |
| 2130 | RxStaCnt1.field.FalseCca; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2131 | } |
| 2132 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2133 | /* Update FCS counters */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2134 | OldValue = pAd->WlanCounters.FCSErrorCount.u.LowPart; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2135 | pAd->WlanCounters.FCSErrorCount.u.LowPart += (RxStaCnt0.field.CrcErr); /* >> 7); */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2136 | if (pAd->WlanCounters.FCSErrorCount.u.LowPart < OldValue) |
| 2137 | pAd->WlanCounters.FCSErrorCount.u.HighPart++; |
| 2138 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2139 | /* Add FCS error count to private counters */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2140 | pRalinkCounters->OneSecRxFcsErrCnt += RxStaCnt0.field.CrcErr; |
| 2141 | OldValue = pRalinkCounters->RealFcsErrCount.u.LowPart; |
| 2142 | pRalinkCounters->RealFcsErrCount.u.LowPart += RxStaCnt0.field.CrcErr; |
| 2143 | if (pRalinkCounters->RealFcsErrCount.u.LowPart < OldValue) |
| 2144 | pRalinkCounters->RealFcsErrCount.u.HighPart++; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2145 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2146 | /* Update Duplicate Rcv check */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2147 | pRalinkCounters->DuplicateRcv += RxStaCnt2.field.RxDupliCount; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2148 | pAd->WlanCounters.FrameDuplicateCount.u.LowPart += |
| 2149 | RxStaCnt2.field.RxDupliCount; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2150 | /* Update RX Overflow counter */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2151 | pAd->Counters8023.RxNoBuffer += (RxStaCnt2.field.RxFifoOverflowCount); |
| 2152 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2153 | /*pAd->RalinkCounters.RxCount = 0; */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2154 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2155 | if (pRalinkCounters->RxCount != pAd->watchDogRxCnt) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2156 | pAd->watchDogRxCnt = pRalinkCounters->RxCount; |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 2157 | pAd->watchDogRxOverFlowCnt = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2158 | } else { |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 2159 | if (RxStaCnt2.field.RxFifoOverflowCount) |
| 2160 | pAd->watchDogRxOverFlowCnt++; |
| 2161 | else |
| 2162 | pAd->watchDogRxOverFlowCnt = 0; |
| 2163 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2164 | #endif /* RTMP_MAC_USB // */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 2165 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2166 | /*if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED) || */ |
| 2167 | /* (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED) && (pAd->MacTab.Size != 1))) */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2168 | if (!pAd->bUpdateBcnCntDone) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2169 | /* Update BEACON sent count */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2170 | RTMP_IO_READ32(pAd, TX_STA_CNT0, &TxStaCnt0.word); |
| 2171 | RTMP_IO_READ32(pAd, TX_STA_CNT1, &StaTx1.word); |
| 2172 | RTMP_IO_READ32(pAd, TX_STA_CNT2, &StaTx2.word); |
| 2173 | pRalinkCounters->OneSecBeaconSentCnt += |
| 2174 | TxStaCnt0.field.TxBeaconCount; |
| 2175 | pRalinkCounters->OneSecTxRetryOkCount += |
| 2176 | StaTx1.field.TxRetransmit; |
| 2177 | pRalinkCounters->OneSecTxNoRetryOkCount += |
| 2178 | StaTx1.field.TxSuccess; |
| 2179 | pRalinkCounters->OneSecTxFailCount += |
| 2180 | TxStaCnt0.field.TxFailCount; |
| 2181 | pAd->WlanCounters.TransmittedFragmentCount.u.LowPart += |
| 2182 | StaTx1.field.TxSuccess; |
| 2183 | pAd->WlanCounters.RetryCount.u.LowPart += |
| 2184 | StaTx1.field.TxRetransmit; |
| 2185 | pAd->WlanCounters.FailedCount.u.LowPart += |
| 2186 | TxStaCnt0.field.TxFailCount; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2187 | } |
| 2188 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2189 | /*if (pAd->bStaFifoTest == TRUE) */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2190 | { |
| 2191 | RTMP_IO_READ32(pAd, TX_AGG_CNT, &TxAggCnt.word); |
| 2192 | RTMP_IO_READ32(pAd, TX_AGG_CNT0, &TxAggCnt0.word); |
| 2193 | RTMP_IO_READ32(pAd, TX_AGG_CNT1, &TxAggCnt1.word); |
| 2194 | RTMP_IO_READ32(pAd, TX_AGG_CNT2, &TxAggCnt2.word); |
| 2195 | RTMP_IO_READ32(pAd, TX_AGG_CNT3, &TxAggCnt3.word); |
| 2196 | RTMP_IO_READ32(pAd, TX_AGG_CNT4, &TxAggCnt4.word); |
| 2197 | RTMP_IO_READ32(pAd, TX_AGG_CNT5, &TxAggCnt5.word); |
| 2198 | RTMP_IO_READ32(pAd, TX_AGG_CNT6, &TxAggCnt6.word); |
| 2199 | RTMP_IO_READ32(pAd, TX_AGG_CNT7, &TxAggCnt7.word); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2200 | pRalinkCounters->TxAggCount += TxAggCnt.field.AggTxCount; |
| 2201 | pRalinkCounters->TxNonAggCount += TxAggCnt.field.NonAggTxCount; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2202 | pRalinkCounters->TxAgg1MPDUCount += |
| 2203 | TxAggCnt0.field.AggSize1Count; |
| 2204 | pRalinkCounters->TxAgg2MPDUCount += |
| 2205 | TxAggCnt0.field.AggSize2Count; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2206 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2207 | pRalinkCounters->TxAgg3MPDUCount += |
| 2208 | TxAggCnt1.field.AggSize3Count; |
| 2209 | pRalinkCounters->TxAgg4MPDUCount += |
| 2210 | TxAggCnt1.field.AggSize4Count; |
| 2211 | pRalinkCounters->TxAgg5MPDUCount += |
| 2212 | TxAggCnt2.field.AggSize5Count; |
| 2213 | pRalinkCounters->TxAgg6MPDUCount += |
| 2214 | TxAggCnt2.field.AggSize6Count; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2215 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2216 | pRalinkCounters->TxAgg7MPDUCount += |
| 2217 | TxAggCnt3.field.AggSize7Count; |
| 2218 | pRalinkCounters->TxAgg8MPDUCount += |
| 2219 | TxAggCnt3.field.AggSize8Count; |
| 2220 | pRalinkCounters->TxAgg9MPDUCount += |
| 2221 | TxAggCnt4.field.AggSize9Count; |
| 2222 | pRalinkCounters->TxAgg10MPDUCount += |
| 2223 | TxAggCnt4.field.AggSize10Count; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2224 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2225 | pRalinkCounters->TxAgg11MPDUCount += |
| 2226 | TxAggCnt5.field.AggSize11Count; |
| 2227 | pRalinkCounters->TxAgg12MPDUCount += |
| 2228 | TxAggCnt5.field.AggSize12Count; |
| 2229 | pRalinkCounters->TxAgg13MPDUCount += |
| 2230 | TxAggCnt6.field.AggSize13Count; |
| 2231 | pRalinkCounters->TxAgg14MPDUCount += |
| 2232 | TxAggCnt6.field.AggSize14Count; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2233 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2234 | pRalinkCounters->TxAgg15MPDUCount += |
| 2235 | TxAggCnt7.field.AggSize15Count; |
| 2236 | pRalinkCounters->TxAgg16MPDUCount += |
| 2237 | TxAggCnt7.field.AggSize16Count; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2238 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2239 | /* Calculate the transmitted A-MPDU count */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2240 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2241 | TxAggCnt0.field.AggSize1Count; |
| 2242 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2243 | (TxAggCnt0.field.AggSize2Count / 2); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2244 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2245 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2246 | (TxAggCnt1.field.AggSize3Count / 3); |
| 2247 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2248 | (TxAggCnt1.field.AggSize4Count / 4); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2249 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2250 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2251 | (TxAggCnt2.field.AggSize5Count / 5); |
| 2252 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2253 | (TxAggCnt2.field.AggSize6Count / 6); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2254 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2255 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2256 | (TxAggCnt3.field.AggSize7Count / 7); |
| 2257 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2258 | (TxAggCnt3.field.AggSize8Count / 8); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2259 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2260 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2261 | (TxAggCnt4.field.AggSize9Count / 9); |
| 2262 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2263 | (TxAggCnt4.field.AggSize10Count / 10); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2264 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2265 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2266 | (TxAggCnt5.field.AggSize11Count / 11); |
| 2267 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2268 | (TxAggCnt5.field.AggSize12Count / 12); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2269 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2270 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2271 | (TxAggCnt6.field.AggSize13Count / 13); |
| 2272 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2273 | (TxAggCnt6.field.AggSize14Count / 14); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2274 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2275 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2276 | (TxAggCnt7.field.AggSize15Count / 15); |
| 2277 | pRalinkCounters->TransmittedAMPDUCount.u.LowPart += |
| 2278 | (TxAggCnt7.field.AggSize16Count / 16); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2279 | } |
| 2280 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2281 | } |
| 2282 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2283 | /* |
| 2284 | ======================================================================== |
| 2285 | |
| 2286 | Routine Description: |
| 2287 | Reset NIC from error |
| 2288 | |
| 2289 | Arguments: |
| 2290 | Adapter Pointer to our adapter |
| 2291 | |
| 2292 | Return Value: |
| 2293 | None |
| 2294 | |
| 2295 | IRQL = PASSIVE_LEVEL |
| 2296 | |
| 2297 | Note: |
| 2298 | Reset NIC from error state |
| 2299 | |
| 2300 | ======================================================================== |
| 2301 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2302 | void NICResetFromError(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2303 | { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2304 | /* Reset BBP (according to alex, reset ASIC will force reset BBP */ |
| 2305 | /* Therefore, skip the reset BBP */ |
| 2306 | /* RTMP_IO_WRITE32(pAd, MAC_CSR1, 0x2); */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2307 | |
| 2308 | RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x1); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2309 | /* Remove ASIC from reset state */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2310 | RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0); |
| 2311 | |
| 2312 | NICInitializeAdapter(pAd, FALSE); |
| 2313 | NICInitAsicFromEEPROM(pAd); |
| 2314 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2315 | /* Switch to current channel, since during reset process, the connection should remains on. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2316 | AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE); |
| 2317 | AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel); |
| 2318 | } |
| 2319 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2320 | int NICLoadFirmware(struct rt_rtmp_adapter *pAd) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2321 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2322 | int status = NDIS_STATUS_SUCCESS; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2323 | if (pAd->chipOps.loadFirmware) |
| 2324 | status = pAd->chipOps.loadFirmware(pAd); |
| 2325 | |
| 2326 | return status; |
| 2327 | } |
| 2328 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2329 | /* |
| 2330 | ======================================================================== |
| 2331 | |
| 2332 | Routine Description: |
| 2333 | erase 8051 firmware image in MAC ASIC |
| 2334 | |
| 2335 | Arguments: |
| 2336 | Adapter Pointer to our adapter |
| 2337 | |
| 2338 | IRQL = PASSIVE_LEVEL |
| 2339 | |
| 2340 | ======================================================================== |
| 2341 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2342 | void NICEraseFirmware(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2343 | { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2344 | if (pAd->chipOps.eraseFirmware) |
| 2345 | pAd->chipOps.eraseFirmware(pAd); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2346 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2347 | } /* End of NICEraseFirmware */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2348 | |
| 2349 | /* |
| 2350 | ======================================================================== |
| 2351 | |
| 2352 | Routine Description: |
| 2353 | Load Tx rate switching parameters |
| 2354 | |
| 2355 | Arguments: |
| 2356 | Adapter Pointer to our adapter |
| 2357 | |
| 2358 | Return Value: |
| 2359 | NDIS_STATUS_SUCCESS firmware image load ok |
| 2360 | NDIS_STATUS_FAILURE image not found |
| 2361 | |
| 2362 | IRQL = PASSIVE_LEVEL |
| 2363 | |
| 2364 | Rate Table Format: |
| 2365 | 1. (B0: Valid Item number) (B1:Initial item from zero) |
| 2366 | 2. Item Number(Dec) Mode(Hex) Current MCS(Dec) TrainUp(Dec) TrainDown(Dec) |
| 2367 | |
| 2368 | ======================================================================== |
| 2369 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2370 | int NICLoadRateSwitchingParams(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2371 | { |
| 2372 | return NDIS_STATUS_SUCCESS; |
| 2373 | } |
| 2374 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2375 | /* |
| 2376 | ======================================================================== |
| 2377 | |
| 2378 | Routine Description: |
| 2379 | Compare two memory block |
| 2380 | |
| 2381 | Arguments: |
| 2382 | pSrc1 Pointer to first memory address |
| 2383 | pSrc2 Pointer to second memory address |
| 2384 | |
| 2385 | Return Value: |
| 2386 | 0: memory is equal |
| 2387 | 1: pSrc1 memory is larger |
| 2388 | 2: pSrc2 memory is larger |
| 2389 | |
| 2390 | IRQL = DISPATCH_LEVEL |
| 2391 | |
| 2392 | Note: |
| 2393 | |
| 2394 | ======================================================================== |
| 2395 | */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2396 | unsigned long RTMPCompareMemory(void *pSrc1, void *pSrc2, unsigned long Length) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2397 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2398 | u8 *pMem1; |
| 2399 | u8 *pMem2; |
| 2400 | unsigned long Index = 0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2401 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2402 | pMem1 = (u8 *)pSrc1; |
| 2403 | pMem2 = (u8 *)pSrc2; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2404 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2405 | for (Index = 0; Index < Length; Index++) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2406 | if (pMem1[Index] > pMem2[Index]) |
| 2407 | return (1); |
| 2408 | else if (pMem1[Index] < pMem2[Index]) |
| 2409 | return (2); |
| 2410 | } |
| 2411 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2412 | /* Equal */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2413 | return (0); |
| 2414 | } |
| 2415 | |
| 2416 | /* |
| 2417 | ======================================================================== |
| 2418 | |
| 2419 | Routine Description: |
| 2420 | Zero out memory block |
| 2421 | |
| 2422 | Arguments: |
| 2423 | pSrc1 Pointer to memory address |
| 2424 | Length Size |
| 2425 | |
| 2426 | Return Value: |
| 2427 | None |
| 2428 | |
| 2429 | IRQL = PASSIVE_LEVEL |
| 2430 | IRQL = DISPATCH_LEVEL |
| 2431 | |
| 2432 | Note: |
| 2433 | |
| 2434 | ======================================================================== |
| 2435 | */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2436 | void RTMPZeroMemory(void *pSrc, unsigned long Length) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2437 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2438 | u8 *pMem; |
| 2439 | unsigned long Index = 0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2440 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2441 | pMem = (u8 *)pSrc; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2442 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2443 | for (Index = 0; Index < Length; Index++) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2444 | pMem[Index] = 0x00; |
| 2445 | } |
| 2446 | } |
| 2447 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2448 | /* |
| 2449 | ======================================================================== |
| 2450 | |
| 2451 | Routine Description: |
| 2452 | Copy data from memory block 1 to memory block 2 |
| 2453 | |
| 2454 | Arguments: |
| 2455 | pDest Pointer to destination memory address |
| 2456 | pSrc Pointer to source memory address |
| 2457 | Length Copy size |
| 2458 | |
| 2459 | Return Value: |
| 2460 | None |
| 2461 | |
| 2462 | IRQL = PASSIVE_LEVEL |
| 2463 | IRQL = DISPATCH_LEVEL |
| 2464 | |
| 2465 | Note: |
| 2466 | |
| 2467 | ======================================================================== |
| 2468 | */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2469 | void RTMPMoveMemory(void *pDest, void *pSrc, unsigned long Length) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2470 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2471 | u8 *pMem1; |
| 2472 | u8 *pMem2; |
| 2473 | u32 Index; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2474 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2475 | ASSERT((Length == 0) || (pDest && pSrc)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2476 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2477 | pMem1 = (u8 *)pDest; |
| 2478 | pMem2 = (u8 *)pSrc; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2479 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2480 | for (Index = 0; Index < Length; Index++) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2481 | pMem1[Index] = pMem2[Index]; |
| 2482 | } |
| 2483 | } |
| 2484 | |
| 2485 | /* |
| 2486 | ======================================================================== |
| 2487 | |
| 2488 | Routine Description: |
| 2489 | Initialize port configuration structure |
| 2490 | |
| 2491 | Arguments: |
| 2492 | Adapter Pointer to our adapter |
| 2493 | |
| 2494 | Return Value: |
| 2495 | None |
| 2496 | |
| 2497 | IRQL = PASSIVE_LEVEL |
| 2498 | |
| 2499 | Note: |
| 2500 | |
| 2501 | ======================================================================== |
| 2502 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2503 | void UserCfgInit(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2504 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2505 | u32 key_index, bss_index; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2506 | |
| 2507 | DBGPRINT(RT_DEBUG_TRACE, ("--> UserCfgInit\n")); |
| 2508 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2509 | /* */ |
Uwe Kleine-König | 9b0131c | 2010-09-01 15:40:25 +0200 | [diff] [blame^] | 2510 | /* part I. initialize common configuration */ |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2511 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2512 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 2513 | pAd->BulkOutReq = 0; |
| 2514 | |
| 2515 | pAd->BulkOutComplete = 0; |
| 2516 | pAd->BulkOutCompleteOther = 0; |
| 2517 | pAd->BulkOutCompleteCancel = 0; |
| 2518 | pAd->BulkInReq = 0; |
| 2519 | pAd->BulkInComplete = 0; |
| 2520 | pAd->BulkInCompleteFail = 0; |
| 2521 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2522 | /*pAd->QuickTimerP = 100; */ |
| 2523 | /*pAd->TurnAggrBulkInCount = 0; */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 2524 | pAd->bUsbTxBulkAggre = 0; |
| 2525 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2526 | /* init as unsed value to ensure driver will set to MCU once. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2527 | pAd->LedIndicatorStrength = 0xFF; |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 2528 | |
| 2529 | pAd->CommonCfg.MaxPktOneTxBulk = 2; |
| 2530 | pAd->CommonCfg.TxBulkFactor = 1; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2531 | pAd->CommonCfg.RxBulkFactor = 1; |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 2532 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2533 | pAd->CommonCfg.TxPower = 100; /*mW */ |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 2534 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2535 | NdisZeroMemory(&pAd->CommonCfg.IOTestParm, |
| 2536 | sizeof(pAd->CommonCfg.IOTestParm)); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2537 | #endif /* RTMP_MAC_USB // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2538 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2539 | for (key_index = 0; key_index < SHARE_KEY_NUM; key_index++) { |
| 2540 | for (bss_index = 0; bss_index < MAX_MBSSID_NUM; bss_index++) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2541 | pAd->SharedKey[bss_index][key_index].KeyLen = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2542 | pAd->SharedKey[bss_index][key_index].CipherAlg = |
| 2543 | CIPHER_NONE; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2544 | } |
| 2545 | } |
| 2546 | |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 2547 | pAd->EepromAccess = FALSE; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2548 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2549 | pAd->Antenna.word = 0; |
| 2550 | pAd->CommonCfg.BBPCurrentBW = BW_20; |
| 2551 | |
| 2552 | pAd->LedCntl.word = 0; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2553 | #ifdef RTMP_MAC_PCI |
| 2554 | pAd->LedIndicatorStrength = 0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2555 | pAd->RLnkCtrlOffset = 0; |
| 2556 | pAd->HostLnkCtrlOffset = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2557 | pAd->StaCfg.PSControl.field.EnableNewPS = TRUE; |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 2558 | pAd->CheckDmaBusyCount = 0; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2559 | #endif /* RTMP_MAC_PCI // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2560 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2561 | pAd->bAutoTxAgcA = FALSE; /* Default is OFF */ |
| 2562 | pAd->bAutoTxAgcG = FALSE; /* Default is OFF */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2563 | pAd->RfIcType = RFIC_2820; |
| 2564 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2565 | /* Init timer for reset complete event */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2566 | pAd->CommonCfg.CentralChannel = 1; |
| 2567 | pAd->bForcePrintTX = FALSE; |
| 2568 | pAd->bForcePrintRX = FALSE; |
| 2569 | pAd->bStaFifoTest = FALSE; |
| 2570 | pAd->bProtectionTest = FALSE; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2571 | pAd->CommonCfg.Dsifs = 10; /* in units of usec */ |
| 2572 | pAd->CommonCfg.TxPower = 100; /*mW */ |
| 2573 | pAd->CommonCfg.TxPowerPercentage = 0xffffffff; /* AUTO */ |
| 2574 | pAd->CommonCfg.TxPowerDefault = 0xffffffff; /* AUTO */ |
| 2575 | pAd->CommonCfg.TxPreamble = Rt802_11PreambleAuto; /* use Long preamble on TX by defaut */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2576 | pAd->CommonCfg.bUseZeroToDisableFragment = FALSE; |
| 2577 | pAd->CommonCfg.RtsThreshold = 2347; |
| 2578 | pAd->CommonCfg.FragmentThreshold = 2346; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2579 | pAd->CommonCfg.UseBGProtection = 0; /* 0: AUTO */ |
| 2580 | pAd->CommonCfg.bEnableTxBurst = TRUE; /*0; */ |
| 2581 | pAd->CommonCfg.PhyMode = 0xff; /* unknown */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2582 | pAd->CommonCfg.BandState = UNKNOWN_BAND; |
| 2583 | pAd->CommonCfg.RadarDetect.CSPeriod = 10; |
| 2584 | pAd->CommonCfg.RadarDetect.CSCount = 0; |
| 2585 | pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2586 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2587 | pAd->CommonCfg.RadarDetect.ChMovingTime = 65; |
| 2588 | pAd->CommonCfg.RadarDetect.LongPulseRadarTh = 3; |
| 2589 | pAd->CommonCfg.bAPSDCapable = FALSE; |
| 2590 | pAd->CommonCfg.bNeedSendTriggerFrame = FALSE; |
| 2591 | pAd->CommonCfg.TriggerTimerCount = 0; |
| 2592 | pAd->CommonCfg.bAPSDForcePowerSave = FALSE; |
| 2593 | pAd->CommonCfg.bCountryFlag = FALSE; |
| 2594 | pAd->CommonCfg.TxStream = 0; |
| 2595 | pAd->CommonCfg.RxStream = 0; |
| 2596 | |
| 2597 | NdisZeroMemory(&pAd->BeaconTxWI, sizeof(pAd->BeaconTxWI)); |
| 2598 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2599 | NdisZeroMemory(&pAd->CommonCfg.HtCapability, |
| 2600 | sizeof(pAd->CommonCfg.HtCapability)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2601 | pAd->HTCEnable = FALSE; |
| 2602 | pAd->bBroadComHT = FALSE; |
| 2603 | pAd->CommonCfg.bRdg = FALSE; |
| 2604 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2605 | NdisZeroMemory(&pAd->CommonCfg.AddHTInfo, |
| 2606 | sizeof(pAd->CommonCfg.AddHTInfo)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2607 | pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE; |
| 2608 | pAd->CommonCfg.BACapability.field.MpduDensity = 0; |
| 2609 | pAd->CommonCfg.BACapability.field.Policy = IMMED_BA; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2610 | pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64; /*32; */ |
| 2611 | pAd->CommonCfg.BACapability.field.TxBAWinLimit = 64; /*32; */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2612 | DBGPRINT(RT_DEBUG_TRACE, |
| 2613 | ("--> UserCfgInit. BACapability = 0x%x\n", |
| 2614 | pAd->CommonCfg.BACapability.word)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2615 | |
| 2616 | pAd->CommonCfg.BACapability.field.AutoBA = FALSE; |
| 2617 | BATableInit(pAd, &pAd->BATable); |
| 2618 | |
| 2619 | pAd->CommonCfg.bExtChannelSwitchAnnouncement = 1; |
| 2620 | pAd->CommonCfg.bHTProtect = 1; |
| 2621 | pAd->CommonCfg.bMIMOPSEnable = TRUE; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2622 | /*2008/11/05:KH add to support Antenna power-saving of AP<-- */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2623 | pAd->CommonCfg.bGreenAPEnable = FALSE; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2624 | /*2008/11/05:KH add to support Antenna power-saving of AP--> */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2625 | pAd->CommonCfg.bBADecline = FALSE; |
| 2626 | pAd->CommonCfg.bDisableReordering = FALSE; |
| 2627 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2628 | if (pAd->MACVersion == 0x28720200) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2629 | pAd->CommonCfg.TxBASize = 13; /*by Jerry recommend */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2630 | } else { |
| 2631 | pAd->CommonCfg.TxBASize = 7; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2632 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2633 | |
| 2634 | pAd->CommonCfg.REGBACapability.word = pAd->CommonCfg.BACapability.word; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2635 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2636 | /*pAd->CommonCfg.HTPhyMode.field.BW = BW_20; */ |
| 2637 | /*pAd->CommonCfg.HTPhyMode.field.MCS = MCS_AUTO; */ |
| 2638 | /*pAd->CommonCfg.HTPhyMode.field.ShortGI = GI_800; */ |
| 2639 | /*pAd->CommonCfg.HTPhyMode.field.STBC = STBC_NONE; */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2640 | pAd->CommonCfg.TxRate = RATE_6; |
| 2641 | |
| 2642 | pAd->CommonCfg.MlmeTransmit.field.MCS = MCS_RATE_6; |
| 2643 | pAd->CommonCfg.MlmeTransmit.field.BW = BW_20; |
| 2644 | pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM; |
| 2645 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2646 | pAd->CommonCfg.BeaconPeriod = 100; /* in mSec */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2647 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2648 | /* */ |
Uwe Kleine-König | 9b0131c | 2010-09-01 15:40:25 +0200 | [diff] [blame^] | 2649 | /* part II. initialize STA specific configuration */ |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2650 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2651 | { |
| 2652 | RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_DIRECT); |
| 2653 | RX_FILTER_CLEAR_FLAG(pAd, fRX_FILTER_ACCEPT_MULTICAST); |
| 2654 | RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_BROADCAST); |
| 2655 | RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_ALL_MULTICAST); |
| 2656 | |
| 2657 | pAd->StaCfg.Psm = PWR_ACTIVE; |
| 2658 | |
| 2659 | pAd->StaCfg.OrigWepStatus = Ndis802_11EncryptionDisabled; |
| 2660 | pAd->StaCfg.PairCipher = Ndis802_11EncryptionDisabled; |
| 2661 | pAd->StaCfg.GroupCipher = Ndis802_11EncryptionDisabled; |
| 2662 | pAd->StaCfg.bMixCipher = FALSE; |
| 2663 | pAd->StaCfg.DefaultKeyId = 0; |
| 2664 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2665 | /* 802.1x port control */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2666 | pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP; |
| 2667 | pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; |
| 2668 | pAd->StaCfg.LastMicErrorTime = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2669 | pAd->StaCfg.MicErrCnt = 0; |
| 2670 | pAd->StaCfg.bBlockAssoc = FALSE; |
| 2671 | pAd->StaCfg.WpaState = SS_NOTUSE; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2672 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2673 | pAd->CommonCfg.NdisRadioStateOff = FALSE; /* New to support microsoft disable radio with OID command */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2674 | |
| 2675 | pAd->StaCfg.RssiTrigger = 0; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2676 | NdisZeroMemory(&pAd->StaCfg.RssiSample, sizeof(struct rt_rssi_sample)); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2677 | pAd->StaCfg.RssiTriggerMode = |
| 2678 | RSSI_TRIGGERED_UPON_BELOW_THRESHOLD; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2679 | pAd->StaCfg.AtimWin = 0; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2680 | pAd->StaCfg.DefaultListenCount = 3; /*default listen count; */ |
| 2681 | pAd->StaCfg.BssType = BSS_INFRA; /* BSS_INFRA or BSS_ADHOC or BSS_MONITOR */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2682 | pAd->StaCfg.bScanReqIsFromWebUI = FALSE; |
| 2683 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE); |
| 2684 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_WAKEUP_NOW); |
| 2685 | |
| 2686 | pAd->StaCfg.bAutoTxRateSwitch = TRUE; |
| 2687 | pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO; |
| 2688 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2689 | |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 2690 | #ifdef PCIE_PS_SUPPORT |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2691 | pAd->brt30xxBanMcuCmd = FALSE; |
| 2692 | pAd->b3090ESpecialChip = FALSE; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2693 | /*KH Debug:the following must be removed */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2694 | pAd->StaCfg.PSControl.field.rt30xxPowerMode = 3; |
| 2695 | pAd->StaCfg.PSControl.field.rt30xxForceASPMTest = 0; |
| 2696 | pAd->StaCfg.PSControl.field.rt30xxFollowHostASPM = 1; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2697 | #endif /* PCIE_PS_SUPPORT // */ |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 2698 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2699 | /* global variables mXXXX used in MAC protocol state machines */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2700 | OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM); |
| 2701 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON); |
| 2702 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON); |
| 2703 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2704 | /* PHY specification */ |
| 2705 | pAd->CommonCfg.PhyMode = PHY_11BG_MIXED; /* default PHY mode */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2706 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED); /* CCK use long preamble */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2707 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2708 | { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2709 | /* user desired power mode */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2710 | pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM; |
| 2711 | pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM; |
| 2712 | pAd->StaCfg.bWindowsACCAMEnable = FALSE; |
| 2713 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2714 | RTMPInitTimer(pAd, &pAd->StaCfg.StaQuickResponeForRateUpTimer, |
| 2715 | GET_TIMER_FUNCTION(StaQuickResponeForRateUpExec), |
| 2716 | pAd, FALSE); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2717 | pAd->StaCfg.StaQuickResponeForRateUpTimerRunning = FALSE; |
| 2718 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2719 | /* Patch for Ndtest */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2720 | pAd->StaCfg.ScanCnt = 0; |
| 2721 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2722 | pAd->StaCfg.bHwRadio = TRUE; /* Default Hardware Radio status is On */ |
| 2723 | pAd->StaCfg.bSwRadio = TRUE; /* Default Software Radio status is On */ |
| 2724 | pAd->StaCfg.bRadio = TRUE; /* bHwRadio && bSwRadio */ |
| 2725 | pAd->StaCfg.bHardwareRadio = FALSE; /* Default is OFF */ |
| 2726 | pAd->StaCfg.bShowHiddenSSID = FALSE; /* Default no show */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2727 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2728 | /* Nitro mode control */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2729 | pAd->StaCfg.bAutoReconnect = TRUE; |
| 2730 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2731 | /* Save the init time as last scan time, the system should do scan after 2 seconds. */ |
| 2732 | /* This patch is for driver wake up from standby mode, system will do scan right away. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2733 | NdisGetSystemUpTime(&pAd->StaCfg.LastScanTime); |
| 2734 | if (pAd->StaCfg.LastScanTime > 10 * OS_HZ) |
| 2735 | pAd->StaCfg.LastScanTime -= (10 * OS_HZ); |
| 2736 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2737 | NdisZeroMemory(pAd->nickname, IW_ESSID_MAX_SIZE + 1); |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 2738 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2739 | sprintf((char *)pAd->nickname, "RT2860STA"); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2740 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2741 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2742 | sprintf((char *)pAd->nickname, "RT2870STA"); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2743 | #endif /* RTMP_MAC_USB // */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2744 | RTMPInitTimer(pAd, &pAd->StaCfg.WpaDisassocAndBlockAssocTimer, |
| 2745 | GET_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc), |
| 2746 | pAd, FALSE); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2747 | pAd->StaCfg.IEEE8021X = FALSE; |
| 2748 | pAd->StaCfg.IEEE8021x_required_keys = FALSE; |
| 2749 | pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2750 | pAd->StaCfg.bRSN_IE_FromWpaSupplicant = FALSE; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2751 | pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2752 | |
| 2753 | NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8); |
| 2754 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2755 | pAd->StaCfg.bAutoConnectByBssid = FALSE; |
| 2756 | pAd->StaCfg.BeaconLostTime = BEACON_LOST_TIME; |
| 2757 | NdisZeroMemory(pAd->StaCfg.WpaPassPhrase, 64); |
| 2758 | pAd->StaCfg.WpaPassPhraseLen = 0; |
| 2759 | pAd->StaCfg.bAutoRoaming = FALSE; |
| 2760 | pAd->StaCfg.bForceTxBurst = FALSE; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2761 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2762 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2763 | /* Default for extra information is not valid */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2764 | pAd->ExtraInfo = EXTRA_INFO_CLEAR; |
| 2765 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2766 | /* Default Config change flag */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2767 | pAd->bConfigChanged = FALSE; |
| 2768 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2769 | /* */ |
| 2770 | /* part III. AP configurations */ |
| 2771 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2772 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2773 | /* */ |
| 2774 | /* part IV. others */ |
| 2775 | /* */ |
| 2776 | /* dynamic BBP R66:sensibity tuning to overcome background noise */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2777 | pAd->BbpTuning.bEnable = TRUE; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2778 | pAd->BbpTuning.FalseCcaLowerThreshold = 100; |
| 2779 | pAd->BbpTuning.FalseCcaUpperThreshold = 512; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2780 | pAd->BbpTuning.R66Delta = 4; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2781 | pAd->Mlme.bEnableAutoAntennaCheck = TRUE; |
| 2782 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2783 | /* */ |
| 2784 | /* Also initial R66CurrentValue, RTUSBResumeMsduTransmission might use this value. */ |
| 2785 | /* if not initial this value, the default value will be 0. */ |
| 2786 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2787 | pAd->BbpTuning.R66CurrentValue = 0x38; |
| 2788 | |
| 2789 | pAd->Bbp94 = BBPR94_DEFAULT; |
| 2790 | pAd->BbpForCCK = FALSE; |
| 2791 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2792 | /* Default is FALSE for test bit 1 */ |
| 2793 | /*pAd->bTest1 = FALSE; */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2794 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2795 | /* initialize MAC table and allocate spin lock */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2796 | NdisZeroMemory(&pAd->MacTab, sizeof(struct rt_mac_table)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2797 | InitializeQueueHeader(&pAd->MacTab.McastPsQueue); |
| 2798 | NdisAllocateSpinLock(&pAd->MacTabLock); |
| 2799 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2800 | /*RTMPInitTimer(pAd, &pAd->RECBATimer, RECBATimerTimeout, pAd, TRUE); */ |
| 2801 | /*RTMPSetTimer(&pAd->RECBATimer, REORDER_EXEC_INTV); */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2802 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2803 | pAd->CommonCfg.bWiFiTest = FALSE; |
| 2804 | #ifdef RTMP_MAC_PCI |
| 2805 | pAd->bPCIclkOff = FALSE; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2806 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2807 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2808 | RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2809 | DBGPRINT(RT_DEBUG_TRACE, ("<-- UserCfgInit\n")); |
| 2810 | } |
| 2811 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2812 | /* IRQL = PASSIVE_LEVEL */ |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2813 | /* */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2814 | /* FUNCTION: AtoH(char *, u8 *, int) */ |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2815 | /* */ |
| 2816 | /* PURPOSE: Converts ascii string to network order hex */ |
| 2817 | /* */ |
| 2818 | /* PARAMETERS: */ |
| 2819 | /* src - pointer to input ascii string */ |
| 2820 | /* dest - pointer to output hex */ |
| 2821 | /* destlen - size of dest */ |
| 2822 | /* */ |
| 2823 | /* COMMENTS: */ |
| 2824 | /* */ |
| 2825 | /* 2 ascii bytes make a hex byte so must put 1st ascii byte of pair */ |
| 2826 | /* into upper nibble and 2nd ascii byte of pair into lower nibble. */ |
| 2827 | /* */ |
| 2828 | /* IRQL = PASSIVE_LEVEL */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2829 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2830 | void AtoH(char *src, u8 *dest, int destlen) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2831 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2832 | char *srcptr; |
| 2833 | u8 *destTemp; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2834 | |
| 2835 | srcptr = src; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2836 | destTemp = (u8 *)dest; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2837 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2838 | while (destlen--) { |
Andy Shevchenko | 1356de0 | 2010-05-24 14:33:27 -0700 | [diff] [blame] | 2839 | *destTemp = hex_to_bin(*srcptr++) << 4; /* Put 1st ascii byte in upper nibble. */ |
| 2840 | *destTemp += hex_to_bin(*srcptr++); /* Add 2nd ascii byte to above. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2841 | destTemp++; |
| 2842 | } |
| 2843 | } |
| 2844 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2845 | /*+++Mark by shiang, not use now, need to remove after confirm */ |
| 2846 | /*---Mark by shiang, not use now, need to remove after confirm */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2847 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2848 | /* |
| 2849 | ======================================================================== |
| 2850 | |
| 2851 | Routine Description: |
| 2852 | Init timer objects |
| 2853 | |
| 2854 | Arguments: |
| 2855 | pAd Pointer to our adapter |
| 2856 | pTimer Timer structure |
| 2857 | pTimerFunc Function to execute when timer expired |
| 2858 | Repeat Ture for period timer |
| 2859 | |
| 2860 | Return Value: |
| 2861 | None |
| 2862 | |
| 2863 | Note: |
| 2864 | |
| 2865 | ======================================================================== |
| 2866 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2867 | void RTMPInitTimer(struct rt_rtmp_adapter *pAd, |
| 2868 | struct rt_ralink_timer *pTimer, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2869 | void *pTimerFunc, void *pData, IN BOOLEAN Repeat) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2870 | { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2871 | /* */ |
| 2872 | /* Set Valid to TRUE for later used. */ |
| 2873 | /* It will crash if we cancel a timer or set a timer */ |
| 2874 | /* that we haven't initialize before. */ |
| 2875 | /* */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2876 | pTimer->Valid = TRUE; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2877 | |
| 2878 | pTimer->PeriodicType = Repeat; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2879 | pTimer->State = FALSE; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2880 | pTimer->cookie = (unsigned long)pData; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2881 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2882 | #ifdef RTMP_TIMER_TASK_SUPPORT |
Bartlomiej Zolnierkiewicz | 59fe2d8 | 2009-04-26 16:06:28 +0200 | [diff] [blame] | 2883 | pTimer->pAd = pAd; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2884 | #endif /* RTMP_TIMER_TASK_SUPPORT // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2885 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2886 | RTMP_OS_Init_Timer(pAd, &pTimer->TimerObj, pTimerFunc, (void *)pTimer); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2887 | } |
| 2888 | |
| 2889 | /* |
| 2890 | ======================================================================== |
| 2891 | |
| 2892 | Routine Description: |
| 2893 | Init timer objects |
| 2894 | |
| 2895 | Arguments: |
| 2896 | pTimer Timer structure |
| 2897 | Value Timer value in milliseconds |
| 2898 | |
| 2899 | Return Value: |
| 2900 | None |
| 2901 | |
| 2902 | Note: |
| 2903 | To use this routine, must call RTMPInitTimer before. |
| 2904 | |
| 2905 | ======================================================================== |
| 2906 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2907 | void RTMPSetTimer(struct rt_ralink_timer *pTimer, unsigned long Value) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2908 | { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2909 | if (pTimer->Valid) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2910 | pTimer->TimerValue = Value; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2911 | pTimer->State = FALSE; |
| 2912 | if (pTimer->PeriodicType == TRUE) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2913 | pTimer->Repeat = TRUE; |
| 2914 | RTMP_SetPeriodicTimer(&pTimer->TimerObj, Value); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2915 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2916 | pTimer->Repeat = FALSE; |
| 2917 | RTMP_OS_Add_Timer(&pTimer->TimerObj, Value); |
| 2918 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2919 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2920 | DBGPRINT_ERR(("RTMPSetTimer failed, Timer hasn't been initialize!\n")); |
| 2921 | } |
| 2922 | } |
| 2923 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2924 | /* |
| 2925 | ======================================================================== |
| 2926 | |
| 2927 | Routine Description: |
| 2928 | Init timer objects |
| 2929 | |
| 2930 | Arguments: |
| 2931 | pTimer Timer structure |
| 2932 | Value Timer value in milliseconds |
| 2933 | |
| 2934 | Return Value: |
| 2935 | None |
| 2936 | |
| 2937 | Note: |
| 2938 | To use this routine, must call RTMPInitTimer before. |
| 2939 | |
| 2940 | ======================================================================== |
| 2941 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2942 | void RTMPModTimer(struct rt_ralink_timer *pTimer, unsigned long Value) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2943 | { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2944 | BOOLEAN Cancel; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2945 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2946 | if (pTimer->Valid) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2947 | pTimer->TimerValue = Value; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2948 | pTimer->State = FALSE; |
| 2949 | if (pTimer->PeriodicType == TRUE) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2950 | RTMPCancelTimer(pTimer, &Cancel); |
| 2951 | RTMPSetTimer(pTimer, Value); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2952 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2953 | RTMP_OS_Mod_Timer(&pTimer->TimerObj, Value); |
| 2954 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2955 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2956 | DBGPRINT_ERR(("RTMPModTimer failed, Timer hasn't been initialize!\n")); |
| 2957 | } |
| 2958 | } |
| 2959 | |
| 2960 | /* |
| 2961 | ======================================================================== |
| 2962 | |
| 2963 | Routine Description: |
| 2964 | Cancel timer objects |
| 2965 | |
| 2966 | Arguments: |
| 2967 | Adapter Pointer to our adapter |
| 2968 | |
| 2969 | Return Value: |
| 2970 | None |
| 2971 | |
| 2972 | IRQL = PASSIVE_LEVEL |
| 2973 | IRQL = DISPATCH_LEVEL |
| 2974 | |
| 2975 | Note: |
| 2976 | 1.) To use this routine, must call RTMPInitTimer before. |
| 2977 | 2.) Reset NIC to initial state AS IS system boot up time. |
| 2978 | |
| 2979 | ======================================================================== |
| 2980 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2981 | void RTMPCancelTimer(struct rt_ralink_timer *pTimer, OUT BOOLEAN * pCancelled) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2982 | { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2983 | if (pTimer->Valid) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2984 | if (pTimer->State == FALSE) |
| 2985 | pTimer->Repeat = FALSE; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2986 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2987 | RTMP_OS_Del_Timer(&pTimer->TimerObj, pCancelled); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2988 | |
| 2989 | if (*pCancelled == TRUE) |
| 2990 | pTimer->State = TRUE; |
| 2991 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2992 | #ifdef RTMP_TIMER_TASK_SUPPORT |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2993 | /* We need to go-through the TimerQ to findout this timer handler and remove it if */ |
| 2994 | /* it's still waiting for execution. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2995 | RtmpTimerQRemove(pTimer->pAd, pTimer); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2996 | #endif /* RTMP_TIMER_TASK_SUPPORT // */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 2997 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2998 | DBGPRINT_ERR(("RTMPCancelTimer failed, Timer hasn't been initialize!\n")); |
| 2999 | } |
| 3000 | } |
| 3001 | |
| 3002 | /* |
| 3003 | ======================================================================== |
| 3004 | |
| 3005 | Routine Description: |
| 3006 | Set LED Status |
| 3007 | |
| 3008 | Arguments: |
| 3009 | pAd Pointer to our adapter |
| 3010 | Status LED Status |
| 3011 | |
| 3012 | Return Value: |
| 3013 | None |
| 3014 | |
| 3015 | IRQL = PASSIVE_LEVEL |
| 3016 | IRQL = DISPATCH_LEVEL |
| 3017 | |
| 3018 | Note: |
| 3019 | |
| 3020 | ======================================================================== |
| 3021 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 3022 | void RTMPSetLED(struct rt_rtmp_adapter *pAd, u8 Status) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 3023 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3024 | /*unsigned long data; */ |
| 3025 | u8 HighByte = 0; |
| 3026 | u8 LowByte; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 3027 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3028 | LowByte = pAd->LedCntl.field.LedMode & 0x7f; |
| 3029 | switch (Status) { |
| 3030 | case LED_LINK_DOWN: |
| 3031 | HighByte = 0x20; |
| 3032 | AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte); |
| 3033 | pAd->LedIndicatorStrength = 0; |
| 3034 | break; |
| 3035 | case LED_LINK_UP: |
| 3036 | if (pAd->CommonCfg.Channel > 14) |
| 3037 | HighByte = 0xa0; |
| 3038 | else |
| 3039 | HighByte = 0x60; |
| 3040 | AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte); |
| 3041 | break; |
| 3042 | case LED_RADIO_ON: |
| 3043 | HighByte = 0x20; |
| 3044 | AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte); |
| 3045 | break; |
| 3046 | case LED_HALT: |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3047 | LowByte = 0; /* Driver sets MAC register and MAC controls LED */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3048 | case LED_RADIO_OFF: |
| 3049 | HighByte = 0; |
| 3050 | AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte); |
| 3051 | break; |
| 3052 | case LED_WPS: |
| 3053 | HighByte = 0x10; |
| 3054 | AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte); |
| 3055 | break; |
| 3056 | case LED_ON_SITE_SURVEY: |
| 3057 | HighByte = 0x08; |
| 3058 | AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte); |
| 3059 | break; |
| 3060 | case LED_POWER_UP: |
| 3061 | HighByte = 0x04; |
| 3062 | AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte); |
| 3063 | break; |
| 3064 | default: |
| 3065 | DBGPRINT(RT_DEBUG_WARN, |
| 3066 | ("RTMPSetLED::Unknown Status %d\n", Status)); |
| 3067 | break; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 3068 | } |
| 3069 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3070 | /* */ |
| 3071 | /* Keep LED status for LED SiteSurvey mode. */ |
| 3072 | /* After SiteSurvey, we will set the LED mode to previous status. */ |
| 3073 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 3074 | if ((Status != LED_ON_SITE_SURVEY) && (Status != LED_POWER_UP)) |
| 3075 | pAd->LedStatus = Status; |
| 3076 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3077 | DBGPRINT(RT_DEBUG_TRACE, |
| 3078 | ("RTMPSetLED::Mode=%d,HighByte=0x%02x,LowByte=0x%02x\n", |
| 3079 | pAd->LedCntl.field.LedMode, HighByte, LowByte)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 3080 | } |
| 3081 | |
| 3082 | /* |
| 3083 | ======================================================================== |
| 3084 | |
| 3085 | Routine Description: |
| 3086 | Set LED Signal Stregth |
| 3087 | |
| 3088 | Arguments: |
| 3089 | pAd Pointer to our adapter |
| 3090 | Dbm Signal Stregth |
| 3091 | |
| 3092 | Return Value: |
| 3093 | None |
| 3094 | |
| 3095 | IRQL = PASSIVE_LEVEL |
| 3096 | |
| 3097 | Note: |
| 3098 | Can be run on any IRQL level. |
| 3099 | |
| 3100 | According to Microsoft Zero Config Wireless Signal Stregth definition as belows. |
| 3101 | <= -90 No Signal |
| 3102 | <= -81 Very Low |
| 3103 | <= -71 Low |
| 3104 | <= -67 Good |
| 3105 | <= -57 Very Good |
| 3106 | > -57 Excellent |
| 3107 | ======================================================================== |
| 3108 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 3109 | void RTMPSetSignalLED(struct rt_rtmp_adapter *pAd, IN NDIS_802_11_RSSI Dbm) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 3110 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3111 | u8 nLed = 0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 3112 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3113 | if (pAd->LedCntl.field.LedMode == LED_MODE_SIGNAL_STREGTH) { |
| 3114 | if (Dbm <= -90) |
| 3115 | nLed = 0; |
| 3116 | else if (Dbm <= -81) |
| 3117 | nLed = 1; |
| 3118 | else if (Dbm <= -71) |
| 3119 | nLed = 3; |
| 3120 | else if (Dbm <= -67) |
| 3121 | nLed = 7; |
| 3122 | else if (Dbm <= -57) |
| 3123 | nLed = 15; |
| 3124 | else |
| 3125 | nLed = 31; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 3126 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3127 | /* */ |
| 3128 | /* Update Signal Stregth to firmware if changed. */ |
| 3129 | /* */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3130 | if (pAd->LedIndicatorStrength != nLed) { |
| 3131 | AsicSendCommandToMcu(pAd, 0x51, 0xff, nLed, |
| 3132 | pAd->LedCntl.field.Polarity); |
| 3133 | pAd->LedIndicatorStrength = nLed; |
| 3134 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 3135 | } |
| 3136 | } |
| 3137 | |
| 3138 | /* |
| 3139 | ======================================================================== |
| 3140 | |
| 3141 | Routine Description: |
| 3142 | Enable RX |
| 3143 | |
| 3144 | Arguments: |
| 3145 | pAd Pointer to our adapter |
| 3146 | |
| 3147 | Return Value: |
| 3148 | None |
| 3149 | |
| 3150 | IRQL <= DISPATCH_LEVEL |
| 3151 | |
| 3152 | Note: |
| 3153 | Before Enable RX, make sure you have enabled Interrupt. |
| 3154 | ======================================================================== |
| 3155 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 3156 | void RTMPEnableRxTx(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 3157 | { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3158 | /* WPDMA_GLO_CFG_STRUC GloCfg; */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3159 | /* unsigned long i = 0; */ |
| 3160 | u32 rx_filter_flag; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3161 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 3162 | DBGPRINT(RT_DEBUG_TRACE, ("==> RTMPEnableRxTx\n")); |
| 3163 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3164 | /* Enable Rx DMA. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 3165 | RT28XXDMAEnable(pAd); |
| 3166 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3167 | /* enable RX of MAC block */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3168 | if (pAd->OpMode == OPMODE_AP) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3169 | rx_filter_flag = APNORMAL; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 3170 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3171 | RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, rx_filter_flag); /* enable RX of DMA block */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3172 | } else { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3173 | if (pAd->CommonCfg.PSPXlink) |
| 3174 | rx_filter_flag = PSPXLINK; |
| 3175 | else |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3176 | rx_filter_flag = STANORMAL; /* Staion not drop control frame will fail WiFi Certification. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3177 | RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, rx_filter_flag); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 3178 | } |
| 3179 | |
| 3180 | RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0xc); |
| 3181 | DBGPRINT(RT_DEBUG_TRACE, ("<== RTMPEnableRxTx\n")); |
| 3182 | } |
| 3183 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3184 | /*+++Add by shiang, move from os/linux/rt_main_dev.c */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 3185 | void CfgInitHook(struct rt_rtmp_adapter *pAd) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3186 | { |
| 3187 | pAd->bBroadComHT = TRUE; |
| 3188 | } |
| 3189 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 3190 | int rt28xx_init(struct rt_rtmp_adapter *pAd, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3191 | char *pDefaultMac, char *pHostName) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3192 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3193 | u32 index; |
| 3194 | u8 TmpPhy; |
| 3195 | int Status; |
| 3196 | u32 MacCsr0 = 0; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3197 | |
| 3198 | #ifdef RTMP_MAC_PCI |
| 3199 | { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3200 | /* If dirver doesn't wake up firmware here, */ |
| 3201 | /* NICLoadFirmware will hang forever when interface is up again. */ |
| 3202 | /* RT2860 PCI */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3203 | if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) && |
| 3204 | OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) { |
| 3205 | AUTO_WAKEUP_STRUC AutoWakeupCfg; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3206 | AsicForceWakeup(pAd, TRUE); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3207 | AutoWakeupCfg.word = 0; |
| 3208 | RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, |
| 3209 | AutoWakeupCfg.word); |
| 3210 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE); |
| 3211 | } |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3212 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3213 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3214 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3215 | /* reset Adapter flags */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3216 | RTMP_CLEAR_FLAGS(pAd); |
| 3217 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3218 | /* Init BssTab & ChannelInfo tabbles for auto channel select. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3219 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3220 | /* Allocate BA Reordering memory */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3221 | ba_reordering_resource_init(pAd, MAX_REORDERING_MPDU_NUM); |
| 3222 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3223 | /* Make sure MAC gets ready. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3224 | index = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3225 | do { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3226 | RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0); |
| 3227 | pAd->MACVersion = MacCsr0; |
| 3228 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3229 | if ((pAd->MACVersion != 0x00) |
| 3230 | && (pAd->MACVersion != 0xFFFFFFFF)) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3231 | break; |
| 3232 | |
| 3233 | RTMPusecDelay(10); |
| 3234 | } while (index++ < 100); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3235 | DBGPRINT(RT_DEBUG_TRACE, |
| 3236 | ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3237 | |
| 3238 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 3239 | #ifdef PCIE_PS_SUPPORT |
| 3240 | /*Iverson patch PCIE L1 issue to make sure that driver can be read,write ,BBP and RF register at pcie L.1 level */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3241 | if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) |
| 3242 | && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) { |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 3243 | RTMP_IO_READ32(pAd, AUX_CTRL, &MacCsr0); |
| 3244 | MacCsr0 |= 0x402; |
| 3245 | RTMP_IO_WRITE32(pAd, AUX_CTRL, MacCsr0); |
| 3246 | DBGPRINT(RT_DEBUG_TRACE, ("AUX_CTRL = 0x%x\n", MacCsr0)); |
| 3247 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3248 | #endif /* PCIE_PS_SUPPORT // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3249 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3250 | /* To fix driver disable/enable hang issue when radio off */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3251 | RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x2); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3252 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3253 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3254 | /* Disable DMA */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3255 | RT28XXDMADisable(pAd); |
| 3256 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3257 | /* Load 8051 firmware */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3258 | Status = NICLoadFirmware(pAd); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3259 | if (Status != NDIS_STATUS_SUCCESS) { |
| 3260 | DBGPRINT_ERR(("NICLoadFirmware failed, Status[=0x%08x]\n", |
| 3261 | Status)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3262 | goto err1; |
| 3263 | } |
| 3264 | |
| 3265 | NICLoadRateSwitchingParams(pAd); |
| 3266 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3267 | /* Disable interrupts here which is as soon as possible */ |
| 3268 | /* This statement should never be true. We might consider to remove it later */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3269 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3270 | if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE)) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3271 | RTMP_ASIC_INTERRUPT_DISABLE(pAd); |
| 3272 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3273 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3274 | |
| 3275 | Status = RTMPAllocTxRxRingMemory(pAd); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3276 | if (Status != NDIS_STATUS_SUCCESS) { |
| 3277 | DBGPRINT_ERR(("RTMPAllocDMAMemory failed, Status[=0x%08x]\n", |
| 3278 | Status)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3279 | goto err1; |
| 3280 | } |
| 3281 | |
| 3282 | RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE); |
| 3283 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3284 | /* initialize MLME */ |
| 3285 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3286 | |
| 3287 | Status = RtmpMgmtTaskInit(pAd); |
| 3288 | if (Status != NDIS_STATUS_SUCCESS) |
| 3289 | goto err2; |
| 3290 | |
| 3291 | Status = MlmeInit(pAd); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3292 | if (Status != NDIS_STATUS_SUCCESS) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3293 | DBGPRINT_ERR(("MlmeInit failed, Status[=0x%08x]\n", Status)); |
| 3294 | goto err2; |
| 3295 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3296 | /* Initialize pAd->StaCfg, pAd->ApCfg, pAd->CommonCfg to manufacture default */ |
| 3297 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3298 | UserCfgInit(pAd); |
| 3299 | Status = RtmpNetTaskInit(pAd); |
| 3300 | if (Status != NDIS_STATUS_SUCCESS) |
| 3301 | goto err3; |
| 3302 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3303 | /* COPY_MAC_ADDR(pAd->ApCfg.MBSSID[apidx].Bssid, netif->hwaddr); */ |
| 3304 | /* pAd->bForcePrintTX = TRUE; */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3305 | |
| 3306 | CfgInitHook(pAd); |
| 3307 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3308 | NdisAllocateSpinLock(&pAd->MacTabLock); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3309 | |
| 3310 | MeasureReqTabInit(pAd); |
| 3311 | TpcReqTabInit(pAd); |
| 3312 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3313 | /* */ |
| 3314 | /* Init the hardware, we need to init asic before read registry, otherwise mac register will be reset */ |
| 3315 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3316 | Status = NICInitializeAdapter(pAd, TRUE); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3317 | if (Status != NDIS_STATUS_SUCCESS) { |
| 3318 | DBGPRINT_ERR(("NICInitializeAdapter failed, Status[=0x%08x]\n", |
| 3319 | Status)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3320 | if (Status != NDIS_STATUS_SUCCESS) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3321 | goto err3; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3322 | } |
| 3323 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3324 | DBGPRINT(RT_DEBUG_OFF, ("1. Phy Mode = %d\n", pAd->CommonCfg.PhyMode)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3325 | |
| 3326 | #ifdef RTMP_MAC_USB |
| 3327 | pAd->CommonCfg.bMultipleIRP = FALSE; |
| 3328 | |
| 3329 | if (pAd->CommonCfg.bMultipleIRP) |
| 3330 | pAd->CommonCfg.NumOfBulkInIRP = RX_RING_SIZE; |
| 3331 | else |
| 3332 | pAd->CommonCfg.NumOfBulkInIRP = 1; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3333 | #endif /* RTMP_MAC_USB // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3334 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3335 | /*Init Ba Capability parameters. */ |
| 3336 | /* RT28XX_BA_INIT(pAd); */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3337 | pAd->CommonCfg.DesiredHtPhy.MpduDensity = |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3338 | (u8)pAd->CommonCfg.BACapability.field.MpduDensity; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3339 | pAd->CommonCfg.DesiredHtPhy.AmsduEnable = |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3340 | (u16)pAd->CommonCfg.BACapability.field.AmsduEnable; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3341 | pAd->CommonCfg.DesiredHtPhy.AmsduSize = |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3342 | (u16)pAd->CommonCfg.BACapability.field.AmsduSize; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3343 | pAd->CommonCfg.DesiredHtPhy.MimoPs = |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3344 | (u16)pAd->CommonCfg.BACapability.field.MMPSmode; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3345 | /* UPdata to HT IE */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3346 | pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3347 | (u16)pAd->CommonCfg.BACapability.field.MMPSmode; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3348 | pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3349 | (u16)pAd->CommonCfg.BACapability.field.AmsduSize; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3350 | pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3351 | (u8)pAd->CommonCfg.BACapability.field.MpduDensity; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3352 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3353 | /* after reading Registry, we now know if in AP mode or STA mode */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3354 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3355 | /* Load 8051 firmware; crash when FW image not existent */ |
| 3356 | /* Status = NICLoadFirmware(pAd); */ |
| 3357 | /* if (Status != NDIS_STATUS_SUCCESS) */ |
| 3358 | /* break; */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3359 | |
| 3360 | DBGPRINT(RT_DEBUG_OFF, ("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode)); |
| 3361 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3362 | /* We should read EEPROM for all cases. rt2860b */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3363 | NICReadEEPROMParameters(pAd, (u8 *)pDefaultMac); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3364 | |
| 3365 | DBGPRINT(RT_DEBUG_OFF, ("3. Phy Mode = %d\n", pAd->CommonCfg.PhyMode)); |
| 3366 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3367 | NICInitAsicFromEEPROM(pAd); /*rt2860b */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3368 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3369 | /* Set PHY to appropriate mode */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3370 | TmpPhy = pAd->CommonCfg.PhyMode; |
| 3371 | pAd->CommonCfg.PhyMode = 0xff; |
| 3372 | RTMPSetPhyMode(pAd, TmpPhy); |
| 3373 | SetCommonHT(pAd); |
| 3374 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3375 | /* No valid channels. */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3376 | if (pAd->ChannelListNum == 0) { |
| 3377 | DBGPRINT(RT_DEBUG_ERROR, |
| 3378 | ("Wrong configuration. No valid channel found. Check \"ContryCode\" and \"ChannelGeography\" setting.\n")); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3379 | goto err4; |
| 3380 | } |
| 3381 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3382 | DBGPRINT(RT_DEBUG_OFF, |
| 3383 | ("MCS Set = %02x %02x %02x %02x %02x\n", |
| 3384 | pAd->CommonCfg.HtCapability.MCSSet[0], |
| 3385 | pAd->CommonCfg.HtCapability.MCSSet[1], |
| 3386 | pAd->CommonCfg.HtCapability.MCSSet[2], |
| 3387 | pAd->CommonCfg.HtCapability.MCSSet[3], |
| 3388 | pAd->CommonCfg.HtCapability.MCSSet[4])); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3389 | |
| 3390 | #ifdef RTMP_RF_RW_SUPPORT |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3391 | /*Init RT30xx RFRegisters after read RFIC type from EEPROM */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3392 | NICInitRFRegisters(pAd); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3393 | #endif /* RTMP_RF_RW_SUPPORT // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3394 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3395 | /* APInitialize(pAd); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3396 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3397 | /* */ |
| 3398 | /* Initialize RF register to default value */ |
| 3399 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3400 | AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE); |
| 3401 | AsicLockChannel(pAd, pAd->CommonCfg.Channel); |
| 3402 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3403 | /* 8051 firmware require the signal during booting time. */ |
| 3404 | /*2008/11/28:KH marked the following codes to patch Frequency offset bug */ |
| 3405 | /*AsicSendCommandToMcu(pAd, 0x72, 0xFF, 0x00, 0x00); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3406 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3407 | if (pAd && (Status != NDIS_STATUS_SUCCESS)) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3408 | /* */ |
| 3409 | /* Undo everything if it failed */ |
| 3410 | /* */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3411 | if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3412 | /* NdisMDeregisterInterrupt(&pAd->Interrupt); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3413 | RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE); |
| 3414 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3415 | /* RTMPFreeAdapter(pAd); // we will free it in disconnect() */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3416 | } else if (pAd) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3417 | /* Microsoft HCT require driver send a disconnect event after driver initialization. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3418 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3419 | /* pAd->IndicateMediaState = NdisMediaStateDisconnected; */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3420 | RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE); |
| 3421 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3422 | DBGPRINT(RT_DEBUG_TRACE, |
| 3423 | ("NDIS_STATUS_MEDIA_DISCONNECT Event B!\n")); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3424 | |
| 3425 | #ifdef RTMP_MAC_USB |
| 3426 | RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS); |
| 3427 | RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS); |
| 3428 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3429 | /* */ |
| 3430 | /* Support multiple BulkIn IRP, */ |
| 3431 | /* the value on pAd->CommonCfg.NumOfBulkInIRP may be large than 1. */ |
| 3432 | /* */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3433 | for (index = 0; index < pAd->CommonCfg.NumOfBulkInIRP; index++) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3434 | RTUSBBulkReceive(pAd); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3435 | DBGPRINT(RT_DEBUG_TRACE, ("RTUSBBulkReceive!\n")); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3436 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3437 | #endif /* RTMP_MAC_USB // */ |
| 3438 | } /* end of else */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3439 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3440 | /* Set up the Mac address */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3441 | RtmpOSNetDevAddrSet(pAd->net_dev, &pAd->CurrentAddress[0]); |
| 3442 | |
| 3443 | DBGPRINT_S(Status, ("<==== rt28xx_init, Status=%x\n", Status)); |
| 3444 | |
| 3445 | return TRUE; |
| 3446 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3447 | err4: |
| 3448 | err3: |
| 3449 | MlmeHalt(pAd); |
| 3450 | err2: |
| 3451 | RTMPFreeTxRxRingMemory(pAd); |
| 3452 | err1: |
| 3453 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3454 | os_free_mem(pAd, pAd->mpdu_blk_pool.mem); /* free BA pool */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3455 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3456 | /* shall not set priv to NULL here because the priv didn't been free yet. */ |
| 3457 | /*net_dev->ml_priv = 0; */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3458 | #ifdef ST |
| 3459 | err0: |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3460 | #endif /* ST // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3461 | |
Sebastian Dalfuß | 06aea99 | 2009-11-07 17:31:12 +0100 | [diff] [blame] | 3462 | DBGPRINT(RT_DEBUG_ERROR, ("rt28xx Initialized fail!\n")); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3463 | return FALSE; |
| 3464 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3465 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3466 | /*---Add by shiang, move from os/linux/rt_main_dev.c */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3467 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 3468 | static int RtmpChipOpsRegister(struct rt_rtmp_adapter *pAd, int infType) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3469 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 3470 | struct rt_rtmp_chip_op *pChipOps = &pAd->chipOps; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3471 | int status; |
| 3472 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 3473 | memset(pChipOps, 0, sizeof(struct rt_rtmp_chip_op)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3474 | |
| 3475 | /* set eeprom related hook functions */ |
| 3476 | status = RtmpChipOpsEepromHook(pAd, infType); |
| 3477 | |
| 3478 | /* set mcu related hook functions */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3479 | switch (infType) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3480 | #ifdef RTMP_PCI_SUPPORT |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3481 | case RTMP_DEV_INF_PCI: |
| 3482 | pChipOps->loadFirmware = RtmpAsicLoadFirmware; |
| 3483 | pChipOps->eraseFirmware = RtmpAsicEraseFirmware; |
| 3484 | pChipOps->sendCommandToMcu = RtmpAsicSendCommandToMcu; |
| 3485 | break; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3486 | #endif /* RTMP_PCI_SUPPORT // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3487 | #ifdef RTMP_USB_SUPPORT |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3488 | case RTMP_DEV_INF_USB: |
| 3489 | pChipOps->loadFirmware = RtmpAsicLoadFirmware; |
| 3490 | pChipOps->sendCommandToMcu = RtmpAsicSendCommandToMcu; |
| 3491 | break; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3492 | #endif /* RTMP_USB_SUPPORT // */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3493 | default: |
| 3494 | break; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3495 | } |
| 3496 | |
| 3497 | return status; |
| 3498 | } |
| 3499 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 3500 | int RtmpRaDevCtrlInit(struct rt_rtmp_adapter *pAd, IN RTMP_INF_TYPE infType) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3501 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3502 | /*void *handle; */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3503 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3504 | /* Assign the interface type. We need use it when do register/EEPROM access. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3505 | pAd->infType = infType; |
| 3506 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3507 | pAd->OpMode = OPMODE_STA; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3508 | DBGPRINT(RT_DEBUG_TRACE, |
| 3509 | ("STA Driver version-%s\n", STA_DRIVER_VERSION)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3510 | |
| 3511 | #ifdef RTMP_MAC_USB |
| 3512 | init_MUTEX(&(pAd->UsbVendorReq_semaphore)); |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3513 | os_alloc_mem(pAd, (u8 **) & pAd->UsbVendorReqBuf, |
Bartlomiej Zolnierkiewicz | ca58fb3 | 2009-10-21 22:44:42 +0200 | [diff] [blame] | 3514 | MAX_PARAM_BUFFER_SIZE - 1); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3515 | if (pAd->UsbVendorReqBuf == NULL) { |
| 3516 | DBGPRINT(RT_DEBUG_ERROR, |
| 3517 | ("Allocate vendor request temp buffer failed!\n")); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3518 | return FALSE; |
| 3519 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3520 | #endif /* RTMP_MAC_USB // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3521 | |
| 3522 | RtmpChipOpsRegister(pAd, infType); |
| 3523 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3524 | return 0; |
| 3525 | } |
| 3526 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 3527 | BOOLEAN RtmpRaDevCtrlExit(struct rt_rtmp_adapter *pAd) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3528 | { |
| 3529 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3530 | RTMPFreeAdapter(pAd); |
| 3531 | |
| 3532 | return TRUE; |
| 3533 | } |
| 3534 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3535 | /* not yet support MBSS */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 3536 | struct net_device *get_netdev_from_bssid(struct rt_rtmp_adapter *pAd, u8 FromWhichBSSID) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3537 | { |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 3538 | struct net_device *dev_p = NULL; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3539 | |
| 3540 | { |
| 3541 | dev_p = pAd->net_dev; |
| 3542 | } |
| 3543 | |
| 3544 | ASSERT(dev_p); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 3545 | return dev_p; /* return one of MBSS */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 3546 | } |