5 void hal_get_ethernet_address( phw_data_t pHwData, u8 *current_address )
7 if( pHwData->SurpriseRemove ) return;
9 memcpy( current_address, pHwData->CurrentMacAddress, ETH_LENGTH_OF_ADDRESS );
12 void hal_set_ethernet_address( phw_data_t pHwData, u8 *current_address )
16 if( pHwData->SurpriseRemove ) return;
18 memcpy( pHwData->CurrentMacAddress, current_address, ETH_LENGTH_OF_ADDRESS );
20 ltmp[0]= cpu_to_le32( *(u32 *)pHwData->CurrentMacAddress );
21 ltmp[1]= cpu_to_le32( *(u32 *)(pHwData->CurrentMacAddress + 4) ) & 0xffff;
23 Wb35Reg_BurstWrite( pHwData, 0x03e8, ltmp, 2, AUTO_INCREMENT );
26 void hal_get_permanent_address( phw_data_t pHwData, u8 *pethernet_address )
28 if( pHwData->SurpriseRemove ) return;
30 memcpy( pethernet_address, pHwData->PermanentMacAddress, 6 );
33 static void hal_led_control(unsigned long data)
35 struct wb35_adapter *adapter = (struct wb35_adapter *) data;
36 phw_data_t pHwData = &adapter->sHwData;
37 struct wb35_reg *reg = &pHwData->reg;
38 u32 LEDSet = (pHwData->SoftwareSet & HAL_LED_SET_MASK) >> HAL_LED_SET_SHIFT;
39 u8 LEDgray[20] = { 0,3,4,6,8,10,11,12,13,14,15,14,13,12,11,10,8,6,4,2 };
40 u8 LEDgray2[30] = { 7,8,9,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0,0,0,0,0,15,14,13,12,11,10,9,8 };
41 u32 TimeInterval = 500, ltmp, ltmp2;
44 if( pHwData->SurpriseRemove ) return;
46 if( pHwData->LED_control ) {
47 ltmp2 = pHwData->LED_control & 0xff;
48 if( ltmp2 == 5 ) // 5 is WPS mode
51 ltmp2 = (pHwData->LED_control>>8) & 0xff;
54 case 1: // [0.2 On][0.1 Off]...
55 pHwData->LED_Blinking %= 3;
56 ltmp = 0x1010; // Led 1 & 0 Green and Red
57 if( pHwData->LED_Blinking == 2 ) // Turn off
60 case 2: // [0.1 On][0.1 Off]...
61 pHwData->LED_Blinking %= 2;
62 ltmp = 0x0010; // Led 0 red color
63 if( pHwData->LED_Blinking ) // Turn off
66 case 3: // [0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.5 Off]...
67 pHwData->LED_Blinking %= 15;
68 ltmp = 0x0010; // Led 0 red color
69 if( (pHwData->LED_Blinking >= 9) || (pHwData->LED_Blinking%2) ) // Turn off 0.6 sec
72 case 4: // [300 On][ off ]
73 ltmp = 0x1000; // Led 1 Green color
74 if( pHwData->LED_Blinking >= 3000 )
75 ltmp = 0; // led maybe on after 300sec * 32bit counter overlap.
78 pHwData->LED_Blinking++;
80 reg->U1BC_LEDConfigure = ltmp;
81 if( LEDSet != 7 ) // Only 111 mode has 2 LEDs on PCB.
83 reg->U1BC_LEDConfigure |= (ltmp &0xff)<<8; // Copy LED result to each LED control register
84 reg->U1BC_LEDConfigure |= (ltmp &0xff00)>>8;
86 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
89 else if( pHwData->CurrentRadioSw || pHwData->CurrentRadioHw ) // If radio off
91 if( reg->U1BC_LEDConfigure & 0x1010 )
93 reg->U1BC_LEDConfigure &= ~0x1010;
94 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
101 case 4: // [100] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
102 if( !pHwData->LED_LinkOn ) // Blink only if not Link On
104 // Blinking if scanning is on progress
105 if( pHwData->LED_Scanning )
107 if( pHwData->LED_Blinking == 0 )
109 reg->U1BC_LEDConfigure |= 0x10;
110 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 On
111 pHwData->LED_Blinking = 1;
116 reg->U1BC_LEDConfigure &= ~0x10;
117 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
118 pHwData->LED_Blinking = 0;
125 if( reg->U1BC_LEDConfigure & 0x10 )
127 reg->U1BC_LEDConfigure &= ~0x10;
128 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
135 if( (reg->U1BC_LEDConfigure & 0x10) == 0 )
137 reg->U1BC_LEDConfigure |= 0x10;
138 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
143 case 6: // [110] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
144 if( !pHwData->LED_LinkOn ) // Blink only if not Link On
146 // Blinking if scanning is on progress
147 if( pHwData->LED_Scanning )
149 if( pHwData->LED_Blinking == 0 )
151 reg->U1BC_LEDConfigure &= ~0xf;
152 reg->U1BC_LEDConfigure |= 0x10;
153 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 On
154 pHwData->LED_Blinking = 1;
159 reg->U1BC_LEDConfigure &= ~0x1f;
160 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
161 pHwData->LED_Blinking = 0;
167 // 20060901 Gray blinking if in disconnect state and not scanning
168 ltmp = reg->U1BC_LEDConfigure;
169 reg->U1BC_LEDConfigure &= ~0x1f;
170 if( LEDgray2[(pHwData->LED_Blinking%30)] )
172 reg->U1BC_LEDConfigure |= 0x10;
173 reg->U1BC_LEDConfigure |= LEDgray2[ (pHwData->LED_Blinking%30) ];
175 pHwData->LED_Blinking++;
176 if( reg->U1BC_LEDConfigure != ltmp )
177 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
184 if( (reg->U1BC_LEDConfigure & 0x10) == 0 )
186 reg->U1BC_LEDConfigure |= 0x10;
187 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
192 case 5: // [101] Only 1 Led be placed on PCB and use LED_1 for showing
193 if( !pHwData->LED_LinkOn ) // Blink only if not Link On
195 // Blinking if scanning is on progress
196 if( pHwData->LED_Scanning )
198 if( pHwData->LED_Blinking == 0 )
200 reg->U1BC_LEDConfigure |= 0x1000;
201 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On
202 pHwData->LED_Blinking = 1;
207 reg->U1BC_LEDConfigure &= ~0x1000;
208 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 Off
209 pHwData->LED_Blinking = 0;
216 if( reg->U1BC_LEDConfigure & 0x1000 )
218 reg->U1BC_LEDConfigure &= ~0x1000;
219 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 Off
225 // Is transmitting/receiving ??
226 if( (adapter->RxByteCount != pHwData->RxByteCountLast ) ||
227 (adapter->TxByteCount != pHwData->TxByteCountLast ) )
229 if( (reg->U1BC_LEDConfigure & 0x3000) != 0x3000 )
231 reg->U1BC_LEDConfigure |= 0x3000;
232 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On
236 pHwData->RxByteCountLast = adapter->RxByteCount;
237 pHwData->TxByteCountLast = adapter->TxByteCount;
242 // Turn On LED_1 and blinking if transmitting/receiving
243 if( (reg->U1BC_LEDConfigure & 0x3000) != 0x1000 )
245 reg->U1BC_LEDConfigure &= ~0x3000;
246 reg->U1BC_LEDConfigure |= 0x1000;
247 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On
253 default: // Default setting. 2 LED be placed on PCB. LED_0: Link On LED_1 Active
254 if( (reg->U1BC_LEDConfigure & 0x3000) != 0x3000 )
256 reg->U1BC_LEDConfigure |= 0x3000;// LED_1 is always on and event enable
257 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
260 if( pHwData->LED_Blinking )
263 reg->U1BC_LEDConfigure &= ~0x0f;
264 reg->U1BC_LEDConfigure |= 0x10;
265 reg->U1BC_LEDConfigure |= LEDgray[ (pHwData->LED_Blinking-1)%20 ];
266 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
268 pHwData->LED_Blinking += 2;
269 if( pHwData->LED_Blinking < 40 )
273 pHwData->LED_Blinking = 0; // Stop blinking
274 reg->U1BC_LEDConfigure &= ~0x0f;
275 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
280 if( pHwData->LED_LinkOn )
282 if( !(reg->U1BC_LEDConfigure & 0x10) ) // Check the LED_0
284 //Try to turn ON LED_0 after gray blinking
285 reg->U1BC_LEDConfigure |= 0x10;
286 pHwData->LED_Blinking = 1; //Start blinking
292 if( reg->U1BC_LEDConfigure & 0x10 ) // Check the LED_0
294 reg->U1BC_LEDConfigure &= ~0x10;
295 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
301 //20060828.1 Active send null packet to avoid AP disconnect
302 if( pHwData->LED_LinkOn )
304 pHwData->NullPacketCount += TimeInterval;
305 if( pHwData->NullPacketCount >= DEFAULT_NULL_PACKET_COUNT )
307 pHwData->NullPacketCount = 0;
312 pHwData->time_count += TimeInterval;
313 Wb35Tx_CurrentTime(adapter, pHwData->time_count); // 20060928 add
314 pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(TimeInterval);
315 add_timer(&pHwData->LEDTimer);
319 u8 hal_init_hardware(phw_data_t pHwData, struct wb35_adapter * adapter)
323 // Initial the variable
324 pHwData->MaxReceiveLifeTime = DEFAULT_MSDU_LIFE_TIME; // Setting Rx maximum MSDU life time
325 pHwData->FragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; // Setting default fragment threshold
327 pHwData->InitialResource = 1;
328 if( Wb35Reg_initial(pHwData)) {
329 pHwData->InitialResource = 2;
330 if (Wb35Tx_initial(pHwData)) {
331 pHwData->InitialResource = 3;
332 if (Wb35Rx_initial(pHwData)) {
333 pHwData->InitialResource = 4;
334 init_timer(&pHwData->LEDTimer);
335 pHwData->LEDTimer.function = hal_led_control;
336 pHwData->LEDTimer.data = (unsigned long) adapter;
337 pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(1000);
338 add_timer(&pHwData->LEDTimer);
341 // For restrict to vendor's hardware
343 SoftwareSet = hal_software_set( pHwData );
346 // Try to make sure the EEPROM contain
348 if( SoftwareSet != 0x82 )
352 Wb35Rx_start( pHwData );
353 Wb35Tx_EP2VM_start(adapter);
360 pHwData->SurpriseRemove = 1;
365 void hal_halt(phw_data_t pHwData, void *ppa_data)
367 switch( pHwData->InitialResource )
370 case 3: del_timer_sync(&pHwData->LEDTimer);
371 msleep(100); // Wait for Timer DPC exit 940623.2
372 Wb35Rx_destroy( pHwData ); // Release the Rx
373 case 2: Wb35Tx_destroy( pHwData ); // Release the Tx
374 case 1: Wb35Reg_destroy( pHwData ); // Release the Wb35 Regisster resources
378 //---------------------------------------------------------------------------------------------------
379 void hal_set_rates(phw_data_t pHwData, u8 *pbss_rates,
380 u8 length, unsigned char basic_rate_set)
382 struct wb35_reg *reg = &pHwData->reg;
384 u8 Rate[12]={ 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 };
385 u8 SupportedRate[16];
386 u8 i, j, k, Count1, Count2, Byte;
388 if( pHwData->SurpriseRemove ) return;
390 if (basic_rate_set) {
391 reg->M28_MacControl &= ~0x000fff00;
394 reg->M28_MacControl &= ~0xfff00000;
399 for (i=0; i<length; i++) {
400 Byte = pbss_rates[i] & 0x7f;
401 for (j=0; j<12; j++) {
402 if( Byte == Rate[j] )
410 reg->M28_MacControl |= tmp;
411 Wb35Reg_Write( pHwData, 0x0828, reg->M28_MacControl );
413 // 930206.2.c M78 setting
414 j = k = Count1 = Count2 = 0;
415 memset( SupportedRate, 0, 16 );
418 for (i=0; i<12; i++) { // Get the supported rate
419 if (tmp & reg->M28_MacControl) {
420 SupportedRate[j] = Rate[i];
422 if (tmp1 & reg->M28_MacControl)
423 SupportedRate[j] |= 0x80;
434 if( !(reg->M28_MacControl & 0x000ff000) ) // if basic rate in 11g domain)
445 // Fill data into support rate until buffer full
446 //---20060926 add by anson's endian
448 *(u32 *)(SupportedRate+(i<<2)) = cpu_to_le32( *(u32 *)(SupportedRate+(i<<2)) );
449 //--- end 20060926 add by anson's endian
450 Wb35Reg_BurstWrite( pHwData,0x087c, (u32 *)SupportedRate, 4, AUTO_INCREMENT );
451 reg->M7C_MacControl = ((u32 *)SupportedRate)[0];
452 reg->M80_MacControl = ((u32 *)SupportedRate)[1];
453 reg->M84_MacControl = ((u32 *)SupportedRate)[2];
454 reg->M88_MacControl = ((u32 *)SupportedRate)[3];
457 tmp = Count1<<28 | Count2<<24;
458 reg->M78_ERPInformation &= ~0xff000000;
459 reg->M78_ERPInformation |= tmp;
460 Wb35Reg_Write( pHwData, 0x0878, reg->M78_ERPInformation );
464 //---------------------------------------------------------------------------------------------------
465 void hal_set_beacon_period( phw_data_t pHwData, u16 beacon_period )
469 if( pHwData->SurpriseRemove ) return;
471 pHwData->BeaconPeriod = beacon_period;
472 tmp = pHwData->BeaconPeriod << 16;
473 tmp |= pHwData->ProbeDelay;
474 Wb35Reg_Write( pHwData, 0x0848, tmp );
478 void hal_set_current_channel_ex( phw_data_t pHwData, ChanInfo channel )
480 struct wb35_reg *reg = &pHwData->reg;
482 if( pHwData->SurpriseRemove )
485 printk("Going to channel: %d/%d\n", channel.band, channel.ChanNo);
487 RFSynthesizer_SwitchingChannel( pHwData, channel );// Switch channel
488 pHwData->Channel = channel.ChanNo;
489 pHwData->band = channel.band;
490 #ifdef _PE_STATE_DUMP_
491 WBDEBUG(("Set channel is %d, band =%d\n", pHwData->Channel, pHwData->band));
493 reg->M28_MacControl &= ~0xff; // Clean channel information field
494 reg->M28_MacControl |= channel.ChanNo;
495 Wb35Reg_WriteWithCallbackValue( pHwData, 0x0828, reg->M28_MacControl,
496 (s8 *)&channel, sizeof(ChanInfo));
498 //---------------------------------------------------------------------------------------------------
499 void hal_set_current_channel( phw_data_t pHwData, ChanInfo channel )
501 hal_set_current_channel_ex( pHwData, channel );
503 //---------------------------------------------------------------------------------------------------
504 void hal_get_current_channel( phw_data_t pHwData, ChanInfo *channel )
506 channel->ChanNo = pHwData->Channel;
507 channel->band = pHwData->band;
509 //---------------------------------------------------------------------------------------------------
510 void hal_set_accept_broadcast( phw_data_t pHwData, u8 enable )
512 struct wb35_reg *reg = &pHwData->reg;
514 if( pHwData->SurpriseRemove ) return;
516 reg->M00_MacControl &= ~0x02000000;//The HW value
519 reg->M00_MacControl |= 0x02000000;//The HW value
521 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
524 //for wep key error detection, we need to accept broadcast packets to be received temporary.
525 void hal_set_accept_promiscuous( phw_data_t pHwData, u8 enable)
527 struct wb35_reg *reg = &pHwData->reg;
529 if (pHwData->SurpriseRemove) return;
531 reg->M00_MacControl |= 0x00400000;
532 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
534 reg->M00_MacControl&=~0x00400000;
535 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
539 void hal_set_accept_multicast( phw_data_t pHwData, u8 enable )
541 struct wb35_reg *reg = &pHwData->reg;
543 if( pHwData->SurpriseRemove ) return;
545 reg->M00_MacControl &= ~0x01000000;//The HW value
546 if (enable) reg->M00_MacControl |= 0x01000000;//The HW value
547 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
550 void hal_set_accept_beacon( phw_data_t pHwData, u8 enable )
552 struct wb35_reg *reg = &pHwData->reg;
554 if( pHwData->SurpriseRemove ) return;
557 if( !enable )//Due to SME and MLME are not suitable for 35
560 reg->M00_MacControl &= ~0x04000000;//The HW value
562 reg->M00_MacControl |= 0x04000000;//The HW value
564 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
566 //---------------------------------------------------------------------------------------------------
567 void hal_set_multicast_address( phw_data_t pHwData, u8 *address, u8 number )
569 struct wb35_reg *reg = &pHwData->reg;
572 if( pHwData->SurpriseRemove ) return;
574 //Erases and refills the card multicast registers. Used when an address
575 // has been deleted and all bits must be recomputed.
576 reg->M04_MulticastAddress1 = 0;
577 reg->M08_MulticastAddress2 = 0;
582 CardGetMulticastBit( (address+(number*ETH_LENGTH_OF_ADDRESS)), &Byte, &Bit);
583 reg->Multicast[Byte] |= Bit;
587 Wb35Reg_BurstWrite( pHwData, 0x0804, (u32 *)reg->Multicast, 2, AUTO_INCREMENT );
589 //---------------------------------------------------------------------------------------------------
590 u8 hal_get_accept_beacon( phw_data_t pHwData )
592 struct wb35_reg *reg = &pHwData->reg;
594 if( pHwData->SurpriseRemove ) return 0;
596 if( reg->M00_MacControl & 0x04000000 )
602 unsigned char hal_reset_hardware( phw_data_t pHwData, void* ppa )
608 void hal_stop( phw_data_t pHwData )
610 struct wb35_reg *reg = &pHwData->reg;
612 pHwData->Wb35Rx.rx_halt = 1;
613 Wb35Rx_stop( pHwData );
615 pHwData->Wb35Tx.tx_halt = 1;
616 Wb35Tx_stop( pHwData );
618 reg->D00_DmaControl &= ~0xc0000000;//Tx Off, Rx Off
619 Wb35Reg_Write( pHwData, 0x0400, reg->D00_DmaControl );
622 unsigned char hal_idle(phw_data_t pHwData)
624 struct wb35_reg *reg = &pHwData->reg;
625 PWBUSB pWbUsb = &pHwData->WbUsb;
627 if( !pHwData->SurpriseRemove && ( pWbUsb->DetectCount || reg->EP0vm_state!=VM_STOP ) )
632 //---------------------------------------------------------------------------------------------------
633 void hal_set_cwmin( phw_data_t pHwData, u8 cwin_min )
635 struct wb35_reg *reg = &pHwData->reg;
637 if( pHwData->SurpriseRemove ) return;
639 pHwData->cwmin = cwin_min;
640 reg->M2C_MacControl &= ~0x7c00; //bit 10 ~ 14
641 reg->M2C_MacControl |= (pHwData->cwmin<<10);
642 Wb35Reg_Write( pHwData, 0x082c, reg->M2C_MacControl );
645 s32 hal_get_rssi( phw_data_t pHwData, u32 *HalRssiArry, u8 Count )
647 struct wb35_reg *reg = &pHwData->reg;
652 if( pHwData->SurpriseRemove ) return -200;
653 if( Count > MAX_ACC_RSSI_COUNT ) // Because the TS may use this funtion
654 Count = MAX_ACC_RSSI_COUNT;
656 // RSSI = C1 + C2 * (agc_state[7:0] + offset_map(lna_state[1:0]))
657 // C1 = -195, C2 = 0.66 = 85/128
658 for (i=0; i<Count; i++)
660 r01.value = HalRssiArry[i];
661 tmp = ((( r01.R01_AGC_state + reg->LNAValue[r01.R01_LNA_state]) * 85 ) >>7 ) - 195;
665 if( pHwData->phy_type == RF_AIROHA_2230 ) ltmp -= 5; // 10;
666 if( pHwData->phy_type == RF_AIROHA_2230S ) ltmp -= 5; // 10; 20060420 Add this
668 //if( ltmp < -200 ) ltmp = -200;
669 if( ltmp < -110 ) ltmp = -110;// 1.0.24.0 For NJRC
673 //----------------------------------------------------------------------------------------------------
674 s32 hal_get_rssi_bss(struct wb35_adapter *adapter, u16 idx, u8 Count)
676 phw_data_t pHwData = &adapter->sHwData;
677 struct wb35_reg *reg = &pHwData->reg;
681 // u32 *HalRssiArry = psBSS(idx)->HalRssi;
683 if( pHwData->SurpriseRemove ) return -200;
684 if( Count > MAX_ACC_RSSI_COUNT ) // Because the TS may use this funtion
685 Count = MAX_ACC_RSSI_COUNT;
687 // RSSI = C1 + C2 * (agc_state[7:0] + offset_map(lna_state[1:0]))
688 // C1 = -195, C2 = 0.66 = 85/128
690 for (i=0; i<Count; i++)
692 r01.value = HalRssiArry[i];
693 tmp = ((( r01.R01_AGC_state + reg->LNAValue[r01.R01_LNA_state]) * 85 ) >>7 ) - 195;
697 if (psBSS(idx)->HalRssiIndex == 0)
698 psBSS(idx)->HalRssiIndex = MAX_ACC_RSSI_COUNT;
699 j = (u8)psBSS(idx)->HalRssiIndex-1;
701 for (i=0; i<Count; i++)
703 r01.value = psBSS(idx)->HalRssi[j];
704 tmp = ((( r01.R01_AGC_state + reg->LNAValue[r01.R01_LNA_state]) * 85 ) >>7 ) - 195;
708 j = MAX_ACC_RSSI_COUNT;
714 if( pHwData->phy_type == RF_AIROHA_2230 ) ltmp -= 5; // 10;
715 if( pHwData->phy_type == RF_AIROHA_2230S ) ltmp -= 5; // 10; 20060420 Add this
717 //if( ltmp < -200 ) ltmp = -200;
718 if( ltmp < -110 ) ltmp = -110;// 1.0.24.0 For NJRC
723 //---------------------------------------------------------------------------
725 void hal_set_phy_type( phw_data_t pHwData, u8 PhyType )
727 pHwData->phy_type = PhyType;
730 void hal_get_phy_type( phw_data_t pHwData, u8 *PhyType )
732 *PhyType = pHwData->phy_type;
735 void hal_reset_counter( phw_data_t pHwData )
737 pHwData->dto_tx_retry_count = 0;
738 pHwData->dto_tx_frag_count = 0;
739 memset( pHwData->tx_retry_count, 0, 8);
742 void hal_set_radio_mode( phw_data_t pHwData, unsigned char radio_off)
744 struct wb35_reg *reg = &pHwData->reg;
746 if( pHwData->SurpriseRemove ) return;
748 if (radio_off) //disable Baseband receive off
750 pHwData->CurrentRadioSw = 1; // off
751 reg->M24_MacControl &= 0xffffffbf;
755 pHwData->CurrentRadioSw = 0; // on
756 reg->M24_MacControl |= 0x00000040;
758 Wb35Reg_Write( pHwData, 0x0824, reg->M24_MacControl );
761 u8 hal_get_antenna_number( phw_data_t pHwData )
763 struct wb35_reg *reg = &pHwData->reg;
765 if ((reg->BB2C & BIT(11)) == 0)
771 void hal_set_antenna_number( phw_data_t pHwData, u8 number )
774 struct wb35_reg *reg = &pHwData->reg;
777 reg->BB2C |= BIT(11);
779 reg->BB2C &= ~BIT(11);
781 Wb35Reg_Write( pHwData, 0x102c, reg->BB2C );
782 #ifdef _PE_STATE_DUMP_
783 WBDEBUG(("Current antenna number : %d\n", number));
787 //----------------------------------------------------------------------------------------------------
788 //0 : radio on; 1: radio off
789 u8 hal_get_hw_radio_off( phw_data_t pHwData )
791 struct wb35_reg *reg = &pHwData->reg;
793 if( pHwData->SurpriseRemove ) return 1;
795 //read the bit16 of register U1B0
796 Wb35Reg_Read( pHwData, 0x3b0, ®->U1B0 );
797 if ((reg->U1B0 & 0x00010000)) {
798 pHwData->CurrentRadioHw = 1;
801 pHwData->CurrentRadioHw = 0;
806 unsigned char hal_get_dxx_reg( phw_data_t pHwData, u16 number, u32 * pValue )
808 if( number < 0x1000 )
810 return Wb35Reg_ReadSync( pHwData, number, pValue );
813 unsigned char hal_set_dxx_reg( phw_data_t pHwData, u16 number, u32 value )
817 if( number < 0x1000 )
819 ret = Wb35Reg_WriteSync( pHwData, number, value );
823 void hal_scan_status_indicate(phw_data_t pHwData, unsigned char IsOnProgress)
825 if( pHwData->SurpriseRemove ) return;
826 pHwData->LED_Scanning = IsOnProgress ? 1 : 0;
829 void hal_system_power_change(phw_data_t pHwData, u32 PowerState)
831 if( PowerState != 0 )
833 pHwData->SurpriseRemove = 1;
834 if( pHwData->WbUsb.IsUsb20 )
839 if( !pHwData->WbUsb.IsUsb20 )
844 void hal_surprise_remove(struct wb35_adapter *adapter)
846 phw_data_t pHwData = &adapter->sHwData;
848 if (atomic_inc_return( &pHwData->SurpriseRemoveCount ) == 1) {
849 #ifdef _PE_STATE_DUMP_
850 WBDEBUG(("Calling hal_surprise_remove\n"));
852 WBLINUX_stop( adapter );
856 void hal_rate_change(struct wb35_adapter *adapter) // Notify the HAL rate is changing 20060613.1
858 phw_data_t pHwData = &adapter->sHwData;
859 u8 rate = CURRENT_TX_RATE;
861 BBProcessor_RateChanging( pHwData, rate );
864 void hal_set_rf_power(phw_data_t pHwData, u8 PowerIndex)
866 RFSynthesizer_SetPowerIndex( pHwData, PowerIndex );
869 unsigned char hal_set_LED(phw_data_t pHwData, u32 Mode) // 20061108 for WPS led control
871 pHwData->LED_Blinking = 0;
872 pHwData->LED_control = Mode;
873 pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(10);
874 add_timer(&pHwData->LEDTimer);