1 /**************************************************************************** 2 **+-----------------------------------------------------------------------+** 3 **| |** 4 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |** 5 **| All rights reserved. |** 6 **| |** 7 **| Redistribution and use in source and binary forms, with or without |** 8 **| modification, are permitted provided that the following conditions |** 9 **| are met: |** 10 **| |** 11 **| * Redistributions of source code must retain the above copyright |** 12 **| notice, this list of conditions and the following disclaimer. |** 13 **| * Redistributions in binary form must reproduce the above copyright |** 14 **| notice, this list of conditions and the following disclaimer in |** 15 **| the documentation and/or other materials provided with the |** 16 **| distribution. |** 17 **| * Neither the name Texas Instruments nor the names of its |** 18 **| contributors may be used to endorse or promote products derived |** 19 **| from this software without specific prior written permission. |** 20 **| |** 21 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |** 22 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |** 23 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |** 24 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |** 25 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |** 26 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |** 27 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |** 28 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |** 29 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |** 30 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |** 31 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |** 32 **| |** 33 **+-----------------------------------------------------------------------+** 34 ****************************************************************************/ 35 36 37 #include "arch_ti.h" 38 39 #include <linux/stddef.h> 40 #include <linux/string.h> 41 #include <linux/time.h> 42 #include <linux/timer.h> 43 #include <linux/module.h> 44 #include <linux/kernel.h> 45 #include <linux/netdevice.h> 46 #include <linux/etherdevice.h> 47 #include <linux/vmalloc.h> 48 #include <linux/string.h> 49 #include <linux/delay.h> 50 #include <linux/time.h> 51 #include <linux/list.h> 52 #include <asm/io.h> 53 54 #include "debug_module.h" 55 #include "esta_drv.h" 56 #ifdef DRIVER_PROFILING 57 #include "tiwlan_profile.h" 58 #endif 59 #include "osApi.h" 60 #include "osTIType.h" 61 #include "srcApi.h" 62 #include "whalHwRegs.h" 63 #include "bmtrace.h" 64 #include "TI_IPC_Api.h" 65 #include "whalBus_Defs.h" 66 #include "802_11Defs.h" 67 #include "Ethernet.h" 68 69 #define OS_PROTECT_HANDLE 0xffffeee0 70 /*#define DEBUG_REG_ACCESS*/ 71 72 #ifdef DEBUG_REG_ACCESS 73 #define PRINT_REG(fmt, args...) print_info(fmt, args) 74 #else 75 #define PRINT_REG(fmt, args...) 76 #endif 77 #define NOPRINT_REG(fmt, args...) 78 79 #ifdef ESTA_TIMER_DEBUG 80 #define esta_timer_log(fmt,args...) printk(fmt, ## args) 81 #else 82 #define esta_timer_log(fmt,args...) 83 #endif 84 85 #define FRAG_SIZE 200 86 87 /* Wlan chip reset defines */ 88 #define GPIO_16 16 89 #define GPIO_16_DIRECTION_OUTPUT 0 90 #define GPIO_16_CLEAR 0 91 #define GPIO_16_SET 1 92 93 #define GPIO1_IRQSTATUS1 0xFFFBE418 94 #define GPIO1_DATAIN 0xFFFBE42C 95 96 /********************* LOCAL DECLARATIONS ************************/ 97 static inline void os_timer_dec_use_count(timer_obj_t *tmr); 98 static int os_tl_timerHandlr(struct tiwlan_req *req); 99 static void os_timerHandlr(unsigned long parm); 100 static void send_frag(char* msg, int message_len, int level, int module); 101 102 BOOL use_debug_module = FALSE; 103 104 /**************************************************************************************** 105 * * 106 * OS Report API * 107 * * 108 ****************************************************************************************/ 109 110 /**************************************************************************************** 111 * os_setDebugMode() 112 **************************************************************************************** 113 DESCRIPTION: Set the Debug Mode 114 115 INPUT: 116 117 RETURN: None 118 119 NOTES: 120 *****************************************************************************************/ 121 void os_setDebugMode(BOOL enable) 122 { 123 use_debug_module = enable; 124 } 125 126 127 /**************************************************************************************** 128 * os_printf() 129 **************************************************************************************** 130 DESCRIPTION: Print formatted output. 131 132 INPUT: format - Specifies the string, to be printed 133 134 RETURN: None 135 136 NOTES: 137 *****************************************************************************************/ 138 void os_printf(const char *format ,...) 139 { 140 static int from_new_line = 1; /* Used to save the last message EOL */ 141 static UINT8 module = 0; /* Used to save the last message module */ 142 static UINT8 level = 0; /* Used to save the last message level */ 143 va_list ap; 144 static char msg[500]; 145 char *p_msg = msg; /* Pointer to the message */ 146 UINT16 message_len; 147 UINT32 sec = 0; 148 UINT32 uSec = 0; 149 150 /* Format the message and keep the message length */ 151 va_start(ap,format); 152 message_len = vsnprintf(&msg[1], sizeof(msg) - 1, format, ap); 153 154 155 if (use_debug_module) 156 { 157 /*********************/ 158 /* Use debug module */ 159 /*******************/ 160 161 if (msg[1] == '$') 162 { 163 /************************************ 164 Message format: "$XX" 165 ||| 166 message prefix ----||| 167 module index -------|| 168 severity index ------| 169 ************************************/ 170 171 level = (msg[2] - 'A'); 172 module = (msg[3] - 'A'); 173 } 174 else 175 { 176 send_frag(msg, message_len, level, module); 177 } 178 } 179 else 180 { 181 /***********************/ 182 /* Use regular printk */ 183 /*********************/ 184 185 if( from_new_line ) 186 { 187 if (msg[1] == '$') 188 { 189 p_msg += 4; 190 } 191 192 sec = os_timeStampUs(NULL); 193 uSec = sec % 1000000; 194 sec /= 1000000; 195 196 printk(KERN_INFO DRIVER_NAME ": %d.%06d: %s",sec,uSec,p_msg); 197 } 198 else 199 { 200 printk(&msg[1]); 201 } 202 203 from_new_line = ( msg[message_len] == '\n' ); 204 } 205 } 206 207 static void send_frag(char* msg, int message_len, int level, int module) 208 { 209 #ifdef TIWLAN_OMAP1610 /* Dm: */ 210 int return_value; 211 int offset = 1; 212 int TmpLen; 213 char* FragMsg; 214 215 do 216 { 217 TmpLen = min(message_len - offset, FRAG_SIZE); 218 FragMsg = msg + offset - 1; 219 FragMsg[0] = module; 220 221 return_value = debug_module_enqueue_message(DEBUG_MODULE_TRACE_QUEUE_ID, level, FragMsg, TmpLen+1, CONTROL_CODE_TYPE_MESSAGE); 222 223 if (return_value) 224 { 225 /* Message overrun */ 226 227 /* Send the overrun indication to the debug module */ 228 os_memoryCopy(NULL, &msg[1], "*** Message Overrun ***", strlen("*** Message Overrun ***")); 229 msg[0] = 0; 230 debug_module_enqueue_message(DEBUG_MODULE_TRACE_QUEUE_ID, 0, msg, (strlen("*** Message Overrun ***") + 1), CONTROL_CODE_TYPE_MESSAGE); 231 232 /* Print overrun indication to the terminal */ 233 /*printk(KERN_INFO DRIVER_NAME ": %d.%06d: %s\n", sec, uSec, "**** Debug module message overrun! ****\n");*/ 234 } 235 offset += TmpLen; 236 }while (offset < message_len); 237 238 #endif 239 } 240 241 /**************************************************************************************** 242 * * 243 * OS DMA CALLBACK API * 244 ****************************************************************************************/ 245 246 /**************************************************************************************** 247 * os_TNETWIF_BusTxn_Complete() 248 **************************************************************************************** 249 DESCRIPTION: Callback directly called at an IRQ context from the SPI modue 250 This should triger a tasklet_schedule so that the End of DMA will be handled 251 in a tasklet context and then be directed to the TNETWIF to call the Client callback. 252 253 INPUT: OsContext - our adapter context. 254 255 RETURN: None 256 257 NOTES: 258 *****************************************************************************************/ 259 void os_TNETWIF_BusTxn_Complete(TI_HANDLE OsContext,int status) 260 { 261 tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext; 262 263 drv->dma_done = 1; 264 #ifdef DM_USE_WORKQUEUE 265 /* printk("TI: %s:\t%lu\n", __FUNCTION__, jiffies); */ 266 #ifdef CONFIG_ANDROID_POWER 267 android_lock_suspend( &drv->timer_wake_lock ); 268 #endif 269 queue_work( drv->tiwlan_wq, &drv->tw ); 270 #else 271 tasklet_schedule(&drv->tl); 272 #endif 273 } 274 275 /**************************************************************************************** 276 * * 277 * OS TIMER API * 278 * * 279 ****************************************************************************************/ 280 281 /**************************************************************************************** 282 * os_timerCreate() 283 **************************************************************************************** 284 DESCRIPTION: This function creates and initializes a timer object associated with a 285 caller's pRoutine function. 286 287 ARGUMENTS: 288 289 RETURN: A handle of the created timer. 290 TI_HANDLE_INVALID if there is insufficient memory available 291 292 NOTES: Using the Kernel timer feature, problem is that kernel timers are one-shots. 293 For timers that are periodic this abstraction layer will have to mediate 294 between the callback function and the re-submission of a timer request. 295 296 *****************************************************************************************/ 297 TI_HANDLE 298 os_timerCreate( 299 TI_HANDLE OsContext, 300 PTIMER_FUNCTION pRoutine, 301 TI_HANDLE Context 302 ) 303 { 304 timer_obj_t *tmr; 305 306 #ifdef ESTA_TIMER_DEBUG 307 esta_timer_log("\n\n%s:%d ::os_timerCreate(%p,%p,%p)",__FUNCTION__, __LINE__,OsContext,pRoutine,Context); 308 #endif 309 ti_nodprintf(TIWLAN_LOG_INFO, "\n----> os_timerCreate function = 0x%08x , context= 0x%08x", 310 (int)pRoutine, (int)Context); 311 312 os_profile (OsContext, 6, 0); 313 314 tmr = os_memoryAlloc (OsContext, sizeof(timer_obj_t)); 315 if (tmr == NULL) 316 return(TI_HANDLE_INVALID); 317 318 memset (tmr,0,sizeof(timer_obj_t)); 319 320 init_timer(&tmr->timer); 321 INIT_LIST_HEAD(&tmr->req.list); 322 tmr->timer.function = os_timerHandlr; 323 tmr->timer.data = (int)tmr; 324 tmr->req.drv = (tiwlan_net_dev_t *)OsContext; 325 tmr->req.u.req.p1 = (UINT32)pRoutine; 326 tmr->req.u.req.p2 = (UINT32)Context; 327 tmr->req.u.req.f = os_tl_timerHandlr; 328 tmr->use_count = 1; 329 330 esta_timer_log("=%p\n\n", tmr); 331 332 return (TI_HANDLE)tmr; 333 } 334 335 336 /**************************************************************************************** 337 * os_timerDestroy() 338 **************************************************************************************** 339 DESCRIPTION: This function destroy the timer object. 340 341 ARGUMENTS: 342 343 RETURN: 344 345 NOTES: Returning the Kernel level timer_list memory allocation and the 346 abstraction level timer object. 347 *****************************************************************************************/ 348 VOID 349 os_timerDestroy( 350 TI_HANDLE OsContext, 351 TI_HANDLE TimerHandle 352 ) 353 { 354 timer_obj_t *tmr = TimerHandle; 355 356 os_profile (OsContext, 6, 0); 357 358 os_timerStop (OsContext, TimerHandle); 359 os_timer_dec_use_count (tmr); 360 } 361 362 363 /**************************************************************************************** 364 * os_timerStart() 365 **************************************************************************************** 366 DESCRIPTION: This function start the timer object. 367 368 ARGUMENTS: 369 370 RETURN: 371 372 NOTES: 373 *****************************************************************************************/ 374 VOID 375 os_timerStart( 376 TI_HANDLE OsContext, 377 TI_HANDLE TimerHandle, 378 UINT32 DelayMs, 379 BOOL bPeriodic 380 ) 381 { 382 timer_obj_t *tmr= (timer_obj_t *)TimerHandle; 383 384 UINT32 jiffie_cnt = msecs_to_jiffies(DelayMs); 385 386 #ifdef ESTA_TIMER_DEBUG 387 esta_timer_log("\n\n%s:%d ::os_timerStart(%p,%p,%u,%d)\n\n",__FUNCTION__, __LINE__,OsContext,TimerHandle,DelayMs,bPeriodic); 388 #endif 389 390 tmr->req.u.req.p3 = bPeriodic; 391 tmr->req.u.req.p4 = jiffie_cnt; 392 tmr->timer.data = (unsigned long)tmr; 393 mod_timer(&tmr->timer, jiffies + jiffie_cnt); 394 395 396 return; 397 } 398 399 /**************************************************************************************** 400 * os_stopTimer() 401 **************************************************************************************** 402 DESCRIPTION: This function stop the timer object. 403 404 ARGUMENTS: 405 406 RETURN: 407 408 NOTES: 409 *****************************************************************************************/ 410 VOID 411 os_timerStop( 412 TI_HANDLE OsContext, 413 TI_HANDLE TimerHandle 414 ) 415 { 416 timer_obj_t *tmr= (timer_obj_t *)TimerHandle; 417 418 del_timer_sync(&tmr->timer); 419 tmr->req.u.req.p3 = 0; /* Turn "periodic" off */ 420 list_del_init(&tmr->req.list); 421 422 return; 423 } 424 425 /**************************************************************************************** 426 * os_periodicIntrTimerStart() 427 **************************************************************************************** 428 DESCRIPTION: This function starts the periodic interrupt mechanism. This mode is used 429 when interrupts that usually received from the Fw is now masked, and we are 430 checking for any need of Fw handling in time periods. 431 432 ARGUMENTS: 433 434 RETURN: 435 436 NOTES: Power level of the CHIP should be always awake in this mode (no ELP) 437 *****************************************************************************************/ 438 VOID 439 os_periodicIntrTimerStart( 440 TI_HANDLE OsContext 441 ) 442 { 443 tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext; 444 445 mod_timer (&drv->poll_timer, jiffies + TIWLAN_IRQ_POLL_INTERVAL); 446 } 447 448 /**************************************************************************************** 449 * os_timeStampMs() 450 **************************************************************************************** 451 DESCRIPTION: This function returns the number of milliseconds that have elapsed since 452 the system was booted. 453 454 ARGUMENTS: OsContext - our adapter context. 455 456 RETURN: 457 458 NOTES: 459 *****************************************************************************************/ 460 UINT32 461 os_timeStampMs( 462 TI_HANDLE OsContext 463 ) 464 { 465 struct timeval tv; 466 do_gettimeofday(&tv); 467 return tv.tv_sec*1000 + tv.tv_usec/1000; 468 } 469 470 /**************************************************************************************** 471 * os_timeStampUs() 472 **************************************************************************************** 473 DESCRIPTION: This function returns the number of microseconds that have elapsed since 474 the system was booted. 475 476 ARGUMENTS: OsContext - our adapter context. 477 Note that sometimes this function will be called with NULL(!!!) as argument! 478 479 RETURN: 480 481 NOTES: 482 *****************************************************************************************/ 483 UINT32 484 os_timeStampUs( 485 TI_HANDLE OsContext 486 ) 487 { 488 struct timeval tv; 489 do_gettimeofday(&tv); 490 return tv.tv_sec*1000000 + tv.tv_usec; 491 } 492 493 /**************************************************************************************** 494 * os_StalluSec() 495 **************************************************************************************** 496 DESCRIPTION: This function make delay in microseconds. 497 498 ARGUMENTS: OsContext - our adapter context. 499 uSec - delay time in microseconds 500 501 RETURN: 502 503 NOTES: 504 *****************************************************************************************/ 505 VOID 506 os_StalluSec( 507 TI_HANDLE OsContext, 508 UINT32 uSec 509 ) 510 { 511 /*UINT32 usec_now = os_timeStampUs(OsContext); 512 while(os_timeStampUs(OsContext) - usec_now < uSec) 513 ; 514 */ 515 udelay(uSec); 516 } 517 518 /**************************************************************************************** 519 * os_WaitComplete() 520 **************************************************************************************** 521 DESCRIPTION: This function start waiting for the complete 522 523 ARGUMENTS: 524 525 RETURN: 526 527 NOTES: can be called only from process context, and not from tasklet 528 *****************************************************************************************/ 529 VOID 530 os_WaitComplete( 531 TI_HANDLE OsContext 532 ) 533 { 534 tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext; 535 536 /* ti_dprintf(TIWLAN_LOG_INFO, "os_WaitComplete drv %x drv->comp %x\n",(UINT32)drv,(UINT32)&drv->comp); */ 537 538 /* 539 he tasklet should them send back the user (here)the completion event so the user could 540 go through the configuration phase 541 */ 542 wait_for_completion(&drv->comp); 543 } 544 545 /**************************************************************************************** 546 * os_Complete() 547 **************************************************************************************** 548 DESCRIPTION: This function signals to the waiting process that completion occured 549 550 ARGUMENTS: 551 552 RETURN: 553 554 NOTES: 555 *****************************************************************************************/ 556 VOID 557 os_Complete( 558 TI_HANDLE OsContext 559 ) 560 { 561 tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext; 562 563 /* ti_dprintf(TIWLAN_LOG_INFO, "os_Complete drv %x drv->comp %x\n",(UINT32)drv, (UINT32)&drv->comp); */ 564 565 /* 566 Call the completion routine that will unblock the caller that was waiting on that object 567 */ 568 complete(&drv->comp); 569 } 570 571 572 573 /**************************************************************************************** 574 * * 575 * Hardware access functions API * 576 * * 577 ****************************************************************************************/ 578 579 /**************************************************************************************** 580 * os_clearWlanReady() 581 **************************************************************************************** 582 DESCRIPTION: Clear the WLAN Ready Interrupt Line stored in the PIC Controller 583 584 INPUT: None 585 586 RETURN: None 587 588 NOTES: 589 *****************************************************************************************/ 590 591 __inline__ VOID 592 os_clearWlanReady( 593 void) 594 { 595 #ifdef TIWLAN_OMAP1610 596 omap_writel(4,GPIO1_IRQSTATUS1); 597 #endif 598 } 599 600 601 /**************************************************************************************** 602 * os_senseIrqLine() 603 **************************************************************************************** 604 DESCRIPTION: Read the WLAN_IRQ line 605 606 INPUT: void 607 608 RETURN: Read value 609 610 NOTES: 611 *****************************************************************************************/ 612 613 __inline__ UINT32 614 os_senseIrqLine( 615 TI_HANDLE OsContext 616 ) 617 { 618 #ifdef TIWLAN_OMAP1610 619 return (omap_readl(GPIO1_DATAIN) & 0x4); 620 #else 621 return 0; 622 #endif 623 } 624 625 626 627 /**************************************************************************************** 628 * os_hwGetRegistersAddr() 629 **************************************************************************************** 630 DESCRIPTION: 631 632 ARGUMENTS: 633 634 RETURN: 635 636 NOTES: 637 *****************************************************************************************/ 638 PVOID 639 os_hwGetRegistersAddr( 640 TI_HANDLE OsContext 641 ) 642 { 643 return (PVOID)OS_API_REG_ADRR; 644 } 645 646 /**************************************************************************************** 647 * os_hwGetMemoryAddr() 648 **************************************************************************************** 649 DESCRIPTION: 650 651 ARGUMENTS: 652 653 RETURN: 654 655 NOTES: 656 *****************************************************************************************/ 657 PVOID 658 os_hwGetMemoryAddr( 659 TI_HANDLE OsContext 660 ) 661 { 662 return (PVOID)OS_API_MEM_ADRR; 663 } 664 665 /**************************************************************************************** 666 * os_memoryGetPhysicalLow() 667 **************************************************************************************** 668 DESCRIPTION: return the lower 32 bits of a 64bit number / address * 669 670 ARGUMENTS: 671 672 RETURN: 673 674 NOTES: 675 *****************************************************************************************/ 676 UINT32 os_memoryGetPhysicalLow (OS_PHYSICAL_ADDRESS pAddr) 677 { 678 UINT32 res; 679 res = pAddr & 0xffffffff; 680 ti_dprintf(TIWLAN_LOG_ERROR, "\n 64bit low. Got 0x%x; Returning 0x%x \n", (UINT32)pAddr, res); 681 return res; 682 } 683 684 /**************************************************************************************** 685 * os_memoryGetPhysicalHigh() 686 **************************************************************************************** 687 DESCRIPTION: return the higher order 32 bits of a 64bit number / address * 688 689 ARGUMENTS: 690 691 RETURN: 692 693 NOTES: 694 *****************************************************************************************/ 695 UINT32 os_memoryGetPhysicalHigh (OS_PHYSICAL_ADDRESS pAddr) 696 { 697 UINT32 res; 698 res = pAddr >> 32; 699 ti_dprintf(TIWLAN_LOG_ERROR, "\n 64bit high. Got 0x%x; Returning 0x%x \n", (UINT32)pAddr, res); 700 return res; 701 } 702 703 704 /**************************************************************************************** 705 * * 706 * Protection services API * 707 * * 708 **************************************************************************************** 709 * OS protection is implemented as dummy functions because * 710 * all driver code is executed in context of a single tasklet, * 711 * except IOCTL handlers and xmition. * 712 * Protection in IOCTL handlers and hard_start_xmit is done by different * 713 * means. * 714 ****************************************************************************************/ 715 716 717 /**************************************************************************************** 718 * os_protectCreate() 719 **************************************************************************************** 720 DESCRIPTION: 721 722 ARGUMENTS: OsContext - our adapter context. 723 724 RETURN: A handle of the created mutex/spinlock. 725 TI_HANDLE_INVALID if there is insufficient memory available or problems 726 initializing the mutex 727 728 NOTES: 729 *****************************************************************************************/ 730 TI_HANDLE 731 os_protectCreate( 732 TI_HANDLE OsContext 733 ) 734 { 735 return (TI_HANDLE)OS_PROTECT_HANDLE; 736 } 737 738 739 740 /**************************************************************************************** 741 * os_protectDestroy() 742 **************************************************************************************** 743 DESCRIPTION: 744 745 ARGUMENTS: OsContext - our adapter context. 746 747 RETURN: None - This had better work since there is not a return value to the user 748 749 NOTES: 750 *****************************************************************************************/ 751 VOID 752 os_protectDestroy( 753 TI_HANDLE OsContext, 754 TI_HANDLE ProtectCtx 755 ) 756 { 757 return; 758 } 759 760 761 /**************************************************************************************** 762 * os_protectLock() 763 **************************************************************************************** 764 DESCRIPTION: 765 766 ARGUMENTS: OsContext - our adapter context. 767 768 RETURN: None - This had better work since there is not a return value to the user 769 770 NOTES: 771 *****************************************************************************************/ 772 VOID 773 os_protectLock( 774 TI_HANDLE OsContext, 775 TI_HANDLE ProtectContext 776 ) 777 { 778 #if 1 /* uncomment for work in INDIRECT mode (HwACXAccessMethod=0) */ 779 tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext; 780 spin_lock_irqsave(&drv->lock, drv->flags); 781 #endif 782 } 783 784 785 /**************************************************************************************** 786 * os_protectUnlock() 787 **************************************************************************************** 788 DESCRIPTION: 789 790 ARGUMENTS: OsContext - our adapter context. 791 792 RETURN: None - This had better work since there is not a return value to the user 793 794 NOTES: 795 *****************************************************************************************/ 796 VOID 797 os_protectUnlock( 798 TI_HANDLE OsContext, 799 TI_HANDLE ProtectContext 800 ) 801 { 802 #if 1 /* uncomment for work in INDIRECT mode (HwACXAccessMethod=0) */ 803 tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext; 804 spin_unlock_irqrestore(&drv->lock, drv->flags); 805 #endif 806 } 807 808 809 /*----------------------------------------------------------------------------- 810 811 Routine Name: 812 813 os_resetWakeOnGpio 814 815 Routine Description: 816 817 set the GPIO to low after awaking the TNET from ELP. 818 819 Arguments: 820 821 OsContext - our adapter context. 822 823 824 Return Value: 825 826 None 827 828 -----------------------------------------------------------------------------*/ 829 VOID 830 os_hardResetTnetw( void ) 831 { 832 /* 833 * Define the OMAP GPIO registers, the TNETW reset is currently connected 834 * to GPIO 16, this logic assumes that the loading code had muxed the 835 * GPIO 16 to the Y1 pinout. 836 */ 837 /* direction out */ 838 #ifdef TIWLAN_OMAP1610 839 omap_set_gpio_direction(GPIO_16, GPIO_16_DIRECTION_OUTPUT); 840 841 /* clear reset WLAN chip */ 842 omap_set_gpio_dataout(GPIO_16, GPIO_16_CLEAR); 843 844 /* wait for 50msec */ 845 mdelay(50); 846 omap_set_gpio_dataout(GPIO_16, GPIO_16_SET); 847 848 /* wait for 50msec */ 849 mdelay(50); 850 #endif /* Dm: */ 851 #ifdef TIWLAN_MSM7000 852 msm_wifi_reset(1); /* Reset active */ 853 msm_wifi_power(0); /* Power disable */ 854 msm_wifi_power(1); /* Power enable */ 855 msm_wifi_reset(0); /* Reset clear */ 856 #endif 857 } 858 859 860 #ifndef GWSI_DRIVER 861 862 /**************************************************************************************** 863 START OF TI DRIVER API 864 *****************************************************************************************/ 865 866 /**************************************************************************************** 867 * os_setWakeOnGpio() 868 **************************************************************************************** 869 DESCRIPTION: set the GPIO to high for awaking the TNET from ELP. 870 871 ARGUMENTS: OsContext - our adapter context. 872 873 RETURN: None 874 875 NOTES: 876 *****************************************************************************************/ 877 VOID 878 os_setWakeOnGpio( 879 TI_HANDLE OsContext 880 ) 881 { 882 #ifdef TIWLAN_OMAP1610 883 /* 884 Clear ELP_REQ by GPIO_CLEAR_DATAOUT 885 */ 886 os_resetWakeOnGpio(OsContext); 887 888 /* 889 Rising edge on ELP_REQ by GPIO_SET_DATAOUT 890 */ 891 omap_writel(0x00000200, 0xFFFBBCF0); 892 #endif 893 } 894 895 /**************************************************************************************** 896 * os_resetWakeOnGpio() 897 **************************************************************************************** 898 DESCRIPTION: set the GPIO to low after awaking the TNET from ELP. 899 900 ARGUMENTS: OsContext - our adapter context. 901 902 RETURN: None 903 904 NOTES: 905 *****************************************************************************************/ 906 VOID 907 os_resetWakeOnGpio( 908 TI_HANDLE OsContext 909 ) 910 { 911 /* 912 Clear ELP_REQ by GPIO_CLEAR_DATAOUT 913 */ 914 #ifdef TIWLAN_OMAP1610 915 omap_writel(0x00000200, 0xFFFBBCB0); 916 #endif 917 } 918 919 /**************************************************************************************** 920 * _os_memorySharedFree() 921 **************************************************************************************** 922 DESCRIPTION: 923 924 ARGUMENTS: 925 926 RETURN: 927 928 NOTES: 929 *****************************************************************************************/ 930 VOID 931 _os_memorySharedFree( 932 TI_HANDLE OsContext, 933 PVOID pVirtual, 934 UINT32 Size, 935 OS_PHYSICAL_ADDRESS pPhysical 936 ) 937 { 938 ti_dprintf(TIWLAN_LOG_ERROR, "\n\n\n %s is not implemented\n\n\n", __FUNCTION__); 939 } 940 941 /**************************************************************************************** 942 * _os_memorySharedAlloc() 943 **************************************************************************************** 944 DESCRIPTION: 945 946 ARGUMENTS: 947 948 RETURN: 949 950 NOTES: 951 *****************************************************************************************/ 952 PVOID 953 _os_memorySharedAlloc( 954 TI_HANDLE OsContext, 955 UINT32 Size, 956 OS_PHYSICAL_ADDRESS *pPhysical 957 ) 958 { 959 ti_dprintf(TIWLAN_LOG_ERROR, "\n\n\n %s is not implemented\n\n\n", __FUNCTION__); 960 return NULL; 961 } 962 963 /**************************************************************************************** 964 * os_powerStateBusy() 965 **************************************************************************************** 966 DESCRIPTION: notify to the host that the TI_WLAN application is busy. 967 968 ARGUMENTS: OsContext - our adapter context. 969 970 RETURN: 971 972 NOTES: 973 *****************************************************************************************/ 974 VOID 975 os_powerStateBusy( 976 TI_HANDLE OsContext 977 ) 978 { 979 #if 0 980 ti_dprintf(TIWLAN_LOG_INFO, 981 "%s(%d) - os_powerStateBusy: TI_WLAN is busy!\n", 982 __FILE__,__LINE__); 983 #endif 984 } 985 986 /**************************************************************************************** 987 * os_powerStateIdle() 988 **************************************************************************************** 989 DESCRIPTION: notify to the host that the TI_WLAN application is idle. 990 991 ARGUMENTS: OsContext - our adapter context. 992 993 RETURN: 994 995 NOTES: 996 *****************************************************************************************/ 997 VOID 998 os_powerStateIdle( 999 TI_HANDLE OsContext 1000 ) 1001 { 1002 #if 0 1003 ti_dprintf(TIWLAN_LOG_INFO, 1004 "%s(%d) - os_powerStateIdle: TI_WLAN is idle!\n", 1005 __FILE__,__LINE__); 1006 #endif 1007 } 1008 1009 /**************************************************************************************** 1010 * os_memoryMove() 1011 **************************************************************************************** 1012 DESCRIPTION: Move memory block from pSource to pDestination 1013 1014 ARGUMENTS: OsContext - Our adapter context. 1015 pDestination - destination 1016 pSource - source 1017 Size - Number of characters 1018 RETURN: 1019 1020 NOTES: 1021 *****************************************************************************************/ 1022 VOID 1023 os_memoryMove( 1024 TI_HANDLE pOsContext, 1025 PVOID pDestination, 1026 PVOID pSource, 1027 UINT32 Size 1028 ) 1029 { 1030 memmove(pDestination, pSource, Size); 1031 } 1032 1033 1034 /**************************************************************************************** 1035 * os_memoryMoveToHw() 1036 **************************************************************************************** 1037 DESCRIPTION: This function copies data from a system-space buffer to device memory. 1038 1039 ARGUMENTS: OsContext - Our adapter context. 1040 1041 pTarget - Specifies the base address within a device memory range where 1042 the copy should begin. 1043 1044 pSource - Pointer to a system-space buffer from which this function copies 1045 data to the destination range. 1046 1047 Size - Specifies the number of bytes to copy. 1048 1049 RETURN: None 1050 1051 NOTES: 1052 *****************************************************************************************/ 1053 VOID 1054 os_memoryMoveToHw( 1055 TI_HANDLE OsContext, 1056 PVOID pTarget, 1057 PVOID pSource, 1058 UINT32 Size 1059 ) 1060 { 1061 print_info("\nos_memoryMoveToHw pTarget 0x%08x pSource 0x%08x Size 0x%08x",(int)pTarget, (int)pSource,(int)Size); 1062 print_info("\n-------------------------> Not Implemented <--------------------------------------------------- "); 1063 } 1064 1065 /**************************************************************************************** 1066 * os_memoryMoveFromHw() 1067 **************************************************************************************** 1068 DESCRIPTION: This function copies data from a system-space buffer to device memory. 1069 1070 ARGUMENTS: OsContext - Our adapter context. 1071 1072 pTarget - Pointer to a system-space buffer into which this function copies 1073 data from device memory. 1074 1075 pSource - Specifies the base virtual address within device memory from 1076 which to copy the data. 1077 1078 Size - Specifies the number of bytes to copy. 1079 1080 RETURN: None 1081 1082 NOTES: 1083 *****************************************************************************************/ 1084 VOID 1085 os_memoryMoveFromHw( 1086 TI_HANDLE OsContext, 1087 PVOID pTarget, 1088 PVOID pSource, 1089 UINT32 Size 1090 ) 1091 { 1092 print_info("\nos_memoryMoveFromHw pTarget 0x%08x pSource 0x%08x Size 0x%08x",(int)pTarget, (int)pSource,(int)Size); 1093 print_info("\n-------------------------> Not Implemented <--------------------------------------------------- "); 1094 } 1095 1096 /**************************************************************************************** 1097 * os_hwReadMemRegisterUINT8() 1098 **************************************************************************************** 1099 DESCRIPTION: Reads a UINT8 from a memory-mapped device register. 1100 1101 ARGUMENTS: OsContext - our adapter context. 1102 1103 Register - Pointer to the memory-mapped register. 1104 1105 Data - Pointer to the caller-supplied variable in which this function 1106 returns the UINT8 read from Register. 1107 1108 RETURN: None 1109 1110 NOTES: 1111 *****************************************************************************************/ 1112 VOID 1113 os_hwReadMemRegisterUINT8( 1114 TI_HANDLE OsContext, 1115 PUCHAR Register, 1116 PUINT8 Data 1117 ) 1118 { 1119 *Data = *Register; 1120 PRINT_REG("R8: %p=0x%x\n", Register, *Data); 1121 return; 1122 } 1123 1124 /**************************************************************************************** 1125 * os_hwWriteMemRegisterUINT16() 1126 **************************************************************************************** 1127 DESCRIPTION: Writes a 'unsigned short' to a memory-mapped device register. 1128 1129 ARGUMENTS: OsContext - our adapter context. 1130 1131 Register - Pointer to the memory-mapped register. 1132 1133 Data - Specifies the caller-supplied UINT16 that this function transfers 1134 to the Register. 1135 1136 RETURN: None 1137 1138 NOTES: 1139 *****************************************************************************************/ 1140 VOID 1141 os_hwWriteMemRegisterUINT16( 1142 TI_HANDLE OsContext, 1143 PUINT16 Register, 1144 UINT16 Data 1145 ) 1146 { 1147 PRINT_REG("W16: %p=0x%x\n", Register, Data); 1148 *Register = Data; 1149 return; 1150 } 1151 1152 /**************************************************************************************** 1153 * os_hwReadMemRegisterUINT16() 1154 **************************************************************************************** 1155 DESCRIPTION: Reads a UINT16 from a memory-mapped device register. 1156 1157 ARGUMENTS: OsContext - our adapter context. 1158 1159 Register - Pointer to the memory-mapped register. 1160 1161 Data - Pointer to the caller-supplied variable in which this function 1162 returns the UINT16 read from Register. 1163 1164 RETURN: None 1165 1166 NOTES: 1167 *****************************************************************************************/ 1168 VOID 1169 os_hwReadMemRegisterUINT16( 1170 TI_HANDLE OsContext, 1171 PUINT16 Register, 1172 PUINT16 Data 1173 ) 1174 { 1175 *Data = *Register; 1176 PRINT_REG("R16: %p=0x%x\n", Register, *Data); 1177 return; 1178 } 1179 1180 /**************************************************************************************** 1181 * os_hwWriteMemRegisterUINT32() 1182 **************************************************************************************** 1183 DESCRIPTION: Writes a 'unsigned long' to a memory-mapped device register. 1184 1185 ARGUMENTS: OsContext - our adapter context. 1186 1187 Register - Pointer to the memory-mapped register. 1188 1189 Data - Specifies the caller-supplied UINT32 that this function transfers 1190 to the Register. 1191 1192 RETURN: None 1193 1194 NOTES: 1195 *****************************************************************************************/ 1196 VOID 1197 os_hwWriteMemRegisterUINT32( 1198 TI_HANDLE OsContext, 1199 PUINT32 Register, 1200 UINT32 Data 1201 ) 1202 { 1203 PRINT_REG("W32: %p=0x%x\n", Register, Data); 1204 *Register = Data; 1205 return; 1206 } 1207 1208 1209 /**************************************************************************************** 1210 * os_hwReadMemRegisterUINT32() 1211 **************************************************************************************** 1212 DESCRIPTION: Reads a UINT32 from a memory-mapped device register. 1213 1214 ARGUMENTS: OsContext - our adapter context. 1215 1216 Register - Pointer to the memory-mapped register. 1217 1218 Data - Pointer to the caller-supplied variable in which this function 1219 returns the UINT32 read from Register. 1220 1221 RETURN: None 1222 1223 NOTES: 1224 *****************************************************************************************/ 1225 VOID 1226 os_hwReadMemRegisterUINT32( 1227 TI_HANDLE OsContext, 1228 PUINT32 Register, 1229 PUINT32 Data 1230 ) 1231 { 1232 *Data = *Register; 1233 PRINT_REG("R32: %p=0x%x\n", Register, *Data); 1234 return; 1235 } 1236 1237 1238 /**************************************************************************************** 1239 * os_receivePacket() 1240 **************************************************************************************** 1241 DESCRIPTION: 1242 1243 ARGUMENTS: 1244 1245 RETURN: 1246 1247 NOTES: 1248 *****************************************************************************************/ 1249 BOOL 1250 os_receivePacket( 1251 TI_HANDLE OsContext, 1252 PVOID pPacket, 1253 UINT16 Length 1254 ) 1255 { 1256 tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext; 1257 struct sk_buff *skb; 1258 mem_MSDU_T* pMsdu = (mem_MSDU_T*)pPacket; 1259 mem_BD_T *pCurBd; 1260 ti_nodprintf(TIWLAN_LOG_INFO, "os_receivePacket - Received EAPOL len-%d\n", pMsdu->firstBDPtr->length ); 1261 1262 bm_trace(10, Length, 0); 1263 1264 if (pMsdu->firstBDPtr->length > Length) { /* Dm: Security fix */ 1265 ti_dprintf(TIWLAN_LOG_ERROR, " TI: %s - Security Error\n", __FUNCTION__); 1266 return FALSE; 1267 } 1268 1269 skb = dev_alloc_skb(Length+2); 1270 if(!skb) { 1271 print_deb(" os_receivePacket() : dev_alloc_skb failed!\n"); 1272 configMgr_memMngrFreeMSDU(drv->adapter.CoreHalCtx, memMgr_MsduHandle(pPacket)); 1273 drv->stats.rx_dropped++; 1274 return FALSE; 1275 } 1276 skb_reserve(skb, 2); 1277 1278 pCurBd = pMsdu->firstBDPtr; 1279 while (pCurBd) { 1280 memcpy(skb_put(skb,pCurBd->length),pCurBd->data+pCurBd->dataOffset,pCurBd->length); 1281 pCurBd = pCurBd->nextBDPtr; 1282 } 1283 1284 skb->dev = drv->netdev; 1285 skb->protocol = eth_type_trans(skb, drv->netdev); 1286 skb->ip_summed = CHECKSUM_NONE; 1287 1288 drv->stats.rx_packets++; 1289 drv->stats.rx_bytes += skb->len; 1290 1291 bm_trace(11, Length, 0); 1292 #ifdef CONFIG_ANDROID_POWER 1293 drv->receive_packet = 1; /* Remember to stay awake */ 1294 #endif 1295 netif_rx(skb); 1296 1297 configMgr_memMngrFreeMSDU(drv->adapter.CoreHalCtx, memMgr_MsduHandle(pPacket)); 1298 1299 bm_trace(12, Length, 0); 1300 1301 return TRUE; 1302 } 1303 1304 /**************************************************************************************** 1305 * os_sendPacket() 1306 **************************************************************************************** 1307 DESCRIPTION: send EAPOL packet from Supplicant 1308 1309 ARGUMENTS: 1310 1311 RETURN: 1312 1313 NOTES: 1314 *****************************************************************************************/ 1315 INT32 1316 os_sendPacket( 1317 TI_HANDLE OsContext, 1318 PVOID pPacket, 1319 UINT16 Length 1320 ) 1321 { 1322 struct net_device *dev = (struct net_device *)OsContext; 1323 tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)NETDEV_GET_PRIVATE(dev); 1324 1325 INT32 status; 1326 mem_MSDU_T* pMsdu; 1327 char *pMsduData; 1328 UINT32 packetHeaderLength; 1329 1330 ti_nodprintf(TIWLAN_LOG_INFO, "os_sendPacket - Transmit EAPOL len-%x\n",Length ); 1331 1332 /* 1333 * Allocate enough place also for 802.11 header (24 bytes) and LLC (8 bytes) 1334 * to replace the Ethernet header (14 bytes) 1335 */ 1336 if(!Length) 1337 { 1338 ti_dprintf(TIWLAN_LOG_ERROR, " EAPOL Packet Length = 0 \n"); 1339 return -1; 1340 } 1341 /* 1342 * Retrieve the Packet Header length 1343 * from QoS Manager (through configMgr) and RSN 1344 */ 1345 packetHeaderLength = configMgr_getPacketHeaderLength(drv->adapter.CoreHalCtx,pPacket,TX_DATA_EAPOL_MSDU); 1346 1347 /* 1348 * need to reserve enough space for header translation 1349 * in the same first Bd. 1350 * Allocate enough place also for 802.11 header (24 bytes or 26 for QoS) and LLC (8 bytes) 1351 * to replace the Ethernet header (14 bytes) 1352 */ 1353 1354 status = configMgr_allocMSDU(drv->adapter.CoreHalCtx, &pMsdu, 1355 Length + packetHeaderLength , OS_ABS_TX_MODULE); 1356 if(status != OK) 1357 { 1358 ti_dprintf(TIWLAN_LOG_ERROR, " configMgr_allocMSDU failed !!!\n"); 1359 ++drv->alloc_msdu_failures; 1360 return -ENOMEM; 1361 } 1362 1363 /* 1364 * case 1: only legacy wlan header 1365 * 1366 * case 2: only QoS wlan header 1367 * 1368 * case 3: only legacy wlan header with new snap 1369 * 1370 * case 4: only QoS wlan header with new snap 1371 */ 1372 pMsdu->firstBDPtr->dataOffset = packetHeaderLength - ETHERNET_HDR_LEN; 1373 pMsduData = pMsdu->firstBDPtr->data + pMsdu->firstBDPtr->dataOffset; 1374 memcpy(pMsduData, pPacket, Length); 1375 pMsdu->dataLen = Length; 1376 pMsdu->firstBDPtr->length = pMsdu->dataLen + pMsdu->firstBDPtr->dataOffset; 1377 pMsdu->freeFunc = 0; 1378 pMsdu->freeArgs[0] = 0; 1379 pMsdu->freeArgs[1] = 0; 1380 1381 /* 1382 * Propagate Msdu through Config Manager. 1383 * Set DTag to 0 1384 * (note that classification is further handled in the Core) 1385 */ 1386 status = configMgr_sendMsdu(drv->adapter.CoreHalCtx, pMsdu, 0); 1387 1388 return status; 1389 } 1390 1391 1392 #endif /* NDEF GWSI_DRIVER*/ 1393 1394 1395 1396 /******************************************************************************************************* 1397 1398 LOCAL FUNCTIONS 1399 1400 ********************************************************************************************************/ 1401 1402 /*----------------------------------------------------------------------------- 1403 Routine Name: 1404 1405 os_timer_dec_use_count 1406 1407 Routine Description: 1408 1409 This function is decrements timer use count. 1410 When use_count becomes 0, the timer block is destroyed 1411 -----------------------------------------------------------------------------*/ 1412 static inline void os_timer_dec_use_count(timer_obj_t *tmr) 1413 { 1414 if (unlikely(!tmr->use_count)) { 1415 ti_dprintf(TIWLAN_LOG_ERROR, "\n\n\n %s: attempt to delete a deleted timer %p\n\n\n", __FUNCTION__, tmr); 1416 tmr->use_count = 1; 1417 } 1418 if (!(--tmr->use_count)) 1419 os_memoryFree(tmr->req.drv, tmr, sizeof(timer_obj_t)); 1420 } 1421 1422 1423 /*----------------------------------------------------------------------------- 1424 1425 Routine Name: 1426 1427 os_tl_timerHandlr 1428 1429 Routine Description: 1430 1431 This function is called in context of the control tasklet. 1432 It evokes user timer handler and restarts the timer if periodic 1433 1434 Arguments: 1435 p1 - user handler 1436 p2 - user parameter 1437 p3 - periodic 1438 p4 - jiffies 1439 1440 Return Value: 1441 1442 None. 1443 1444 Notes: 1445 1446 -----------------------------------------------------------------------------*/ 1447 static int os_tl_timerHandlr(struct tiwlan_req *req) 1448 { 1449 timer_obj_t *tmr= (timer_obj_t *)req; 1450 PTIMER_FUNCTION f = (PTIMER_FUNCTION)req->u.req.p1; 1451 TI_HANDLE parm = (TI_HANDLE)req->u.req.p2; 1452 1453 esta_timer_log("%s: req=0x%x f=0x%p parm=0x%p\n", __FUNCTION__, req, f, parm); 1454 ++tmr->use_count; 1455 f(parm); 1456 if (req->u.req.p3) /* Periodic ? */ 1457 mod_timer(&tmr->timer, jiffies + req->u.req.p4); 1458 os_timer_dec_use_count(tmr); 1459 1460 return 0; 1461 } 1462 1463 1464 /*----------------------------------------------------------------------------- 1465 1466 Routine Name: 1467 1468 os_timerHandlr 1469 1470 Routine Description: 1471 1472 This function is called on timer expiration in context of 1473 softIsr. It delegates the timer handling to the control tasklet. 1474 1475 Arguments: 1476 parm - timer object handle 1477 1478 Return Value: 1479 1480 None. 1481 1482 Notes: 1483 1484 -----------------------------------------------------------------------------*/ 1485 static void os_timerHandlr(unsigned long parm) 1486 { 1487 timer_obj_t *tmr= (timer_obj_t *)parm; 1488 tiwlan_net_dev_t *drv = tmr->req.drv; 1489 unsigned long flags; 1490 1491 esta_timer_log("%s: drv=%p f=0x%x ctx=0x%x\n", 1492 __FUNCTION__, tmr->req.drv, tmr->req.u.req.p1, tmr->req.u.req.p2); 1493 1494 spin_lock_irqsave(&drv->lock, flags); 1495 list_del(&tmr->req.list); 1496 list_add_tail(&tmr->req.list, &drv->request_q); 1497 spin_unlock_irqrestore(&drv->lock, flags); 1498 #ifdef DM_USE_WORKQUEUE 1499 /* printk("TI: %s:\t%lu\n", __FUNCTION__, jiffies); */ 1500 #ifdef CONFIG_ANDROID_POWER 1501 android_lock_suspend( &drv->timer_wake_lock ); 1502 #endif 1503 queue_work( drv->tiwlan_wq, &drv->tw ); 1504 #else 1505 tasklet_schedule(&drv->tl); 1506 #endif 1507 } 1508 1509 1510 /*----------------------------------------------------------------------------- 1511 1512 Routine Name: 1513 1514 os_connectionStatus 1515 1516 Routine Description: 1517 1518 The eSTA-DK will call this API so the OS stack is aware that the 1519 WLAN layer is ready to function. 1520 1521 Arguments: 1522 cStatus = 1; WLAN in ready for network packets 1523 cStatus = 0; WLAN in not ready for network packets 1524 1525 Return Value: 1526 1527 None 1528 1529 -----------------------------------------------------------------------------*/ 1530 1531 tiINT32 1532 os_IndicateEvent(IPC_EV_DATA* pData) 1533 { 1534 IPC_EVENT_PARAMS * pInParam = (IPC_EVENT_PARAMS *)pData; 1535 tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)(pInParam->hUserParam); 1536 /*UCHAR AuthBuf[sizeof(ULONG) + sizeof(OS_802_11_AUTHENTICATION_REQUEST)];*/ 1537 1538 ti_nodprintf(TIWLAN_LOG_INFO, "\n os_ConnectionStatus Event 0x%08x \n", CsStatus->Event); 1539 1540 switch(pInParam->uEventType) 1541 { 1542 case IPC_EVENT_ASSOCIATED: 1543 if (drv->netdev != NULL) { 1544 netif_carrier_on(drv->netdev); 1545 #if defined(CONFIG_TROUT_PWRSINK) || defined(CONFIG_HTC_PWRSINK) 1546 queue_delayed_work(drv->tiwlan_wq, &drv->trxw, 0); 1547 #endif 1548 } 1549 break; 1550 1551 case IPC_EVENT_DISASSOCIATED: 1552 if (drv->netdev != NULL) { 1553 #if defined(CONFIG_TROUT_PWRSINK) || defined(CONFIG_HTC_PWRSINK) 1554 unsigned percent; 1555 1556 cancel_delayed_work_sync(&drv->trxw); 1557 percent = ( drv->started ) ? PWRSINK_WIFI_PERCENT_BASE : 0; 1558 #ifdef CONFIG_HTC_PWRSINK 1559 htc_pwrsink_set(PWRSINK_WIFI, percent); 1560 #else 1561 trout_pwrsink_set(PWRSINK_WIFI, percent); 1562 #endif 1563 #endif 1564 netif_carrier_off(drv->netdev); 1565 } 1566 break; 1567 1568 case IPC_EVENT_LINK_SPEED: 1569 drv->adapter.LinkSpeed = (*(PULONG)pData->uBuffer * 10000) / 2; 1570 ti_nodprintf(TIWLAN_LOG_INFO, "\n Link Speed = 0x%08x \n",drv->adapter.LinkSpeed); 1571 break; 1572 1573 case IPC_EVENT_AUTH_SUCC: 1574 /* *(PULONG)AuthBuf = os802_11StatusType_Authentication; 1575 memcpy((PUCHAR)&AuthBuf[sizeof(ULONG)], pData->uBuffer,sizeof(OS_802_11_AUTHENTICATION_REQUEST));*/ 1576 ti_dprintf(TIWLAN_LOG_OTHER, "\n Auth Succ Event from Driver to another BSSID. \n"); 1577 break; 1578 1579 case IPC_EVENT_SCAN_COMPLETE: 1580 ti_dprintf(TIWLAN_LOG_OTHER, "\n Driver Event = Scan Complete. \n"); 1581 break; 1582 1583 case IPC_EVENT_TIMEOUT: 1584 ti_dprintf(TIWLAN_LOG_OTHER, "\n Driver Event = Timeout. \n"); 1585 break; 1586 1587 case IPC_EVENT_CCKM_START: 1588 ti_dprintf(TIWLAN_LOG_OTHER, "\n Driver Event = IPC_EVENT_CCKM_START \n"); 1589 break; 1590 1591 default: 1592 ti_dprintf(TIWLAN_LOG_ERROR, "\n Unrecognized driver event. \n"); 1593 break; 1594 1595 } 1596 1597 return OK; 1598 } 1599 1600 1601 /****************************************************************************/ 1602 /* The following 4 functions are debug functions that enable the user 1603 to set/reset GPIO_25 and GPIO_27 in the OMAP - for debug purposes. 1604 Note: In order to enable GPIO_25/GPIO_27 the user must enable the define 1605 TIWLAN_OMAP1610_CRTWIPP_GPIO_DEBUG in the esta_drv.c/osapi.c files. */ 1606 1607 void os_ToggleDebugGPIO(int count) 1608 { 1609 #if 0 1610 int i,j; 1611 1612 omap_writel(0x00000200, 0xFFFBBCB0 );/* 0 */ 1613 for(i=0;i<count;i++) 1614 { 1615 omap_writel(0x00000200, 0xFFFBBCF0 );/* 1 */ 1616 for(j=0;j<100;j++); 1617 omap_writel(0x00000200, 0xFFFBBCB0 );/* 0 */ 1618 for(j=0;j<100;j++); 1619 } 1620 #endif 1621 } 1622 #ifdef TIWLAN_OMAP1610_CRTWIPP_GPIO_DEBUG 1623 VOID 1624 os_SetGpio_25( 1625 TI_HANDLE OsContext 1626 ) 1627 { 1628 /* 1629 Setting GPIO_25 by GPIO_SET_DATAOUT 1630 */ 1631 omap_writel(0x00000200, 0xFFFBECF0 ); 1632 } 1633 1634 1635 VOID 1636 os_ResetGpio25( 1637 TI_HANDLE OsContext 1638 ) 1639 { 1640 /* 1641 Clear GPIO_25 by GPIO_CLEAR_DATAOUT 1642 */ 1643 omap_writel(0x00000200, 0xFFFBECB0 ); 1644 } 1645 1646 1647 VOID 1648 os_SetGpio27( 1649 TI_HANDLE OsContext 1650 ) 1651 { 1652 /* 1653 Setting GPIO_27 by GPIO_SET_DATAOUT 1654 */ 1655 omap_writel(0x00000800, 0xFFFBECF0 ); 1656 } 1657 1658 1659 VOID 1660 os_ResetGpio27( 1661 TI_HANDLE OsContext 1662 ) 1663 { 1664 /* 1665 Clear GPIO_27 by GPIO_CLEAR_DATAOUT 1666 */ 1667 omap_writel(0x00000800, 0xFFFBECB0 ); 1668 } 1669 #endif 1670 /******************************************************************************/ 1671 1672 VOID 1673 os_disableIrq( TI_HANDLE OsContext) 1674 { 1675 tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext; 1676 disable_irq (drv->irq); 1677 } 1678 1679 VOID 1680 os_enableIrq( TI_HANDLE OsContext) 1681 { 1682 tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext; 1683 enable_irq (drv->irq); 1684 } 1685 1686 int 1687 os_getFirmwareImage( 1688 TI_HANDLE OsContext, 1689 PUINT8 *pBuffer, 1690 PUINT32 Length, 1691 UINT8 RadioType 1692 ) 1693 { 1694 tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext; 1695 1696 *pBuffer = drv->firmware_image.va; 1697 *Length = drv->firmware_image.size; 1698 1699 return OK; 1700 } 1701 1702 1703 /*----------------------------------------------------------------------------- 1704 1705 Routine Name: 1706 1707 os_getRadioImage 1708 1709 Routine Description: 1710 1711 1712 Arguments: 1713 1714 1715 Return Value: 1716 1717 OK 1718 1719 -----------------------------------------------------------------------------*/ 1720 int 1721 os_getRadioImage( 1722 TI_HANDLE OsContext, 1723 PUINT8 *pBuffer, 1724 PUINT32 Length, 1725 UINT8 RadioType 1726 ) 1727 { 1728 1729 #ifdef FIRMWARE_DYNAMIC_LOAD 1730 tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext; 1731 1732 *pBuffer = drv->eeprom_image.va; 1733 *Length = drv->eeprom_image.size; 1734 #else 1735 extern unsigned char tiwlan_radimage[]; 1736 extern unsigned int sizeof_tiwlan_radimage; 1737 *pBuffer = (PUINT8)tiwlan_radimage; 1738 *Length = sizeof_tiwlan_radimage; 1739 #endif 1740 ti_dprintf(TIWLAN_LOG_INFO, "%s: radio type: 0x%x\n", __FUNCTION__, RadioType); 1741 1742 return OK; 1743 } 1744 1745 1746 #ifdef DRIVER_PROFILING 1747 void _os_profile (TI_HANDLE OsContext, UINT32 fn, UINT32 par) 1748 { 1749 tiwlan_profile (OsContext, fn, par); 1750 } 1751 #endif 1752 1753 VOID 1754 os_closeFirmwareImage( TI_HANDLE OsContext ) 1755 { 1756 return; 1757 } 1758 1759 VOID 1760 os_closeRadioImage( TI_HANDLE OsContext ) 1761 { 1762 return; 1763 } 1764