Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 197117
b: refs/heads/master
c: 593ef41
h: refs/heads/master
i:
  197115: 576ee07
v: v3
  • Loading branch information
Olimpiu Pascariu authored and Greg Kroah-Hartman committed May 11, 2010
1 parent 64f9cd5 commit 2e5cc81
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 52 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 08db6c59a2d4d8162d7544ffaa9aa7d27ce9e50a
refs/heads/master: 593ef41c95c82a7c8d09c28db4893f4dd2ff0134
129 changes: 78 additions & 51 deletions trunk/drivers/staging/rtl8187se/r8180_rtl8225z2.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/*
This is part of the rtl8180-sa2400 driver
released under the GPL (See file COPYING for details).
Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
This files contains programming code for the rtl8225
radio frontend.
*Many* thanks to Realtek Corp. for their great support!
*/
* This is part of the rtl8180-sa2400 driver
* released under the GPL (See file COPYING for details).
* Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
*
* This files contains programming code for the rtl8225
* radio frontend.
*
* *Many* thanks to Realtek Corp. for their great support!
*/

#include "r8180_hw.h"
#include "r8180_rtl8225.h"
Expand Down Expand Up @@ -225,7 +224,7 @@ static void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch)
}

static const u8 rtl8225z2_threshold[] = {
0x8d, 0x8d, 0x8d, 0x8d, 0x9d, 0xad, 0xbd,
0x8d, 0x8d, 0x8d, 0x8d, 0x9d, 0xad, 0xbd,
};

static const u8 rtl8225z2_gain_bg[] = {
Expand Down Expand Up @@ -307,7 +306,7 @@ static u32 read_rtl8225(struct net_device *dev, u8 adr)
u32 data2Write = ((u32)(adr & 0x1f)) << 27;
u32 dataRead;
u32 mask;
u16 oval,oval2,oval3,tmp;
u16 oval, oval2, oval3, tmp;
int i;
short bit, rw;
u8 wLength = 6;
Expand All @@ -325,41 +324,57 @@ static u32 read_rtl8225(struct net_device *dev, u8 adr)

oval &= ~0xf;

write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4);
write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN);
udelay(4);

write_nic_word(dev, RFPinsOutput, oval ); udelay(5);
write_nic_word(dev, RFPinsOutput, oval);
udelay(5);

rw = 0;

mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1));

for (i = 0; i < wLength/2; i++) {
bit = ((data2Write&mask) != 0) ? 1 : 0;
write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1);
write_nic_word(dev, RFPinsOutput, bit | oval | rw);
udelay(1);

write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2);
write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2);
write_nic_word(dev, RFPinsOutput,
bit | oval | BB_HOST_BANG_CLK | rw);
udelay(2);
write_nic_word(dev, RFPinsOutput,
bit | oval | BB_HOST_BANG_CLK | rw);
udelay(2);

mask = (low2high) ? (mask<<1): (mask>>1);
mask = (low2high) ? (mask<<1) : (mask>>1);

if (i == 2) {
rw = BB_HOST_BANG_RW;
write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2);
write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2);
write_nic_word(dev, RFPinsOutput,
bit | oval | BB_HOST_BANG_CLK | rw);
udelay(2);
write_nic_word(dev, RFPinsOutput, bit | oval | rw);
udelay(2);
break;
}

bit = ((data2Write&mask) != 0) ? 1: 0;
bit = ((data2Write&mask) != 0) ? 1 : 0;

write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2);
write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2);
write_nic_word(dev, RFPinsOutput,
oval | bit | rw | BB_HOST_BANG_CLK);
udelay(2);
write_nic_word(dev, RFPinsOutput,
oval | bit | rw | BB_HOST_BANG_CLK);
udelay(2);

write_nic_word(dev, RFPinsOutput, oval| bit |rw); udelay(1);
write_nic_word(dev, RFPinsOutput, oval | bit | rw);
udelay(1);

mask = (low2high) ? (mask<<1) : (mask>>1);
}

write_nic_word(dev, RFPinsOutput, rw|oval); udelay(2);
write_nic_word(dev, RFPinsOutput, rw|oval);
udelay(2);
mask = (low2high) ? 0x01 : (((u32)0x01) << (12-1));

/*
Expand All @@ -371,9 +386,12 @@ static u32 read_rtl8225(struct net_device *dev, u8 adr)
for (i = 0; i < rLength; i++) {
write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1);

write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2);
write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2);
write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2);
write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK);
udelay(2);
write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK);
udelay(2);
write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK);
udelay(2);
tmp = read_nic_word(dev, RFPinsInput);

dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0);
Expand All @@ -383,7 +401,9 @@ static u32 read_rtl8225(struct net_device *dev, u8 adr)
mask = (low2high) ? (mask<<1) : (mask>>1);
}

write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2);
write_nic_word(dev, RFPinsOutput,
BB_HOST_BANG_EN | BB_HOST_BANG_RW | oval);
udelay(2);

write_nic_word(dev, RFPinsEnable, oval2);
write_nic_word(dev, RFPinsSelect, oval3); /* Set To SW Switch */
Expand Down Expand Up @@ -426,7 +446,7 @@ void rtl8225z2_rf_close(struct net_device *dev)
s8 DbmToTxPwrIdx(struct r8180_priv *priv, WIRELESS_MODE WirelessMode,
s32 PowerInDbm)
{
bool bUseDefault = true;
bool bUseDefault = true;
s8 TxPwrIdx = 0;

/*
Expand Down Expand Up @@ -486,8 +506,10 @@ void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch)
if (IS_DOT11D_ENABLE(priv->ieee80211) &&
IS_DOT11D_STATE_DONE(priv->ieee80211)) {
u8 MaxTxPwrInDbm = DOT11D_GetMaxTxPwrInDbm(priv->ieee80211, ch);
u8 CckMaxPwrIdx = DbmToTxPwrIdx(priv, WIRELESS_MODE_B, MaxTxPwrInDbm);
u8 OfdmMaxPwrIdx = DbmToTxPwrIdx(priv, WIRELESS_MODE_G, MaxTxPwrInDbm);
u8 CckMaxPwrIdx = DbmToTxPwrIdx(priv, WIRELESS_MODE_B,
MaxTxPwrInDbm);
u8 OfdmMaxPwrIdx = DbmToTxPwrIdx(priv, WIRELESS_MODE_G,
MaxTxPwrInDbm);

if (cck_power_level > CckMaxPwrIdx)
cck_power_level = CckMaxPwrIdx;
Expand Down Expand Up @@ -524,7 +546,7 @@ void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch)
if (ofdm_power_level <= 11) {
write_phy_ofdm(dev, 0x07, 0x5c);
write_phy_ofdm(dev, 0x09, 0x5c);
}
}

if (ofdm_power_level <= 17) {
write_phy_ofdm(dev, 0x07, 0x54);
Expand Down Expand Up @@ -613,7 +635,7 @@ void rtl8225z2_rf_init(struct net_device *dev)
int i;
short channel = 1;
u16 brsr;
u32 data,addr;
u32 data, addr;

priv->chan = channel;

Expand Down Expand Up @@ -740,7 +762,7 @@ void rtl8225z2_rf_init(struct net_device *dev)
write_phy_ofdm(dev, 0x26, 0x90); mdelay(1);
write_phy_ofdm(dev, 0x27, 0x88); mdelay(1);

rtl8225z2_set_gain(dev,4);
rtl8225z2_set_gain(dev, 4);

write_phy_cck(dev, 0x0, 0x98); mdelay(1);
write_phy_cck(dev, 0x3, 0x20); mdelay(1);
Expand Down Expand Up @@ -803,12 +825,12 @@ void rtl8225z2_rf_set_mode(struct net_device *dev)
write_phy_ofdm(dev, 0xf, 0x20);
write_phy_ofdm(dev, 0x11, 0x7);

rtl8225z2_set_gain(dev,4);
rtl8225z2_set_gain(dev, 4);

write_phy_ofdm(dev,0x15, 0x40);
write_phy_ofdm(dev,0x17, 0x40);
write_phy_ofdm(dev, 0x15, 0x40);
write_phy_ofdm(dev, 0x17, 0x40);

write_nic_dword(dev, 0x94,0x10000000);
write_nic_dword(dev, 0x94, 0x10000000);
} else {
write_rtl8225(dev, 0x5, 0x1864);
write_nic_dword(dev, RF_PARA, 0x10044);
Expand All @@ -819,18 +841,18 @@ void rtl8225z2_rf_set_mode(struct net_device *dev)
write_phy_ofdm(dev, 0xf, 0x20);
write_phy_ofdm(dev, 0x11, 0x7);

rtl8225z2_set_gain(dev,4);
rtl8225z2_set_gain(dev, 4);

write_phy_ofdm(dev,0x15, 0x40);
write_phy_ofdm(dev,0x17, 0x40);
write_phy_ofdm(dev, 0x15, 0x40);
write_phy_ofdm(dev, 0x17, 0x40);

write_nic_dword(dev, 0x94,0x04000002);
write_nic_dword(dev, 0x94, 0x04000002);
}
}

#define MAX_DOZE_WAITING_TIMES_85B 20
#define MAX_POLLING_24F_TIMES_87SE 10
#define LPS_MAX_SLEEP_WAITING_TIMES_87SE 5
#define MAX_DOZE_WAITING_TIMES_85B 20
#define MAX_POLLING_24F_TIMES_87SE 10
#define LPS_MAX_SLEEP_WAITING_TIMES_87SE 5

bool SetZebraRFPowerState8185(struct net_device *dev,
RT_RF_POWER_STATE eRFPowerState)
Expand Down Expand Up @@ -882,12 +904,14 @@ bool SetZebraRFPowerState8185(struct net_device *dev,
break;
case eRfSleep:
for (QueueID = 0, i = 0; QueueID < 6;) {
if (get_curr_tx_free_desc(dev, QueueID) == priv->txringcount) {
if (get_curr_tx_free_desc(dev, QueueID) ==
priv->txringcount) {
QueueID++;
continue;
} else {
priv->TxPollingTimes++;
if (priv->TxPollingTimes >= LPS_MAX_SLEEP_WAITING_TIMES_87SE) {
if (priv->TxPollingTimes >=
LPS_MAX_SLEEP_WAITING_TIMES_87SE) {
bActionAllowed = false;
break;
} else
Expand Down Expand Up @@ -915,7 +939,8 @@ bool SetZebraRFPowerState8185(struct net_device *dev,
while (true) {
u8 tmp24F = read_nic_byte(dev, 0x24f);

if ((tmp24F == 0x01) || (tmp24F == 0x09)) {
if ((tmp24F == 0x01) ||
(tmp24F == 0x09)) {
bTurnOffBB = true;
break;
} else {
Expand All @@ -935,7 +960,8 @@ bool SetZebraRFPowerState8185(struct net_device *dev,
if (bTurnOffBB) {
/* turn off BB */
u1bTmp = read_nic_byte(dev, 0x24E);
write_nic_byte(dev, 0x24E, (u1bTmp | BIT5 | BIT6));
write_nic_byte(dev, 0x24E,
(u1bTmp | BIT5 | BIT6));

/* turn off AFE PLL */
write_nic_byte(dev, 0x54, 0xFC);
Expand All @@ -945,7 +971,8 @@ bool SetZebraRFPowerState8185(struct net_device *dev,
break;
case eRfOff:
for (QueueID = 0, i = 0; QueueID < 6;) {
if (get_curr_tx_free_desc(dev, QueueID) == priv->txringcount) {
if (get_curr_tx_free_desc(dev, QueueID) ==
priv->txringcount) {
QueueID++;
continue;
} else {
Expand Down

0 comments on commit 2e5cc81

Please sign in to comment.