示例#1
0
void rtl8225z2_rf_set_chan(struct net_device *dev, short ch)
{
	rtl8225z2_SetTXPowerLevel(dev, ch);

	RF_WriteReg(dev, 0x7, rtl8225_chan[ch]);

	if ((RF_ReadReg(dev, 0x7) & 0x0F80) != rtl8225_chan[ch])
		RF_WriteReg(dev, 0x7, rtl8225_chan[ch]);

	mdelay(1);

	force_pci_posting(dev);
	mdelay(10);
}
示例#2
0
void rtl8225z2_rf_set_chan(struct net_device *dev, short ch)
{
/*
	short gset = (priv->ieee80211->state == IEEE80211_LINKED &&
		ieee80211_is_54g(priv->ieee80211->current_network)) ||
		priv->ieee80211->iw_mode == IW_MODE_MONITOR;
*/
	rtl8225z2_SetTXPowerLevel(dev, ch);

	RF_WriteReg(dev, 0x7, rtl8225_chan[ch]);

	//YJ,add,080828, if set channel failed, write again
	if((RF_ReadReg(dev, 0x7) & 0x0F80) != rtl8225_chan[ch])
	{
		RF_WriteReg(dev, 0x7, rtl8225_chan[ch]);
	}

	mdelay(1);

	force_pci_posting(dev);
	mdelay(10);
//deleted by David : 2006/8/9
#if 0
	write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22

	if(gset)
		write_nic_byte(dev,DIFS,20); //DIFS: 20
	else
		write_nic_byte(dev,DIFS,0x24); //DIFS: 36

	if(priv->ieee80211->state == IEEE80211_LINKED &&
		ieee80211_is_shortslot(priv->ieee80211->current_network))
		write_nic_byte(dev,SLOT,0x9); //SLOT: 9

	else
		write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14)


	if(gset){
		write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B)
		write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37
		//DMESG("using G net params");
	}else{
		write_nic_byte(dev,EIFS,91 - 0x24); // EIFS: 91 (0x5B)
		write_nic_byte(dev,CW_VAL,0xa5); //CW VALUE: 0x37
		//DMESG("using B net params");
	}
#endif

}
示例#3
0
void rtl8225z2_rf_close(struct net_device *dev)
{
	RF_WriteReg(dev, 0x4, 0x1f);

	force_pci_posting(dev);
	mdelay(1);

	rtl8180_set_anaparam(dev, RTL8225z2_ANAPARAM_OFF);
	rtl8185_set_anaparam2(dev, RTL8225z2_ANAPARAM2_OFF);
}
示例#4
0
bool SetZebraRFPowerState8185(struct net_device *dev,
			      RT_RF_POWER_STATE eRFPowerState)
{
	struct r8180_priv *priv = ieee80211_priv(dev);
	u8			btCR9346, btConfig3;
	bool bActionAllowed = true, bTurnOffBB = true;
	u8			u1bTmp;
	int			i;
	bool		bResult = true;
	u8			QueueID;

	if (priv->SetRFPowerStateInProgress == true)
		return false;

	priv->SetRFPowerStateInProgress = true;

	btCR9346 = read_nic_byte(dev, CR9346);
	write_nic_byte(dev, CR9346, (btCR9346 | 0xC0));

	btConfig3 = read_nic_byte(dev, CONFIG3);
	write_nic_byte(dev, CONFIG3, (btConfig3 | CONFIG3_PARM_En));

	switch (eRFPowerState) {
	case eRfOn:
		write_nic_word(dev, 0x37C, 0x00EC);

		/* turn on AFE */
		write_nic_byte(dev, 0x54, 0x00);
		write_nic_byte(dev, 0x62, 0x00);

		/* turn on RF */
		RF_WriteReg(dev, 0x0, 0x009f); udelay(500);
		RF_WriteReg(dev, 0x4, 0x0972); udelay(500);

		/* turn on RF again */
		RF_WriteReg(dev, 0x0, 0x009f); udelay(500);
		RF_WriteReg(dev, 0x4, 0x0972); udelay(500);

		/* turn on BB */
		write_phy_ofdm(dev, 0x10, 0x40);
		write_phy_ofdm(dev, 0x12, 0x40);

		/* Avoid power down at init time. */
		write_nic_byte(dev, CONFIG4, priv->RFProgType);

		u1bTmp = read_nic_byte(dev, 0x24E);
		write_nic_byte(dev, 0x24E, (u1bTmp & (~(BIT5 | BIT6))));
		break;
	case eRfSleep:
		for (QueueID = 0, i = 0; QueueID < 6;) {
			if (get_curr_tx_free_desc(dev, QueueID) ==
							priv->txringcount) {
				QueueID++;
				continue;
			} else {
				priv->TxPollingTimes++;
				if (priv->TxPollingTimes >=
					LPS_MAX_SLEEP_WAITING_TIMES_87SE) {
					bActionAllowed = false;
					break;
				} else
					udelay(10);
			}
		}

		if (bActionAllowed) {
			/* turn off BB RXIQ matrix to cut off rx signal */
			write_phy_ofdm(dev, 0x10, 0x00);
			write_phy_ofdm(dev, 0x12, 0x00);

			/* turn off RF */
			RF_WriteReg(dev, 0x4, 0x0000);
			RF_WriteReg(dev, 0x0, 0x0000);

			/* turn off AFE except PLL */
			write_nic_byte(dev, 0x62, 0xff);
			write_nic_byte(dev, 0x54, 0xec);

			mdelay(1);

			{
				int i = 0;
				while (true) {
					u8 tmp24F = read_nic_byte(dev, 0x24f);

					if ((tmp24F == 0x01) ||
							(tmp24F == 0x09)) {
						bTurnOffBB = true;
						break;
					} else {
						udelay(10);
						i++;
						priv->TxPollingTimes++;

						if (priv->TxPollingTimes >= LPS_MAX_SLEEP_WAITING_TIMES_87SE) {
							bTurnOffBB = false;
							break;
						} else
							udelay(10);
					}
				}
			}

			if (bTurnOffBB) {
				/* turn off BB */
				u1bTmp = read_nic_byte(dev, 0x24E);
				write_nic_byte(dev, 0x24E,
						(u1bTmp | BIT5 | BIT6));

				/* turn off AFE PLL */
				write_nic_byte(dev, 0x54, 0xFC);
				write_nic_word(dev, 0x37C, 0x00FC);
			}
		}
		break;
	case eRfOff:
		for (QueueID = 0, i = 0; QueueID < 6;) {
			if (get_curr_tx_free_desc(dev, QueueID) ==
					priv->txringcount) {
				QueueID++;
				continue;
			} else {
				udelay(10);
				i++;
			}

			if (i >= MAX_DOZE_WAITING_TIMES_85B)
				break;
		}

		/* turn off BB RXIQ matrix to cut off rx signal */
		write_phy_ofdm(dev, 0x10, 0x00);
		write_phy_ofdm(dev, 0x12, 0x00);

		/* turn off RF */
		RF_WriteReg(dev, 0x4, 0x0000);
		RF_WriteReg(dev, 0x0, 0x0000);

		/* turn off AFE except PLL */
		write_nic_byte(dev, 0x62, 0xff);
		write_nic_byte(dev, 0x54, 0xec);

		mdelay(1);

		{
			int i = 0;

			while (true) {
				u8 tmp24F = read_nic_byte(dev, 0x24f);

				if ((tmp24F == 0x01) || (tmp24F == 0x09)) {
					bTurnOffBB = true;
					break;
				} else {
					bTurnOffBB = false;
					udelay(10);
					i++;
				}

				if (i > MAX_POLLING_24F_TIMES_87SE)
					break;
			}
		}

		if (bTurnOffBB) {
			/* turn off BB */
			u1bTmp = read_nic_byte(dev, 0x24E);
			write_nic_byte(dev, 0x24E, (u1bTmp | BIT5 | BIT6));

			/* turn off AFE PLL (80M) */
			write_nic_byte(dev, 0x54, 0xFC);
			write_nic_word(dev, 0x37C, 0x00FC);
		}
		break;
	}

	btConfig3 &= ~(CONFIG3_PARM_En);
	write_nic_byte(dev, CONFIG3, btConfig3);

	btCR9346 &= ~(0xC0);
	write_nic_byte(dev, CR9346, btCR9346);

	if (bResult && bActionAllowed)
		priv->eRFPowerState = eRFPowerState;

	priv->SetRFPowerStateInProgress = false;

	return bResult && bActionAllowed;
}