From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932197AbZHPTa5 (ORCPT ); Sun, 16 Aug 2009 15:30:57 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932141AbZHPTa4 (ORCPT ); Sun, 16 Aug 2009 15:30:56 -0400 Received: from mail-fx0-f215.google.com ([209.85.220.215]:55539 "EHLO mail-fx0-f215.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932138AbZHPTaw (ORCPT ); Sun, 16 Aug 2009 15:30:52 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:in-reply-to:references:subject; b=Cw06J5NBLFuSBxM5KwQmYQBUYWMX0lEetkkJbwC4RlDiBtF1k3EL3pgilYx5oUf9i/ KlwbNU8/EV2JCOhyxY7WMRkGHtgxAt4lM5tkbI32CCZN0RdpeIrh8l38Vk8AsknYsOp1 PHrhBc4yRMfZK+ks7loB8gZxdEtPvHvjPdR+c= From: Bartlomiej Zolnierkiewicz To: "Greg Kroah-Hartman" Cc: devel@driverdev.osuosl.org, Bartlomiej Zolnierkiewicz , linux-kernel@vger.kernel.org Date: Sun, 16 Aug 2009 21:31:04 +0200 Message-Id: <20090816193104.3789.12936.sendpatchset@localhost.localdomain> In-Reply-To: <20090816192934.3789.3648.sendpatchset@localhost.localdomain> References: <20090816192934.3789.3648.sendpatchset@localhost.localdomain> Subject: [PATCH 12/22] Staging: rtxxx0: unify RT{USB,MP}FilterCalibration() Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartlomiej Zolnierkiewicz Subject: [PATCH] Staging: rtxxx0: unify RT{USB,MP}FilterCalibration() RTMP_BBP_IO_{READ,WRITE}8_BY_REG_ID equals RTUSB{Read,Write}BBPRegister in case of USB chipsets so unify RT30xx and !RT30xx code. Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/staging/rt2860/common/rtmp_init.c | 154 +----------------------------- 1 file changed, 10 insertions(+), 144 deletions(-) Index: b/drivers/staging/rt2860/common/rtmp_init.c =================================================================== --- a/drivers/staging/rt2860/common/rtmp_init.c +++ b/drivers/staging/rt2860/common/rtmp_init.c @@ -1099,145 +1099,6 @@ NDIS_STATUS NICReadRegParameters( ======================================================================== */ -#ifndef RT30xx -VOID RTUSBFilterCalibration( - IN PRTMP_ADAPTER pAd) -{ - UCHAR R55x = 0, value, FilterTarget = 0x1E, BBPValue; - UINT loop = 0, count = 0, loopcnt = 0, ReTry = 0; - UCHAR RF_R24_Value = 0; - - // Give bbp filter initial value - pAd->Mlme.CaliBW20RfR24 = 0x16; - pAd->Mlme.CaliBW40RfR24 = 0x36; //Bit[5] must be 1 for BW 40 - - do - { - if (loop == 1) //BandWidth = 40 MHz - { - // Write 0x27 to RF_R24 to program filter - RF_R24_Value = 0x27; - RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value); - FilterTarget = 0x19; - - // when calibrate BW40, BBP mask must set to BW40. - RTUSBReadBBPRegister(pAd, BBP_R4, &BBPValue); - BBPValue&= (~0x18); - BBPValue|= (0x10); - RTUSBWriteBBPRegister(pAd, BBP_R4, BBPValue); - } - else //BandWidth = 20 MHz - { - // Write 0x07 to RF_R24 to program filter - RF_R24_Value = 0x07; - RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value); - FilterTarget = 0x16; - } - - // Write 0x01 to RF_R22 to enable baseband loopback mode - RT30xxReadRFRegister(pAd, RF_R22, &value); - value |= 0x01; - RT30xxWriteRFRegister(pAd, RF_R22, value); - - // Write 0x00 to BBP_R24 to set power & frequency of passband test tone - RTUSBWriteBBPRegister(pAd, BBP_R24, 0); - - do - { - // Write 0x90 to BBP_R25 to transmit test tone - RTUSBWriteBBPRegister(pAd, BBP_R25, 0x90); - - RTMPusecDelay(1000); - // Read BBP_R55[6:0] for received power, set R55x = BBP_R55[6:0] - RTUSBReadBBPRegister(pAd, BBP_R55, &value); - R55x = value & 0xFF; - - } while ((ReTry++ < 100) && (R55x == 0)); - - // Write 0x06 to BBP_R24 to set power & frequency of stopband test tone - RTUSBWriteBBPRegister(pAd, BBP_R24, 0x06); - - while(TRUE) - { - // Write 0x90 to BBP_R25 to transmit test tone - RTUSBWriteBBPRegister(pAd, BBP_R25, 0x90); - - //We need to wait for calibration - RTMPusecDelay(1000); - RTUSBReadBBPRegister(pAd, BBP_R55, &value); - value &= 0xFF; - if ((R55x - value) < FilterTarget) - { - RF_R24_Value ++; - } - else if ((R55x - value) == FilterTarget) - { - RF_R24_Value ++; - count ++; - } - else - { - break; - } - - // prevent infinite loop cause driver hang. - if (loopcnt++ > 100) - { - DBGPRINT(RT_DEBUG_ERROR, ("RTUSBFilterCalibration - can't find a valid value, loopcnt=%d stop calibrating", loopcnt)); - break; - } - - // Write RF_R24 to program filter - RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value); - } - - if (count > 0) - { - RF_R24_Value = RF_R24_Value - ((count) ? (1) : (0)); - } - - // Store for future usage - if (loopcnt < 100) - { - if (loop++ == 0) - { - //BandWidth = 20 MHz - pAd->Mlme.CaliBW20RfR24 = (UCHAR)RF_R24_Value; - } - else - { - //BandWidth = 40 MHz - pAd->Mlme.CaliBW40RfR24 = (UCHAR)RF_R24_Value; - break; - } - } - else - break; - - RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value); - - // reset count - count = 0; - } while(TRUE); - - // - // Set back to initial state - // - RTUSBWriteBBPRegister(pAd, BBP_R24, 0); - - RT30xxReadRFRegister(pAd, RF_R22, &value); - value &= ~(0x01); - RT30xxWriteRFRegister(pAd, RF_R22, value); - - // set BBP back to BW20 - RTUSBReadBBPRegister(pAd, BBP_R4, &BBPValue); - BBPValue&= (~0x18); - RTUSBWriteBBPRegister(pAd, BBP_R4, BBPValue); - - DBGPRINT(RT_DEBUG_TRACE, ("RTUSBFilterCalibration - CaliBW20RfR24=0x%x, CaliBW40RfR24=0x%x\n", pAd->Mlme.CaliBW20RfR24, pAd->Mlme.CaliBW40RfR24)); -} -#endif /* RT30xx */ -#ifdef RT30xx VOID RTMPFilterCalibration( IN PRTMP_ADAPTER pAd) { @@ -1246,9 +1107,13 @@ VOID RTMPFilterCalibration( UCHAR RF_R24_Value = 0; // Give bbp filter initial value +#ifndef RT30xx + pAd->Mlme.CaliBW20RfR24 = 0x16; + pAd->Mlme.CaliBW40RfR24 = 0x36; //Bit[5] must be 1 for BW 40 +#else pAd->Mlme.CaliBW20RfR24 = 0x1F; pAd->Mlme.CaliBW40RfR24 = 0x2F; //Bit[5] must be 1 for BW 40 - +#endif do { if (loop == 1) //BandWidth = 40 MHz @@ -1266,11 +1131,12 @@ VOID RTMPFilterCalibration( BBPValue&= (~0x18); BBPValue|= (0x10); RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue); - +#ifdef RT30xx // set to BW40 RT30xxReadRFRegister(pAd, RF_R31, &value); value |= 0x20; RT30xxWriteRFRegister(pAd, RF_R31, value); +#endif } else //BandWidth = 20 MHz { @@ -1281,11 +1147,12 @@ VOID RTMPFilterCalibration( FilterTarget = 0x13; else FilterTarget = 0x16; - +#ifdef RT30xx // set to BW20 RT30xxReadRFRegister(pAd, RF_R31, &value); value &= (~0x20); RT30xxWriteRFRegister(pAd, RF_R31, value); +#endif } // Write 0x01 to RF_R22 to enable baseband loopback mode @@ -1390,7 +1257,6 @@ VOID RTMPFilterCalibration( DBGPRINT(RT_DEBUG_TRACE, ("RTMPFilterCalibration - CaliBW20RfR24=0x%x, CaliBW40RfR24=0x%x\n", pAd->Mlme.CaliBW20RfR24, pAd->Mlme.CaliBW40RfR24)); } -#endif /* RT30xx */ VOID NICInitRT30xxRFRegisters(IN PRTMP_ADAPTER pAd) { @@ -1417,7 +1283,7 @@ VOID NICInitRT30xxRFRegisters(IN PRTMP_A } //For RF filter Calibration - RTUSBFilterCalibration(pAd); + RTMPFilterCalibration(pAd); } #endif #ifdef RT30xx