3 void hal_get_ethernet_address( phw_data_t pHwData, u8 *current_address )
5 if( pHwData->SurpriseRemove ) return;
7 memcpy( current_address, pHwData->CurrentMacAddress, ETH_LENGTH_OF_ADDRESS );
10 void hal_set_ethernet_address( phw_data_t pHwData, u8 *current_address )
14 if( pHwData->SurpriseRemove ) return;
16 memcpy( pHwData->CurrentMacAddress, current_address, ETH_LENGTH_OF_ADDRESS );
18 ltmp[0]= cpu_to_le32( *(u32 *)pHwData->CurrentMacAddress );
19 ltmp[1]= cpu_to_le32( *(u32 *)(pHwData->CurrentMacAddress + 4) ) & 0xffff;
21 Wb35Reg_BurstWrite( pHwData, 0x03e8, ltmp, 2, AUTO_INCREMENT );
24 void hal_get_permanent_address( phw_data_t pHwData, u8 *pethernet_address )
26 if( pHwData->SurpriseRemove ) return;
28 memcpy( pethernet_address, pHwData->PermanentMacAddress, 6 );
31 static void hal_led_control(unsigned long data)
33 phw_data_t pHwData = (phw_data_t) data;
34 struct wb35_adapter * adapter = pHwData->adapter;
35 struct wb35_reg *reg = &pHwData->reg;
36 u32 LEDSet = (pHwData->SoftwareSet & HAL_LED_SET_MASK) >> HAL_LED_SET_SHIFT;
37 u8 LEDgray[20] = { 0,3,4,6,8,10,11,12,13,14,15,14,13,12,11,10,8,6,4,2 };
38 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 };
39 u32 TimeInterval = 500, ltmp, ltmp2;
42 if( pHwData->SurpriseRemove ) return;
44 if( pHwData->LED_control ) {
45 ltmp2 = pHwData->LED_control & 0xff;
46 if( ltmp2 == 5 ) // 5 is WPS mode
49 ltmp2 = (pHwData->LED_control>>8) & 0xff;
52 case 1: // [0.2 On][0.1 Off]...
53 pHwData->LED_Blinking %= 3;
54 ltmp = 0x1010; // Led 1 & 0 Green and Red
55 if( pHwData->LED_Blinking == 2 ) // Turn off
58 case 2: // [0.1 On][0.1 Off]...
59 pHwData->LED_Blinking %= 2;
60 ltmp = 0x0010; // Led 0 red color
61 if( pHwData->LED_Blinking ) // Turn off
64 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]...
65 pHwData->LED_Blinking %= 15;
66 ltmp = 0x0010; // Led 0 red color
67 if( (pHwData->LED_Blinking >= 9) || (pHwData->LED_Blinking%2) ) // Turn off 0.6 sec
70 case 4: // [300 On][ off ]
71 ltmp = 0x1000; // Led 1 Green color
72 if( pHwData->LED_Blinking >= 3000 )
73 ltmp = 0; // led maybe on after 300sec * 32bit counter overlap.
76 pHwData->LED_Blinking++;
78 reg->U1BC_LEDConfigure = ltmp;
79 if( LEDSet != 7 ) // Only 111 mode has 2 LEDs on PCB.
81 reg->U1BC_LEDConfigure |= (ltmp &0xff)<<8; // Copy LED result to each LED control register
82 reg->U1BC_LEDConfigure |= (ltmp &0xff00)>>8;
84 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
87 else if( pHwData->CurrentRadioSw || pHwData->CurrentRadioHw ) // If radio off
89 if( reg->U1BC_LEDConfigure & 0x1010 )
91 reg->U1BC_LEDConfigure &= ~0x1010;
92 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
99 case 4: // [100] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
100 if( !pHwData->LED_LinkOn ) // Blink only if not Link On
102 // Blinking if scanning is on progress
103 if( pHwData->LED_Scanning )
105 if( pHwData->LED_Blinking == 0 )
107 reg->U1BC_LEDConfigure |= 0x10;
108 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 On
109 pHwData->LED_Blinking = 1;
114 reg->U1BC_LEDConfigure &= ~0x10;
115 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
116 pHwData->LED_Blinking = 0;
123 if( reg->U1BC_LEDConfigure & 0x10 )
125 reg->U1BC_LEDConfigure &= ~0x10;
126 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
133 if( (reg->U1BC_LEDConfigure & 0x10) == 0 )
135 reg->U1BC_LEDConfigure |= 0x10;
136 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
141 case 6: // [110] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
142 if( !pHwData->LED_LinkOn ) // Blink only if not Link On
144 // Blinking if scanning is on progress
145 if( pHwData->LED_Scanning )
147 if( pHwData->LED_Blinking == 0 )
149 reg->U1BC_LEDConfigure &= ~0xf;
150 reg->U1BC_LEDConfigure |= 0x10;
151 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 On
152 pHwData->LED_Blinking = 1;
157 reg->U1BC_LEDConfigure &= ~0x1f;
158 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
159 pHwData->LED_Blinking = 0;
165 // 20060901 Gray blinking if in disconnect state and not scanning
166 ltmp = reg->U1BC_LEDConfigure;
167 reg->U1BC_LEDConfigure &= ~0x1f;
168 if( LEDgray2[(pHwData->LED_Blinking%30)] )
170 reg->U1BC_LEDConfigure |= 0x10;
171 reg->U1BC_LEDConfigure |= LEDgray2[ (pHwData->LED_Blinking%30) ];
173 pHwData->LED_Blinking++;
174 if( reg->U1BC_LEDConfigure != ltmp )
175 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
182 if( (reg->U1BC_LEDConfigure & 0x10) == 0 )
184 reg->U1BC_LEDConfigure |= 0x10;
185 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
190 case 5: // [101] Only 1 Led be placed on PCB and use LED_1 for showing
191 if( !pHwData->LED_LinkOn ) // Blink only if not Link On
193 // Blinking if scanning is on progress
194 if( pHwData->LED_Scanning )
196 if( pHwData->LED_Blinking == 0 )
198 reg->U1BC_LEDConfigure |= 0x1000;
199 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On
200 pHwData->LED_Blinking = 1;
205 reg->U1BC_LEDConfigure &= ~0x1000;
206 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 Off
207 pHwData->LED_Blinking = 0;
214 if( reg->U1BC_LEDConfigure & 0x1000 )
216 reg->U1BC_LEDConfigure &= ~0x1000;
217 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 Off
223 // Is transmitting/receiving ??
224 if( (OS_CURRENT_RX_BYTE( adapter ) != pHwData->RxByteCountLast ) ||
225 (OS_CURRENT_TX_BYTE( adapter ) != pHwData->TxByteCountLast ) )
227 if( (reg->U1BC_LEDConfigure & 0x3000) != 0x3000 )
229 reg->U1BC_LEDConfigure |= 0x3000;
230 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On
234 pHwData->RxByteCountLast = OS_CURRENT_RX_BYTE( adapter );
235 pHwData->TxByteCountLast = OS_CURRENT_TX_BYTE( adapter );
240 // Turn On LED_1 and blinking if transmitting/receiving
241 if( (reg->U1BC_LEDConfigure & 0x3000) != 0x1000 )
243 reg->U1BC_LEDConfigure &= ~0x3000;
244 reg->U1BC_LEDConfigure |= 0x1000;
245 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On
251 default: // Default setting. 2 LED be placed on PCB. LED_0: Link On LED_1 Active
252 if( (reg->U1BC_LEDConfigure & 0x3000) != 0x3000 )
254 reg->U1BC_LEDConfigure |= 0x3000;// LED_1 is always on and event enable
255 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
258 if( pHwData->LED_Blinking )
261 reg->U1BC_LEDConfigure &= ~0x0f;
262 reg->U1BC_LEDConfigure |= 0x10;
263 reg->U1BC_LEDConfigure |= LEDgray[ (pHwData->LED_Blinking-1)%20 ];
264 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
266 pHwData->LED_Blinking += 2;
267 if( pHwData->LED_Blinking < 40 )
271 pHwData->LED_Blinking = 0; // Stop blinking
272 reg->U1BC_LEDConfigure &= ~0x0f;
273 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
278 if( pHwData->LED_LinkOn )
280 if( !(reg->U1BC_LEDConfigure & 0x10) ) // Check the LED_0
282 //Try to turn ON LED_0 after gray blinking
283 reg->U1BC_LEDConfigure |= 0x10;
284 pHwData->LED_Blinking = 1; //Start blinking
290 if( reg->U1BC_LEDConfigure & 0x10 ) // Check the LED_0
292 reg->U1BC_LEDConfigure &= ~0x10;
293 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
299 //20060828.1 Active send null packet to avoid AP disconnect
300 if( pHwData->LED_LinkOn )
302 pHwData->NullPacketCount += TimeInterval;
303 if( pHwData->NullPacketCount >= DEFAULT_NULL_PACKET_COUNT )
305 pHwData->NullPacketCount = 0;
310 pHwData->time_count += TimeInterval;
311 Wb35Tx_CurrentTime( pHwData, pHwData->time_count ); // 20060928 add
312 pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(TimeInterval);
313 add_timer(&pHwData->LEDTimer);
317 u8 hal_init_hardware(phw_data_t pHwData, struct wb35_adapter * adapter)
320 pHwData->adapter = adapter;
322 // Initial the variable
323 pHwData->MaxReceiveLifeTime = DEFAULT_MSDU_LIFE_TIME; // Setting Rx maximum MSDU life time
324 pHwData->FragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; // Setting default fragment threshold
326 pHwData->InitialResource = 1;
327 if( Wb35Reg_initial(pHwData)) {
328 pHwData->InitialResource = 2;
329 if (Wb35Tx_initial(pHwData)) {
330 pHwData->InitialResource = 3;
331 if (Wb35Rx_initial(pHwData)) {
332 pHwData->InitialResource = 4;
333 init_timer(&pHwData->LEDTimer);
334 pHwData->LEDTimer.function = hal_led_control;
335 pHwData->LEDTimer.data = (unsigned long) pHwData;
336 pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(1000);
337 add_timer(&pHwData->LEDTimer);
340 // For restrict to vendor's hardware
342 SoftwareSet = hal_software_set( pHwData );
345 // Try to make sure the EEPROM contain
347 if( SoftwareSet != 0x82 )
351 Wb35Rx_start( pHwData );
352 Wb35Tx_EP2VM_start( pHwData );
359 pHwData->SurpriseRemove = 1;
364 void hal_halt(phw_data_t pHwData, void *ppa_data)
366 switch( pHwData->InitialResource )
369 case 3: del_timer_sync(&pHwData->LEDTimer);
370 msleep(100); // Wait for Timer DPC exit 940623.2
371 Wb35Rx_destroy( pHwData ); // Release the Rx
372 case 2: Wb35Tx_destroy( pHwData ); // Release the Tx
373 case 1: Wb35Reg_destroy( pHwData ); // Release the Wb35 Regisster resources
377 //---------------------------------------------------------------------------------------------------
378 void hal_set_rates(phw_data_t pHwData, u8 *pbss_rates,
379 u8 length, unsigned char basic_rate_set)
381 struct wb35_reg *reg = &pHwData->reg;
383 u8 Rate[12]={ 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 };
384 u8 SupportedRate[16];
385 u8 i, j, k, Count1, Count2, Byte;
387 if( pHwData->SurpriseRemove ) return;
389 if (basic_rate_set) {
390 reg->M28_MacControl &= ~0x000fff00;
393 reg->M28_MacControl &= ~0xfff00000;
398 for (i=0; i<length; i++) {
399 Byte = pbss_rates[i] & 0x7f;
400 for (j=0; j<12; j++) {
401 if( Byte == Rate[j] )
409 reg->M28_MacControl |= tmp;
410 Wb35Reg_Write( pHwData, 0x0828, reg->M28_MacControl );
412 // 930206.2.c M78 setting
413 j = k = Count1 = Count2 = 0;
414 memset( SupportedRate, 0, 16 );
417 for (i=0; i<12; i++) { // Get the supported rate
418 if (tmp & reg->M28_MacControl) {
419 SupportedRate[j] = Rate[i];
421 if (tmp1 & reg->M28_MacControl)
422 SupportedRate[j] |= 0x80;
433 if( !(reg->M28_MacControl & 0x000ff000) ) // if basic rate in 11g domain)
444 // Fill data into support rate until buffer full
445 //---20060926 add by anson's endian
447 *(u32 *)(SupportedRate+(i<<2)) = cpu_to_le32( *(u32 *)(SupportedRate+(i<<2)) );
448 //--- end 20060926 add by anson's endian
449 Wb35Reg_BurstWrite( pHwData,0x087c, (u32 *)SupportedRate, 4, AUTO_INCREMENT );
450 reg->M7C_MacControl = ((u32 *)SupportedRate)[0];
451 reg->M80_MacControl = ((u32 *)SupportedRate)[1];
452 reg->M84_MacControl = ((u32 *)SupportedRate)[2];
453 reg->M88_MacControl = ((u32 *)SupportedRate)[3];
456 tmp = Count1<<28 | Count2<<24;
457 reg->M78_ERPInformation &= ~0xff000000;
458 reg->M78_ERPInformation |= tmp;
459 Wb35Reg_Write( pHwData, 0x0878, reg->M78_ERPInformation );
463 //---------------------------------------------------------------------------------------------------
464 void hal_set_beacon_period( phw_data_t pHwData, u16 beacon_period )
468 if( pHwData->SurpriseRemove ) return;
470 pHwData->BeaconPeriod = beacon_period;
471 tmp = pHwData->BeaconPeriod << 16;
472 tmp |= pHwData->ProbeDelay;
473 Wb35Reg_Write( pHwData, 0x0848, tmp );
477 void hal_set_current_channel_ex( phw_data_t pHwData, ChanInfo channel )
479 struct wb35_reg *reg = &pHwData->reg;
481 if( pHwData->SurpriseRemove )
484 printk("Going to channel: %d/%d\n", channel.band, channel.ChanNo);
486 RFSynthesizer_SwitchingChannel( pHwData, channel );// Switch channel
487 pHwData->Channel = channel.ChanNo;
488 pHwData->band = channel.band;
489 #ifdef _PE_STATE_DUMP_
490 WBDEBUG(("Set channel is %d, band =%d\n", pHwData->Channel, pHwData->band));
492 reg->M28_MacControl &= ~0xff; // Clean channel information field
493 reg->M28_MacControl |= channel.ChanNo;
494 Wb35Reg_WriteWithCallbackValue( pHwData, 0x0828, reg->M28_MacControl,
495 (s8 *)&channel, sizeof(ChanInfo));
497 //---------------------------------------------------------------------------------------------------
498 void hal_set_current_channel( phw_data_t pHwData, ChanInfo channel )
500 hal_set_current_channel_ex( pHwData, channel );
502 //---------------------------------------------------------------------------------------------------
503 void hal_get_current_channel( phw_data_t pHwData, ChanInfo *channel )
505 channel->ChanNo = pHwData->Channel;
506 channel->band = pHwData->band;
508 //---------------------------------------------------------------------------------------------------
509 void hal_set_accept_broadcast( phw_data_t pHwData, u8 enable )
511 struct wb35_reg *reg = &pHwData->reg;
513 if( pHwData->SurpriseRemove ) return;
515 reg->M00_MacControl &= ~0x02000000;//The HW value
518 reg->M00_MacControl |= 0x02000000;//The HW value
520 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
523 //for wep key error detection, we need to accept broadcast packets to be received temporary.
524 void hal_set_accept_promiscuous( phw_data_t pHwData, u8 enable)
526 struct wb35_reg *reg = &pHwData->reg;
528 if (pHwData->SurpriseRemove) return;
530 reg->M00_MacControl |= 0x00400000;
531 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
533 reg->M00_MacControl&=~0x00400000;
534 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
538 void hal_set_accept_multicast( phw_data_t pHwData, u8 enable )
540 struct wb35_reg *reg = &pHwData->reg;
542 if( pHwData->SurpriseRemove ) return;
544 reg->M00_MacControl &= ~0x01000000;//The HW value
545 if (enable) reg->M00_MacControl |= 0x01000000;//The HW value
546 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
549 void hal_set_accept_beacon( phw_data_t pHwData, u8 enable )
551 struct wb35_reg *reg = &pHwData->reg;
553 if( pHwData->SurpriseRemove ) return;
556 if( !enable )//Due to SME and MLME are not suitable for 35
559 reg->M00_MacControl &= ~0x04000000;//The HW value
561 reg->M00_MacControl |= 0x04000000;//The HW value
563 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
565 //---------------------------------------------------------------------------------------------------
566 void hal_set_multicast_address( phw_data_t pHwData, u8 *address, u8 number )
568 struct wb35_reg *reg = &pHwData->reg;
571 if( pHwData->SurpriseRemove ) return;
573 //Erases and refills the card multicast registers. Used when an address
574 // has been deleted and all bits must be recomputed.
575 reg->M04_MulticastAddress1 = 0;
576 reg->M08_MulticastAddress2 = 0;
581 CardGetMulticastBit( (address+(number*ETH_LENGTH_OF_ADDRESS)), &Byte, &Bit);
582 reg->Multicast[Byte] |= Bit;
586 Wb35Reg_BurstWrite( pHwData, 0x0804, (u32 *)reg->Multicast, 2, AUTO_INCREMENT );
588 //---------------------------------------------------------------------------------------------------
589 u8 hal_get_accept_beacon( phw_data_t pHwData )
591 struct wb35_reg *reg = &pHwData->reg;
593 if( pHwData->SurpriseRemove ) return 0;
595 if( reg->M00_MacControl & 0x04000000 )
601 unsigned char hal_reset_hardware( phw_data_t pHwData, void* ppa )
607 void hal_stop( phw_data_t pHwData )
609 struct wb35_reg *reg = &pHwData->reg;
611 pHwData->Wb35Rx.rx_halt = 1;
612 Wb35Rx_stop( pHwData );
614 pHwData->Wb35Tx.tx_halt = 1;
615 Wb35Tx_stop( pHwData );
617 reg->D00_DmaControl &= ~0xc0000000;//Tx Off, Rx Off
618 Wb35Reg_Write( pHwData, 0x0400, reg->D00_DmaControl );
621 unsigned char hal_idle(phw_data_t pHwData)
623 struct wb35_reg *reg = &pHwData->reg;
624 PWBUSB pWbUsb = &pHwData->WbUsb;
626 if( !pHwData->SurpriseRemove && ( pWbUsb->DetectCount || reg->EP0vm_state!=VM_STOP ) )
631 //---------------------------------------------------------------------------------------------------
632 void hal_set_cwmin( phw_data_t pHwData, u8 cwin_min )
634 struct wb35_reg *reg = &pHwData->reg;
636 if( pHwData->SurpriseRemove ) return;
638 pHwData->cwmin = cwin_min;
639 reg->M2C_MacControl &= ~0x7c00; //bit 10 ~ 14
640 reg->M2C_MacControl |= (pHwData->cwmin<<10);
641 Wb35Reg_Write( pHwData, 0x082c, reg->M2C_MacControl );
644 s32 hal_get_rssi( phw_data_t pHwData, u32 *HalRssiArry, u8 Count )
646 struct wb35_reg *reg = &pHwData->reg;
651 if( pHwData->SurpriseRemove ) return -200;
652 if( Count > MAX_ACC_RSSI_COUNT ) // Because the TS may use this funtion
653 Count = MAX_ACC_RSSI_COUNT;
655 // RSSI = C1 + C2 * (agc_state[7:0] + offset_map(lna_state[1:0]))
656 // C1 = -195, C2 = 0.66 = 85/128
657 for (i=0; i<Count; i++)
659 r01.value = HalRssiArry[i];
660 tmp = ((( r01.R01_AGC_state + reg->LNAValue[r01.R01_LNA_state]) * 85 ) >>7 ) - 195;
664 if( pHwData->phy_type == RF_AIROHA_2230 ) ltmp -= 5; // 10;
665 if( pHwData->phy_type == RF_AIROHA_2230S ) ltmp -= 5; // 10; 20060420 Add this
667 //if( ltmp < -200 ) ltmp = -200;
668 if( ltmp < -110 ) ltmp = -110;// 1.0.24.0 For NJRC
672 //----------------------------------------------------------------------------------------------------
673 s32 hal_get_rssi_bss( phw_data_t pHwData, u16 idx, u8 Count )
675 struct wb35_reg *reg = &pHwData->reg;
679 struct wb35_adapter * adapter = pHwData->adapter;
680 // u32 *HalRssiArry = psBSS(idx)->HalRssi;
682 if( pHwData->SurpriseRemove ) return -200;
683 if( Count > MAX_ACC_RSSI_COUNT ) // Because the TS may use this funtion
684 Count = MAX_ACC_RSSI_COUNT;
686 // RSSI = C1 + C2 * (agc_state[7:0] + offset_map(lna_state[1:0]))
687 // C1 = -195, C2 = 0.66 = 85/128
689 for (i=0; i<Count; i++)
691 r01.value = HalRssiArry[i];
692 tmp = ((( r01.R01_AGC_state + reg->LNAValue[r01.R01_LNA_state]) * 85 ) >>7 ) - 195;
696 if (psBSS(idx)->HalRssiIndex == 0)
697 psBSS(idx)->HalRssiIndex = MAX_ACC_RSSI_COUNT;
698 j = (u8)psBSS(idx)->HalRssiIndex-1;
700 for (i=0; i<Count; i++)
702 r01.value = psBSS(idx)->HalRssi[j];
703 tmp = ((( r01.R01_AGC_state + reg->LNAValue[r01.R01_LNA_state]) * 85 ) >>7 ) - 195;
707 j = MAX_ACC_RSSI_COUNT;
713 if( pHwData->phy_type == RF_AIROHA_2230 ) ltmp -= 5; // 10;
714 if( pHwData->phy_type == RF_AIROHA_2230S ) ltmp -= 5; // 10; 20060420 Add this
716 //if( ltmp < -200 ) ltmp = -200;
717 if( ltmp < -110 ) ltmp = -110;// 1.0.24.0 For NJRC
722 //---------------------------------------------------------------------------
724 void hal_set_phy_type( phw_data_t pHwData, u8 PhyType )
726 pHwData->phy_type = PhyType;
729 void hal_get_phy_type( phw_data_t pHwData, u8 *PhyType )
731 *PhyType = pHwData->phy_type;
734 void hal_reset_counter( phw_data_t pHwData )
736 pHwData->dto_tx_retry_count = 0;
737 pHwData->dto_tx_frag_count = 0;
738 memset( pHwData->tx_retry_count, 0, 8);
741 void hal_set_radio_mode( phw_data_t pHwData, unsigned char radio_off)
743 struct wb35_reg *reg = &pHwData->reg;
745 if( pHwData->SurpriseRemove ) return;
747 if (radio_off) //disable Baseband receive off
749 pHwData->CurrentRadioSw = 1; // off
750 reg->M24_MacControl &= 0xffffffbf;
754 pHwData->CurrentRadioSw = 0; // on
755 reg->M24_MacControl |= 0x00000040;
757 Wb35Reg_Write( pHwData, 0x0824, reg->M24_MacControl );
760 u8 hal_get_antenna_number( phw_data_t pHwData )
762 struct wb35_reg *reg = &pHwData->reg;
764 if ((reg->BB2C & BIT(11)) == 0)
770 void hal_set_antenna_number( phw_data_t pHwData, u8 number )
773 struct wb35_reg *reg = &pHwData->reg;
776 reg->BB2C |= BIT(11);
778 reg->BB2C &= ~BIT(11);
780 Wb35Reg_Write( pHwData, 0x102c, reg->BB2C );
781 #ifdef _PE_STATE_DUMP_
782 WBDEBUG(("Current antenna number : %d\n", number));
786 //----------------------------------------------------------------------------------------------------
787 //0 : radio on; 1: radio off
788 u8 hal_get_hw_radio_off( phw_data_t pHwData )
790 struct wb35_reg *reg = &pHwData->reg;
792 if( pHwData->SurpriseRemove ) return 1;
794 //read the bit16 of register U1B0
795 Wb35Reg_Read( pHwData, 0x3b0, ®->U1B0 );
796 if ((reg->U1B0 & 0x00010000)) {
797 pHwData->CurrentRadioHw = 1;
800 pHwData->CurrentRadioHw = 0;
805 unsigned char hal_get_dxx_reg( phw_data_t pHwData, u16 number, u32 * pValue )
807 if( number < 0x1000 )
809 return Wb35Reg_ReadSync( pHwData, number, pValue );
812 unsigned char hal_set_dxx_reg( phw_data_t pHwData, u16 number, u32 value )
816 if( number < 0x1000 )
818 ret = Wb35Reg_WriteSync( pHwData, number, value );
822 void hal_scan_status_indicate(phw_data_t pHwData, unsigned char IsOnProgress)
824 if( pHwData->SurpriseRemove ) return;
825 pHwData->LED_Scanning = IsOnProgress ? 1 : 0;
828 void hal_system_power_change(phw_data_t pHwData, u32 PowerState)
830 if( PowerState != 0 )
832 pHwData->SurpriseRemove = 1;
833 if( pHwData->WbUsb.IsUsb20 )
838 if( !pHwData->WbUsb.IsUsb20 )
843 void hal_surprise_remove( phw_data_t pHwData )
845 struct wb35_adapter * adapter = pHwData->adapter;
846 if (OS_ATOMIC_INC( adapter, &pHwData->SurpriseRemoveCount ) == 1) {
847 #ifdef _PE_STATE_DUMP_
848 WBDEBUG(("Calling hal_surprise_remove\n"));
854 void hal_rate_change( phw_data_t pHwData ) // Notify the HAL rate is changing 20060613.1
856 struct wb35_adapter * adapter = pHwData->adapter;
857 u8 rate = CURRENT_TX_RATE;
859 BBProcessor_RateChanging( pHwData, rate );
862 void hal_set_rf_power(phw_data_t pHwData, u8 PowerIndex)
864 RFSynthesizer_SetPowerIndex( pHwData, PowerIndex );
867 unsigned char hal_set_LED(phw_data_t pHwData, u32 Mode) // 20061108 for WPS led control
869 pHwData->LED_Blinking = 0;
870 pHwData->LED_control = Mode;
871 pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(10);
872 add_timer(&pHwData->LEDTimer);