28 #include "ieee80211/dot11d.h"
30 #define TC_3W_POLL_MAX_TRY_CNT 5
32 static u8 MAC_REG_TABLE[][2] = {
37 {0x08, 0xae}, {0x0a, 0x72}, {0x5b, 0x42},
38 {0x84, 0x88}, {0x85, 0x24}, {0x88, 0x54}, {0x8b, 0xb8}, {0x8c, 0x03},
39 {0x8d, 0x40}, {0x8e, 0x00}, {0x8f, 0x00}, {0x5b, 0x18}, {0x91, 0x03},
40 {0x94, 0x0F}, {0x95, 0x32},
41 {0x96, 0x00}, {0x97, 0x07}, {0xb4, 0x22}, {0xdb, 0x00},
42 {0xf0, 0x32}, {0xf1, 0x32}, {0xf2, 0x00}, {0xf3, 0x00}, {0xf4, 0x32},
43 {0xf5, 0x43}, {0xf6, 0x00}, {0xf7, 0x00}, {0xf8, 0x46}, {0xf9, 0xa4},
44 {0xfa, 0x00}, {0xfb, 0x00}, {0xfc, 0x96}, {0xfd, 0xa4}, {0xfe, 0x00},
51 {0x58, 0x00}, {0x59, 0x00}, {0x5a, 0x04}, {0x5b, 0x00}, {0x60, 0x24},
52 {0x61, 0x97}, {0x62, 0xF0}, {0x63, 0x09}, {0x80, 0x0F}, {0x81, 0xFF},
53 {0x82, 0xFF}, {0x83, 0x03},
54 {0xC4, 0x22}, {0xC5, 0x22}, {0xC6, 0x22}, {0xC7, 0x22}, {0xC8, 0x22},
55 {0xC9, 0x22}, {0xCA, 0x22}, {0xCB, 0x22}, {0xCC, 0x22}, {0xCD, 0x22},
61 {0x0c, 0x04}, {0x4c, 0x30}, {0x4d, 0x08}, {0x50, 0x05}, {0x51, 0xf5},
62 {0x52, 0x04}, {0x53, 0xa0}, {0x54, 0xff}, {0x55, 0xff}, {0x56, 0xff},
63 {0x57, 0xff}, {0x58, 0x08}, {0x59, 0x08}, {0x5a, 0x08}, {0x5b, 0x08},
64 {0x60, 0x08}, {0x61, 0x08}, {0x62, 0x08}, {0x63, 0x08}, {0x64, 0x2f},
65 {0x8c, 0x3f}, {0x8d, 0x3f}, {0x8e, 0x3f},
66 {0x8f, 0x3f}, {0xc4, 0xff}, {0xc5, 0xff}, {0xc6, 0xff}, {0xc7, 0xff},
67 {0xc8, 0x00}, {0xc9, 0x00}, {0xca, 0x80}, {0xcb, 0x00},
70 {0x5e, 0x00}, {0x9f, 0x03}
74 static u8 ZEBRA_AGC[] = {
76 0x7E, 0x7E, 0x7E, 0x7E, 0x7D, 0x7C, 0x7B, 0x7A, 0x79, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72,
77 0x71, 0x70, 0x6F, 0x6E, 0x6D, 0x6C, 0x6B, 0x6A, 0x69, 0x68, 0x67, 0x66, 0x65, 0x64, 0x63, 0x62,
78 0x48, 0x47, 0x46, 0x45, 0x44, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x08, 0x07,
79 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
80 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x15, 0x16,
81 0x17, 0x17, 0x18, 0x18, 0x19, 0x1a, 0x1a, 0x1b, 0x1b, 0x1c, 0x1c, 0x1d, 0x1d, 0x1d, 0x1e, 0x1e,
82 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x23, 0x23, 0x24,
83 0x24, 0x25, 0x25, 0x25, 0x26, 0x26, 0x27, 0x27, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F
86 static u32 ZEBRA_RF_RX_GAIN_TABLE[] = {
87 0x0096, 0x0076, 0x0056, 0x0036, 0x0016, 0x01f6, 0x01d6, 0x01b6,
88 0x0196, 0x0176, 0x00F7, 0x00D7, 0x00B7, 0x0097, 0x0077, 0x0057,
89 0x0037, 0x00FB, 0x00DB, 0x00BB, 0x00FF, 0x00E3, 0x00C3, 0x00A3,
90 0x0083, 0x0063, 0x0043, 0x0023, 0x0003, 0x01E3, 0x01C3, 0x01A3,
91 0x0183, 0x0163, 0x0143, 0x0123, 0x0103
94 static u8 OFDM_CONFIG[] = {
99 0x10, 0x0F, 0x0A, 0x0C, 0x14, 0xFA, 0xFF, 0x50,
100 0x00, 0x50, 0x00, 0x00, 0x00, 0x5C, 0x00, 0x00,
102 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0xA8, 0x26,
103 0x32, 0x33, 0x06, 0xA5, 0x6F, 0x55, 0xC8, 0xBB,
105 0x0A, 0xE1, 0x2C, 0x4A, 0x86, 0x83, 0x34, 0x00,
106 0x4F, 0x24, 0x6F, 0xC2, 0x03, 0x40, 0x80, 0x00,
108 0xC0, 0xC1, 0x58, 0xF1, 0x00, 0xC4, 0x90, 0x3e,
109 0xD8, 0x3C, 0x7B, 0x10, 0x10
136 unsigned char cmdByte;
137 unsigned long dataBytes;
141 cmdByte = (
u8)(data & 0x000000ff);
154 for (idx = 0; idx < 30; idx++) {
157 if ((u1bTmp &
BIT7) == 0)
163 for (idx = 0; idx < 3; idx++)
229 if (TryCnt == TC_3W_POLL_MAX_TRY_CNT) {
231 " %#X RE|WE bits are not clear!!\n", u1bTmp);
257 if (nDataBufBitCnt == 16) {
259 }
else if (nDataBufBitCnt == 64) {
265 int ByteCnt = nDataBufBitCnt / 8;
267 if ((nDataBufBitCnt % 8) != 0) {
269 "HwThreeWire(): nDataBufBitCnt(%d)"
270 " should be multiple of 8!!!\n",
274 nDataBufBitCnt &= ~7;
277 if (nDataBufBitCnt > 64) {
279 " nDataBufBitCnt(%d) should <= 64!!!\n",
285 for (idx = 0; idx < ByteCnt; idx++)
328 *((
u16 *)pDataBuf) &= 0x0FFF;
342 data2Write = (data << 4) | (
u32)(offset & 0x0f);
345 HwHSSIThreeWire(dev, (
u8 *)(&data2Write), len, 1, 1);
354 data2Write = ((
u32)(offset & 0x0f));
356 HwHSSIThreeWire(dev, (
u8 *)(&data2Write), wlen, 1, 0);
357 dataRead = data2Write;
370 UCharData = (
u8)((Data & 0x0000ff00) >> 8);
389 return RegisterContent;
401 bool bAntennaSwitched =
true;
409 if (DefaultAnt == 1) {
435 if (DefaultAnt == 1) {
460 return bAntennaSwitched;
475 u32 u4bRegOffset, u4bRegValue, u4bRF23, u4bRF24;
492 if (u4bRF23 == 0x818 && u4bRF24 == 0x70C) {
542 for (i = 0; i <= 36; i++) {
590 printk(
"ZEBRA_Config_85BASIC_HardCode(): (%02x)\n",
649 for (i = 0; i < 128; i++) {
651 data = ZEBRA_AGC[i+1];
653 data = data | 0x0000008F;
657 addr = addr | 0x0000008E;
674 for (i = 0; i < 60; i++) {
676 u4bRegValue = OFDM_CONFIG[
i];
680 (u4bRegOffset & 0x7f) |
681 ((u4bRegValue & 0xff) << 8)));
809 u8 bUNIVERSAL_CONTROL_RL = 0;
810 u8 bUNIVERSAL_CONTROL_AGC = 1;
811 u8 bUNIVERSAL_CONTROL_ANT = 1;
812 u8 bAUTO_RATE_FALLBACK_CTL = 1;
818 if (bUNIVERSAL_CONTROL_RL)
827 if (bUNIVERSAL_CONTROL_AGC) {
841 if (bUNIVERSAL_CONTROL_ANT) {
845 val8 = val8 & (val8|0x02);
853 if (bAUTO_RATE_FALLBACK_CTL) {
862 static void MacConfig_85BASIC_HardCode(
struct net_device *dev)
870 u32 u4bRegOffset, u4bRegValue, u4bPageIndex = 0;
873 nLinesRead =
sizeof(MAC_REG_TABLE)/2;
875 for (i = 0; i < nLinesRead; i++) {
876 u4bRegOffset = MAC_REG_TABLE[
i][0];
877 u4bRegValue = MAC_REG_TABLE[
i][1];
879 if (u4bRegOffset == 0x5e)
880 u4bPageIndex = u4bRegValue;
882 u4bRegOffset |= (u4bPageIndex << 8);
889 static void MacConfig_85BASIC(
struct net_device *dev)
893 MacConfig_85BASIC_HardCode(dev);
933 u8 btSupportedWirelessMode = 0;
936 return btSupportedWirelessMode;
947 u8 bFollowLegacySetting = 0;
977 bFollowLegacySetting = 1;
982 if (bFollowLegacySetting) {
989 AcParam.
f.AciAifsn.f.AIFSN = 2;
990 AcParam.
f.AciAifsn.f.ACM = 0;
991 AcParam.
f.Ecw.f.ECWmin = ChnlAccessSetting->
CWminIndex;
992 AcParam.
f.Ecw.f.ECWmax = ChnlAccessSetting->
CWmaxIndex;
993 AcParam.
f.TXOPLimit = 0;
998 AcParam.
f.TXOPLimit = 0x01FF;
1001 AcParam.
f.TXOPLimit = 0x0020;
1003 for (eACI = 0; eACI <
AC_MAX; eACI++) {
1004 AcParam.
f.AciAifsn.f.ACI = (
u8)eACI;
1012 eACI = pAcParam->
f.AciAifsn.f.ACI;
1037 DMESGW(
"SetHwReg8185(): invalid ACI: %d !\n", eACI);
1049 if (pAciAifsn->
f.ACM) {
1065 DMESGW(
"SetHwReg8185(): [HW_VAR_ACM_CTRL] ACM set failed: eACI is %d\n", eACI);
1100 if ((btWirelessMode & btSupportedWirelessMode) == 0) {
1102 DMESGW(
"ActSetWirelessMode8185(): WirelessMode(%d) is not supported (%d)!\n",
1103 btWirelessMode, btSupportedWirelessMode);
1117 DMESGW(
"ActSetWirelessMode8185(): No valid wireless mode supported, btSupportedWirelessMode(%x)!!!\n",
1118 btSupportedWirelessMode);
1134 DMESG(
"WIRELESS_MODE_A\n");
1136 DMESG(
"WIRELESS_MODE_B\n");
1138 DMESG(
"WIRELESS_MODE_G\n");
1163 for (i = 0; i < 6 ; i++)
1164 priv->
ieee80211->current_network.bssid[i] = 0x55;
1196 for (i = 0; i < 6; i++)
1197 priv->
ieee80211->current_network.bssid[i] = 0x22;
1260 bool bResult =
false;
1281 bool bActionAllowed =
false;
1282 bool bConnectBySSID =
false;
1284 u16 RFWaitCounter = 0;
1293 spin_unlock_irqrestore(&priv->
rf_ps_lock, flag);
1300 if (RFWaitCounter > 1000) {
1301 printk(
"MgntActSet_RF_State(): Wait too long to set RF\n");
1308 spin_unlock_irqrestore(&priv->
rf_ps_lock, flag);
1314 switch (StateToSet) {
1324 bActionAllowed =
true;
1327 bConnectBySSID =
true;
1349 bActionAllowed =
true;
1353 bActionAllowed =
true;
1359 if (bActionAllowed) {
1364 if (StateToSet ==
eRfOn) {
1366 if (bConnectBySSID) {
1371 else if (StateToSet ==
eRfOff)
1379 spin_unlock_irqrestore(&priv->
rf_ps_lock, flag);
1380 return bActionAllowed;
1448 u8 SupportedWirelessMode;
1449 u8 InitWirelessMode;
1450 u8 bInvalidWirelessMode = 0;
1470 MacConfig_85BASIC(dev);
1498 TmpU1b = TmpU1b & ~
BIT3;
1502 btCR9346 &= ~(0xC0);
1528 bInvalidWirelessMode = 1;
1533 (ieee->
mode & SupportedWirelessMode) == 0) {
1534 bInvalidWirelessMode = 1;
1548 DMESGW(
"InitializeAdapter8185(): No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n",
1549 SupportedWirelessMode);
1554 if (bInvalidWirelessMode)
1559 InitWirelessMode = ieee->
mode;
1578 netif_start_queue(dev);
1589 DMESG(
"NIC in promisc mode");