?? mconfig.c
字號:
// Finished getting the first set of data
// Get second set of data - in the while loop till the second set is obtained
cl_cal_done = 0;
while (cl_cal_done == 0) {
data = REGR(devNum,0x9860);
data = data | 0x1;
REGW(devNum,0x9860, data);
// Check for cal done
for (i = 0; i < 1000; i++) {
if ((REGR(devNum, PHY_AGC_CONTROL) & (enableCal)) == 0 ) {
break;
}
mSleep(1);
}
if(i >= 1000) {
printf("Device Number %d:Didn't complete cal but keep going anyway\n", devNum);
}
offset = cl_cal_reg[0];
data = REGR(devNum, offset);
add_I_second[0] = (data >> 16) & 0x7ff;
add_Q_second[0] = (data >> 5) & 0x7ff;
if (((add_I_second[0]>>10) & 0x1) == 1) {
add_I_second[0] = add_I_second[0] | 0xfffff800;
}
if (((add_Q_second[0]>>10) & 0x1) == 1) {
add_Q_second[0] = add_Q_second[0] | 0xfffff800;
}
// Get the difference between the first set and the current set
add_I_diff = abs(add_I_first[0] - add_I_second[0]);
add_Q_diff = abs(add_Q_first[0] - add_Q_second[0]);
// Recognize the current set as the second set if diff > 8
if ((add_I_diff > 8) || (add_Q_diff > 8)) {
for (kk=0; kk<9; kk++) { // Get the full second set
offset = cl_cal_reg[kk];
data = REGR(devNum, offset);
add_I_second[kk] = (data >> 16) & 0x7ff;
add_Q_second[kk] = (data >> 5) & 0x7ff;
if (((add_I_second[kk]>>10) & 0x1) == 1) {
add_I_second[kk] = add_I_second[kk] | 0xfffff800;
}
if (((add_Q_second[kk]>>10) & 0x1) == 1) {
add_Q_second[kk] = add_Q_second[kk] | 0xfffff800;
}
}
cl_cal_done = 1;
}
}
// Form the average of the two values
for (kk=0; kk<9; kk++) {
add_I_avg[kk] = (add_I_first[kk] + add_I_second[kk])/2;
add_Q_avg[kk] = (add_Q_first[kk] + add_Q_second[kk])/2;
add_I_avg[kk] = add_I_avg[kk] & 0x7FF; // To take care of signed values
add_Q_avg[kk] = add_Q_avg[kk] & 0x7FF; // To take care of signed values
}
// Write back the average values into the registers
for (kk=0; kk<9; kk++) {
offset = cl_cal_reg[kk];
data = REGR(devNum, offset);
data = data & 0xF800001F; // Clear the bits where the avg is to be written
data = data | (add_I_avg[kk] << 16) | (add_Q_avg[kk] << 5); // Or in the avg data
REGW(devNum,cl_cal_reg[kk], data);
}
// Enable Carrier Leak Correction
data = REGR(devNum,0xa358);
data = data | 0x40000000;
REGW(devNum,0xa358, data);
//printf("Done Carrier Leak cal workaround\n\n");
}
//++JC++
/**************************************************************************
* resetDevice - reset the device and initialize all registers
*
*/
MANLIB_API void resetDevice
(
A_UINT32 devNum,
A_UCHAR *mac,
A_UCHAR *bss,
A_UINT32 freq,
A_UINT32 turbo
)
{
LIB_DEV_INFO *pLibDev = gLibInfo.pLibDevArray[devNum];
A_INT32 i;
A_UINT32 *pValue = NULL;
A_UINT32 newThreshold, newThresholdTurbo;
A_UINT32 temp1, temp2, temp3, temp4, temp5, temp6;
A_UINT32 modifier;
A_BOOL earHere = FALSE;
A_UINT32 prev_freq;
A_UINT32 gpioData;
A_UINT32 timeout = 0;
//++JC++
A_UINT32 bank6_data[63];
A_INT32 zz = 0;
A_INT32 bank6_over = 0;
A_UINT32 di_31_00, di_63_32, di_67_64, do_31_00, do_63_32, do_67_64;
A_UINT32 os0, os1, dreg0, dreg1, da0, da1, da2, tmp, offset, data;
A_INT32 kk, shift_good, num_tries;
//++JC++
#ifndef CUSTOMER_REL
// A_UINT32 resetDevice_start, resetDevice_end;
// printf("SNOOP::calling resetDevice:with turbo=%d:freq=%d\n", turbo, freq);
// resetDevice_start=milliTime();
#endif
//strip off the channelMask flags, not using this any more, leave for now just
//in case somewhere in the code we set the mask.
pLibDev->channelMasks = turbo & 0xffff0000;
turbo = turbo & 0xffff;
//look for the other alternative way of setting the 2.5Mhz channel centers
//look for channel *10
//printf("SNOOP: freq at 1= %d\n", freq);
if((freq >= 49000) && (freq < 60000)) {
if((freq % 10) == 0) {
freq = freq / 10;
//printf("SNOOP: freq at 2= %d\n", freq);
}
else {
//must be a 2.5 MHz channel - check
//printf("SNOOP: freq at 3= %d\n", freq);
if((freq % 25) != 0) {
mError(devNum, EINVAL, "Illegal channel value %d:resetDevice\n", freq);
return;
}
pLibDev->channelMasks |= QUARTER_CHANNEL_MASK;
freq = (freq - 25) / 10;
}
}
if((freq >= 24120) && (freq <= 24840)) {
if((freq % 10) == 0) {
freq = freq / 10;
}
else {
mError(devNum, EINVAL, "Illegal channel value %d:resetDevice\n", freq);
return;
}
}
//printf("SNOOP: freq = %d, channelMasks = %x\n", freq, pLibDev->channelMasks);
// temporarily disable eeprom load for griffin SNOOP: remove asap
if (isGriffin(pLibDev->swDevID)) {
// printf("Disabling EEPROM load for griffin\n");
// pLibDev->eePromLoad = FALSE;
}
prev_freq = pLibDev->freqForResetDevice;
pLibDev->turbo = 0;
pLibDev->mdkErrno = 0;
if (checkDevNum(devNum) == FALSE) {
mError(devNum, EINVAL, "Device Number %d:resetDevice\n", devNum);
return;
}
if (gLibInfo.pLibDevArray[devNum]->devState < INIT_STATE) {
mError(devNum, EILSEQ, "Device Number %d:resetDevice: Device should be initialized before calling reset\n", devNum);
return;
}
pLibDev->hwDevID = (pLibDev->devMap.OScfgRead(devNum, 0) >> 16) & 0xffff;
// Dont call the driver init code for now
#if (MDK_AP) || (CUSTOMER_REL) || (!INCLUDE_DRIVER_CODE)
pLibDev->use_init = !DRIVER_INIT_CODE;
#endif
if (pLibDev->use_init == DRIVER_INIT_CODE) {
#if (!CUSTOMER_REL) && (INCLUDE_DRIVER_CODE)
#ifndef NO_LIB_PRINT
printf("resetDevice::Using Driver init code\n");
#endif
if (m_ar5212Reset(pLibDev, mac, bss, freq, turbo) != 0) {
}
if (!loadCfgData(devNum, freq))
{
printf(" Load cfgdata\n");
return;
}
if(!setupEEPromMap(devNum))
{
mError(devNum, EIO, "Error: unable to load EEPROM\n");
return;
}
#endif //CUSTOMER_REL
}
else {
// load config data, if return value = 0 return from resetDevice
if (!loadCfgData(devNum, freq))
{
printf(" Load cfgdata\n");
return;
}
//++JC++
if(((pLibDev->swDevID & 0xff) == 0x0018) && (pLibDev->mode == 0)) {
pLibDev->mode = 1;
// printf("Debug:: Setting 11g mode in resetDevice for Griffin\n");
}
//++JC++
hwReset(devNum, BUS_RESET | BB_RESET | MAC_RESET);
// program the pll, check to see if we want to override it
if(pLibDev->libCfgParams.applyPLLOverride) {
REGW(devNum, 0xa200, 0);
REGW(devNum, 0x987c, pLibDev->libCfgParams.pllValue);
mSleep(2);
}
else {
pllProgram(devNum, turbo);
}
// Put baseband into base/TURBO mode
pLibDev->turbo = turbo;
if(turbo == TURBO_ENABLE) {
REGW(devNum, PHY_FRAME_CONTROL, REGR(devNum, PHY_FRAME_CONTROL) | PHY_FC_TURBO_MODE);
//check the turbo bit is set
//FJC, increased this timeout from 10 to 20, sometimes predator fails here.
for (i = 0; i < 20; i++) {
if (REGR(devNum, PHY_FRAME_CONTROL) & PHY_FC_TURBO_MODE) {
break;
}
mSleep(1);
}
if(i == 10) {
mError(devNum, EIO, "Device Number %d:ResetDevice: Unable to put the device into tubo mode\n", devNum);
return;
}
// Reset the baseband
hwReset(devNum, BB_RESET);
}
else {
// Base mode
REGW(devNum, PHY_FRAME_CONTROL, REGR(devNum, PHY_FRAME_CONTROL) & ~PHY_FC_TURBO_MODE);
//put these back, in case they were written for 11g turbo
}
/* Hack for AR6000 to stop reg defaulting so INI can be written */
if (isDragon(devNum)) {
REGW(devNum, 0x99dc, 0xFFFFFFFF);
}
/* New section to handle mode switching */
if(ar5kInitData[pLibDev->ar5kInitIndex].cfgVersion < 2) {
switch(pLibDev->mode) {
case MODE_11A: //11a
if ((pLibDev->swDevID == 0xe011) || (pLibDev->swDevID == 0xf11b)||(pLibDev->swDevID == 0x0012)) {
changeField(devNum, "bb_enable_xpaa", 1);
changeField(devNum, "bb_enable_xpab", 0);
changeField(devNum, "rf_b_B_mode", 0);
}
break;
case MODE_11G: //11g
if ((pLibDev->swDevID == 0xe011) || (pLibDev->swDevID == 0xf11b)||(pLibDev->swDevID == 0x0012)) {
changeField(devNum, "bb_enable_xpaa", 0);
changeField(devNum, "bb_enable_xpab", 1);
changeField(devNum, "rf_b_B_mode", 1);
}
break;
case MODE_11B: //11b
break;
}
}
else {
//Do the new handling from the ini files
switch(pLibDev->mode) {
case MODE_11A: //11a
if(pLibDev->turbo != TURBO_ENABLE) { //11a base
pValue = &(pLibDev->pModeArray->value11a);
}
else { //11a turbo
pValue = &(pLibDev->pModeArray->value11aTurbo);
}
break;
case MODE_11G: //11g
case MODE_11O: //ofdm@2.4
if((pLibDev->turbo != TURBO_ENABLE) || (ar5kInitData[pLibDev->ar5kInitIndex].cfgVersion < 3)) { //11g base
pValue = &(pLibDev->pModeArray->value11g);
}
else {
pValue = &(pLibDev->pModeArray->value11gTurbo);
}
break;
case MODE_11B: //11b
pValue = &(pLibDev->pModeArray->value11b);
break;
} //end switch
//do all the mode change fields
for(i = 0; i < pLibDev->sizeModeArray; i++) {
// changeField(devNum, pLibDev->regArray[pLibDev->pModeArray[i].indexToMainArray].fieldName,
// *pValue);
updateField(devNum, &pLibDev->regArray[pLibDev->pModeArray[i].indexToMainArray],
*pValue, 0);
//increment value pointer by size of an array element
pValue = (A_UINT32 *)((A_CHAR *)pValue + sizeof(MODE_INFO));
}
}
//workaround needed for first rev of Oahu
if(pLibDev->macRev == 0x40) {
changeField(devNum, "mc_disable_dynamic_clock", 1);
}
//see if need to perform any tx threshold adjusting
if(pLibDev->adjustTxThresh) {
getField(devNum, "mc_trig_level", &newThreshold, &newThresholdTurbo);
if((pLibDev->turbo == TURBO_ENABLE) && (ar5kInitData[pLibDev->ar5kInitIndex].cfgVersion < 2)) {
newThreshold = newThresholdTurbo * 2;
}
else {
newThreshold = newThreshold * 2;
}
if (newThreshold > 0x3f) {
newThreshold = 0x3f;
}
changeField(devNum, "mc_trig_level", newThreshold);
pLibDev->adjustTxThresh = 0;
}
if(((pLibDev->swDevID & 0xff) >= 0x13) && (!isFalcon(devNum))) {
if(pLibDev->libCfgParams.enableXR) {
changeField(devNum, "bb_enable_xr", 1);
}
else {
changeField(devNum, "bb_enable_xr", 0);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -