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 wbsoft_priv *adapter = (struct wbsoft_priv *) 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);
318 u8 hal_init_hardware(struct ieee80211_hw *hw)
320 struct wbsoft_priv *priv = hw->priv;
321 phw_data_t pHwData = &priv->sHwData;
324 // Initial the variable
325 pHwData->MaxReceiveLifeTime = DEFAULT_MSDU_LIFE_TIME; // Setting Rx maximum MSDU life time
326 pHwData->FragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; // Setting default fragment threshold
328 pHwData->InitialResource = 1;
329 if( Wb35Reg_initial(pHwData)) {
330 pHwData->InitialResource = 2;
331 if (Wb35Tx_initial(pHwData)) {
332 pHwData->InitialResource = 3;
333 if (Wb35Rx_initial(pHwData)) {
334 pHwData->InitialResource = 4;
335 init_timer(&pHwData->LEDTimer);
336 pHwData->LEDTimer.function = hal_led_control;
337 pHwData->LEDTimer.data = (unsigned long) priv;
338 pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(1000);
339 add_timer(&pHwData->LEDTimer);
342 // For restrict to vendor's hardware
344 SoftwareSet = hal_software_set( pHwData );
347 // Try to make sure the EEPROM contain
349 if( SoftwareSet != 0x82 )
354 Wb35Tx_EP2VM_start(priv);
361 pHwData->SurpriseRemove = 1;
366 void hal_halt(phw_data_t pHwData, void *ppa_data)
368 switch( pHwData->InitialResource )
371 case 3: del_timer_sync(&pHwData->LEDTimer);
372 msleep(100); // Wait for Timer DPC exit 940623.2
373 Wb35Rx_destroy( pHwData ); // Release the Rx
374 case 2: Wb35Tx_destroy( pHwData ); // Release the Tx
375 case 1: Wb35Reg_destroy( pHwData ); // Release the Wb35 Regisster resources
379 //---------------------------------------------------------------------------------------------------
380 void hal_set_rates(phw_data_t pHwData, u8 *pbss_rates,
381 u8 length, unsigned char basic_rate_set)
383 struct wb35_reg *reg = &pHwData->reg;
385 u8 Rate[12]={ 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 };
386 u8 SupportedRate[16];
387 u8 i, j, k, Count1, Count2, Byte;
389 if( pHwData->SurpriseRemove ) return;
391 if (basic_rate_set) {
392 reg->M28_MacControl &= ~0x000fff00;
395 reg->M28_MacControl &= ~0xfff00000;
400 for (i=0; i<length; i++) {
401 Byte = pbss_rates[i] & 0x7f;
402 for (j=0; j<12; j++) {
403 if( Byte == Rate[j] )
411 reg->M28_MacControl |= tmp;
412 Wb35Reg_Write( pHwData, 0x0828, reg->M28_MacControl );
414 // 930206.2.c M78 setting
415 j = k = Count1 = Count2 = 0;
416 memset( SupportedRate, 0, 16 );
419 for (i=0; i<12; i++) { // Get the supported rate
420 if (tmp & reg->M28_MacControl) {
421 SupportedRate[j] = Rate[i];
423 if (tmp1 & reg->M28_MacControl)
424 SupportedRate[j] |= 0x80;
435 if( !(reg->M28_MacControl & 0x000ff000) ) // if basic rate in 11g domain)
446 // Fill data into support rate until buffer full
447 //---20060926 add by anson's endian
449 *(u32 *)(SupportedRate+(i<<2)) = cpu_to_le32( *(u32 *)(SupportedRate+(i<<2)) );
450 //--- end 20060926 add by anson's endian
451 Wb35Reg_BurstWrite( pHwData,0x087c, (u32 *)SupportedRate, 4, AUTO_INCREMENT );
452 reg->M7C_MacControl = ((u32 *)SupportedRate)[0];
453 reg->M80_MacControl = ((u32 *)SupportedRate)[1];
454 reg->M84_MacControl = ((u32 *)SupportedRate)[2];
455 reg->M88_MacControl = ((u32 *)SupportedRate)[3];
458 tmp = Count1<<28 | Count2<<24;
459 reg->M78_ERPInformation &= ~0xff000000;
460 reg->M78_ERPInformation |= tmp;
461 Wb35Reg_Write( pHwData, 0x0878, reg->M78_ERPInformation );
465 //---------------------------------------------------------------------------------------------------
466 void hal_set_beacon_period( phw_data_t pHwData, u16 beacon_period )
470 if( pHwData->SurpriseRemove ) return;
472 pHwData->BeaconPeriod = beacon_period;
473 tmp = pHwData->BeaconPeriod << 16;
474 tmp |= pHwData->ProbeDelay;
475 Wb35Reg_Write( pHwData, 0x0848, tmp );
479 void hal_set_current_channel_ex( phw_data_t pHwData, ChanInfo channel )
481 struct wb35_reg *reg = &pHwData->reg;
483 if( pHwData->SurpriseRemove )
486 printk("Going to channel: %d/%d\n", channel.band, channel.ChanNo);
488 RFSynthesizer_SwitchingChannel( pHwData, channel );// Switch channel
489 pHwData->Channel = channel.ChanNo;
490 pHwData->band = channel.band;
491 #ifdef _PE_STATE_DUMP_
492 WBDEBUG(("Set channel is %d, band =%d\n", pHwData->Channel, pHwData->band));
494 reg->M28_MacControl &= ~0xff; // Clean channel information field
495 reg->M28_MacControl |= channel.ChanNo;
496 Wb35Reg_WriteWithCallbackValue( pHwData, 0x0828, reg->M28_MacControl,
497 (s8 *)&channel, sizeof(ChanInfo));
499 //---------------------------------------------------------------------------------------------------
500 void hal_set_current_channel( phw_data_t pHwData, ChanInfo channel )
502 hal_set_current_channel_ex( pHwData, channel );
504 //---------------------------------------------------------------------------------------------------
505 void hal_get_current_channel( phw_data_t pHwData, ChanInfo *channel )
507 channel->ChanNo = pHwData->Channel;
508 channel->band = pHwData->band;
510 //---------------------------------------------------------------------------------------------------
511 void hal_set_accept_broadcast( phw_data_t pHwData, u8 enable )
513 struct wb35_reg *reg = &pHwData->reg;
515 if( pHwData->SurpriseRemove ) return;
517 reg->M00_MacControl &= ~0x02000000;//The HW value
520 reg->M00_MacControl |= 0x02000000;//The HW value
522 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
525 //for wep key error detection, we need to accept broadcast packets to be received temporary.
526 void hal_set_accept_promiscuous( phw_data_t pHwData, u8 enable)
528 struct wb35_reg *reg = &pHwData->reg;
530 if (pHwData->SurpriseRemove) return;
532 reg->M00_MacControl |= 0x00400000;
533 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
535 reg->M00_MacControl&=~0x00400000;
536 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
540 void hal_set_accept_multicast( phw_data_t pHwData, u8 enable )
542 struct wb35_reg *reg = &pHwData->reg;
544 if( pHwData->SurpriseRemove ) return;
546 reg->M00_MacControl &= ~0x01000000;//The HW value
547 if (enable) reg->M00_MacControl |= 0x01000000;//The HW value
548 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
551 void hal_set_accept_beacon( phw_data_t pHwData, u8 enable )
553 struct wb35_reg *reg = &pHwData->reg;
555 if( pHwData->SurpriseRemove ) return;
558 if( !enable )//Due to SME and MLME are not suitable for 35
561 reg->M00_MacControl &= ~0x04000000;//The HW value
563 reg->M00_MacControl |= 0x04000000;//The HW value
565 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
567 //---------------------------------------------------------------------------------------------------
568 void hal_set_multicast_address( phw_data_t pHwData, u8 *address, u8 number )
570 struct wb35_reg *reg = &pHwData->reg;
573 if( pHwData->SurpriseRemove ) return;
575 //Erases and refills the card multicast registers. Used when an address
576 // has been deleted and all bits must be recomputed.
577 reg->M04_MulticastAddress1 = 0;
578 reg->M08_MulticastAddress2 = 0;
583 CardGetMulticastBit( (address+(number*ETH_LENGTH_OF_ADDRESS)), &Byte, &Bit);
584 reg->Multicast[Byte] |= Bit;
588 Wb35Reg_BurstWrite( pHwData, 0x0804, (u32 *)reg->Multicast, 2, AUTO_INCREMENT );
590 //---------------------------------------------------------------------------------------------------
591 u8 hal_get_accept_beacon( phw_data_t pHwData )
593 struct wb35_reg *reg = &pHwData->reg;
595 if( pHwData->SurpriseRemove ) return 0;
597 if( reg->M00_MacControl & 0x04000000 )
603 unsigned char hal_reset_hardware( phw_data_t pHwData, void* ppa )
609 void hal_stop( phw_data_t pHwData )
611 struct wb35_reg *reg = &pHwData->reg;
613 pHwData->Wb35Rx.rx_halt = 1;
614 Wb35Rx_stop( pHwData );
616 pHwData->Wb35Tx.tx_halt = 1;
617 Wb35Tx_stop( pHwData );
619 reg->D00_DmaControl &= ~0xc0000000;//Tx Off, Rx Off
620 Wb35Reg_Write( pHwData, 0x0400, reg->D00_DmaControl );
623 unsigned char hal_idle(phw_data_t pHwData)
625 struct wb35_reg *reg = &pHwData->reg;
626 PWBUSB pWbUsb = &pHwData->WbUsb;
628 if( !pHwData->SurpriseRemove && ( pWbUsb->DetectCount || reg->EP0vm_state!=VM_STOP ) )
633 //---------------------------------------------------------------------------------------------------
634 void hal_set_cwmin( phw_data_t pHwData, u8 cwin_min )
636 struct wb35_reg *reg = &pHwData->reg;
638 if( pHwData->SurpriseRemove ) return;
640 pHwData->cwmin = cwin_min;
641 reg->M2C_MacControl &= ~0x7c00; //bit 10 ~ 14
642 reg->M2C_MacControl |= (pHwData->cwmin<<10);
643 Wb35Reg_Write( pHwData, 0x082c, reg->M2C_MacControl );
646 s32 hal_get_rssi( phw_data_t pHwData, u32 *HalRssiArry, u8 Count )
648 struct wb35_reg *reg = &pHwData->reg;
653 if( pHwData->SurpriseRemove ) return -200;
654 if( Count > MAX_ACC_RSSI_COUNT ) // Because the TS may use this funtion
655 Count = MAX_ACC_RSSI_COUNT;
657 // RSSI = C1 + C2 * (agc_state[7:0] + offset_map(lna_state[1:0]))
658 // C1 = -195, C2 = 0.66 = 85/128
659 for (i=0; i<Count; i++)
661 r01.value = HalRssiArry[i];
662 tmp = ((( r01.R01_AGC_state + reg->LNAValue[r01.R01_LNA_state]) * 85 ) >>7 ) - 195;
666 if( pHwData->phy_type == RF_AIROHA_2230 ) ltmp -= 5; // 10;
667 if( pHwData->phy_type == RF_AIROHA_2230S ) ltmp -= 5; // 10; 20060420 Add this
669 //if( ltmp < -200 ) ltmp = -200;
670 if( ltmp < -110 ) ltmp = -110;// 1.0.24.0 For NJRC
674 //----------------------------------------------------------------------------------------------------
675 s32 hal_get_rssi_bss(struct wbsoft_priv *adapter, u16 idx, u8 Count)
677 phw_data_t pHwData = &adapter->sHwData;
678 struct wb35_reg *reg = &pHwData->reg;
682 // u32 *HalRssiArry = psBSS(idx)->HalRssi;
684 if( pHwData->SurpriseRemove ) return -200;
685 if( Count > MAX_ACC_RSSI_COUNT ) // Because the TS may use this funtion
686 Count = MAX_ACC_RSSI_COUNT;
688 // RSSI = C1 + C2 * (agc_state[7:0] + offset_map(lna_state[1:0]))
689 // C1 = -195, C2 = 0.66 = 85/128
691 for (i=0; i<Count; i++)
693 r01.value = HalRssiArry[i];
694 tmp = ((( r01.R01_AGC_state + reg->LNAValue[r01.R01_LNA_state]) * 85 ) >>7 ) - 195;
698 if (psBSS(idx)->HalRssiIndex == 0)
699 psBSS(idx)->HalRssiIndex = MAX_ACC_RSSI_COUNT;
700 j = (u8)psBSS(idx)->HalRssiIndex-1;
702 for (i=0; i<Count; i++)
704 r01.value = psBSS(idx)->HalRssi[j];
705 tmp = ((( r01.R01_AGC_state + reg->LNAValue[r01.R01_LNA_state]) * 85 ) >>7 ) - 195;
709 j = MAX_ACC_RSSI_COUNT;
715 if( pHwData->phy_type == RF_AIROHA_2230 ) ltmp -= 5; // 10;
716 if( pHwData->phy_type == RF_AIROHA_2230S ) ltmp -= 5; // 10; 20060420 Add this
718 //if( ltmp < -200 ) ltmp = -200;
719 if( ltmp < -110 ) ltmp = -110;// 1.0.24.0 For NJRC
724 //---------------------------------------------------------------------------
726 void hal_set_phy_type( phw_data_t pHwData, u8 PhyType )
728 pHwData->phy_type = PhyType;
731 void hal_get_phy_type( phw_data_t pHwData, u8 *PhyType )
733 *PhyType = pHwData->phy_type;
736 void hal_reset_counter( phw_data_t pHwData )
738 pHwData->dto_tx_retry_count = 0;
739 pHwData->dto_tx_frag_count = 0;
740 memset( pHwData->tx_retry_count, 0, 8);
743 void hal_set_radio_mode( phw_data_t pHwData, unsigned char radio_off)
745 struct wb35_reg *reg = &pHwData->reg;
747 if( pHwData->SurpriseRemove ) return;
749 if (radio_off) //disable Baseband receive off
751 pHwData->CurrentRadioSw = 1; // off
752 reg->M24_MacControl &= 0xffffffbf;
756 pHwData->CurrentRadioSw = 0; // on
757 reg->M24_MacControl |= 0x00000040;
759 Wb35Reg_Write( pHwData, 0x0824, reg->M24_MacControl );
762 u8 hal_get_antenna_number( phw_data_t pHwData )
764 struct wb35_reg *reg = &pHwData->reg;
766 if ((reg->BB2C & BIT(11)) == 0)
772 void hal_set_antenna_number( phw_data_t pHwData, u8 number )
775 struct wb35_reg *reg = &pHwData->reg;
778 reg->BB2C |= BIT(11);
780 reg->BB2C &= ~BIT(11);
782 Wb35Reg_Write( pHwData, 0x102c, reg->BB2C );
783 #ifdef _PE_STATE_DUMP_
784 WBDEBUG(("Current antenna number : %d\n", number));
788 //----------------------------------------------------------------------------------------------------
789 //0 : radio on; 1: radio off
790 u8 hal_get_hw_radio_off( phw_data_t pHwData )
792 struct wb35_reg *reg = &pHwData->reg;
794 if( pHwData->SurpriseRemove ) return 1;
796 //read the bit16 of register U1B0
797 Wb35Reg_Read( pHwData, 0x3b0, ®->U1B0 );
798 if ((reg->U1B0 & 0x00010000)) {
799 pHwData->CurrentRadioHw = 1;
802 pHwData->CurrentRadioHw = 0;
807 unsigned char hal_get_dxx_reg( phw_data_t pHwData, u16 number, u32 * pValue )
809 if( number < 0x1000 )
811 return Wb35Reg_ReadSync( pHwData, number, pValue );
814 unsigned char hal_set_dxx_reg( phw_data_t pHwData, u16 number, u32 value )
818 if( number < 0x1000 )
820 ret = Wb35Reg_WriteSync( pHwData, number, value );
824 void hal_scan_status_indicate(phw_data_t pHwData, unsigned char IsOnProgress)
826 if( pHwData->SurpriseRemove ) return;
827 pHwData->LED_Scanning = IsOnProgress ? 1 : 0;
830 void hal_system_power_change(phw_data_t pHwData, u32 PowerState)
832 if( PowerState != 0 )
834 pHwData->SurpriseRemove = 1;
835 if( pHwData->WbUsb.IsUsb20 )
840 if( !pHwData->WbUsb.IsUsb20 )
845 void hal_surprise_remove(struct wbsoft_priv *adapter)
847 phw_data_t pHwData = &adapter->sHwData;
849 if (atomic_inc_return( &pHwData->SurpriseRemoveCount ) == 1) {
850 #ifdef _PE_STATE_DUMP_
851 WBDEBUG(("Calling hal_surprise_remove\n"));
853 WBLINUX_stop( adapter );
857 void hal_rate_change(struct wbsoft_priv *adapter) // Notify the HAL rate is changing 20060613.1
859 phw_data_t pHwData = &adapter->sHwData;
860 u8 rate = CURRENT_TX_RATE;
862 BBProcessor_RateChanging( pHwData, rate );
865 void hal_set_rf_power(phw_data_t pHwData, u8 PowerIndex)
867 RFSynthesizer_SetPowerIndex( pHwData, PowerIndex );
870 unsigned char hal_set_LED(phw_data_t pHwData, u32 Mode) // 20061108 for WPS led control
872 pHwData->LED_Blinking = 0;
873 pHwData->LED_control = Mode;
874 pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(10);
875 add_timer(&pHwData->LEDTimer);