PCI: Add helpers to manage pci_dev->irq and pci_dev->irq_managed
[linux-2.6/btrfs-unstable.git] / drivers / staging / rtl8188eu / hal / rtl8188e_hal_init.c
blob7904d2260f2cfd6b0f0e2eafeb1727ddab5683e7
1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
20 #define _HAL_INIT_C_
22 #include <linux/firmware.h>
23 #include <linux/vmalloc.h>
24 #include <drv_types.h>
25 #include <rtw_efuse.h>
26 #include <phy.h>
27 #include <rtl8188e_hal.h>
29 #include <rtw_iol.h>
31 void iol_mode_enable(struct adapter *padapter, u8 enable)
33 u8 reg_0xf0 = 0;
35 if (enable) {
36 /* Enable initial offload */
37 reg_0xf0 = usb_read8(padapter, REG_SYS_CFG);
38 usb_write8(padapter, REG_SYS_CFG, reg_0xf0|SW_OFFLOAD_EN);
40 if (!padapter->bFWReady) {
41 DBG_88E("bFWReady == false call reset 8051...\n");
42 _8051Reset88E(padapter);
45 } else {
46 /* disable initial offload */
47 reg_0xf0 = usb_read8(padapter, REG_SYS_CFG);
48 usb_write8(padapter, REG_SYS_CFG, reg_0xf0 & ~SW_OFFLOAD_EN);
52 s32 iol_execute(struct adapter *padapter, u8 control)
54 s32 status = _FAIL;
55 u8 reg_0x88 = 0;
56 u32 start = 0, passing_time = 0;
58 control = control&0x0f;
59 reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0);
60 usb_write8(padapter, REG_HMEBOX_E0, reg_0x88|control);
62 start = jiffies;
63 while ((reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0)) & control &&
64 (passing_time = rtw_get_passing_time_ms(start)) < 1000) {
68 reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0);
69 status = (reg_0x88 & control) ? _FAIL : _SUCCESS;
70 if (reg_0x88 & control<<4)
71 status = _FAIL;
72 return status;
75 static s32 iol_InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy)
77 s32 rst = _SUCCESS;
78 iol_mode_enable(padapter, 1);
79 usb_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy);
80 rst = iol_execute(padapter, CMD_INIT_LLT);
81 iol_mode_enable(padapter, 0);
82 return rst;
86 s32 rtl8188e_iol_efuse_patch(struct adapter *padapter)
88 s32 result = _SUCCESS;
90 DBG_88E("==> %s\n", __func__);
91 if (rtw_IOL_applied(padapter)) {
92 iol_mode_enable(padapter, 1);
93 result = iol_execute(padapter, CMD_READ_EFUSE_MAP);
94 if (result == _SUCCESS)
95 result = iol_execute(padapter, CMD_EFUSE_PATCH);
97 iol_mode_enable(padapter, 0);
99 return result;
102 #define MAX_REG_BOLCK_SIZE 196
104 void _8051Reset88E(struct adapter *padapter)
106 u8 u1bTmp;
108 u1bTmp = usb_read8(padapter, REG_SYS_FUNC_EN+1);
109 usb_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp&(~BIT2));
110 usb_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp|(BIT2));
111 DBG_88E("=====> _8051Reset88E(): 8051 reset success .\n");
114 void rtl8188e_InitializeFirmwareVars(struct adapter *padapter)
116 struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter);
118 /* Init Fw LPS related. */
119 padapter->pwrctrlpriv.bFwCurrentInPSMode = false;
121 /* Init H2C counter. by tynli. 2009.12.09. */
122 pHalData->LastHMEBoxNum = 0;
125 static void rtl8188e_free_hal_data(struct adapter *padapter)
127 kfree(padapter->HalData);
128 padapter->HalData = NULL;
131 static struct HAL_VERSION ReadChipVersion8188E(struct adapter *padapter)
133 u32 value32;
134 struct HAL_VERSION ChipVersion;
135 struct hal_data_8188e *pHalData;
137 pHalData = GET_HAL_DATA(padapter);
139 value32 = usb_read32(padapter, REG_SYS_CFG);
140 ChipVersion.ICType = CHIP_8188E;
141 ChipVersion.ChipType = ((value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP);
143 ChipVersion.RFType = RF_TYPE_1T1R;
144 ChipVersion.VendorType = ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC);
145 ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK)>>CHIP_VER_RTL_SHIFT; /* IC version (CUT) */
147 /* For regulator mode. by tynli. 2011.01.14 */
148 pHalData->RegulatorMode = ((value32 & TRP_BT_EN) ? RT_LDO_REGULATOR : RT_SWITCHING_REGULATOR);
150 ChipVersion.ROMVer = 0; /* ROM code version. */
152 dump_chip_info(ChipVersion);
154 pHalData->VersionID = ChipVersion;
156 if (IS_1T2R(ChipVersion)) {
157 pHalData->rf_type = RF_1T2R;
158 pHalData->NumTotalRFPath = 2;
159 } else if (IS_2T2R(ChipVersion)) {
160 pHalData->rf_type = RF_2T2R;
161 pHalData->NumTotalRFPath = 2;
162 } else{
163 pHalData->rf_type = RF_1T1R;
164 pHalData->NumTotalRFPath = 1;
167 MSG_88E("RF_Type is %x!!\n", pHalData->rf_type);
169 return ChipVersion;
172 static void rtl8188e_read_chip_version(struct adapter *padapter)
174 ReadChipVersion8188E(padapter);
177 static void rtl8188e_SetHalODMVar(struct adapter *Adapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet)
179 struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter);
180 struct odm_dm_struct *podmpriv = &pHalData->odmpriv;
181 switch (eVariable) {
182 case HAL_ODM_STA_INFO:
184 struct sta_info *psta = pValue1;
186 if (bSet) {
187 DBG_88E("### Set STA_(%d) info\n", psta->mac_id);
188 ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, psta);
189 ODM_RAInfo_Init(podmpriv, psta->mac_id);
190 } else {
191 DBG_88E("### Clean STA_(%d) info\n", psta->mac_id);
192 ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, NULL);
195 break;
196 case HAL_ODM_P2P_STATE:
197 ODM_CmnInfoUpdate(podmpriv, ODM_CMNINFO_WIFI_DIRECT, bSet);
198 break;
199 case HAL_ODM_WIFI_DISPLAY_STATE:
200 ODM_CmnInfoUpdate(podmpriv, ODM_CMNINFO_WIFI_DISPLAY, bSet);
201 break;
202 default:
203 break;
207 static void hal_notch_filter_8188e(struct adapter *adapter, bool enable)
209 if (enable) {
210 DBG_88E("Enable notch filter\n");
211 usb_write8(adapter, rOFDM0_RxDSP+1, usb_read8(adapter, rOFDM0_RxDSP+1) | BIT1);
212 } else {
213 DBG_88E("Disable notch filter\n");
214 usb_write8(adapter, rOFDM0_RxDSP+1, usb_read8(adapter, rOFDM0_RxDSP+1) & ~BIT1);
217 void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc)
219 pHalFunc->free_hal_data = &rtl8188e_free_hal_data;
221 pHalFunc->dm_init = &rtl8188e_init_dm_priv;
223 pHalFunc->read_chip_version = &rtl8188e_read_chip_version;
225 pHalFunc->set_bwmode_handler = &phy_set_bw_mode;
226 pHalFunc->set_channel_handler = &phy_sw_chnl;
228 pHalFunc->hal_dm_watchdog = &rtl8188e_HalDmWatchDog;
230 pHalFunc->Add_RateATid = &rtl8188e_Add_RateATid;
232 pHalFunc->AntDivBeforeLinkHandler = &AntDivBeforeLink8188E;
233 pHalFunc->AntDivCompareHandler = &AntDivCompare8188E;
234 pHalFunc->read_rfreg = &phy_query_rf_reg;
235 pHalFunc->write_rfreg = &phy_set_rf_reg;
237 pHalFunc->sreset_init_value = &sreset_init_value;
238 pHalFunc->sreset_get_wifi_status = &sreset_get_wifi_status;
240 pHalFunc->SetHalODMVarHandler = &rtl8188e_SetHalODMVar;
242 pHalFunc->hal_notch_filter = &hal_notch_filter_8188e;
245 /* */
246 /* */
247 /* LLT R/W/Init function */
248 /* */
249 /* */
250 static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data)
252 s32 status = _SUCCESS;
253 s32 count = 0;
254 u32 value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS);
255 u16 LLTReg = REG_LLT_INIT;
257 usb_write32(padapter, LLTReg, value);
259 /* polling */
260 do {
261 value = usb_read32(padapter, LLTReg);
262 if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value))
263 break;
265 if (count > POLLING_LLT_THRESHOLD) {
266 RT_TRACE(_module_hal_init_c_, _drv_err_, ("Failed to polling write LLT done at address %d!\n", address));
267 status = _FAIL;
268 break;
270 } while (count++);
272 return status;
275 s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy)
277 s32 status = _FAIL;
278 u32 i;
279 u32 Last_Entry_Of_TxPktBuf = LAST_ENTRY_OF_TX_PKT_BUFFER;/* 176, 22k */
281 if (rtw_IOL_applied(padapter)) {
282 status = iol_InitLLTTable(padapter, txpktbuf_bndy);
283 } else {
284 for (i = 0; i < (txpktbuf_bndy - 1); i++) {
285 status = _LLTWrite(padapter, i, i + 1);
286 if (_SUCCESS != status)
287 return status;
290 /* end of list */
291 status = _LLTWrite(padapter, (txpktbuf_bndy - 1), 0xFF);
292 if (_SUCCESS != status)
293 return status;
295 /* Make the other pages as ring buffer */
296 /* This ring buffer is used as beacon buffer if we config this MAC as two MAC transfer. */
297 /* Otherwise used as local loopback buffer. */
298 for (i = txpktbuf_bndy; i < Last_Entry_Of_TxPktBuf; i++) {
299 status = _LLTWrite(padapter, i, (i + 1));
300 if (_SUCCESS != status)
301 return status;
304 /* Let last entry point to the start entry of ring buffer */
305 status = _LLTWrite(padapter, Last_Entry_Of_TxPktBuf, txpktbuf_bndy);
306 if (_SUCCESS != status) {
307 return status;
311 return status;
314 void
315 Hal_InitPGData88E(struct adapter *padapter)
317 struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter);
319 if (!pEEPROM->bautoload_fail_flag) { /* autoload OK. */
320 if (!is_boot_from_eeprom(padapter)) {
321 /* Read EFUSE real map to shadow. */
322 EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI);
324 } else {/* autoload fail */
325 RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("AutoLoad Fail reported from CR9346!!\n"));
326 /* update to default value 0xFF */
327 if (!is_boot_from_eeprom(padapter))
328 EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI);
332 void
333 Hal_EfuseParseIDCode88E(
334 struct adapter *padapter,
335 u8 *hwinfo
338 struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter);
339 u16 EEPROMId;
341 /* Checl 0x8129 again for making sure autoload status!! */
342 EEPROMId = le16_to_cpu(*((__le16 *)hwinfo));
343 if (EEPROMId != RTL_EEPROM_ID) {
344 DBG_88E("EEPROM ID(%#x) is invalid!!\n", EEPROMId);
345 pEEPROM->bautoload_fail_flag = true;
346 } else {
347 pEEPROM->bautoload_fail_flag = false;
350 DBG_88E("EEPROM ID = 0x%04x\n", EEPROMId);
353 static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, u8 *PROMContent, bool AutoLoadFail)
355 u32 rfPath, eeAddr = EEPROM_TX_PWR_INX_88E, group, TxCount = 0;
357 memset(pwrInfo24G, 0, sizeof(struct txpowerinfo24g));
359 if (AutoLoadFail) {
360 for (rfPath = 0; rfPath < MAX_RF_PATH; rfPath++) {
361 /* 2.4G default value */
362 for (group = 0; group < MAX_CHNL_GROUP_24G; group++) {
363 pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX;
364 pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX;
366 for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) {
367 if (TxCount == 0) {
368 pwrInfo24G->BW20_Diff[rfPath][0] = EEPROM_DEFAULT_24G_HT20_DIFF;
369 pwrInfo24G->OFDM_Diff[rfPath][0] = EEPROM_DEFAULT_24G_OFDM_DIFF;
370 } else {
371 pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
372 pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
373 pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
374 pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
378 return;
381 for (rfPath = 0; rfPath < MAX_RF_PATH; rfPath++) {
382 /* 2.4G default value */
383 for (group = 0; group < MAX_CHNL_GROUP_24G; group++) {
384 pwrInfo24G->IndexCCK_Base[rfPath][group] = PROMContent[eeAddr++];
385 if (pwrInfo24G->IndexCCK_Base[rfPath][group] == 0xFF)
386 pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX;
388 for (group = 0; group < MAX_CHNL_GROUP_24G-1; group++) {
389 pwrInfo24G->IndexBW40_Base[rfPath][group] = PROMContent[eeAddr++];
390 if (pwrInfo24G->IndexBW40_Base[rfPath][group] == 0xFF)
391 pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX;
393 for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) {
394 if (TxCount == 0) {
395 pwrInfo24G->BW40_Diff[rfPath][TxCount] = 0;
396 if (PROMContent[eeAddr] == 0xFF) {
397 pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_HT20_DIFF;
398 } else {
399 pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4;
400 if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */
401 pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0;
404 if (PROMContent[eeAddr] == 0xFF) {
405 pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_OFDM_DIFF;
406 } else {
407 pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f);
408 if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */
409 pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0;
411 pwrInfo24G->CCK_Diff[rfPath][TxCount] = 0;
412 eeAddr++;
413 } else {
414 if (PROMContent[eeAddr] == 0xFF) {
415 pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
416 } else {
417 pwrInfo24G->BW40_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4;
418 if (pwrInfo24G->BW40_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */
419 pwrInfo24G->BW40_Diff[rfPath][TxCount] |= 0xF0;
422 if (PROMContent[eeAddr] == 0xFF) {
423 pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
424 } else {
425 pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f);
426 if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */
427 pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0;
429 eeAddr++;
431 if (PROMContent[eeAddr] == 0xFF) {
432 pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
433 } else {
434 pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4;
435 if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */
436 pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0;
439 if (PROMContent[eeAddr] == 0xFF) {
440 pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
441 } else {
442 pwrInfo24G->CCK_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f);
443 if (pwrInfo24G->CCK_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */
444 pwrInfo24G->CCK_Diff[rfPath][TxCount] |= 0xF0;
446 eeAddr++;
452 static u8 Hal_GetChnlGroup88E(u8 chnl, u8 *pGroup)
454 u8 bIn24G = true;
456 if (chnl <= 14) {
457 bIn24G = true;
459 if (chnl < 3) /* Channel 1-2 */
460 *pGroup = 0;
461 else if (chnl < 6) /* Channel 3-5 */
462 *pGroup = 1;
463 else if (chnl < 9) /* Channel 6-8 */
464 *pGroup = 2;
465 else if (chnl < 12) /* Channel 9-11 */
466 *pGroup = 3;
467 else if (chnl < 14) /* Channel 12-13 */
468 *pGroup = 4;
469 else if (chnl == 14) /* Channel 14 */
470 *pGroup = 5;
471 } else {
472 bIn24G = false;
474 if (chnl <= 40)
475 *pGroup = 0;
476 else if (chnl <= 48)
477 *pGroup = 1;
478 else if (chnl <= 56)
479 *pGroup = 2;
480 else if (chnl <= 64)
481 *pGroup = 3;
482 else if (chnl <= 104)
483 *pGroup = 4;
484 else if (chnl <= 112)
485 *pGroup = 5;
486 else if (chnl <= 120)
487 *pGroup = 5;
488 else if (chnl <= 128)
489 *pGroup = 6;
490 else if (chnl <= 136)
491 *pGroup = 7;
492 else if (chnl <= 144)
493 *pGroup = 8;
494 else if (chnl <= 153)
495 *pGroup = 9;
496 else if (chnl <= 161)
497 *pGroup = 10;
498 else if (chnl <= 177)
499 *pGroup = 11;
501 return bIn24G;
504 void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail)
506 if (AutoLoadFail) {
507 padapter->pwrctrlpriv.bHWPowerdown = false;
508 padapter->pwrctrlpriv.bSupportRemoteWakeup = false;
509 } else {
510 /* hw power down mode selection , 0:rf-off / 1:power down */
512 if (padapter->registrypriv.hwpdn_mode == 2)
513 padapter->pwrctrlpriv.bHWPowerdown = (hwinfo[EEPROM_RF_FEATURE_OPTION_88E] & BIT4);
514 else
515 padapter->pwrctrlpriv.bHWPowerdown = padapter->registrypriv.hwpdn_mode;
517 /* decide hw if support remote wakeup function */
518 /* if hw supported, 8051 (SIE) will generate WeakUP signal(D+/D- toggle) when autoresume */
519 padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0] & BIT1) ? true : false;
521 DBG_88E("%s...bHWPwrPindetect(%x)-bHWPowerdown(%x) , bSupportRemoteWakeup(%x)\n", __func__,
522 padapter->pwrctrlpriv.bHWPwrPindetect, padapter->pwrctrlpriv.bHWPowerdown , padapter->pwrctrlpriv.bSupportRemoteWakeup);
524 DBG_88E("### PS params => power_mgnt(%x), usbss_enable(%x) ###\n", padapter->registrypriv.power_mgnt, padapter->registrypriv.usbss_enable);
528 void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *PROMContent, bool AutoLoadFail)
530 struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter);
531 struct txpowerinfo24g pwrInfo24G;
532 u8 rfPath, ch, group;
533 u8 bIn24G, TxCount;
535 Hal_ReadPowerValueFromPROM_8188E(&pwrInfo24G, PROMContent, AutoLoadFail);
537 if (!AutoLoadFail)
538 pHalData->bTXPowerDataReadFromEEPORM = true;
540 for (rfPath = 0; rfPath < pHalData->NumTotalRFPath; rfPath++) {
541 for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++) {
542 bIn24G = Hal_GetChnlGroup88E(ch, &group);
543 if (bIn24G) {
544 pHalData->Index24G_CCK_Base[rfPath][ch] = pwrInfo24G.IndexCCK_Base[rfPath][group];
545 if (ch == 14)
546 pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][4];
547 else
548 pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][group];
550 if (bIn24G) {
551 DBG_88E("======= Path %d, Channel %d =======\n", rfPath, ch);
552 DBG_88E("Index24G_CCK_Base[%d][%d] = 0x%x\n", rfPath, ch , pHalData->Index24G_CCK_Base[rfPath][ch]);
553 DBG_88E("Index24G_BW40_Base[%d][%d] = 0x%x\n", rfPath, ch , pHalData->Index24G_BW40_Base[rfPath][ch]);
556 for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) {
557 pHalData->CCK_24G_Diff[rfPath][TxCount] = pwrInfo24G.CCK_Diff[rfPath][TxCount];
558 pHalData->OFDM_24G_Diff[rfPath][TxCount] = pwrInfo24G.OFDM_Diff[rfPath][TxCount];
559 pHalData->BW20_24G_Diff[rfPath][TxCount] = pwrInfo24G.BW20_Diff[rfPath][TxCount];
560 pHalData->BW40_24G_Diff[rfPath][TxCount] = pwrInfo24G.BW40_Diff[rfPath][TxCount];
561 DBG_88E("======= TxCount %d =======\n", TxCount);
562 DBG_88E("CCK_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->CCK_24G_Diff[rfPath][TxCount]);
563 DBG_88E("OFDM_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->OFDM_24G_Diff[rfPath][TxCount]);
564 DBG_88E("BW20_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->BW20_24G_Diff[rfPath][TxCount]);
565 DBG_88E("BW40_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->BW40_24G_Diff[rfPath][TxCount]);
569 /* 2010/10/19 MH Add Regulator recognize for CU. */
570 if (!AutoLoadFail) {
571 pHalData->EEPROMRegulatory = (PROMContent[EEPROM_RF_BOARD_OPTION_88E]&0x7); /* bit0~2 */
572 if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF)
573 pHalData->EEPROMRegulatory = (EEPROM_DEFAULT_BOARD_OPTION&0x7); /* bit0~2 */
574 } else {
575 pHalData->EEPROMRegulatory = 0;
577 DBG_88E("EEPROMRegulatory = 0x%x\n", pHalData->EEPROMRegulatory);
580 void Hal_EfuseParseXtal_8188E(struct adapter *pAdapter, u8 *hwinfo, bool AutoLoadFail)
582 struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter);
584 if (!AutoLoadFail) {
585 pHalData->CrystalCap = hwinfo[EEPROM_XTAL_88E];
586 if (pHalData->CrystalCap == 0xFF)
587 pHalData->CrystalCap = EEPROM_Default_CrystalCap_88E;
588 } else {
589 pHalData->CrystalCap = EEPROM_Default_CrystalCap_88E;
591 DBG_88E("CrystalCap: 0x%2x\n", pHalData->CrystalCap);
594 void Hal_EfuseParseBoardType88E(struct adapter *pAdapter, u8 *hwinfo, bool AutoLoadFail)
596 struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter);
598 if (!AutoLoadFail)
599 pHalData->BoardType = (hwinfo[EEPROM_RF_BOARD_OPTION_88E]
600 & 0xE0) >> 5;
601 else
602 pHalData->BoardType = 0;
603 DBG_88E("Board Type: 0x%2x\n", pHalData->BoardType);
606 void Hal_EfuseParseEEPROMVer88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail)
608 struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter);
610 if (!AutoLoadFail) {
611 pHalData->EEPROMVersion = hwinfo[EEPROM_VERSION_88E];
612 if (pHalData->EEPROMVersion == 0xFF)
613 pHalData->EEPROMVersion = EEPROM_Default_Version;
614 } else {
615 pHalData->EEPROMVersion = 1;
617 RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
618 ("Hal_EfuseParseEEPROMVer(), EEVer = %d\n",
619 pHalData->EEPROMVersion));
622 void rtl8188e_EfuseParseChnlPlan(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail)
624 padapter->mlmepriv.ChannelPlan =
625 hal_com_get_channel_plan(padapter,
626 hwinfo ? hwinfo[EEPROM_ChannelPlan_88E] : 0xFF,
627 padapter->registrypriv.channel_plan,
628 RT_CHANNEL_DOMAIN_WORLD_WIDE_13, AutoLoadFail);
630 DBG_88E("mlmepriv.ChannelPlan = 0x%02x\n", padapter->mlmepriv.ChannelPlan);
633 void Hal_EfuseParseCustomerID88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail)
635 struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter);
637 if (!AutoLoadFail) {
638 pHalData->EEPROMCustomerID = hwinfo[EEPROM_CUSTOMERID_88E];
639 } else {
640 pHalData->EEPROMCustomerID = 0;
641 pHalData->EEPROMSubCustomerID = 0;
643 DBG_88E("EEPROM Customer ID: 0x%2x\n", pHalData->EEPROMCustomerID);
646 void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter, u8 *PROMContent, bool AutoLoadFail)
648 struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter);
649 struct registry_priv *registry_par = &pAdapter->registrypriv;
651 if (!AutoLoadFail) {
652 /* Antenna Diversity setting. */
653 if (registry_par->antdiv_cfg == 2) { /* 2:By EFUSE */
654 pHalData->AntDivCfg = (PROMContent[EEPROM_RF_BOARD_OPTION_88E]&0x18)>>3;
655 if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF)
656 pHalData->AntDivCfg = (EEPROM_DEFAULT_BOARD_OPTION&0x18)>>3;
657 } else {
658 pHalData->AntDivCfg = registry_par->antdiv_cfg; /* 0:OFF , 1:ON, 2:By EFUSE */
661 if (registry_par->antdiv_type == 0) {
662 /* If TRxAntDivType is AUTO in advanced setting, use EFUSE value instead. */
663 pHalData->TRxAntDivType = PROMContent[EEPROM_RF_ANTENNA_OPT_88E];
664 if (pHalData->TRxAntDivType == 0xFF)
665 pHalData->TRxAntDivType = CG_TRX_HW_ANTDIV; /* For 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */
666 } else {
667 pHalData->TRxAntDivType = registry_par->antdiv_type;
670 if (pHalData->TRxAntDivType == CG_TRX_HW_ANTDIV || pHalData->TRxAntDivType == CGCS_RX_HW_ANTDIV)
671 pHalData->AntDivCfg = 1; /* 0xC1[3] is ignored. */
672 } else {
673 pHalData->AntDivCfg = 0;
674 pHalData->TRxAntDivType = pHalData->TRxAntDivType; /* The value in the driver setting of device manager. */
676 DBG_88E("EEPROM : AntDivCfg = %x, TRxAntDivType = %x\n", pHalData->AntDivCfg, pHalData->TRxAntDivType);
679 void Hal_ReadThermalMeter_88E(struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail)
681 struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter);
683 /* ThermalMeter from EEPROM */
684 if (!AutoloadFail)
685 pHalData->EEPROMThermalMeter = PROMContent[EEPROM_THERMAL_METER_88E];
686 else
687 pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E;
689 if (pHalData->EEPROMThermalMeter == 0xff || AutoloadFail) {
690 pHalData->bAPKThermalMeterIgnore = true;
691 pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E;
693 DBG_88E("ThermalMeter = 0x%x\n", pHalData->EEPROMThermalMeter);