First Support on Ginger and OMAP TI
[linux-ginger.git] / drivers / staging / otus / hal / hprw.c
blobd9fad47d5d59685a4a88ac6b2c48e4406bf27524
1 /*
2 * Copyright (c) 2007-2008 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 #include "../80211core/cprecomp.h"
17 #include "hpani.h"
18 #include "hpusb.h"
19 #include "hpreg.h"
20 #include "../80211core/ratectrl.h"
22 extern void zfIdlCmd(zdev_t* dev, u32_t* cmd, u16_t cmdLen);
24 extern void zfCoreCwmBusy(zdev_t* dev, u16_t busy);
25 u16_t zfDelayWriteInternalReg(zdev_t* dev, u32_t addr, u32_t val);
26 u16_t zfFlushDelayWrite(zdev_t* dev);
28 //#define zm_hp_priv(x) struct zsHpPriv* hpPriv=zgWlanDev.hpPrivate;
30 void zfInitCmdQueue(zdev_t* dev)
32 struct zsHpPriv* hpPriv;
34 zmw_get_wlan_dev(dev);
35 hpPriv = (struct zsHpPriv*)(wd->hpPrivate);
37 zmw_declare_for_critical_section();
39 zmw_enter_critical_section(dev);
40 #ifdef ZM_XP_USB_MULTCMD
41 hpPriv->cmdTail = hpPriv->cmdHead = hpPriv->cmdSend = 0;
42 #else
43 hpPriv->cmdTail = hpPriv->cmdHead = 0;
44 #endif
45 hpPriv->cmdPending = 0;
46 hpPriv->cmd.delayWcmdCount = 0;
47 zmw_leave_critical_section(dev);
50 u16_t zfPutCmd(zdev_t* dev, u32_t* cmd, u16_t cmdLen, u16_t src, u8_t* buf)
52 u16_t i;
53 struct zsHpPriv* hpPriv;
55 zmw_get_wlan_dev(dev);
56 hpPriv=wd->hpPrivate;
58 /* Make sure command length < ZM_MAX_CMD_SIZE */
59 zm_assert(cmdLen <= ZM_MAX_CMD_SIZE);
60 /* Make sure command queue not full */
61 //zm_assert(((hpPriv->cmdTail+1) & (ZM_CMD_QUEUE_SIZE-1)) != hpPriv->cmdHead);
62 if (((hpPriv->cmdTail+1) & (ZM_CMD_QUEUE_SIZE-1)) == hpPriv->cmdHead ) {
63 zm_debug_msg0("CMD queue full!!");
64 return 0;
67 hpPriv->cmdQ[hpPriv->cmdTail].cmdLen = cmdLen;
68 hpPriv->cmdQ[hpPriv->cmdTail].src = src;
69 hpPriv->cmdQ[hpPriv->cmdTail].buf = buf;
70 for (i=0; i<(cmdLen>>2); i++)
72 hpPriv->cmdQ[hpPriv->cmdTail].cmd[i] = cmd[i];
75 hpPriv->cmdTail = (hpPriv->cmdTail+1) & (ZM_CMD_QUEUE_SIZE-1);
77 return 0;
80 u16_t zfGetCmd(zdev_t* dev, u32_t* cmd, u16_t* cmdLen, u16_t* src, u8_t** buf)
82 u16_t i;
83 struct zsHpPriv* hpPriv;
85 zmw_get_wlan_dev(dev);
86 hpPriv=wd->hpPrivate;
88 if (hpPriv->cmdTail == hpPriv->cmdHead)
90 return 3;
93 *cmdLen = hpPriv->cmdQ[hpPriv->cmdHead].cmdLen;
94 *src = hpPriv->cmdQ[hpPriv->cmdHead].src;
95 *buf = hpPriv->cmdQ[hpPriv->cmdHead].buf;
96 for (i=0; i<((*cmdLen)>>2); i++)
98 cmd[i] = hpPriv->cmdQ[hpPriv->cmdHead].cmd[i];
101 hpPriv->cmdHead = (hpPriv->cmdHead+1) & (ZM_CMD_QUEUE_SIZE-1);
103 return 0;
106 #ifdef ZM_XP_USB_MULTCMD
107 void zfSendCmdEx(zdev_t* dev)
109 u32_t ncmd[ZM_MAX_CMD_SIZE/4];
110 u16_t ncmdLen = 0;
111 u16_t cmdFlag = 0;
112 u16_t i;
113 struct zsHpPriv* hpPriv;
115 zmw_get_wlan_dev(dev);
116 hpPriv=wd->hpPrivate;
118 zmw_declare_for_critical_section();
120 zmw_enter_critical_section(dev);
122 if (hpPriv->cmdPending == 0)
124 if (hpPriv->cmdTail != hpPriv->cmdSend)
126 cmdFlag = 1;
127 /* Get queueing command */
128 ncmdLen= hpPriv->cmdQ[hpPriv->cmdSend].cmdLen;
129 for (i=0; i<(ncmdLen>>2); i++)
131 ncmd[i] = hpPriv->cmdQ[hpPriv->cmdSend].cmd[i];
133 hpPriv->cmdSend = (hpPriv->cmdSend+1) & (ZM_CMD_QUEUE_SIZE-1);
135 hpPriv->cmdPending = 1;
139 zmw_leave_critical_section(dev);
141 if ((cmdFlag == 1))
143 zfIdlCmd(dev, ncmd, ncmdLen);
147 void zfiSendCmdComp(zdev_t* dev)
149 struct zsHpPriv* hpPriv;
151 zmw_get_wlan_dev(dev);
152 hpPriv=wd->hpPrivate;
154 zmw_declare_for_critical_section();
156 zmw_enter_critical_section(dev);
157 hpPriv->cmdPending = 0;
158 zmw_leave_critical_section(dev);
160 zfSendCmdEx(dev);
162 #endif
164 u16_t zfIssueCmd(zdev_t* dev, u32_t* cmd, u16_t cmdLen, u16_t src, u8_t* buf)
166 u16_t cmdFlag = 0;
167 u16_t ret;
168 struct zsHpPriv* hpPriv;
170 zmw_get_wlan_dev(dev);
171 hpPriv=wd->hpPrivate;
173 zmw_declare_for_critical_section();
175 zm_msg2_mm(ZM_LV_1, "cmdLen=", cmdLen);
177 zmw_enter_critical_section(dev);
179 #ifdef ZM_XP_USB_MULTCMD
180 ret = zfPutCmd(dev, cmd, cmdLen, src, buf);
181 zmw_leave_critical_section(dev);
183 if (ret != 0)
185 return 1;
188 zfSendCmdEx(dev);
189 #else
190 if (hpPriv->cmdPending == 0)
192 hpPriv->cmdPending = 1;
193 cmdFlag = 1;
195 ret = zfPutCmd(dev, cmd, cmdLen, src, buf);
197 zmw_leave_critical_section(dev);
199 if (ret != 0)
201 return 1;
204 if (cmdFlag == 1)
206 zfIdlCmd(dev, cmd, cmdLen);
208 #endif
209 return 0;
212 void zfIdlRsp(zdev_t* dev, u32_t* rsp, u16_t rspLen)
214 u32_t cmd[ZM_MAX_CMD_SIZE/4];
215 u16_t cmdLen;
216 u16_t src;
217 u8_t* buf;
218 u32_t ncmd[ZM_MAX_CMD_SIZE/4];
219 u16_t ncmdLen = 0;
220 u16_t ret;
221 u16_t cmdFlag = 0;
222 u16_t i;
223 s32_t nf;
224 s32_t noisefloor[4];
225 struct zsHpPriv* hpPriv;
227 zmw_get_wlan_dev(dev);
228 hpPriv=wd->hpPrivate;
231 zmw_declare_for_critical_section();
233 zmw_enter_critical_section(dev);
235 ret = zfGetCmd(dev, cmd, &cmdLen, &src, &buf);
236 #if 0
237 zm_assert(ret == 0);
238 #else
239 if (ret != 0)
241 zm_debug_msg0("Error IdlRsp because none cmd!!\n");
242 #ifndef ZM_XP_USB_MULTCMD
243 zmw_leave_critical_section(dev);
244 return;
245 #endif
247 #endif
248 #ifdef ZM_XP_USB_MULTCMD
249 zmw_leave_critical_section(dev);
250 #else
251 if (hpPriv->cmdTail != hpPriv->cmdHead)
253 cmdFlag = 1;
254 /* Get queueing command */
255 ncmdLen= hpPriv->cmdQ[hpPriv->cmdHead].cmdLen;
256 for (i=0; i<(ncmdLen>>2); i++)
258 ncmd[i] = hpPriv->cmdQ[hpPriv->cmdHead].cmd[i];
261 else
263 hpPriv->cmdPending = 0;
266 zmw_leave_critical_section(dev);
268 if (cmdFlag == 1)
270 zfIdlCmd(dev, ncmd, ncmdLen);
272 #endif
273 if (src == ZM_OID_READ)
275 ZM_PERFORMANCE_REG(dev, 0x11772c, rsp[1]);
276 zfwDbgReadRegDone(dev, cmd[1], rsp[1]);
278 else if (src == ZM_OID_FLASH_CHKSUM)
280 zfwDbgGetFlashChkSumDone(dev, rsp+1);
282 else if (src == ZM_OID_FLASH_READ)
284 u32_t datalen;
285 u16_t i;
287 datalen = (rsp[0] & 255);
289 zfwDbgReadFlashDone(dev, cmd[1], rsp+1, datalen);
291 else if (src == ZM_OID_FLASH_PROGRAM)
293 /* Non do */
295 else if (src == ZM_OID_WRITE)
297 zfwDbgWriteRegDone(dev, cmd[1], cmd[2]);
299 else if (src == ZM_OID_TALLY)
301 zfCollectHWTally(dev, rsp, 0);
303 else if (src == ZM_OID_TALLY_APD)
305 zfCollectHWTally(dev, rsp, 1);
306 zfwDbgReadTallyDone(dev);
307 #ifdef ZM_ENABLE_BA_RATECTRL
308 zfRateCtrlAggrSta(dev);
309 #endif
311 else if (src == ZM_OID_DKTX_STATUS)
313 zm_debug_msg0("src = zm_OID_DKTX_STATUS");
314 zfwDbgQueryHwTxBusyDone(dev, rsp[1]);
316 else if (src == ZM_CMD_SET_FREQUENCY)
319 //#ifdef ZM_OTUS_ENABLE_RETRY_FREQ_CHANGE
320 #if 0
321 zm_debug_msg1("Retry Set Frequency = ", rsp[1]);
323 #if 1
324 // Read the Noise Floor value !
325 nf = ((rsp[2]>>19) & 0x1ff);
326 if ((nf & 0x100) != 0x0)
328 noisefloor[0] = 0 - ((nf ^ 0x1ff) + 1);
330 else
332 noisefloor[0] = nf;
335 zm_debug_msg1("Noise Floor[1] = ", noisefloor[0]);
337 nf = ((rsp[3]>>19) & 0x1ff);
338 if ((nf & 0x100) != 0x0)
340 noisefloor[1] = 0 - ((nf ^ 0x1ff) + 1);
342 else
344 noisefloor[1] = nf;
347 zm_debug_msg1("Noise Floor[2] = ", noisefloor[1]);
348 zm_debug_msg1("Is Site Survey = ", hpPriv->isSiteSurvey);
349 #endif
351 if ( (rsp[1] && hpPriv->freqRetryCounter == 0) ||
352 (((noisefloor[0]>-60)||(noisefloor[1]>-60)) && hpPriv->freqRetryCounter==0) ||
353 ((abs(noisefloor[0]-noisefloor[1])>=9) && hpPriv->freqRetryCounter==0) )
355 zm_debug_msg0("Retry to issue the frequency change command");
357 if ( hpPriv->recordFreqRetryCounter == 1 )
359 zm_debug_msg0("Cold Reset");
361 zfHpSetFrequencyEx(dev, hpPriv->latestFrequency,
362 hpPriv->latestBw40,
363 hpPriv->latestExtOffset,
366 if ( hpPriv->isSiteSurvey != 2 )
368 hpPriv->freqRetryCounter++;
370 hpPriv->recordFreqRetryCounter = 0;
372 else
374 zfHpSetFrequencyEx(dev, hpPriv->latestFrequency,
375 hpPriv->latestBw40,
376 hpPriv->latestExtOffset,
379 hpPriv->recordFreqRetryCounter++;
381 else
382 #endif
384 /* ret: Bit0: AGC calibration 0=>finish 1=>unfinish */
385 /* Bit1: Noise calibration 0=>finish 1=>unfinish */
386 /* Bit2: Noise calibration finish, but NF value unexcepted => 1 */
387 if ( (rsp[1] & 0x1) || (rsp[1] & 0x4) )
389 zm_debug_msg1("Set Frequency fail : ret = ", rsp[1]);
391 /* 1. AGC Calibration fail */
392 /* 2. Noise Calibration finish but error NoiseFloor value */
393 /* and not in sitesurvey, try more twice */
394 if ( hpPriv->isSiteSurvey == 2 )
396 if ( hpPriv->recordFreqRetryCounter < 2 )
398 /* cold reset */
399 zfHpSetFrequencyEx(dev, hpPriv->latestFrequency,
400 hpPriv->latestBw40,
401 hpPriv->latestExtOffset,
403 hpPriv->recordFreqRetryCounter++;
404 zm_debug_msg1("Retry to issue the frequency change command(cold reset) counter = ", hpPriv->recordFreqRetryCounter);
406 else
408 /* Fail : we would not accept this result! */
409 zm_debug_msg0("\n\n\n\n Fail twice cold reset \n\n\n\n");
410 hpPriv->coldResetNeedFreq = 0;
411 hpPriv->recordFreqRetryCounter = 0;
412 zfCoreSetFrequencyComplete(dev);
415 else
417 /* in sitesurvey, coldreset in next channel */
418 hpPriv->coldResetNeedFreq = 1;
419 hpPriv->recordFreqRetryCounter = 0;
420 zfCoreSetFrequencyComplete(dev);
423 else if (rsp[1] & 0x2)
425 zm_debug_msg1("Set Frequency fail 2 : ret = ", rsp[1]);
427 /* Noise Calibration un-finish */
428 /* and not in sitesurvey, try more once */
429 if ( hpPriv->isSiteSurvey == 2 )
431 if ( hpPriv->recordFreqRetryCounter < 1 )
433 /* cold reset */
434 zfHpSetFrequencyEx(dev, hpPriv->latestFrequency,
435 hpPriv->latestBw40,
436 hpPriv->latestExtOffset,
438 hpPriv->recordFreqRetryCounter++;
439 zm_debug_msg1("2 Retry to issue the frequency change command(cold reset) counter = ", hpPriv->recordFreqRetryCounter);
441 else
443 /* Fail : we would not accept this result! */
444 zm_debug_msg0("\n\n\n\n 2 Fail twice cold reset \n\n\n\n");
445 hpPriv->coldResetNeedFreq = 0;
446 hpPriv->recordFreqRetryCounter = 0;
447 zfCoreSetFrequencyComplete(dev);
450 else
452 /* in sitesurvey, skip this frequency */
453 hpPriv->coldResetNeedFreq = 0;
454 hpPriv->recordFreqRetryCounter = 0;
455 zfCoreSetFrequencyComplete(dev);
458 //else if (rsp[1] & 0x4)
460 // zm_debug_msg1("Set Frequency fail 3 : ret = ", rsp[1]);
461 // hpPriv->coldResetNeedFreq = 0;
462 // hpPriv->recordFreqRetryCounter = 0;
463 // zfCoreSetFrequencyComplete(dev);
465 else
467 //hpPriv->freqRetryCounter = 0;
468 zm_debug_msg2(" return complete, ret = ", rsp[1]);
470 /* set bb_heavy_clip_enable */
471 if (hpPriv->enableBBHeavyClip && hpPriv->hwBBHeavyClip &&
472 hpPriv->doBBHeavyClip)
474 u32_t setValue = 0x200;
476 setValue |= hpPriv->setValueHeavyClip;
478 //zm_dbg(("Do heavy clip setValue = %d\n", setValue));
480 zfDelayWriteInternalReg(dev, 0x99e0+0x1bc000, setValue);
481 zfFlushDelayWrite(dev);
484 hpPriv->coldResetNeedFreq = 0;
485 hpPriv->recordFreqRetryCounter = 0;
486 zfCoreSetFrequencyComplete(dev);
489 #if 1
490 // Read the Noise Floor value !
491 nf = ((rsp[2]>>19) & 0x1ff);
492 if ((nf & 0x100) != 0x0)
494 noisefloor[0] = 0 - ((nf ^ 0x1ff) + 1);
496 else
498 noisefloor[0] = nf;
501 //zm_debug_msg1("Noise Floor[1] = ", noisefloor[0]);
503 nf = ((rsp[3]>>19) & 0x1ff);
504 if ((nf & 0x100) != 0x0)
506 noisefloor[1] = 0 - ((nf ^ 0x1ff) + 1);
508 else
510 noisefloor[1] = nf;
513 //zm_debug_msg1("Noise Floor[2] = ", noisefloor[1]);
515 nf = ((rsp[5]>>23) & 0x1ff);
516 if ((nf & 0x100) != 0x0)
518 noisefloor[2] = 0 - ((nf ^ 0x1ff) + 1);
520 else
522 noisefloor[2] = nf;
525 //zm_debug_msg1("Noise Floor ext[1] = ", noisefloor[2]);
527 nf = ((rsp[6]>>23) & 0x1ff);
528 if ((nf & 0x100) != 0x0)
530 noisefloor[3] = 0 - ((nf ^ 0x1ff) + 1);
532 else
534 noisefloor[3] = nf;
537 //zm_debug_msg1("Noise Floor ext[2] = ", noisefloor[3]);
539 //zm_debug_msg1("Is Site Survey = ", hpPriv->isSiteSurvey);
540 #endif
542 else if (src == ZM_CMD_SET_KEY)
544 zfCoreSetKeyComplete(dev);
546 else if (src == ZM_CWM_READ)
548 zm_msg2_mm(ZM_LV_0, "CWM rsp[1]=", rsp[1]);
549 zm_msg2_mm(ZM_LV_0, "CWM rsp[2]=", rsp[2]);
550 zfCoreCwmBusy(dev, zfCwmIsExtChanBusy(rsp[1], rsp[2]));
552 else if (src == ZM_MAC_READ)
554 /* rsp[1] = ZM_SEEPROM_MAC_ADDRESS_OFFSET; */
555 /* rsp[2] = ZM_SEEPROM_MAC_ADDRESS_OFFSET+4; */
556 /* rsp[3] = ZM_SEEPROM_REGDOMAIN_OFFSET; */
557 /* rsp[4] = ZM_SEEPROM_VERISON_OFFSET; */
558 /* rsp[5] = ZM_SEEPROM_HARDWARE_TYPE_OFFSET; */
559 /* rsp[6] = ZM_SEEPROM_HW_HEAVY_CLIP; */
561 u8_t addr[6], CCS, WWR;
562 u16_t CountryDomainCode;
564 /* BB heavy clip */
565 //hpPriv->eepromHeavyClipFlag = (u8_t)((rsp[6]>>24) & 0xff); // force enable 8107
566 //zm_msg2_mm(ZM_LV_0, "eepromHeavyClipFlag", hpPriv->eepromHeavyClipFlag);
567 #if 0
568 if (hpPriv->hwBBHeavyClip)
570 zm_msg0_mm(ZM_LV_0, "enable BB Heavy Clip");
572 else
574 zm_msg0_mm(ZM_LV_0, "Not enable BB Heavy Clip");
576 #endif
577 zm_msg2_mm(ZM_LV_0, "MAC rsp[1]=", rsp[1]);
578 zm_msg2_mm(ZM_LV_0, "MAC rsp[2]=", rsp[2]);
580 addr[0] = (u8_t)(rsp[1] & 0xff);
581 addr[1] = (u8_t)((rsp[1]>>8) & 0xff);
582 addr[2] = (u8_t)((rsp[1]>>16) & 0xff);
583 addr[3] = (u8_t)((rsp[1]>>24) & 0xff);
584 addr[4] = (u8_t)(rsp[2] & 0xff);
585 addr[5] = (u8_t)((rsp[2]>>8) & 0xff);
586 /*#ifdef ZM_FB50
587 addr[0] = (u8_t)(0 & 0xff);
588 addr[1] = (u8_t)(3 & 0xff);
589 addr[2] = (u8_t)(127 & 0xff);
590 addr[3] = (u8_t)(0 & 0xff);
591 addr[4] = (u8_t)(9 & 0xff);
592 addr[5] = (u8_t)(11 & 0xff);
593 #endif*/
595 zfDelayWriteInternalReg(dev, ZM_MAC_REG_MAC_ADDR_L,
596 ((((u32_t)addr[3])<<24) | (((u32_t)addr[2])<<16) | (((u32_t)addr[1])<<8) | addr[0]));
597 zfDelayWriteInternalReg(dev, ZM_MAC_REG_MAC_ADDR_H,
598 ((((u32_t)addr[5])<<8) | addr[4]));
599 zfFlushDelayWrite(dev);
601 wd->ledStruct.ledMode[0] = (u16_t)(rsp[5]&0xffff);
602 wd->ledStruct.ledMode[1] = (u16_t)(rsp[5]>>16);
603 zm_msg2_mm(ZM_LV_0, "ledMode[0]=", wd->ledStruct.ledMode[0]);
604 zm_msg2_mm(ZM_LV_0, "ledMode[1]=", wd->ledStruct.ledMode[1]);
606 /* Regulatory Related Setting */
607 zm_msg2_mm(ZM_LV_0, "RegDomain rsp=", rsp[3]);
608 zm_msg2_mm(ZM_LV_0, "OpFlags+EepMisc=", rsp[4]);
609 hpPriv->OpFlags = (u8_t)((rsp[4]>>16) & 0xff);
610 if ((rsp[2] >> 24) == 0x1) //Tx mask == 0x1
612 zm_msg0_mm(ZM_LV_0, "OTUS 1x2");
613 hpPriv->halCapability |= ZM_HP_CAP_11N_ONE_TX_STREAM;
615 else
617 zm_msg0_mm(ZM_LV_0, "OTUS 2x2");
619 if (hpPriv->OpFlags & 0x1)
621 hpPriv->halCapability |= ZM_HP_CAP_5G;
623 if (hpPriv->OpFlags & 0x2)
625 hpPriv->halCapability |= ZM_HP_CAP_2G;
629 CCS = (u8_t)((rsp[3] & 0x8000) >> 15);
630 WWR = (u8_t)((rsp[3] & 0x4000) >> 14);
631 CountryDomainCode = (u16_t)(rsp[3] & 0x3FFF);
633 if (rsp[3] != 0xffffffff)
635 if (CCS)
637 //zm_debug_msg0("CWY - Get Regulation Table from Country Code");
638 zfHpGetRegulationTablefromCountry(dev, CountryDomainCode);
640 else
642 //zm_debug_msg0("CWY - Get Regulation Table from Reg Domain");
643 zfHpGetRegulationTablefromRegionCode(dev, CountryDomainCode);
645 if (WWR)
647 //zm_debug_msg0("CWY - Enable 802.11d");
648 /* below line shall be unmarked after A band is ready */
649 //zfiWlanSetDot11DMode(dev, 1);
652 else
654 zfHpGetRegulationTablefromRegionCode(dev, NO_ENUMRD);
657 zfCoreMacAddressNotify(dev, addr);
660 else if (src == ZM_EEPROM_READ)
662 #if 0
663 u8_t addr[6], CCS, WWR;
664 u16_t CountryDomainCode;
665 #endif
666 for (i=0; i<ZM_HAL_MAX_EEPROM_PRQ; i++)
668 if (hpPriv->eepromImageIndex < 1024)
670 hpPriv->eepromImage[hpPriv->eepromImageIndex++] = rsp[i+1];
674 if (hpPriv->eepromImageIndex == (ZM_HAL_MAX_EEPROM_REQ*ZM_HAL_MAX_EEPROM_PRQ))
676 #if 0
677 for (i=0; i<1024; i++)
679 zm_msg2_mm(ZM_LV_0, "index=", i);
680 zm_msg2_mm(ZM_LV_0, "eepromImage=", hpPriv->eepromImage[i]);
682 #endif
683 zm_msg2_mm(ZM_LV_0, "MAC [1]=", hpPriv->eepromImage[0x20c/4]);
684 zm_msg2_mm(ZM_LV_0, "MAC [2]=", hpPriv->eepromImage[0x210/4]);
685 #if 0
686 addr[0] = (u8_t)(hpPriv->eepromImage[0x20c/4] & 0xff);
687 addr[1] = (u8_t)((hpPriv->eepromImage[0x20c/4]>>8) & 0xff);
688 addr[2] = (u8_t)((hpPriv->eepromImage[0x20c/4]>>16) & 0xff);
689 addr[3] = (u8_t)((hpPriv->eepromImage[0x20c/4]>>24) & 0xff);
690 addr[4] = (u8_t)(hpPriv->eepromImage[0x210/4] & 0xff);
691 addr[5] = (u8_t)((hpPriv->eepromImage[0x210/4]>>8) & 0xff);
693 zfCoreMacAddressNotify(dev, addr);
695 zfDelayWriteInternalReg(dev, ZM_MAC_REG_MAC_ADDR_L,
696 ((((u32_t)addr[3])<<24) | (((u32_t)addr[2])<<16) | (((u32_t)addr[1])<<8) | addr[0]));
697 zfDelayWriteInternalReg(dev, ZM_MAC_REG_MAC_ADDR_H,
698 ((((u32_t)addr[5])<<8) | addr[4]));
699 zfFlushDelayWrite(dev);
701 /* Regulatory Related Setting */
702 zm_msg2_mm(ZM_LV_0, "RegDomain =", hpPriv->eepromImage[0x208/4]);
703 CCS = (u8_t)((hpPriv->eepromImage[0x208/4] & 0x8000) >> 15);
704 WWR = (u8_t)((hpPriv->eepromImage[0x208/4] & 0x4000) >> 14);
705 /* below line shall be unmarked after A band is ready */
706 //CountryDomainCode = (u16_t)(hpPriv->eepromImage[0x208/4] & 0x3FFF);
707 CountryDomainCode = 8;
708 if (CCS)
710 //zm_debug_msg0("CWY - Get Regulation Table from Country Code");
711 zfHpGetRegulationTablefromCountry(dev, CountryDomainCode);
713 else
715 //zm_debug_msg0("CWY - Get Regulation Table from Reg Domain");
716 zfHpGetRegulationTablefromRegionCode(dev, CountryDomainCode);
718 if (WWR)
720 //zm_debug_msg0("CWY - Enable 802.11d");
721 /* below line shall be unmarked after A band is ready */
722 //zfiWlanSetDot11DMode(dev, 1);
724 #endif
725 zfCoreHalInitComplete(dev);
727 else
729 hpPriv->eepromImageRdReq++;
730 zfHpLoadEEPROMFromFW(dev);
733 else if (src == ZM_EEPROM_WRITE)
735 zfwDbgWriteEepromDone(dev, cmd[1], cmd[2]);
737 else if (src == ZM_ANI_READ)
739 u32_t cycleTime, ctlClear;
741 zm_msg2_mm(ZM_LV_0, "ANI rsp[1]=", rsp[1]);
742 zm_msg2_mm(ZM_LV_0, "ANI rsp[2]=", rsp[2]);
743 zm_msg2_mm(ZM_LV_0, "ANI rsp[3]=", rsp[3]);
744 zm_msg2_mm(ZM_LV_0, "ANI rsp[4]=", rsp[4]);
746 hpPriv->ctlBusy += rsp[1];
747 hpPriv->extBusy += rsp[2];
749 cycleTime = 100000; //100 miniseconds
751 if (cycleTime > rsp[1])
753 ctlClear = (cycleTime - rsp[1]) / 100;
755 else
757 ctlClear = 0;
759 if (wd->aniEnable)
760 zfHpAniArPoll(dev, ctlClear, rsp[3], rsp[4]);
762 else if (src == ZM_CMD_ECHO)
764 if ( ((struct zsHpPriv*)wd->hpPrivate)->halReInit )
766 zfCoreHalInitComplete(dev);
767 ((struct zsHpPriv*)wd->hpPrivate)->halReInit = 0;
769 else
771 zfHpLoadEEPROMFromFW(dev);
774 else if (src == ZM_OID_FW_DL_INIT)
776 zfwDbgDownloadFwInitDone(dev);
778 return;
782 /************************************************************************/
783 /* */
784 /* FUNCTION DESCRIPTION zfWriteRegInternalReg */
785 /* Write on chip internal register immediately. */
786 /* */
787 /* INPUTS */
788 /* dev : device pointer */
789 /* addr : register address */
790 /* val : value */
791 /* */
792 /* OUTPUTS */
793 /* 0 : success */
794 /* other : fail */
795 /* */
796 /* AUTHOR */
797 /* Stephen Chen ZyDAS Technology Corporation 2005.11 */
798 /* */
799 /************************************************************************/
800 u32_t zfWriteRegInternalReg(zdev_t* dev, u32_t addr, u32_t val)
802 u32_t cmd[3];
803 u16_t ret;
805 cmd[0] = 0x00000108;
806 cmd[1] = addr;
807 cmd[2] = val;
809 ret = zfIssueCmd(dev, cmd, 12, ZM_OID_INTERNAL_WRITE, NULL);
810 return ret;
814 /************************************************************************/
815 /* */
816 /* FUNCTION DESCRIPTION zfDelayWriteInternalReg */
817 /* Write on chip internal register, write operation may be */
818 /* postponed to form a multiple write command. */
819 /* */
820 /* INPUTS */
821 /* dev : device pointer */
822 /* addr : register address */
823 /* val : value */
824 /* */
825 /* OUTPUTS */
826 /* 0 : command been postponed */
827 /* 1 : commands been executed */
828 /* */
829 /* AUTHOR */
830 /* Stephen Chen ZyDAS Technology Corporation 2005.11 */
831 /* */
832 /************************************************************************/
833 u16_t zfDelayWriteInternalReg(zdev_t* dev, u32_t addr, u32_t val)
835 u32_t cmd[(ZM_MAX_CMD_SIZE/4)];
836 u16_t i;
837 u16_t ret;
838 struct zsHpPriv* hpPriv;
840 zmw_get_wlan_dev(dev);
841 hpPriv=wd->hpPrivate;
843 zmw_declare_for_critical_section();
845 /* enter critical section */
846 zmw_enter_critical_section(dev);
848 /* Store command to global buffer */
849 hpPriv->cmd.delayWcmdAddr[hpPriv->cmd.delayWcmdCount] = addr;
850 hpPriv->cmd.delayWcmdVal[hpPriv->cmd.delayWcmdCount++] = val;
852 /* If pending command reach size limit */
853 if ((hpPriv->cmd.delayWcmdCount) >= ((ZM_MAX_CMD_SIZE - 4) >> 3))
855 cmd[0] = 0x00000100 + (hpPriv->cmd.delayWcmdCount<<3);
857 /* copy command to cmd buffer */
858 for (i=0; i<hpPriv->cmd.delayWcmdCount; i++)
860 cmd[1+(i<<1)] = hpPriv->cmd.delayWcmdAddr[i];
861 cmd[2+(i<<1)] = hpPriv->cmd.delayWcmdVal[i];
863 /* reset pending command */
864 hpPriv->cmd.delayWcmdCount = 0;
866 /* leave critical section */
867 zmw_leave_critical_section(dev);
869 /* issue write command */
870 ret = zfIssueCmd(dev, cmd, 4+(i<<3), ZM_OID_INTERNAL_WRITE, NULL);
872 return 1;
874 else
876 /* leave critical section */
877 zmw_leave_critical_section(dev);
879 return 0;
884 /************************************************************************/
885 /* */
886 /* FUNCTION DESCRIPTION zfFlushDelayWrite */
887 /* Flush pending write command. */
888 /* */
889 /* INPUTS */
890 /* dev : device pointer */
891 /* */
892 /* OUTPUTS */
893 /* 0 : no pending command */
894 /* 1 : commands been executed */
895 /* */
896 /* AUTHOR */
897 /* Stephen Chen ZyDAS Technology Corporation 2005.11 */
898 /* */
899 /************************************************************************/
900 u16_t zfFlushDelayWrite(zdev_t* dev)
902 u32_t cmd[(ZM_MAX_CMD_SIZE/4)];
903 u16_t i;
904 u16_t ret;
905 struct zsHpPriv* hpPriv;
907 zmw_get_wlan_dev(dev);
908 hpPriv=wd->hpPrivate;
910 zmw_declare_for_critical_section();
912 /* enter critical section */
913 zmw_enter_critical_section(dev);
915 /* If there is pending command */
916 if (hpPriv->cmd.delayWcmdCount > 0)
918 cmd[0] = 0x00000100 + (hpPriv->cmd.delayWcmdCount<<3);
920 /* copy command to cmd buffer */
921 for (i=0; i<hpPriv->cmd.delayWcmdCount; i++)
923 cmd[1+(i<<1)] = hpPriv->cmd.delayWcmdAddr[i];
924 cmd[2+(i<<1)] = hpPriv->cmd.delayWcmdVal[i];
926 /* reset pending command */
927 hpPriv->cmd.delayWcmdCount = 0;
929 /* leave critical section */
930 zmw_leave_critical_section(dev);
932 /* issue write command */
933 ret = zfIssueCmd(dev, cmd, 4+(i<<3), ZM_OID_INTERNAL_WRITE, NULL);
935 return 1;
937 else
939 /* leave critical section */
940 zmw_leave_critical_section(dev);
942 return 0;
947 u32_t zfiDbgDelayWriteReg(zdev_t* dev, u32_t addr, u32_t val)
949 zfDelayWriteInternalReg(dev, addr, val);
950 return 0;
953 u32_t zfiDbgFlushDelayWrite(zdev_t* dev)
955 zfFlushDelayWrite(dev);
956 return 0;
959 /************************************************************************/
960 /* */
961 /* FUNCTION DESCRIPTION zfiDbgWriteReg */
962 /* Write register. */
963 /* */
964 /* INPUTS */
965 /* dev : device pointer */
966 /* addr : register address */
967 /* val : value */
968 /* */
969 /* OUTPUTS */
970 /* 0 : success */
971 /* other : fail */
972 /* */
973 /* AUTHOR */
974 /* Stephen Chen ZyDAS Technology Corporation 2005.10 */
975 /* */
976 /************************************************************************/
977 u32_t zfiDbgWriteReg(zdev_t* dev, u32_t addr, u32_t val)
979 u32_t cmd[3];
980 u16_t ret;
982 cmd[0] = 0x00000108;
983 cmd[1] = addr;
984 cmd[2] = val;
986 ret = zfIssueCmd(dev, cmd, 12, ZM_OID_WRITE, 0);
987 return ret;
989 /************************************************************************/
990 /* */
991 /* FUNCTION DESCRIPTION zfiDbgWriteFlash */
992 /* Write flash. */
993 /* */
994 /* INPUTS */
995 /* dev : device pointer */
996 /* addr : register address */
997 /* val : value */
998 /* */
999 /* OUTPUTS */
1000 /* 0 : success */
1001 /* other : fail */
1002 /* */
1003 /* AUTHOR */
1004 /* Yjsung ZyDAS Technology Corporation 2007.02 */
1005 /* */
1006 /************************************************************************/
1007 u32_t zfiDbgWriteFlash(zdev_t* dev, u32_t addr, u32_t val)
1009 u32_t cmd[3];
1010 u16_t ret;
1012 //cmd[0] = 0x0000B008;
1013 /* len[0] : type[0xB0] : seq[?] */
1014 cmd[0] = 8 | (ZM_CMD_WFLASH << 8);
1015 cmd[1] = addr;
1016 cmd[2] = val;
1018 ret = zfIssueCmd(dev, cmd, 12, ZM_OID_WRITE, 0);
1019 return ret;
1022 /************************************************************************/
1023 /* */
1024 /* FUNCTION DESCRIPTION zfiDbgWriteEeprom */
1025 /* Write EEPROM. */
1026 /* */
1027 /* INPUTS */
1028 /* dev : device pointer */
1029 /* addr : register address */
1030 /* val : value */
1031 /* */
1032 /* OUTPUTS */
1033 /* 0 : success */
1034 /* other : fail */
1035 /* */
1036 /* AUTHOR */
1037 /* Paul ZyDAS Technology Corporation 2007.06 */
1038 /* */
1039 /************************************************************************/
1040 u32_t zfiDbgWriteEeprom(zdev_t* dev, u32_t addr, u32_t val)
1042 u32_t cmd[3];
1043 u16_t ret;
1045 //cmd[0] = 0x0000B008;
1046 /* len[0] : type[0xB0] : seq[?] */
1047 cmd[0] = 8 | (ZM_CMD_WREEPROM << 8);
1048 cmd[1] = addr;
1049 cmd[2] = val;
1051 ret = zfIssueCmd(dev, cmd, 12, ZM_EEPROM_WRITE, 0);
1052 return ret;
1055 /************************************************************************/
1056 /* */
1057 /* FUNCTION DESCRIPTION zfiDbgBlockWriteEeprom */
1058 /* Block Write Eeprom. */
1059 /* */
1060 /* p.s: now,it will write 16 bytes register data per block (N=4) */
1061 /* */
1062 /* INPUTS */
1063 /* dev : device pointer */
1064 /* addr : register address */
1065 /* buf : input data buffer pointer */
1066 /* */
1067 /* OUTPUTS */
1068 /* 0 : success */
1069 /* other : fail */
1070 /* */
1071 /* AUTHOR */
1072 /* Paul ZyDAS Technology Corporation 2007.06 */
1073 /* */
1074 /************************************************************************/
1075 //#define N buflen/4
1076 //#define SIZE (2*N+1)
1078 u32_t zfiDbgBlockWriteEeprom(zdev_t* dev, u32_t addr, u32_t* buf)
1080 u32_t cmd[9]; //2N+1
1081 u16_t ret,i;
1083 //cmd[0] = 0x0000B008;
1084 /* len[0] : type[0xB0] : seq[?] */
1086 //cmd[0] = (8*N) | (ZM_CMD_WFLASH << 8);
1087 cmd[0] = 32 | (ZM_CMD_WREEPROM << 8); //8N
1089 for (i=0; i<4; i++) // i<N
1091 cmd[(2*i)+1] = addr+(4*i);
1092 cmd[(2*i)+2] = *(buf+i);
1095 ret = zfIssueCmd(dev, cmd, 36, ZM_EEPROM_WRITE, 0); //8N+4
1097 // added for EEPROMUpdate, wait a moment for prevent cmd queue full!
1098 //zfwSleep(dev, 1);
1100 return ret;
1104 /* write EEPROM with wrlen : wrlen must be 4*n */
1105 /* command format : cmd_info(4) + addr(4) + eeprom(wrlen) */
1106 u32_t zfiDbgBlockWriteEeprom_v2(zdev_t* dev, u32_t addr, u32_t* buf, u32_t wrlen)
1108 u32_t cmd[16];
1109 u16_t ret,i;
1111 /* len[0] : type[0xB0] : seq[?] */
1112 /* len = addr(4) + eeprom_block(wrlen) */
1113 cmd[0] = (wrlen+4) | (ZM_CMD_MEM_WREEPROM << 8);
1114 cmd[1] = addr;
1116 for (i=0; i<(wrlen/4); i++) // i<wrlen/4
1118 cmd[2+i] = *(buf+i);
1120 /* cmd_info(4) + addr(4) + eeprom(wrlen) */
1121 ret = zfIssueCmd(dev, cmd, (u16_t)(wrlen+8), ZM_EEPROM_WRITE, 0);
1123 return ret;
1126 /************************************************************************/
1127 /* */
1128 /* FUNCTION DESCRIPTION zfDbgOpenEeprom */
1129 /* Open EEPROM. */
1130 /* */
1131 /* INPUTS */
1132 /* dev : device pointer */
1133 /* */
1134 /* OUTPUTS */
1135 /* */
1136 /* AUTHOR */
1137 /* Paul ZyDAS Technology Corporation 2007.06 */
1138 /* */
1139 /************************************************************************/
1140 void zfDbgOpenEeprom(zdev_t* dev)
1142 // unlock EEPROM
1143 zfDelayWriteInternalReg(dev, 0x1D1400, 0x12345678);
1144 zfDelayWriteInternalReg(dev, 0x1D1404, 0x55aa00ff);
1145 zfDelayWriteInternalReg(dev, 0x1D1408, 0x13579ace);
1146 zfDelayWriteInternalReg(dev, 0x1D1414, 0x0);
1147 zfFlushDelayWrite(dev);
1150 /************************************************************************/
1151 /* */
1152 /* FUNCTION DESCRIPTION zfDbgCloseEeprom */
1153 /* Close EEPROM. */
1154 /* */
1155 /* INPUTS */
1156 /* dev : device pointer */
1157 /* */
1158 /* OUTPUTS */
1159 /* */
1160 /* AUTHOR */
1161 /* Paul ZyDAS Technology Corporation 2007.05 */
1162 /* */
1163 /************************************************************************/
1164 void zfDbgCloseEeprom(zdev_t* dev)
1166 // lock EEPROM
1167 zfDelayWriteInternalReg(dev, 0x1D1400, 0x87654321);
1168 //zfDelayWriteInternalReg(dev, 0x1D1404, 0xffffffff);
1169 //zfDelayWriteInternalReg(dev, 0x1D1408, 0xffffffff);
1170 //zfDelayWriteInternalReg(dev, 0x1D1414, 0x100);
1171 zfFlushDelayWrite(dev);
1173 #if 0
1174 /************************************************************************/
1175 /* */
1176 /* FUNCTION DESCRIPTION zfiSeriallyWriteEeprom */
1177 /* Write EEPROM Serially. */
1178 /* */
1179 /* INPUTS */
1180 /* dev : device pointer */
1181 /* addr : start address of writing EEPROM */
1182 /* buf : input data buffer */
1183 /* buflen : size of input data buffer */
1184 /* (length of data write into EEPROM) */
1185 /* */
1186 /* OUTPUTS */
1187 /* */
1188 /* */
1189 /* */
1190 /* AUTHOR */
1191 /* Paul ZyDAS Technology Corporation 2007.06 */
1192 /* */
1193 /************************************************************************/
1194 u32_t zfiSeriallyWriteEeprom(zdev_t* dev, u32_t addr, u32_t* buf, u32_t buflen)
1196 u32_t count;
1197 u16_t i,ret,blocksize;
1198 u8_t temp[2];
1200 // per 4 bytes = 1 count
1201 count = buflen/4;
1203 // Open EEPROM
1204 zfDbgOpenEeprom(dev);
1206 // Write EEPROM
1207 for (i=0; i<count; i++)
1209 if (zfwWriteEeprom(dev, (addr+(4*i)), *(buf+i), 0) != 0)
1211 // Update failed, Close EEPROM
1212 zm_debug_msg0("zfwWriteEeprom failed \n");
1213 zfDbgCloseEeprom(dev);
1214 return 1;
1218 // Close EEPROM
1219 zfDbgCloseEeprom(dev);
1220 return 0;
1222 #endif
1223 #if 0
1224 /************************************************************************/
1225 /* */
1226 /* FUNCTION DESCRIPTION zfiSeriallyBlockWriteEeprom */
1227 /* Block Write EEPROM Serially. */
1228 /* (BlockWrite: per 16bytes write EEPROM once) */
1229 /* */
1230 /* INPUTS */
1231 /* dev : device pointer */
1232 /* addr : register address */
1233 /* buf : input data buffer */
1234 /* buflen : access data size of buf */
1235 /* */
1236 /* OUTPUTS */
1237 /* 0 : success */
1238 /* other : fail */
1239 /* */
1240 /* AUTHOR */
1241 /* Paul ZyDAS Technology Corporation 2007.05 */
1242 /* */
1243 /************************************************************************/
1244 u32_t zfiSeriallyBlockWriteEeprom(zdev_t* dev, u32_t addr, u32_t* buf, u32_t buflen)
1246 u32_t count;
1247 u16_t i,ret,blocksize;
1248 u8_t temp[2];
1250 // per 4 bytes = 1 count
1251 count = buflen/4;
1253 // Open EEPROM
1254 zfDbgOpenEeprom(dev);
1256 // Write EEPROM
1257 // EEPROM Write start address from: 0x1000!?
1258 // per 16bytes(N=4) block write EEPROM once
1259 for (i=0; i<(count/4); i++) // count/N
1261 //zfiDbgBlockWriteEeprom(dev, (addr+(4*N*i)), buf+(N*i));
1262 //zfiDbgBlockWriteEeprom(dev, (addr+(16*i)), buf+(4*i));
1263 if (zfwBlockWriteEeprom(dev, (addr+(16*i)), buf+(4*i), 0) != 0)
1265 zm_debug_msg0("zfiDbgBlockWriteEeprom failed \n");
1266 // Close EEPROM
1267 zfDbgCloseEeprom(dev);
1268 return 1;
1272 // Close EEPROM
1273 zfDbgCloseEeprom(dev);
1274 return 0;
1276 #endif
1277 #if 0
1278 /************************************************************************/
1279 /* */
1280 /* FUNCTION DESCRIPTION zfiDbgDumpEeprom */
1281 /* Dump EEPROM. */
1282 /* */
1283 /* INPUTS */
1284 /* dev : device pointer */
1285 /* addr : start address of dumping EEPROM */
1286 /* datalen : length of access EEPROM data */
1287 /* buf : point of buffer, the buffer saved dump data */
1288 /* */
1289 /* OUTPUTS */
1290 /* 0 : success */
1291 /* other : fail */
1292 /* */
1293 /* AUTHOR */
1294 /* Paul ZyDAS Technology Corporation 2007.06 */
1295 /* */
1296 /************************************************************************/
1297 u32_t zfiDbgDumpEeprom(zdev_t* dev, u32_t addr, u32_t datalen, u32_t* buf)
1299 u32_t count;
1300 u16_t i,ret;
1302 count = datalen/4;
1304 // over EEPROM length
1305 if(datalen > 0x2000)
1307 return 1;
1310 for(i=0; i<count; i++)
1312 buf[i] = zfwReadEeprom(dev, addr+(4*i));
1315 return 0;
1317 #endif
1318 /************************************************************************/
1319 /* */
1320 /* FUNCTION DESCRIPTION zfiDbgReadReg */
1321 /* Read register. */
1322 /* */
1323 /* INPUTS */
1324 /* dev : device pointer */
1325 /* addr : register address */
1326 /* */
1327 /* OUTPUTS */
1328 /* 0 : success */
1329 /* other : fail */
1330 /* */
1331 /* AUTHOR */
1332 /* Stephen Chen ZyDAS Technology Corporation 2005.10 */
1333 /* */
1334 /************************************************************************/
1335 u32_t zfiDbgReadReg(zdev_t* dev, u32_t addr)
1337 u32_t cmd[2];
1338 u16_t ret;
1340 cmd[0] = 0x00000004;
1341 cmd[1] = addr;
1343 ret = zfIssueCmd(dev, cmd, 8, ZM_OID_READ, 0);
1344 return ret;
1348 /************************************************************************/
1349 /* */
1350 /* FUNCTION DESCRIPTION zfiDbgReadTally */
1351 /* Read register. */
1352 /* */
1353 /* INPUTS */
1354 /* dev : device pointer */
1355 /* */
1356 /* OUTPUTS */
1357 /* 0 : success */
1358 /* other : fail */
1359 /* */
1360 /* AUTHOR */
1361 /* Stephen Chen ZyDAS Technology Corporation 2005.10 */
1362 /* */
1363 /************************************************************************/
1364 u32_t zfiDbgReadTally(zdev_t* dev)
1366 u32_t cmd[1];
1367 u16_t ret;
1368 zmw_get_wlan_dev(dev);
1370 if ( ((struct zsHpPriv*)wd->hpPrivate)->halReInit )
1372 return 1;
1375 /* len[0] : type[0x81] : seq[?] */
1376 cmd[0] = 0 | (ZM_CMD_TALLY << 8);
1377 ret = zfIssueCmd(dev, cmd, 4, ZM_OID_TALLY, 0);
1379 /* len[0] : type[0x82] : seq[?] */
1380 cmd[0] = 0 | (ZM_CMD_TALLY_APD << 8);
1381 ret = zfIssueCmd(dev, cmd, 4, ZM_OID_TALLY_APD, 0);
1383 return ret;
1387 u32_t zfiDbgSetIFSynthesizer(zdev_t* dev, u32_t value)
1389 u32_t cmd[2];
1390 u16_t ret;
1392 /* len[4] : type[0x32] : seq[?] */
1393 cmd[0] = 0x4 | (ZM_OID_SYNTH << 8);
1394 cmd[1] = value;
1396 ret = zfIssueCmd(dev, cmd, 8, ZM_OID_SYNTH, 0);
1397 return ret;
1400 u32_t zfiDbgQueryHwTxBusy(zdev_t* dev)
1402 u32_t cmd[1];
1403 u16_t ret;
1405 /* len[4] : type[0xC0] : seq[?] */
1406 cmd[0] = 0 | (ZM_CMD_DKTX_STATUS << 8);
1408 ret = zfIssueCmd(dev, cmd, 4, ZM_OID_DKTX_STATUS, 0);
1409 return ret;
1412 //Paul++
1413 #if 0
1414 u16_t zfHpBlockEraseFlash(zdev_t *dev, u32_t addr)
1416 u32_t cmd[(ZM_MAX_CMD_SIZE/4)];
1417 u16_t ret;
1419 cmd[0] = 0x00000004 | (ZM_CMD_FLASH_ERASE << 8);
1420 cmd[1] = addr;
1422 ret = zfIssueCmd(dev, cmd, 8, ZM_OID_INTERNAL_WRITE, NULL);
1423 return ret;
1425 #endif
1427 #if 0
1428 u16_t zfiDbgProgramFlash(zdev_t *dev, u32_t offset, u32_t len, u32_t *data)
1430 u32_t cmd[(ZM_MAX_CMD_SIZE/4)];
1431 u16_t ret;
1432 u16_t i;
1435 cmd[0] = (ZM_CMD_FLASH_PROG << 8) | ((len+8) & 0xff);
1436 cmd[1] = offset;
1437 cmd[2] = len;
1439 for (i = 0; i < (len >> 2); i++)
1441 cmd[3+i] = data[i];
1444 ret = zfIssueCmd(dev, cmd, 12, ZM_OID_FLASH_PROGRAM, NULL);
1446 return ret;
1448 #endif
1450 /************************************************************************/
1451 /* */
1452 /* FUNCTION DESCRIPTION zfiDbgChipEraseFlash */
1453 /* Chip Erase Flash. */
1454 /* */
1455 /* INPUTS */
1456 /* dev : device pointer */
1457 /* */
1458 /* OUTPUTS */
1459 /* 0 : success */
1460 /* other : fail */
1461 /* */
1462 /* AUTHOR */
1463 /* Paul Atheros Technology Corporation 2007.09 */
1464 /* */
1465 /************************************************************************/
1466 u16_t zfiDbgChipEraseFlash(zdev_t *dev)
1468 u32_t cmd[(ZM_MAX_CMD_SIZE/4)];
1469 u16_t ret;
1471 cmd[0] = 0x00000000 | (ZM_CMD_FLASH_ERASE << 8);
1473 ret = zfIssueCmd(dev, cmd, 4, ZM_OID_INTERNAL_WRITE, NULL);
1474 return ret;
1476 /************************************************************************/
1477 /* */
1478 /* FUNCTION DESCRIPTION zfiDbgGetFlashCheckSum */
1479 /* Get FlashCheckSum. */
1480 /* */
1481 /* INPUTS */
1482 /* dev : device pointer */
1483 /* addr : Start address of getchksum */
1484 /* len : total lenth of calculate getchksum */
1485 /* */
1486 /* OUTPUTS */
1487 /* 0 : success */
1488 /* other : fail */
1489 /* */
1490 /* AUTHOR */
1491 /* Paul Atheros Technology Corporation 2007.08 */
1492 /* */
1493 /************************************************************************/
1494 u32_t zfiDbgGetFlashCheckSum(zdev_t *dev, u32_t addr, u32_t len)
1496 u32_t cmd[(ZM_MAX_CMD_SIZE/4)];
1497 u32_t ret;
1499 cmd[0] = 0x00000008 | (ZM_CMD_FLASH_CHKSUM << 8);
1500 cmd[1] = addr;
1501 cmd[2] = len;
1503 ret = zfIssueCmd(dev, cmd, 12, ZM_OID_FLASH_CHKSUM, NULL);
1505 return ret;
1508 /************************************************************************/
1509 /* */
1510 /* FUNCTION DESCRIPTION zfiDbgReadFlash */
1511 /* Read Flash. */
1512 /* */
1513 /* INPUTS */
1514 /* dev : device pointer */
1515 /* addr : Start address of read flash */
1516 /* len : total lenth of read flash data */
1517 /* */
1518 /* OUTPUTS */
1519 /* 0 : success */
1520 /* other : fail */
1521 /* */
1522 /* AUTHOR */
1523 /* Paul Atheros Technology Corporation 2007.09 */
1524 /* */
1525 /************************************************************************/
1526 u32_t zfiDbgReadFlash(zdev_t *dev, u32_t addr, u32_t len)
1528 u32_t cmd[(ZM_MAX_CMD_SIZE/4)];
1529 u32_t ret;
1531 cmd[0] = len | (ZM_CMD_FLASH_READ << 8);
1532 cmd[1] = addr;
1534 ret = zfIssueCmd(dev, cmd, 8, ZM_OID_FLASH_READ, NULL);
1535 return ret;
1538 /************************************************************************/
1539 /* */
1540 /* FUNCTION DESCRIPTION zfiDownloadFwSet */
1541 /* Before Download FW, */
1542 /* Command FW to Software reset and close watch dog control. */
1543 /* */
1544 /* */
1545 /* INPUTS */
1546 /* dev : device pointer */
1547 /* */
1548 /* OUTPUTS */
1549 /* 0 : success */
1550 /* other : fail */
1551 /* */
1552 /* AUTHOR */
1553 /* Paul Atheros Technology Corporation 2007.09 */
1554 /* */
1555 /************************************************************************/
1556 u32_t zfiDownloadFwSet(zdev_t *dev)
1558 //softwarereset
1559 //close watch dog
1560 u32_t cmd[(ZM_MAX_CMD_SIZE/4)];
1561 u32_t ret;
1563 cmd[0] = 0x00000008 | (ZM_CMD_FW_DL_INIT << 8);
1565 ret = zfIssueCmd(dev, cmd, 12, ZM_OID_FW_DL_INIT, NULL);
1567 return ret;
1569 //Paul--