aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorPekka Enberg <penberg@cs.helsinki.fi>2009-04-08 04:14:04 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-19 14:00:38 -0400
commita32b9810d920e28072b955ed020f21672fa7eac5 (patch)
treef0201f8043d591f2409518a13031b5bc8c6672cd /drivers/staging
parent9ca748ce517a09068a897fddf9672f2a3286573f (diff)
Staging: w35und: reformat wbusb.c
Impact: cleanup Use scripts/Lindent on the file and clean up the rest by hand. Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/winbond/wbusb.c563
1 files changed, 270 insertions, 293 deletions
diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c
index 692e19c8e8b..cb311416eef 100644
--- a/drivers/staging/winbond/wbusb.c
+++ b/drivers/staging/winbond/wbusb.c
@@ -19,13 +19,13 @@ MODULE_LICENSE("GPL");
19MODULE_VERSION("0.1"); 19MODULE_VERSION("0.1");
20 20
21static struct usb_device_id wb35_table[] __devinitdata = { 21static struct usb_device_id wb35_table[] __devinitdata = {
22 {USB_DEVICE(0x0416, 0x0035)}, 22 { USB_DEVICE(0x0416, 0x0035) },
23 {USB_DEVICE(0x18E8, 0x6201)}, 23 { USB_DEVICE(0x18E8, 0x6201) },
24 {USB_DEVICE(0x18E8, 0x6206)}, 24 { USB_DEVICE(0x18E8, 0x6206) },
25 {USB_DEVICE(0x18E8, 0x6217)}, 25 { USB_DEVICE(0x18E8, 0x6217) },
26 {USB_DEVICE(0x18E8, 0x6230)}, 26 { USB_DEVICE(0x18E8, 0x6230) },
27 {USB_DEVICE(0x18E8, 0x6233)}, 27 { USB_DEVICE(0x18E8, 0x6233) },
28 {USB_DEVICE(0x1131, 0x2035)}, 28 { USB_DEVICE(0x1131, 0x2035) },
29 { 0, } 29 { 0, }
30}; 30};
31 31
@@ -36,7 +36,7 @@ static struct ieee80211_rate wbsoft_rates[] = {
36}; 36};
37 37
38static struct ieee80211_channel wbsoft_channels[] = { 38static struct ieee80211_channel wbsoft_channels[] = {
39 { .center_freq = 2412}, 39 { .center_freq = 2412 },
40}; 40};
41 41
42static struct ieee80211_supported_band wbsoft_band_2GHz = { 42static struct ieee80211_supported_band wbsoft_band_2GHz = {
@@ -47,14 +47,14 @@ static struct ieee80211_supported_band wbsoft_band_2GHz = {
47}; 47};
48 48
49static int wbsoft_add_interface(struct ieee80211_hw *dev, 49static int wbsoft_add_interface(struct ieee80211_hw *dev,
50 struct ieee80211_if_init_conf *conf) 50 struct ieee80211_if_init_conf *conf)
51{ 51{
52 printk("wbsoft_add interface called\n"); 52 printk("wbsoft_add interface called\n");
53 return 0; 53 return 0;
54} 54}
55 55
56static void wbsoft_remove_interface(struct ieee80211_hw *dev, 56static void wbsoft_remove_interface(struct ieee80211_hw *dev,
57 struct ieee80211_if_init_conf *conf) 57 struct ieee80211_if_init_conf *conf)
58{ 58{
59 printk("wbsoft_remove interface called\n"); 59 printk("wbsoft_remove interface called\n");
60} 60}
@@ -79,9 +79,9 @@ static int wbsoft_get_tx_stats(struct ieee80211_hw *hw,
79} 79}
80 80
81static void wbsoft_configure_filter(struct ieee80211_hw *dev, 81static void wbsoft_configure_filter(struct ieee80211_hw *dev,
82 unsigned int changed_flags, 82 unsigned int changed_flags,
83 unsigned int *total_flags, 83 unsigned int *total_flags,
84 int mc_count, struct dev_mc_list *mclist) 84 int mc_count, struct dev_mc_list *mclist)
85{ 85{
86 unsigned int new_flags; 86 unsigned int new_flags;
87 87
@@ -106,7 +106,6 @@ static int wbsoft_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
106 return NETDEV_TX_OK; 106 return NETDEV_TX_OK;
107} 107}
108 108
109
110static int wbsoft_start(struct ieee80211_hw *dev) 109static int wbsoft_start(struct ieee80211_hw *dev)
111{ 110{
112 struct wbsoft_priv *priv = dev->priv; 111 struct wbsoft_priv *priv = dev->priv;
@@ -131,17 +130,17 @@ static int wbsoft_config(struct ieee80211_hw *dev, u32 changed)
131 hal_set_current_channel(&priv->sHwData, ch); 130 hal_set_current_channel(&priv->sHwData, ch);
132 hal_set_beacon_period(&priv->sHwData, conf->beacon_int); 131 hal_set_beacon_period(&priv->sHwData, conf->beacon_int);
133 hal_set_accept_broadcast(&priv->sHwData, 1); 132 hal_set_accept_broadcast(&priv->sHwData, 1);
134 hal_set_accept_promiscuous(&priv->sHwData, 1); 133 hal_set_accept_promiscuous(&priv->sHwData, 1);
135 hal_set_accept_multicast(&priv->sHwData, 1); 134 hal_set_accept_multicast(&priv->sHwData, 1);
136 hal_set_accept_beacon(&priv->sHwData, 1); 135 hal_set_accept_beacon(&priv->sHwData, 1);
137 hal_set_radio_mode(&priv->sHwData, 0); 136 hal_set_radio_mode(&priv->sHwData, 0);
138 137
139 return 0; 138 return 0;
140} 139}
141 140
142static int wbsoft_config_interface(struct ieee80211_hw *dev, 141static int wbsoft_config_interface(struct ieee80211_hw *dev,
143 struct ieee80211_vif *vif, 142 struct ieee80211_vif *vif,
144 struct ieee80211_if_conf *conf) 143 struct ieee80211_if_conf *conf)
145{ 144{
146 printk("wbsoft_config_interface called\n"); 145 printk("wbsoft_config_interface called\n");
147 return 0; 146 return 0;
@@ -169,285 +168,256 @@ static const struct ieee80211_ops wbsoft_ops = {
169 168
170static void hal_led_control(unsigned long data) 169static void hal_led_control(unsigned long data)
171{ 170{
172 struct wbsoft_priv *adapter = (struct wbsoft_priv *) data; 171 struct wbsoft_priv *adapter = (struct wbsoft_priv *)data;
173 struct hw_data * pHwData = &adapter->sHwData; 172 struct hw_data *pHwData = &adapter->sHwData;
174 struct wb35_reg *reg = &pHwData->reg; 173 struct wb35_reg *reg = &pHwData->reg;
175 u32 LEDSet = (pHwData->SoftwareSet & HAL_LED_SET_MASK) >> HAL_LED_SET_SHIFT; 174 u32 LEDSet = (pHwData->SoftwareSet & HAL_LED_SET_MASK) >> HAL_LED_SET_SHIFT;
176 u8 LEDgray[20] = { 0,3,4,6,8,10,11,12,13,14,15,14,13,12,11,10,8,6,4,2 }; 175 u8 LEDgray[20] = { 0, 3, 4, 6, 8, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 8, 6, 4, 2 };
177 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 }; 176 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 };
178 u32 TimeInterval = 500, ltmp, ltmp2; 177 u32 TimeInterval = 500, ltmp, ltmp2;
179 ltmp=0; 178 ltmp = 0;
180 179
181 if( pHwData->SurpriseRemove ) return; 180 if (pHwData->SurpriseRemove)
181 return;
182 182
183 if( pHwData->LED_control ) { 183 if (pHwData->LED_control) {
184 ltmp2 = pHwData->LED_control & 0xff; 184 ltmp2 = pHwData->LED_control & 0xff;
185 if( ltmp2 == 5 ) // 5 is WPS mode 185 if (ltmp2 == 5) // 5 is WPS mode
186 { 186 {
187 TimeInterval = 100; 187 TimeInterval = 100;
188 ltmp2 = (pHwData->LED_control>>8) & 0xff; 188 ltmp2 = (pHwData->LED_control >> 8) & 0xff;
189 switch( ltmp2 ) 189 switch (ltmp2) {
190 { 190 case 1: // [0.2 On][0.1 Off]...
191 case 1: // [0.2 On][0.1 Off]... 191 pHwData->LED_Blinking %= 3;
192 pHwData->LED_Blinking %= 3; 192 ltmp = 0x1010; // Led 1 & 0 Green and Red
193 ltmp = 0x1010; // Led 1 & 0 Green and Red 193 if (pHwData->LED_Blinking == 2) // Turn off
194 if( pHwData->LED_Blinking == 2 ) // Turn off 194 ltmp = 0;
195 ltmp = 0; 195 break;
196 break; 196 case 2: // [0.1 On][0.1 Off]...
197 case 2: // [0.1 On][0.1 Off]... 197 pHwData->LED_Blinking %= 2;
198 pHwData->LED_Blinking %= 2; 198 ltmp = 0x0010; // Led 0 red color
199 ltmp = 0x0010; // Led 0 red color 199 if (pHwData->LED_Blinking) // Turn off
200 if( pHwData->LED_Blinking ) // Turn off 200 ltmp = 0;
201 ltmp = 0; 201 break;
202 break; 202 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]...
203 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]... 203 pHwData->LED_Blinking %= 15;
204 pHwData->LED_Blinking %= 15; 204 ltmp = 0x0010; // Led 0 red color
205 ltmp = 0x0010; // Led 0 red color 205 if ((pHwData->LED_Blinking >= 9) || (pHwData->LED_Blinking % 2)) // Turn off 0.6 sec
206 if( (pHwData->LED_Blinking >= 9) || (pHwData->LED_Blinking%2) ) // Turn off 0.6 sec 206 ltmp = 0;
207 ltmp = 0; 207 break;
208 break; 208 case 4: // [300 On][ off ]
209 case 4: // [300 On][ off ] 209 ltmp = 0x1000; // Led 1 Green color
210 ltmp = 0x1000; // Led 1 Green color 210 if (pHwData->LED_Blinking >= 3000)
211 if( pHwData->LED_Blinking >= 3000 ) 211 ltmp = 0; // led maybe on after 300sec * 32bit counter overlap.
212 ltmp = 0; // led maybe on after 300sec * 32bit counter overlap. 212 break;
213 break;
214 } 213 }
215 pHwData->LED_Blinking++; 214 pHwData->LED_Blinking++;
216 215
217 reg->U1BC_LEDConfigure = ltmp; 216 reg->U1BC_LEDConfigure = ltmp;
218 if( LEDSet != 7 ) // Only 111 mode has 2 LEDs on PCB. 217 if (LEDSet != 7) // Only 111 mode has 2 LEDs on PCB.
219 { 218 {
220 reg->U1BC_LEDConfigure |= (ltmp &0xff)<<8; // Copy LED result to each LED control register 219 reg->U1BC_LEDConfigure |= (ltmp & 0xff) << 8; // Copy LED result to each LED control register
221 reg->U1BC_LEDConfigure |= (ltmp &0xff00)>>8; 220 reg->U1BC_LEDConfigure |= (ltmp & 0xff00) >> 8;
222 } 221 }
223 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); 222 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure);
224 } 223 }
225 } 224 } else if (pHwData->CurrentRadioSw || pHwData->CurrentRadioHw) // If radio off
226 else if( pHwData->CurrentRadioSw || pHwData->CurrentRadioHw ) // If radio off
227 { 225 {
228 if( reg->U1BC_LEDConfigure & 0x1010 ) 226 if (reg->U1BC_LEDConfigure & 0x1010) {
229 {
230 reg->U1BC_LEDConfigure &= ~0x1010; 227 reg->U1BC_LEDConfigure &= ~0x1010;
231 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); 228 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure);
232 } 229 }
233 } 230 } else {
234 else 231 switch (LEDSet) {
235 { 232 case 4: // [100] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
236 switch( LEDSet ) 233 if (!pHwData->LED_LinkOn) // Blink only if not Link On
237 { 234 {
238 case 4: // [100] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing 235 // Blinking if scanning is on progress
239 if( !pHwData->LED_LinkOn ) // Blink only if not Link On 236 if (pHwData->LED_Scanning) {
240 { 237 if (pHwData->LED_Blinking == 0) {
241 // Blinking if scanning is on progress 238 reg->U1BC_LEDConfigure |= 0x10;
242 if( pHwData->LED_Scanning ) 239 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 On
243 { 240 pHwData->LED_Blinking = 1;
244 if( pHwData->LED_Blinking == 0 ) 241 TimeInterval = 300;
245 { 242 } else {
246 reg->U1BC_LEDConfigure |= 0x10; 243 reg->U1BC_LEDConfigure &= ~0x10;
247 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 On 244 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
248 pHwData->LED_Blinking = 1; 245 pHwData->LED_Blinking = 0;
249 TimeInterval = 300; 246 TimeInterval = 300;
250 }
251 else
252 {
253 reg->U1BC_LEDConfigure &= ~0x10;
254 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
255 pHwData->LED_Blinking = 0;
256 TimeInterval = 300;
257 }
258 } 247 }
259 else 248 } else {
260 { 249 //Turn Off LED_0
261 //Turn Off LED_0 250 if (reg->U1BC_LEDConfigure & 0x10) {
262 if( reg->U1BC_LEDConfigure & 0x10 ) 251 reg->U1BC_LEDConfigure &= ~0x10;
263 { 252 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
264 reg->U1BC_LEDConfigure &= ~0x10;
265 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
266 }
267 } 253 }
268 } 254 }
269 else 255 } else {
270 { 256 // Turn On LED_0
271 // Turn On LED_0 257 if ((reg->U1BC_LEDConfigure & 0x10) == 0) {
272 if( (reg->U1BC_LEDConfigure & 0x10) == 0 ) 258 reg->U1BC_LEDConfigure |= 0x10;
273 { 259 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
274 reg->U1BC_LEDConfigure |= 0x10;
275 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
276 }
277 } 260 }
278 break; 261 }
262 break;
279 263
280 case 6: // [110] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing 264 case 6: // [110] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
281 if( !pHwData->LED_LinkOn ) // Blink only if not Link On 265 if (!pHwData->LED_LinkOn) // Blink only if not Link On
282 { 266 {
283 // Blinking if scanning is on progress 267 // Blinking if scanning is on progress
284 if( pHwData->LED_Scanning ) 268 if (pHwData->LED_Scanning) {
285 { 269 if (pHwData->LED_Blinking == 0) {
286 if( pHwData->LED_Blinking == 0 ) 270 reg->U1BC_LEDConfigure &= ~0xf;
287 { 271 reg->U1BC_LEDConfigure |= 0x10;
288 reg->U1BC_LEDConfigure &= ~0xf; 272 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 On
289 reg->U1BC_LEDConfigure |= 0x10; 273 pHwData->LED_Blinking = 1;
290 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 On 274 TimeInterval = 300;
291 pHwData->LED_Blinking = 1; 275 } else {
292 TimeInterval = 300;
293 }
294 else
295 {
296 reg->U1BC_LEDConfigure &= ~0x1f;
297 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
298 pHwData->LED_Blinking = 0;
299 TimeInterval = 300;
300 }
301 }
302 else
303 {
304 // 20060901 Gray blinking if in disconnect state and not scanning
305 ltmp = reg->U1BC_LEDConfigure;
306 reg->U1BC_LEDConfigure &= ~0x1f; 276 reg->U1BC_LEDConfigure &= ~0x1f;
307 if( LEDgray2[(pHwData->LED_Blinking%30)] ) 277 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
308 { 278 pHwData->LED_Blinking = 0;
309 reg->U1BC_LEDConfigure |= 0x10; 279 TimeInterval = 300;
310 reg->U1BC_LEDConfigure |= LEDgray2[ (pHwData->LED_Blinking%30) ];
311 }
312 pHwData->LED_Blinking++;
313 if( reg->U1BC_LEDConfigure != ltmp )
314 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
315 TimeInterval = 100;
316 } 280 }
317 } 281 } else {
318 else 282 // 20060901 Gray blinking if in disconnect state and not scanning
319 { 283 ltmp = reg->U1BC_LEDConfigure;
320 // Turn On LED_0 284 reg->U1BC_LEDConfigure &= ~0x1f;
321 if( (reg->U1BC_LEDConfigure & 0x10) == 0 ) 285 if (LEDgray2[(pHwData->LED_Blinking % 30)]) {
322 {
323 reg->U1BC_LEDConfigure |= 0x10; 286 reg->U1BC_LEDConfigure |= 0x10;
324 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off 287 reg->U1BC_LEDConfigure |=
288 LEDgray2[(pHwData->LED_Blinking % 30)];
325 } 289 }
290 pHwData->LED_Blinking++;
291 if (reg->U1BC_LEDConfigure != ltmp)
292 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
293 TimeInterval = 100;
326 } 294 }
327 break; 295 } else {
296 // Turn On LED_0
297 if ((reg->U1BC_LEDConfigure & 0x10) == 0) {
298 reg->U1BC_LEDConfigure |= 0x10;
299 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
300 }
301 }
302 break;
328 303
329 case 5: // [101] Only 1 Led be placed on PCB and use LED_1 for showing 304 case 5: // [101] Only 1 Led be placed on PCB and use LED_1 for showing
330 if( !pHwData->LED_LinkOn ) // Blink only if not Link On 305 if (!pHwData->LED_LinkOn) // Blink only if not Link On
331 { 306 {
332 // Blinking if scanning is on progress 307 // Blinking if scanning is on progress
333 if( pHwData->LED_Scanning ) 308 if (pHwData->LED_Scanning) {
334 { 309 if (pHwData->LED_Blinking == 0) {
335 if( pHwData->LED_Blinking == 0 ) 310 reg->U1BC_LEDConfigure |=
336 { 311 0x1000;
337 reg->U1BC_LEDConfigure |= 0x1000; 312 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 On
338 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On 313 pHwData->LED_Blinking = 1;
339 pHwData->LED_Blinking = 1; 314 TimeInterval = 300;
340 TimeInterval = 300; 315 } else {
341 } 316 reg->U1BC_LEDConfigure &=
342 else 317 ~0x1000;
343 { 318 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 Off
344 reg->U1BC_LEDConfigure &= ~0x1000; 319 pHwData->LED_Blinking = 0;
345 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 Off 320 TimeInterval = 300;
346 pHwData->LED_Blinking = 0;
347 TimeInterval = 300;
348 }
349 } 321 }
350 else 322 } else {
351 { 323 //Turn Off LED_1
352 //Turn Off LED_1 324 if (reg->U1BC_LEDConfigure & 0x1000) {
353 if( reg->U1BC_LEDConfigure & 0x1000 ) 325 reg->U1BC_LEDConfigure &=
354 { 326 ~0x1000;
355 reg->U1BC_LEDConfigure &= ~0x1000; 327 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 Off
356 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 Off
357 }
358 } 328 }
359 } 329 }
360 else 330 } else {
361 { 331 // Is transmitting/receiving ??
362 // Is transmitting/receiving ?? 332 if ((adapter->RxByteCount !=
363 if( (adapter->RxByteCount != pHwData->RxByteCountLast ) || 333 pHwData->RxByteCountLast)
364 (adapter->TxByteCount != pHwData->TxByteCountLast ) ) 334 || (adapter->TxByteCount !=
365 { 335 pHwData->TxByteCountLast)) {
366 if( (reg->U1BC_LEDConfigure & 0x3000) != 0x3000 ) 336 if ((reg->U1BC_LEDConfigure & 0x3000) !=
367 { 337 0x3000) {
368 reg->U1BC_LEDConfigure |= 0x3000; 338 reg->U1BC_LEDConfigure |=
369 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On 339 0x3000;
370 } 340 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 On
371
372 // Update variable
373 pHwData->RxByteCountLast = adapter->RxByteCount;
374 pHwData->TxByteCountLast = adapter->TxByteCount;
375 TimeInterval = 200;
376 } 341 }
377 else 342 // Update variable
378 { 343 pHwData->RxByteCountLast =
379 // Turn On LED_1 and blinking if transmitting/receiving 344 adapter->RxByteCount;
380 if( (reg->U1BC_LEDConfigure & 0x3000) != 0x1000 ) 345 pHwData->TxByteCountLast =
381 { 346 adapter->TxByteCount;
382 reg->U1BC_LEDConfigure &= ~0x3000; 347 TimeInterval = 200;
383 reg->U1BC_LEDConfigure |= 0x1000; 348 } else {
384 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On 349 // Turn On LED_1 and blinking if transmitting/receiving
385 } 350 if ((reg->U1BC_LEDConfigure & 0x3000) !=
351 0x1000) {
352 reg->U1BC_LEDConfigure &=
353 ~0x3000;
354 reg->U1BC_LEDConfigure |=
355 0x1000;
356 Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 On
386 } 357 }
387 } 358 }
388 break; 359 }
360 break;
389 361
390 default: // Default setting. 2 LED be placed on PCB. LED_0: Link On LED_1 Active 362 default: // Default setting. 2 LED be placed on PCB. LED_0: Link On LED_1 Active
391 if( (reg->U1BC_LEDConfigure & 0x3000) != 0x3000 ) 363 if ((reg->U1BC_LEDConfigure & 0x3000) != 0x3000) {
392 { 364 reg->U1BC_LEDConfigure |= 0x3000; // LED_1 is always on and event enable
393 reg->U1BC_LEDConfigure |= 0x3000;// LED_1 is always on and event enable 365 Wb35Reg_Write(pHwData, 0x03bc,
394 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); 366 reg->U1BC_LEDConfigure);
395 } 367 }
396 368
397 if( pHwData->LED_Blinking ) 369 if (pHwData->LED_Blinking) {
398 { 370 // Gray blinking
399 // Gray blinking 371 reg->U1BC_LEDConfigure &= ~0x0f;
372 reg->U1BC_LEDConfigure |= 0x10;
373 reg->U1BC_LEDConfigure |=
374 LEDgray[(pHwData->LED_Blinking - 1) % 20];
375 Wb35Reg_Write(pHwData, 0x03bc,
376 reg->U1BC_LEDConfigure);
377
378 pHwData->LED_Blinking += 2;
379 if (pHwData->LED_Blinking < 40)
380 TimeInterval = 100;
381 else {
382 pHwData->LED_Blinking = 0; // Stop blinking
400 reg->U1BC_LEDConfigure &= ~0x0f; 383 reg->U1BC_LEDConfigure &= ~0x0f;
401 reg->U1BC_LEDConfigure |= 0x10; 384 Wb35Reg_Write(pHwData, 0x03bc,
402 reg->U1BC_LEDConfigure |= LEDgray[ (pHwData->LED_Blinking-1)%20 ]; 385 reg->U1BC_LEDConfigure);
403 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
404
405 pHwData->LED_Blinking += 2;
406 if( pHwData->LED_Blinking < 40 )
407 TimeInterval = 100;
408 else
409 {
410 pHwData->LED_Blinking = 0; // Stop blinking
411 reg->U1BC_LEDConfigure &= ~0x0f;
412 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
413 }
414 break;
415 } 386 }
387 break;
388 }
416 389
417 if( pHwData->LED_LinkOn ) 390 if (pHwData->LED_LinkOn) {
391 if (!(reg->U1BC_LEDConfigure & 0x10)) // Check the LED_0
418 { 392 {
419 if( !(reg->U1BC_LEDConfigure & 0x10) ) // Check the LED_0 393 //Try to turn ON LED_0 after gray blinking
420 { 394 reg->U1BC_LEDConfigure |= 0x10;
421 //Try to turn ON LED_0 after gray blinking 395 pHwData->LED_Blinking = 1; //Start blinking
422 reg->U1BC_LEDConfigure |= 0x10; 396 TimeInterval = 50;
423 pHwData->LED_Blinking = 1; //Start blinking
424 TimeInterval = 50;
425 }
426 } 397 }
427 else 398 } else {
399 if (reg->U1BC_LEDConfigure & 0x10) // Check the LED_0
428 { 400 {
429 if( reg->U1BC_LEDConfigure & 0x10 ) // Check the LED_0 401 reg->U1BC_LEDConfigure &= ~0x10;
430 { 402 Wb35Reg_Write(pHwData, 0x03bc,
431 reg->U1BC_LEDConfigure &= ~0x10; 403 reg->U1BC_LEDConfigure);
432 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
433 }
434 } 404 }
435 break; 405 }
406 break;
436 } 407 }
437 408
438 //20060828.1 Active send null packet to avoid AP disconnect 409 //20060828.1 Active send null packet to avoid AP disconnect
439 if( pHwData->LED_LinkOn ) 410 if (pHwData->LED_LinkOn) {
440 {
441 pHwData->NullPacketCount += TimeInterval; 411 pHwData->NullPacketCount += TimeInterval;
442 if( pHwData->NullPacketCount >= DEFAULT_NULL_PACKET_COUNT ) 412 if (pHwData->NullPacketCount >=
443 { 413 DEFAULT_NULL_PACKET_COUNT) {
444 pHwData->NullPacketCount = 0; 414 pHwData->NullPacketCount = 0;
445 } 415 }
446 } 416 }
447 } 417 }
448 418
449 pHwData->time_count += TimeInterval; 419 pHwData->time_count += TimeInterval;
450 Wb35Tx_CurrentTime(adapter, pHwData->time_count); // 20060928 add 420 Wb35Tx_CurrentTime(adapter, pHwData->time_count); // 20060928 add
451 pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(TimeInterval); 421 pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(TimeInterval);
452 add_timer(&pHwData->LEDTimer); 422 add_timer(&pHwData->LEDTimer);
453} 423}
@@ -455,7 +425,7 @@ static void hal_led_control(unsigned long data)
455static int hal_init_hardware(struct ieee80211_hw *hw) 425static int hal_init_hardware(struct ieee80211_hw *hw)
456{ 426{
457 struct wbsoft_priv *priv = hw->priv; 427 struct wbsoft_priv *priv = hw->priv;
458 struct hw_data * pHwData = &priv->sHwData; 428 struct hw_data *pHwData = &priv->sHwData;
459 u16 SoftwareSet; 429 u16 SoftwareSet;
460 430
461 pHwData->MaxReceiveLifeTime = DEFAULT_MSDU_LIFE_TIME; 431 pHwData->MaxReceiveLifeTime = DEFAULT_MSDU_LIFE_TIME;
@@ -472,18 +442,18 @@ static int hal_init_hardware(struct ieee80211_hw *hw)
472 442
473 init_timer(&pHwData->LEDTimer); 443 init_timer(&pHwData->LEDTimer);
474 pHwData->LEDTimer.function = hal_led_control; 444 pHwData->LEDTimer.function = hal_led_control;
475 pHwData->LEDTimer.data = (unsigned long) priv; 445 pHwData->LEDTimer.data = (unsigned long)priv;
476 pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(1000); 446 pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(1000);
477 add_timer(&pHwData->LEDTimer); 447 add_timer(&pHwData->LEDTimer);
478 448
479 SoftwareSet = hal_software_set( pHwData ); 449 SoftwareSet = hal_software_set(pHwData);
480 450
481 #ifdef Vendor2 451#ifdef Vendor2
482 // Try to make sure the EEPROM contain 452 // Try to make sure the EEPROM contain
483 SoftwareSet >>= 8; 453 SoftwareSet >>= 8;
484 if( SoftwareSet != 0x82 ) 454 if (SoftwareSet != 0x82)
485 return false; 455 return false;
486 #endif 456#endif
487 457
488 Wb35Rx_start(hw); 458 Wb35Rx_start(hw);
489 Wb35Tx_EP2VM_start(priv); 459 Wb35Tx_EP2VM_start(priv);
@@ -504,40 +474,41 @@ error_reg_destroy:
504static int wb35_hw_init(struct ieee80211_hw *hw) 474static int wb35_hw_init(struct ieee80211_hw *hw)
505{ 475{
506 struct wbsoft_priv *priv = hw->priv; 476 struct wbsoft_priv *priv = hw->priv;
507 struct hw_data * pHwData = &priv->sHwData; 477 struct hw_data *pHwData = &priv->sHwData;
508 u8 *pMacAddr; 478 u8 EEPROM_region;
509 u8 *pMacAddr2; 479 u8 HwRadioOff;
510 u8 EEPROM_region; 480 u8 *pMacAddr2;
511 u8 HwRadioOff; 481 u8 *pMacAddr;
512 int err; 482 int err;
513 483
514 priv->sLocalPara.region_INF = REGION_AUTO;
515 priv->sLocalPara.TxRateMode = RATE_AUTO;
516 priv->sLocalPara.bMacOperationMode = MODE_802_11_BG;
517 priv->Mds.TxRTSThreshold = DEFAULT_RTSThreshold;
518 priv->Mds.TxFragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD;
519 priv->sLocalPara.MTUsize = MAX_ETHERNET_PACKET_SIZE;
520 priv->sLocalPara.bPreambleMode = AUTO_MODE;
521 priv->sLocalPara.RadioOffStatus.boSwRadioOff = false;
522
523 pHwData->phy_type = RF_DECIDE_BY_INF; 484 pHwData->phy_type = RF_DECIDE_BY_INF;
524 485
525 priv->sLocalPara.bWepKeyError= false; 486 priv->Mds.TxRTSThreshold = DEFAULT_RTSThreshold;
526 priv->sLocalPara.bToSelfPacketReceived = false; 487 priv->Mds.TxFragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD;
527 priv->sLocalPara.WepKeyDetectTimerCount= 2 * 100; /* 2 seconds */ 488
489 priv->sLocalPara.region_INF = REGION_AUTO;
490 priv->sLocalPara.TxRateMode = RATE_AUTO;
491 priv->sLocalPara.bMacOperationMode = MODE_802_11_BG;
492 priv->sLocalPara.MTUsize = MAX_ETHERNET_PACKET_SIZE;
493 priv->sLocalPara.bPreambleMode = AUTO_MODE;
494 priv->sLocalPara.bWepKeyError = false;
495 priv->sLocalPara.bToSelfPacketReceived = false;
496 priv->sLocalPara.WepKeyDetectTimerCount = 2 * 100; /* 2 seconds */
497
498 priv->sLocalPara.RadioOffStatus.boSwRadioOff = false;
528 499
529 err = hal_init_hardware(hw); 500 err = hal_init_hardware(hw);
530 if (err) 501 if (err)
531 goto error; 502 goto error;
532 503
533 EEPROM_region = hal_get_region_from_EEPROM( pHwData ); 504 EEPROM_region = hal_get_region_from_EEPROM(pHwData);
534 if (EEPROM_region != REGION_AUTO) 505 if (EEPROM_region != REGION_AUTO)
535 priv->sLocalPara.region = EEPROM_region; 506 priv->sLocalPara.region = EEPROM_region;
536 else { 507 else {
537 if (priv->sLocalPara.region_INF != REGION_AUTO) 508 if (priv->sLocalPara.region_INF != REGION_AUTO)
538 priv->sLocalPara.region = priv->sLocalPara.region_INF; 509 priv->sLocalPara.region = priv->sLocalPara.region_INF;
539 else 510 else
540 priv->sLocalPara.region = REGION_USA; /* default setting */ 511 priv->sLocalPara.region = REGION_USA; /* default setting */
541 } 512 }
542 513
543 // Get Software setting flag from hal 514 // Get Software setting flag from hal
@@ -555,19 +526,20 @@ static int wb35_hw_init(struct ieee80211_hw *hw)
555 pMacAddr2 = priv->sLocalPara.PermanentAddress; 526 pMacAddr2 = priv->sLocalPara.PermanentAddress;
556 527
557 /* Reading ethernet address from EEPROM */ 528 /* Reading ethernet address from EEPROM */
558 hal_get_permanent_address( pHwData, priv->sLocalPara.PermanentAddress ); 529 hal_get_permanent_address(pHwData, priv->sLocalPara.PermanentAddress);
559 if (memcmp(pMacAddr, "\x00\x00\x00\x00\x00\x00", MAC_ADDR_LENGTH) == 0) 530 if (memcmp(pMacAddr, "\x00\x00\x00\x00\x00\x00", MAC_ADDR_LENGTH) == 0)
560 memcpy(pMacAddr, pMacAddr2, MAC_ADDR_LENGTH); 531 memcpy(pMacAddr, pMacAddr2, MAC_ADDR_LENGTH);
561 else { 532 else {
562 /* Set the user define MAC address */ 533 /* Set the user define MAC address */
563 hal_set_ethernet_address(pHwData, priv->sLocalPara.ThisMacAddress); 534 hal_set_ethernet_address(pHwData,
535 priv->sLocalPara.ThisMacAddress);
564 } 536 }
565 537
566 priv->sLocalPara.bAntennaNo = hal_get_antenna_number(pHwData); 538 priv->sLocalPara.bAntennaNo = hal_get_antenna_number(pHwData);
567#ifdef _PE_STATE_DUMP_ 539#ifdef _PE_STATE_DUMP_
568 printk("Driver init, antenna no = %d\n", psLOCAL->bAntennaNo); 540 printk("Driver init, antenna no = %d\n", psLOCAL->bAntennaNo);
569#endif 541#endif
570 hal_get_hw_radio_off( pHwData ); 542 hal_get_hw_radio_off(pHwData);
571 543
572 /* Waiting for HAL setting OK */ 544 /* Waiting for HAL setting OK */
573 while (!hal_idle(pHwData)) 545 while (!hal_idle(pHwData))
@@ -575,10 +547,14 @@ static int wb35_hw_init(struct ieee80211_hw *hw)
575 547
576 MTO_Init(priv); 548 MTO_Init(priv);
577 549
578 HwRadioOff = hal_get_hw_radio_off( pHwData ); 550 HwRadioOff = hal_get_hw_radio_off(pHwData);
579 priv->sLocalPara.RadioOffStatus.boHwRadioOff = !!HwRadioOff; 551 priv->sLocalPara.RadioOffStatus.boHwRadioOff = !!HwRadioOff;
580 552
581 hal_set_radio_mode( pHwData, (unsigned char)(priv->sLocalPara.RadioOffStatus.boSwRadioOff || priv->sLocalPara.RadioOffStatus.boHwRadioOff) ); 553 hal_set_radio_mode(pHwData,
554 (unsigned char)(priv->sLocalPara.RadioOffStatus.
555 boSwRadioOff
556 || priv->sLocalPara.RadioOffStatus.
557 boHwRadioOff));
582 558
583 /* Notify hal that the driver is ready now. */ 559 /* Notify hal that the driver is ready now. */
584 hal_driver_init_OK(pHwData) = 1; 560 hal_driver_init_OK(pHwData) = 1;
@@ -587,23 +563,25 @@ error:
587 return err; 563 return err;
588} 564}
589 565
590static int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id_table) 566static int wb35_probe(struct usb_interface *intf,
567 const struct usb_device_id *id_table)
591{ 568{
592 struct wb_usb *pWbUsb;
593 struct usb_host_interface *interface;
594 struct usb_endpoint_descriptor *endpoint;
595 u32 ltmp;
596 struct usb_device *udev = interface_to_usbdev(intf); 569 struct usb_device *udev = interface_to_usbdev(intf);
597 struct wbsoft_priv *priv; 570 struct usb_endpoint_descriptor *endpoint;
571 struct usb_host_interface *interface;
598 struct ieee80211_hw *dev; 572 struct ieee80211_hw *dev;
573 struct wbsoft_priv *priv;
574 struct wb_usb *pWbUsb;
599 int nr, err; 575 int nr, err;
576 u32 ltmp;
600 577
601 usb_get_dev(udev); 578 usb_get_dev(udev);
602 579
603 /* Check the device if it already be opened */ 580 /* Check the device if it already be opened */
604 nr = usb_control_msg(udev, usb_rcvctrlpipe( udev, 0 ), 581 nr = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
605 0x01, USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN, 582 0x01,
606 0x0, 0x400, &ltmp, 4, HZ*100 ); 583 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
584 0x0, 0x400, &ltmp, 4, HZ * 100);
607 if (nr < 0) { 585 if (nr < 0) {
608 err = nr; 586 err = nr;
609 goto error; 587 goto error;
@@ -629,8 +607,8 @@ static int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id
629 pWbUsb = &priv->sHwData.WbUsb; 607 pWbUsb = &priv->sHwData.WbUsb;
630 pWbUsb->udev = udev; 608 pWbUsb->udev = udev;
631 609
632 interface = intf->cur_altsetting; 610 interface = intf->cur_altsetting;
633 endpoint = &interface->endpoint[0].desc; 611 endpoint = &interface->endpoint[0].desc;
634 612
635 if (endpoint[2].wMaxPacketSize == 512) { 613 if (endpoint[2].wMaxPacketSize == 512) {
636 printk("[w35und] Working on USB 2.0\n"); 614 printk("[w35und] Working on USB 2.0\n");
@@ -643,8 +621,8 @@ static int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id
643 621
644 SET_IEEE80211_DEV(dev, &udev->dev); 622 SET_IEEE80211_DEV(dev, &udev->dev);
645 { 623 {
646 struct hw_data * pHwData = &priv->sHwData; 624 struct hw_data *pHwData = &priv->sHwData;
647 unsigned char dev_addr[MAX_ADDR_LEN]; 625 unsigned char dev_addr[MAX_ADDR_LEN];
648 hal_get_permanent_address(pHwData, dev_addr); 626 hal_get_permanent_address(pHwData, dev_addr);
649 SET_IEEE80211_PERM_ADDR(dev, dev_addr); 627 SET_IEEE80211_PERM_ADDR(dev, dev_addr);
650 } 628 }
@@ -686,10 +664,10 @@ static void hal_halt(struct hw_data *pHwData)
686 664
687static void wb35_hw_halt(struct wbsoft_priv *adapter) 665static void wb35_hw_halt(struct wbsoft_priv *adapter)
688{ 666{
689 Mds_Destroy( adapter ); 667 Mds_Destroy(adapter);
690 668
691 /* Turn off Rx and Tx hardware ability */ 669 /* Turn off Rx and Tx hardware ability */
692 hal_stop( &adapter->sHwData ); 670 hal_stop(&adapter->sHwData);
693#ifdef _PE_USB_INI_DUMP_ 671#ifdef _PE_USB_INI_DUMP_
694 printk("[w35und] Hal_stop O.K.\n"); 672 printk("[w35und] Hal_stop O.K.\n");
695#endif 673#endif
@@ -699,7 +677,6 @@ static void wb35_hw_halt(struct wbsoft_priv *adapter)
699 hal_halt(&adapter->sHwData); 677 hal_halt(&adapter->sHwData);
700} 678}
701 679
702
703static void wb35_disconnect(struct usb_interface *intf) 680static void wb35_disconnect(struct usb_interface *intf)
704{ 681{
705 struct ieee80211_hw *hw = usb_get_intfdata(intf); 682 struct ieee80211_hw *hw = usb_get_intfdata(intf);