PageRenderTime 57ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/pform/linux/src/osapi.c

http://github.com/CyanogenMod/cm-kernel
C | 1763 lines | 795 code | 193 blank | 775 comment | 28 complexity | 78246825439df95065b1570b4d335d77 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0

Large files files are truncated, but you can click here to view the full file

  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. #include "arch_ti.h"
  36. #include <linux/stddef.h>
  37. #include <linux/string.h>
  38. #include <linux/time.h>
  39. #include <linux/timer.h>
  40. #include <linux/module.h>
  41. #include <linux/kernel.h>
  42. #include <linux/netdevice.h>
  43. #include <linux/etherdevice.h>
  44. #include <linux/vmalloc.h>
  45. #include <linux/string.h>
  46. #include <linux/delay.h>
  47. #include <linux/time.h>
  48. #include <linux/list.h>
  49. #include <asm/io.h>
  50. #include "debug_module.h"
  51. #include "esta_drv.h"
  52. #ifdef DRIVER_PROFILING
  53. #include "tiwlan_profile.h"
  54. #endif
  55. #include "osApi.h"
  56. #include "osTIType.h"
  57. #include "srcApi.h"
  58. #include "whalHwRegs.h"
  59. #include "bmtrace.h"
  60. #include "TI_IPC_Api.h"
  61. #include "whalBus_Defs.h"
  62. #include "802_11Defs.h"
  63. #include "Ethernet.h"
  64. #define OS_PROTECT_HANDLE 0xffffeee0
  65. /*#define DEBUG_REG_ACCESS*/
  66. #ifdef DEBUG_REG_ACCESS
  67. #define PRINT_REG(fmt, args...) print_info(fmt, args)
  68. #else
  69. #define PRINT_REG(fmt, args...)
  70. #endif
  71. #define NOPRINT_REG(fmt, args...)
  72. #ifdef ESTA_TIMER_DEBUG
  73. #define esta_timer_log(fmt,args...) printk(fmt, ## args)
  74. #else
  75. #define esta_timer_log(fmt,args...)
  76. #endif
  77. #define FRAG_SIZE 200
  78. /* Wlan chip reset defines */
  79. #define GPIO_16 16
  80. #define GPIO_16_DIRECTION_OUTPUT 0
  81. #define GPIO_16_CLEAR 0
  82. #define GPIO_16_SET 1
  83. #define GPIO1_IRQSTATUS1 0xFFFBE418
  84. #define GPIO1_DATAIN 0xFFFBE42C
  85. /********************* LOCAL DECLARATIONS ************************/
  86. static inline void os_timer_dec_use_count(timer_obj_t *tmr);
  87. static int os_tl_timerHandlr(struct tiwlan_req *req);
  88. static void os_timerHandlr(unsigned long parm);
  89. static void send_frag(char* msg, int message_len, int level, int module);
  90. BOOL use_debug_module = FALSE;
  91. /****************************************************************************************
  92. * *
  93. * OS Report API *
  94. * *
  95. ****************************************************************************************/
  96. /****************************************************************************************
  97. * os_setDebugMode()
  98. ****************************************************************************************
  99. DESCRIPTION: Set the Debug Mode
  100. INPUT:
  101. RETURN: None
  102. NOTES:
  103. *****************************************************************************************/
  104. void os_setDebugMode(BOOL enable)
  105. {
  106. use_debug_module = enable;
  107. }
  108. /****************************************************************************************
  109. * os_printf()
  110. ****************************************************************************************
  111. DESCRIPTION: Print formatted output.
  112. INPUT: format - Specifies the string, to be printed
  113. RETURN: None
  114. NOTES:
  115. *****************************************************************************************/
  116. void os_printf(const char *format ,...)
  117. {
  118. static int from_new_line = 1; /* Used to save the last message EOL */
  119. static UINT8 module = 0; /* Used to save the last message module */
  120. static UINT8 level = 0; /* Used to save the last message level */
  121. va_list ap;
  122. static char msg[500];
  123. char *p_msg = msg; /* Pointer to the message */
  124. UINT16 message_len;
  125. UINT32 sec = 0;
  126. UINT32 uSec = 0;
  127. /* Format the message and keep the message length */
  128. va_start(ap,format);
  129. message_len = vsnprintf(&msg[1], sizeof(msg) - 1, format, ap);
  130. if (use_debug_module)
  131. {
  132. /*********************/
  133. /* Use debug module */
  134. /*******************/
  135. if (msg[1] == '$')
  136. {
  137. /************************************
  138. Message format: "$XX"
  139. |||
  140. message prefix ----|||
  141. module index -------||
  142. severity index ------|
  143. ************************************/
  144. level = (msg[2] - 'A');
  145. module = (msg[3] - 'A');
  146. }
  147. else
  148. {
  149. send_frag(msg, message_len, level, module);
  150. }
  151. }
  152. else
  153. {
  154. /***********************/
  155. /* Use regular printk */
  156. /*********************/
  157. if( from_new_line )
  158. {
  159. if (msg[1] == '$')
  160. {
  161. p_msg += 4;
  162. }
  163. sec = os_timeStampUs(NULL);
  164. uSec = sec % 1000000;
  165. sec /= 1000000;
  166. printk(KERN_INFO DRIVER_NAME ": %d.%06d: %s",sec,uSec,p_msg);
  167. }
  168. else
  169. {
  170. printk(&msg[1]);
  171. }
  172. from_new_line = ( msg[message_len] == '\n' );
  173. }
  174. }
  175. static void send_frag(char* msg, int message_len, int level, int module)
  176. {
  177. #ifdef TIWLAN_OMAP1610 /* Dm: */
  178. int return_value;
  179. int offset = 1;
  180. int TmpLen;
  181. char* FragMsg;
  182. do
  183. {
  184. TmpLen = min(message_len - offset, FRAG_SIZE);
  185. FragMsg = msg + offset - 1;
  186. FragMsg[0] = module;
  187. return_value = debug_module_enqueue_message(DEBUG_MODULE_TRACE_QUEUE_ID, level, FragMsg, TmpLen+1, CONTROL_CODE_TYPE_MESSAGE);
  188. if (return_value)
  189. {
  190. /* Message overrun */
  191. /* Send the overrun indication to the debug module */
  192. os_memoryCopy(NULL, &msg[1], "*** Message Overrun ***", strlen("*** Message Overrun ***"));
  193. msg[0] = 0;
  194. debug_module_enqueue_message(DEBUG_MODULE_TRACE_QUEUE_ID, 0, msg, (strlen("*** Message Overrun ***") + 1), CONTROL_CODE_TYPE_MESSAGE);
  195. /* Print overrun indication to the terminal */
  196. /*printk(KERN_INFO DRIVER_NAME ": %d.%06d: %s\n", sec, uSec, "**** Debug module message overrun! ****\n");*/
  197. }
  198. offset += TmpLen;
  199. }while (offset < message_len);
  200. #endif
  201. }
  202. /****************************************************************************************
  203. * *
  204. * OS DMA CALLBACK API *
  205. ****************************************************************************************/
  206. /****************************************************************************************
  207. * os_TNETWIF_BusTxn_Complete()
  208. ****************************************************************************************
  209. DESCRIPTION: Callback directly called at an IRQ context from the SPI modue
  210. This should triger a tasklet_schedule so that the End of DMA will be handled
  211. in a tasklet context and then be directed to the TNETWIF to call the Client callback.
  212. INPUT: OsContext - our adapter context.
  213. RETURN: None
  214. NOTES:
  215. *****************************************************************************************/
  216. void os_TNETWIF_BusTxn_Complete(TI_HANDLE OsContext,int status)
  217. {
  218. tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
  219. drv->dma_done = 1;
  220. #ifdef DM_USE_WORKQUEUE
  221. /* printk("TI: %s:\t%lu\n", __FUNCTION__, jiffies); */
  222. #ifdef CONFIG_ANDROID_POWER
  223. android_lock_suspend( &drv->timer_wake_lock );
  224. #endif
  225. queue_work( drv->tiwlan_wq, &drv->tw );
  226. #else
  227. tasklet_schedule(&drv->tl);
  228. #endif
  229. }
  230. /****************************************************************************************
  231. * *
  232. * OS TIMER API *
  233. * *
  234. ****************************************************************************************/
  235. /****************************************************************************************
  236. * os_timerCreate()
  237. ****************************************************************************************
  238. DESCRIPTION: This function creates and initializes a timer object associated with a
  239. caller's pRoutine function.
  240. ARGUMENTS:
  241. RETURN: A handle of the created timer.
  242. TI_HANDLE_INVALID if there is insufficient memory available
  243. NOTES: Using the Kernel timer feature, problem is that kernel timers are one-shots.
  244. For timers that are periodic this abstraction layer will have to mediate
  245. between the callback function and the re-submission of a timer request.
  246. *****************************************************************************************/
  247. TI_HANDLE
  248. os_timerCreate(
  249. TI_HANDLE OsContext,
  250. PTIMER_FUNCTION pRoutine,
  251. TI_HANDLE Context
  252. )
  253. {
  254. timer_obj_t *tmr;
  255. #ifdef ESTA_TIMER_DEBUG
  256. esta_timer_log("\n\n%s:%d ::os_timerCreate(%p,%p,%p)",__FUNCTION__, __LINE__,OsContext,pRoutine,Context);
  257. #endif
  258. ti_nodprintf(TIWLAN_LOG_INFO, "\n----> os_timerCreate function = 0x%08x , context= 0x%08x",
  259. (int)pRoutine, (int)Context);
  260. os_profile (OsContext, 6, 0);
  261. tmr = os_memoryAlloc (OsContext, sizeof(timer_obj_t));
  262. if (tmr == NULL)
  263. return(TI_HANDLE_INVALID);
  264. memset (tmr,0,sizeof(timer_obj_t));
  265. init_timer(&tmr->timer);
  266. INIT_LIST_HEAD(&tmr->req.list);
  267. tmr->timer.function = os_timerHandlr;
  268. tmr->timer.data = (int)tmr;
  269. tmr->req.drv = (tiwlan_net_dev_t *)OsContext;
  270. tmr->req.u.req.p1 = (UINT32)pRoutine;
  271. tmr->req.u.req.p2 = (UINT32)Context;
  272. tmr->req.u.req.f = os_tl_timerHandlr;
  273. tmr->use_count = 1;
  274. esta_timer_log("=%p\n\n", tmr);
  275. return (TI_HANDLE)tmr;
  276. }
  277. /****************************************************************************************
  278. * os_timerDestroy()
  279. ****************************************************************************************
  280. DESCRIPTION: This function destroy the timer object.
  281. ARGUMENTS:
  282. RETURN:
  283. NOTES: Returning the Kernel level timer_list memory allocation and the
  284. abstraction level timer object.
  285. *****************************************************************************************/
  286. VOID
  287. os_timerDestroy(
  288. TI_HANDLE OsContext,
  289. TI_HANDLE TimerHandle
  290. )
  291. {
  292. timer_obj_t *tmr = TimerHandle;
  293. os_profile (OsContext, 6, 0);
  294. os_timerStop (OsContext, TimerHandle);
  295. os_timer_dec_use_count (tmr);
  296. }
  297. /****************************************************************************************
  298. * os_timerStart()
  299. ****************************************************************************************
  300. DESCRIPTION: This function start the timer object.
  301. ARGUMENTS:
  302. RETURN:
  303. NOTES:
  304. *****************************************************************************************/
  305. VOID
  306. os_timerStart(
  307. TI_HANDLE OsContext,
  308. TI_HANDLE TimerHandle,
  309. UINT32 DelayMs,
  310. BOOL bPeriodic
  311. )
  312. {
  313. timer_obj_t *tmr= (timer_obj_t *)TimerHandle;
  314. UINT32 jiffie_cnt = msecs_to_jiffies(DelayMs);
  315. #ifdef ESTA_TIMER_DEBUG
  316. esta_timer_log("\n\n%s:%d ::os_timerStart(%p,%p,%u,%d)\n\n",__FUNCTION__, __LINE__,OsContext,TimerHandle,DelayMs,bPeriodic);
  317. #endif
  318. tmr->req.u.req.p3 = bPeriodic;
  319. tmr->req.u.req.p4 = jiffie_cnt;
  320. tmr->timer.data = (unsigned long)tmr;
  321. mod_timer(&tmr->timer, jiffies + jiffie_cnt);
  322. return;
  323. }
  324. /****************************************************************************************
  325. * os_stopTimer()
  326. ****************************************************************************************
  327. DESCRIPTION: This function stop the timer object.
  328. ARGUMENTS:
  329. RETURN:
  330. NOTES:
  331. *****************************************************************************************/
  332. VOID
  333. os_timerStop(
  334. TI_HANDLE OsContext,
  335. TI_HANDLE TimerHandle
  336. )
  337. {
  338. timer_obj_t *tmr= (timer_obj_t *)TimerHandle;
  339. del_timer_sync(&tmr->timer);
  340. tmr->req.u.req.p3 = 0; /* Turn "periodic" off */
  341. list_del_init(&tmr->req.list);
  342. return;
  343. }
  344. /****************************************************************************************
  345. * os_periodicIntrTimerStart()
  346. ****************************************************************************************
  347. DESCRIPTION: This function starts the periodic interrupt mechanism. This mode is used
  348. when interrupts that usually received from the Fw is now masked, and we are
  349. checking for any need of Fw handling in time periods.
  350. ARGUMENTS:
  351. RETURN:
  352. NOTES: Power level of the CHIP should be always awake in this mode (no ELP)
  353. *****************************************************************************************/
  354. VOID
  355. os_periodicIntrTimerStart(
  356. TI_HANDLE OsContext
  357. )
  358. {
  359. tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
  360. mod_timer (&drv->poll_timer, jiffies + TIWLAN_IRQ_POLL_INTERVAL);
  361. }
  362. /****************************************************************************************
  363. * os_timeStampMs()
  364. ****************************************************************************************
  365. DESCRIPTION: This function returns the number of milliseconds that have elapsed since
  366. the system was booted.
  367. ARGUMENTS: OsContext - our adapter context.
  368. RETURN:
  369. NOTES:
  370. *****************************************************************************************/
  371. UINT32
  372. os_timeStampMs(
  373. TI_HANDLE OsContext
  374. )
  375. {
  376. struct timeval tv;
  377. do_gettimeofday(&tv);
  378. return tv.tv_sec*1000 + tv.tv_usec/1000;
  379. }
  380. /****************************************************************************************
  381. * os_timeStampUs()
  382. ****************************************************************************************
  383. DESCRIPTION: This function returns the number of microseconds that have elapsed since
  384. the system was booted.
  385. ARGUMENTS: OsContext - our adapter context.
  386. Note that sometimes this function will be called with NULL(!!!) as argument!
  387. RETURN:
  388. NOTES:
  389. *****************************************************************************************/
  390. UINT32
  391. os_timeStampUs(
  392. TI_HANDLE OsContext
  393. )
  394. {
  395. struct timeval tv;
  396. do_gettimeofday(&tv);
  397. return tv.tv_sec*1000000 + tv.tv_usec;
  398. }
  399. /****************************************************************************************
  400. * os_StalluSec()
  401. ****************************************************************************************
  402. DESCRIPTION: This function make delay in microseconds.
  403. ARGUMENTS: OsContext - our adapter context.
  404. uSec - delay time in microseconds
  405. RETURN:
  406. NOTES:
  407. *****************************************************************************************/
  408. VOID
  409. os_StalluSec(
  410. TI_HANDLE OsContext,
  411. UINT32 uSec
  412. )
  413. {
  414. /*UINT32 usec_now = os_timeStampUs(OsContext);
  415. while(os_timeStampUs(OsContext) - usec_now < uSec)
  416. ;
  417. */
  418. udelay(uSec);
  419. }
  420. /****************************************************************************************
  421. * os_WaitComplete()
  422. ****************************************************************************************
  423. DESCRIPTION: This function start waiting for the complete
  424. ARGUMENTS:
  425. RETURN:
  426. NOTES: can be called only from process context, and not from tasklet
  427. *****************************************************************************************/
  428. VOID
  429. os_WaitComplete(
  430. TI_HANDLE OsContext
  431. )
  432. {
  433. tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
  434. /* ti_dprintf(TIWLAN_LOG_INFO, "os_WaitComplete drv %x drv->comp %x\n",(UINT32)drv,(UINT32)&drv->comp); */
  435. /*
  436. he tasklet should them send back the user (here)the completion event so the user could
  437. go through the configuration phase
  438. */
  439. wait_for_completion(&drv->comp);
  440. }
  441. /****************************************************************************************
  442. * os_Complete()
  443. ****************************************************************************************
  444. DESCRIPTION: This function signals to the waiting process that completion occured
  445. ARGUMENTS:
  446. RETURN:
  447. NOTES:
  448. *****************************************************************************************/
  449. VOID
  450. os_Complete(
  451. TI_HANDLE OsContext
  452. )
  453. {
  454. tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
  455. /* ti_dprintf(TIWLAN_LOG_INFO, "os_Complete drv %x drv->comp %x\n",(UINT32)drv, (UINT32)&drv->comp); */
  456. /*
  457. Call the completion routine that will unblock the caller that was waiting on that object
  458. */
  459. complete(&drv->comp);
  460. }
  461. /****************************************************************************************
  462. * *
  463. * Hardware access functions API *
  464. * *
  465. ****************************************************************************************/
  466. /****************************************************************************************
  467. * os_clearWlanReady()
  468. ****************************************************************************************
  469. DESCRIPTION: Clear the WLAN Ready Interrupt Line stored in the PIC Controller
  470. INPUT: None
  471. RETURN: None
  472. NOTES:
  473. *****************************************************************************************/
  474. __inline__ VOID
  475. os_clearWlanReady(
  476. void)
  477. {
  478. #ifdef TIWLAN_OMAP1610
  479. omap_writel(4,GPIO1_IRQSTATUS1);
  480. #endif
  481. }
  482. /****************************************************************************************
  483. * os_senseIrqLine()
  484. ****************************************************************************************
  485. DESCRIPTION: Read the WLAN_IRQ line
  486. INPUT: void
  487. RETURN: Read value
  488. NOTES:
  489. *****************************************************************************************/
  490. __inline__ UINT32
  491. os_senseIrqLine(
  492. TI_HANDLE OsContext
  493. )
  494. {
  495. #ifdef TIWLAN_OMAP1610
  496. return (omap_readl(GPIO1_DATAIN) & 0x4);
  497. #else
  498. return 0;
  499. #endif
  500. }
  501. /****************************************************************************************
  502. * os_hwGetRegistersAddr()
  503. ****************************************************************************************
  504. DESCRIPTION:
  505. ARGUMENTS:
  506. RETURN:
  507. NOTES:
  508. *****************************************************************************************/
  509. PVOID
  510. os_hwGetRegistersAddr(
  511. TI_HANDLE OsContext
  512. )
  513. {
  514. return (PVOID)OS_API_REG_ADRR;
  515. }
  516. /****************************************************************************************
  517. * os_hwGetMemoryAddr()
  518. ****************************************************************************************
  519. DESCRIPTION:
  520. ARGUMENTS:
  521. RETURN:
  522. NOTES:
  523. *****************************************************************************************/
  524. PVOID
  525. os_hwGetMemoryAddr(
  526. TI_HANDLE OsContext
  527. )
  528. {
  529. return (PVOID)OS_API_MEM_ADRR;
  530. }
  531. /****************************************************************************************
  532. * os_memoryGetPhysicalLow()
  533. ****************************************************************************************
  534. DESCRIPTION: return the lower 32 bits of a 64bit number / address *
  535. ARGUMENTS:
  536. RETURN:
  537. NOTES:
  538. *****************************************************************************************/
  539. UINT32 os_memoryGetPhysicalLow (OS_PHYSICAL_ADDRESS pAddr)
  540. {
  541. UINT32 res;
  542. res = pAddr & 0xffffffff;
  543. ti_dprintf(TIWLAN_LOG_ERROR, "\n 64bit low. Got 0x%x; Returning 0x%x \n", (UINT32)pAddr, res);
  544. return res;
  545. }
  546. /****************************************************************************************
  547. * os_memoryGetPhysicalHigh()
  548. ****************************************************************************************
  549. DESCRIPTION: return the higher order 32 bits of a 64bit number / address *
  550. ARGUMENTS:
  551. RETURN:
  552. NOTES:
  553. *****************************************************************************************/
  554. UINT32 os_memoryGetPhysicalHigh (OS_PHYSICAL_ADDRESS pAddr)
  555. {
  556. UINT32 res;
  557. res = pAddr >> 32;
  558. ti_dprintf(TIWLAN_LOG_ERROR, "\n 64bit high. Got 0x%x; Returning 0x%x \n", (UINT32)pAddr, res);
  559. return res;
  560. }
  561. /****************************************************************************************
  562. * *
  563. * Protection services API *
  564. * *
  565. ****************************************************************************************
  566. * OS protection is implemented as dummy functions because *
  567. * all driver code is executed in context of a single tasklet, *
  568. * except IOCTL handlers and xmition. *
  569. * Protection in IOCTL handlers and hard_start_xmit is done by different *
  570. * means. *
  571. ****************************************************************************************/
  572. /****************************************************************************************
  573. * os_protectCreate()
  574. ****************************************************************************************
  575. DESCRIPTION:
  576. ARGUMENTS: OsContext - our adapter context.
  577. RETURN: A handle of the created mutex/spinlock.
  578. TI_HANDLE_INVALID if there is insufficient memory available or problems
  579. initializing the mutex
  580. NOTES:
  581. *****************************************************************************************/
  582. TI_HANDLE
  583. os_protectCreate(
  584. TI_HANDLE OsContext
  585. )
  586. {
  587. return (TI_HANDLE)OS_PROTECT_HANDLE;
  588. }
  589. /****************************************************************************************
  590. * os_protectDestroy()
  591. ****************************************************************************************
  592. DESCRIPTION:
  593. ARGUMENTS: OsContext - our adapter context.
  594. RETURN: None - This had better work since there is not a return value to the user
  595. NOTES:
  596. *****************************************************************************************/
  597. VOID
  598. os_protectDestroy(
  599. TI_HANDLE OsContext,
  600. TI_HANDLE ProtectCtx
  601. )
  602. {
  603. return;
  604. }
  605. /****************************************************************************************
  606. * os_protectLock()
  607. ****************************************************************************************
  608. DESCRIPTION:
  609. ARGUMENTS: OsContext - our adapter context.
  610. RETURN: None - This had better work since there is not a return value to the user
  611. NOTES:
  612. *****************************************************************************************/
  613. VOID
  614. os_protectLock(
  615. TI_HANDLE OsContext,
  616. TI_HANDLE ProtectContext
  617. )
  618. {
  619. #if 1 /* uncomment for work in INDIRECT mode (HwACXAccessMethod=0) */
  620. tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
  621. spin_lock_irqsave(&drv->lock, drv->flags);
  622. #endif
  623. }
  624. /****************************************************************************************
  625. * os_protectUnlock()
  626. ****************************************************************************************
  627. DESCRIPTION:
  628. ARGUMENTS: OsContext - our adapter context.
  629. RETURN: None - This had better work since there is not a return value to the user
  630. NOTES:
  631. *****************************************************************************************/
  632. VOID
  633. os_protectUnlock(
  634. TI_HANDLE OsContext,
  635. TI_HANDLE ProtectContext
  636. )
  637. {
  638. #if 1 /* uncomment for work in INDIRECT mode (HwACXAccessMethod=0) */
  639. tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
  640. spin_unlock_irqrestore(&drv->lock, drv->flags);
  641. #endif
  642. }
  643. /*-----------------------------------------------------------------------------
  644. Routine Name:
  645. os_resetWakeOnGpio
  646. Routine Description:
  647. set the GPIO to low after awaking the TNET from ELP.
  648. Arguments:
  649. OsContext - our adapter context.
  650. Return Value:
  651. None
  652. -----------------------------------------------------------------------------*/
  653. VOID
  654. os_hardResetTnetw( void )
  655. {
  656. /*
  657. * Define the OMAP GPIO registers, the TNETW reset is currently connected
  658. * to GPIO 16, this logic assumes that the loading code had muxed the
  659. * GPIO 16 to the Y1 pinout.
  660. */
  661. /* direction out */
  662. #ifdef TIWLAN_OMAP1610
  663. omap_set_gpio_direction(GPIO_16, GPIO_16_DIRECTION_OUTPUT);
  664. /* clear reset WLAN chip */
  665. omap_set_gpio_dataout(GPIO_16, GPIO_16_CLEAR);
  666. /* wait for 50msec */
  667. mdelay(50);
  668. omap_set_gpio_dataout(GPIO_16, GPIO_16_SET);
  669. /* wait for 50msec */
  670. mdelay(50);
  671. #endif /* Dm: */
  672. #ifdef TIWLAN_MSM7000
  673. msm_wifi_reset(1); /* Reset active */
  674. msm_wifi_power(0); /* Power disable */
  675. msm_wifi_power(1); /* Power enable */
  676. msm_wifi_reset(0); /* Reset clear */
  677. #endif
  678. }
  679. #ifndef GWSI_DRIVER
  680. /****************************************************************************************
  681. START OF TI DRIVER API
  682. *****************************************************************************************/
  683. /****************************************************************************************
  684. * os_setWakeOnGpio()
  685. ****************************************************************************************
  686. DESCRIPTION: set the GPIO to high for awaking the TNET from ELP.
  687. ARGUMENTS: OsContext - our adapter context.
  688. RETURN: None
  689. NOTES:
  690. *****************************************************************************************/
  691. VOID
  692. os_setWakeOnGpio(
  693. TI_HANDLE OsContext
  694. )
  695. {
  696. #ifdef TIWLAN_OMAP1610
  697. /*
  698. Clear ELP_REQ by GPIO_CLEAR_DATAOUT
  699. */
  700. os_resetWakeOnGpio(OsContext);
  701. /*
  702. Rising edge on ELP_REQ by GPIO_SET_DATAOUT
  703. */
  704. omap_writel(0x00000200, 0xFFFBBCF0);
  705. #endif
  706. }
  707. /****************************************************************************************
  708. * os_resetWakeOnGpio()
  709. ****************************************************************************************
  710. DESCRIPTION: set the GPIO to low after awaking the TNET from ELP.
  711. ARGUMENTS: OsContext - our adapter context.
  712. RETURN: None
  713. NOTES:
  714. *****************************************************************************************/
  715. VOID
  716. os_resetWakeOnGpio(
  717. TI_HANDLE OsContext
  718. )
  719. {
  720. /*
  721. Clear ELP_REQ by GPIO_CLEAR_DATAOUT
  722. */
  723. #ifdef TIWLAN_OMAP1610
  724. omap_writel(0x00000200, 0xFFFBBCB0);
  725. #endif
  726. }
  727. /****************************************************************************************
  728. * _os_memorySharedFree()
  729. ****************************************************************************************
  730. DESCRIPTION:
  731. ARGUMENTS:
  732. RETURN:
  733. NOTES:
  734. *****************************************************************************************/
  735. VOID
  736. _os_memorySharedFree(
  737. TI_HANDLE OsContext,
  738. PVOID pVirtual,
  739. UINT32 Size,
  740. OS_PHYSICAL_ADDRESS pPhysical
  741. )
  742. {
  743. ti_dprintf(TIWLAN_LOG_ERROR, "\n\n\n %s is not implemented\n\n\n", __FUNCTION__);
  744. }
  745. /****************************************************************************************
  746. * _os_memorySharedAlloc()
  747. ****************************************************************************************
  748. DESCRIPTION:
  749. ARGUMENTS:
  750. RETURN:
  751. NOTES:
  752. *****************************************************************************************/
  753. PVOID
  754. _os_memorySharedAlloc(
  755. TI_HANDLE OsContext,
  756. UINT32 Size,
  757. OS_PHYSICAL_ADDRESS *pPhysical
  758. )
  759. {
  760. ti_dprintf(TIWLAN_LOG_ERROR, "\n\n\n %s is not implemented\n\n\n", __FUNCTION__);
  761. return NULL;
  762. }
  763. /****************************************************************************************
  764. * os_powerStateBusy()
  765. ****************************************************************************************
  766. DESCRIPTION: notify to the host that the TI_WLAN application is busy.
  767. ARGUMENTS: OsContext - our adapter context.
  768. RETURN:
  769. NOTES:
  770. *****************************************************************************************/
  771. VOID
  772. os_powerStateBusy(
  773. TI_HANDLE OsContext
  774. )
  775. {
  776. #if 0
  777. ti_dprintf(TIWLAN_LOG_INFO,
  778. "%s(%d) - os_powerStateBusy: TI_WLAN is busy!\n",
  779. __FILE__,__LINE__);
  780. #endif
  781. }
  782. /****************************************************************************************
  783. * os_powerStateIdle()
  784. ****************************************************************************************
  785. DESCRIPTION: notify to the host that the TI_WLAN application is idle.
  786. ARGUMENTS: OsContext - our adapter context.
  787. RETURN:
  788. NOTES:
  789. *****************************************************************************************/
  790. VOID
  791. os_powerStateIdle(
  792. TI_HANDLE OsContext
  793. )
  794. {
  795. #if 0
  796. ti_dprintf(TIWLAN_LOG_INFO,
  797. "%s(%d) - os_powerStateIdle: TI_WLAN is idle!\n",
  798. __FILE__,__LINE__);
  799. #endif
  800. }
  801. /****************************************************************************************
  802. * os_memoryMove()
  803. ****************************************************************************************
  804. DESCRIPTION: Move memory block from pSource to pDestination
  805. ARGUMENTS: OsContext - Our adapter context.
  806. pDestination - destination
  807. pSource - source
  808. Size - Number of characters
  809. RETURN:
  810. NOTES:
  811. *****************************************************************************************/
  812. VOID
  813. os_memoryMove(
  814. TI_HANDLE pOsContext,
  815. PVOID pDestination,
  816. PVOID pSource,
  817. UINT32 Size
  818. )
  819. {
  820. memmove(pDestination, pSource, Size);
  821. }
  822. /****************************************************************************************
  823. * os_memoryMoveToHw()
  824. ****************************************************************************************
  825. DESCRIPTION: This function copies data from a system-space buffer to device memory.
  826. ARGUMENTS: OsContext - Our adapter context.
  827. pTarget - Specifies the base address within a device memory range where
  828. the copy should begin.
  829. pSource - Pointer to a system-space buffer from which this function copies
  830. data to the destination range.
  831. Size - Specifies the number of bytes to copy.
  832. RETURN: None
  833. NOTES:
  834. *****************************************************************************************/
  835. VOID
  836. os_memoryMoveToHw(
  837. TI_HANDLE OsContext,
  838. PVOID pTarget,
  839. PVOID pSource,
  840. UINT32 Size
  841. )
  842. {
  843. print_info("\nos_memoryMoveToHw pTarget 0x%08x pSource 0x%08x Size 0x%08x",(int)pTarget, (int)pSource,(int)Size);
  844. print_info("\n-------------------------> Not Implemented <--------------------------------------------------- ");
  845. }
  846. /****************************************************************************************
  847. * os_memoryMoveFromHw()
  848. ****************************************************************************************
  849. DESCRIPTION: This function copies data from a system-space buffer to device memory.
  850. ARGUMENTS: OsContext - Our adapter context.
  851. pTarget - Pointer to a system-space buffer into which this function copies
  852. data from device memory.
  853. pSource - Specifies the base virtual address within device memory from
  854. which to copy the data.
  855. Size - Specifies the number of bytes to copy.
  856. RETURN: None
  857. NOTES:
  858. *****************************************************************************************/
  859. VOID
  860. os_memoryMoveFromHw(
  861. TI_HANDLE OsContext,
  862. PVOID pTarget,
  863. PVOID pSource,
  864. UINT32 Size
  865. )
  866. {
  867. print_info("\nos_memoryMoveFromHw pTarget 0x%08x pSource 0x%08x Size 0x%08x",(int)pTarget, (int)pSource,(int)Size);
  868. print_info("\n-------------------------> Not Implemented <--------------------------------------------------- ");
  869. }
  870. /****************************************************************************************
  871. * os_hwReadMemRegisterUINT8()
  872. ****************************************************************************************
  873. DESCRIPTION: Reads a UINT8 from a memory-mapped device register.
  874. ARGUMENTS: OsContext - our adapter context.
  875. Register - Pointer to the memory-mapped register.
  876. Data - Pointer to the caller-supplied variable in which this function
  877. returns the UINT8 read from Register.
  878. RETURN: None
  879. NOTES:
  880. *****************************************************************************************/
  881. VOID
  882. os_hwReadMemRegisterUINT8(
  883. TI_HANDLE OsContext,
  884. PUCHAR Register,
  885. PUINT8 Data
  886. )
  887. {
  888. *Data = *Register;
  889. PRINT_REG("R8: %p=0x%x\n", Register, *Data);
  890. return;
  891. }
  892. /****************************************************************************************
  893. * os_hwWriteMemRegisterUINT16()
  894. ****************************************************************************************
  895. DESCRIPTION: Writes a 'unsigned short' to a memory-mapped device register.
  896. ARGUMENTS: OsContext - our adapter context.
  897. Register - Pointer to the memory-mapped register.
  898. Data - Specifies the caller-supplied UINT16 that this function transfers
  899. to the Register.
  900. RETURN: None
  901. NOTES:
  902. *****************************************************************************************/
  903. VOID
  904. os_hwWriteMemRegisterUINT16(
  905. TI_HANDLE OsContext,
  906. PUINT16 Register,
  907. UINT16 Data
  908. )
  909. {
  910. PRINT_REG("W16: %p=0x%x\n", Register, Data);
  911. *Register = Data;
  912. return;
  913. }
  914. /****************************************************************************************
  915. * os_hwReadMemRegisterUINT16()
  916. ****************************************************************************************
  917. DESCRIPTION: Reads a UINT16 from a memory-mapped device register.
  918. ARGUMENTS: OsContext - our adapter context.
  919. Register - Pointer to the memory-mapped register.
  920. Data - Pointer to the caller-supplied variable in which this function
  921. returns the UINT16 read from Register.
  922. RETURN: None
  923. NOTES:
  924. *****************************************************************************************/
  925. VOID
  926. os_hwReadMemRegisterUINT16(
  927. TI_HANDLE OsContext,
  928. PUINT16 Register,
  929. PUINT16 Data
  930. )
  931. {
  932. *Data = *Register;
  933. PRINT_REG("R16: %p=0x%x\n", Register, *Data);
  934. return;
  935. }
  936. /****************************************************************************************
  937. * os_hwWriteMemRegisterUINT32()
  938. ****************************************************************************************
  939. DESCRIPTION: Writes a 'unsigned long' to a memory-mapped device register.
  940. ARGUMENTS: OsContext - our adapter context.
  941. Register - Pointer to the memory-mapped register.
  942. Data - Specifies the caller-supplied UINT32 that this function transfers
  943. to the Register.
  944. RETURN: None
  945. NOTES:
  946. *****************************************************************************************/
  947. VOID
  948. os_hwWriteMemRegisterUINT32(
  949. TI_HANDLE OsContext,
  950. PUINT32 Register,
  951. UINT32 Data
  952. )
  953. {
  954. PRINT_REG("W32: %p=0x%x\n", Register, Data);
  955. *Register = Data;
  956. return;
  957. }
  958. /****************************************************************************************
  959. * os_hwReadMemRegisterUINT32()
  960. ****************************************************************************************
  961. DESCRIPTION: Reads a UINT32 from a memory-mapped device register.
  962. ARGUMENTS: OsContext - our adapter context.
  963. Register - Pointer to the memory-mapped register.
  964. Data - Pointer to the caller-supplied variable in which this function
  965. returns the UINT32 read from Register.
  966. RETURN: None
  967. NOTES:
  968. *****************************************************************************************/
  969. VOID
  970. os_hwReadMemRegisterUINT32(
  971. TI_HANDLE OsContext,
  972. PUINT32 Register,
  973. PUINT32 Data
  974. )
  975. {
  976. *Data = *Register;
  977. PRINT_REG("R32: %p=0x%x\n", Register, *Data);
  978. return;
  979. }
  980. /****************************************************************************************
  981. * os_receivePacket()
  982. ****************************************************************************************
  983. DESCRIPTION:
  984. ARGUMENTS:
  985. RETURN:
  986. NOTES:
  987. *****************************************************************************************/
  988. BOOL
  989. os_receivePacket(
  990. TI_HANDLE OsContext,
  991. PVOID pPacket,
  992. UINT16 Length
  993. )
  994. {
  995. tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
  996. struct sk_buff *skb;
  997. mem_MSDU_T* pMsdu = (mem_MSDU_T*)pPacket;
  998. mem_BD_T *pCurBd;
  999. ti_nodprintf(TIWLAN_LOG_INFO, "os_receivePacket - Received EAPOL len-%d\n", pMsdu->firstBDPtr->length );
  1000. bm_trace(10, Length, 0);
  1001. if (pMsdu->firstBDPtr->length > Length) { /* Dm: Security fix */
  1002. ti_dprintf(TIWLAN_LOG_ERROR, " TI: %s - Security Error\n", __FUNCTION__);
  1003. return FALSE;
  1004. }
  1005. skb = dev_alloc_skb(Length+2);
  1006. if(!skb) {
  1007. print_deb(" os_receivePacket() : dev_alloc_skb failed!\n");
  1008. configMgr_memMngrFreeMSDU(drv->adapter.CoreHalCtx, memMgr_MsduHandle(pPacket));
  1009. drv->stats.rx_dropped++;
  1010. return FALSE;
  1011. }
  1012. skb_reserve(skb, 2);
  1013. pCurBd = pMsdu->firstBDPtr;
  1014. while (pCurBd) {
  1015. memcpy(skb_put(skb,pCurBd->length),pCurBd->data+pCurBd->dataOffset,pCurBd->length);
  1016. pCurBd = pCurBd->nextBDPtr;
  1017. }
  1018. skb->dev = drv->netdev;
  1019. skb->protocol = eth_type_trans(skb, drv->netdev);
  1020. skb->ip_summed = CHECKSUM_NONE;
  1021. drv->stats.rx_packets++;
  1022. drv->stats.rx_bytes += skb->len;
  1023. bm_trace(11, Length, 0);
  1024. #ifdef CONFIG_ANDROID_POWER
  1025. drv->receive_packet = 1; /* Remember to stay awake */
  1026. #endif
  1027. netif_rx(skb);
  1028. configMgr_memMngrFreeMSDU(drv->adapter.CoreHalCtx, memMgr_MsduHandle(pPacket));
  1029. bm_trace(12, Length, 0);
  1030. return TRUE;
  1031. }
  1032. /****************************************************************************************
  1033. * os_sendPacket()
  1034. ****************************************************************************************
  1035. DESCRIPTION: send EAPOL packet from Supplicant
  1036. ARGUMENTS:
  1037. RETURN:
  1038. NOTES:
  1039. *****************************************************************************************/
  1040. INT32
  1041. os_sendPacket(
  1042. TI_HANDLE OsContext,
  1043. PVOID pPacket,
  1044. UINT16 Length
  1045. )
  1046. {
  1047. struct net_device *dev = (struct net_device *)OsContext;
  1048. tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)NETDEV_GET_PRIVATE(dev);
  1049. INT32 status;
  1050. mem_MSDU_T* pMsdu;
  1051. char *pMsduData;
  1052. UINT32 packetHeaderLength;
  1053. ti_nodprintf(TIWLAN_LOG_INFO, "os_sendPacket - Transmit EAPOL len-%x\n",Length );
  1054. /*
  1055. * Allocate enough place also for 802.11 header (24 bytes) and LLC (8 bytes)
  1056. * to replace the Ethernet header (14 bytes)
  1057. */
  1058. if(!Length)
  1059. {
  1060. ti_dprintf(TIWLAN_LOG_ERROR, " EAPOL Packet Length = 0 \n");
  1061. return -1;
  1062. }
  1063. /*
  1064. * Retrieve the Packet Header length
  1065. * from QoS Manager (through configMgr) and RSN
  1066. */
  1067. packetHeaderLength = configMgr_getPacketHeaderLength(drv->adapter.CoreHalCtx,pPacket,TX_DATA_EAPOL_MSDU);
  1068. /*
  1069. * need to reserve enough space for header translation
  1070. * in the same first Bd.
  1071. * Allocate enough place also for 802.11 header (24 bytes or 26 for QoS) and LLC (8 bytes)
  1072. * to replace the Ethernet header (14 bytes)
  1073. */
  1074. status = configMgr_allocMSDU(drv->adapter.CoreHalCtx, &pMsdu,
  1075. Length + packetHeaderLength , OS_ABS_TX_MODULE);
  1076. if(status != OK)
  1077. {
  1078. ti_dprintf(TIWLAN_LOG_ERROR, " configMgr_allocMSDU failed !!!\n");
  1079. ++drv->alloc_msdu_failures;
  1080. return -ENOMEM;
  1081. }
  1082. /*
  1083. * case 1: only legacy wlan header
  1084. *
  1085. * case 2: only QoS wlan header
  1086. *
  1087. * case 3: only legacy wlan header with new snap
  1088. *
  1089. * case 4: only QoS wlan header with new snap
  1090. */
  1091. pMsdu->firstBDPtr->dataOffset = packetHeaderLength - ETHERNET_HDR_LEN;
  1092. pMsduData = pMsdu->firstBDPtr->data + pMsdu->firstBDPtr->dataOffset;
  1093. memcpy(pMsduData, pPacket, Length);
  1094. pMsdu->dataLen = Length;
  1095. pMsdu->firstBDPtr->length = pMsdu->dataLen + pMsdu->firstBDPtr->dataOffset;
  1096. pMsdu->freeFunc = 0;
  1097. pMsdu->freeArgs[0] = 0;
  1098. pMsdu->freeArgs[1] = 0;
  1099. /*
  1100. * Propagate Msdu through Config Manager.
  1101. * Set DTag to 0
  1102. * (note that classification is further handled in the Core)
  1103. */
  1104. status = configMgr_sendMsdu(drv->adapter.CoreHalCtx, pMsdu, 0);
  1105. return status;
  1106. }
  1107. #endif /* NDEF GWSI_DRIVER*/
  1108. /*******************************************************************************************************
  1109. LOCAL FUNCTIONS
  1110. ********************************************************************************************************/
  1111. /*-----------------------------------------------------------------------------
  1112. Routine Name:
  1113. os_timer_dec_use_count
  1114. Routine Description:
  1115. This function is decrements timer use count.
  1116. When use_count becomes 0, the timer block is destroyed
  1117. -----------------------------------------------------------------------------*/
  1118. static inline void os_timer_dec_use_count(timer_obj_t *tmr)
  1119. {
  1120. if (unlikely(!tmr->use_count)) {
  1121. ti_dprintf(TIWLAN_LOG_ERROR, "\n\n\n %s: attempt to delete a deleted timer %p\n\n\n", __FUNCTION__, tmr);
  1122. tmr->use_count = 1;
  1123. }
  1124. if (!(--tmr->use_count))
  1125. os_memoryFree(tmr->req.drv, tmr, sizeof(timer_obj_t));
  1126. }
  1127. /*-----------------------------------------------------------------------------
  1128. Routine Name:
  1129. os_tl_timerHandlr
  1130. Routine Description:
  1131. This function is called in context of the control tasklet.
  1132. It evokes user timer handler and restarts the timer if periodic
  1133. Arguments:
  1134. p1 - user handler
  1135. p2 - user parameter
  1136. p3 - periodic
  1137. p4 - jiffies
  1138. Return Value:
  1139. None.
  1140. Notes:
  1141. -----------------------------------------------------------------------------*/
  1142. static int os_tl_timerHandlr(struct tiwlan_req *req)
  1143. {
  1144. timer_obj_t *tmr= (timer_obj_t *)req;
  1145. PTIMER_FUNCTION f = (PTIMER_FUNCTION)req->u.req.p1;
  1146. TI_HANDLE parm = (TI_HANDLE)req->u.req.p2;
  1147. esta_timer_log("%s: req=0x%x f=0x%p parm=0x%p\n", __FUNCTION__, req, f, parm);
  1148. ++tmr->use_count;
  1149. f(parm);
  1150. if (req->u.req.p3) /* Periodic ? */
  1151. mod_timer(&tmr->timer, jiffies + req->u.req.p4);
  1152. os_timer_dec_use_count(tmr);
  1153. return 0;
  1154. }
  1155. /*-----------------------------------------------------------------------------
  1156. Routine Name:
  1157. os_timerHandlr
  1158. Routine Description:
  1159. This function is called on timer expiration in context of
  1160. softIsr. It delegates the timer handling to the control tasklet.
  1161. Arguments:
  1162. parm - timer object handle
  1163. Return Value:
  1164. None.
  1165. Notes:
  1166. -----------------------------------------------------------------------------*/
  1167. static void os_timerHandlr(unsigned long parm)
  1168. {
  1169. timer_obj_t *tmr= (timer_obj_t *)parm;
  1170. tiwlan_net_dev_t *drv = tmr->req.drv;
  1171. unsigned long flags;
  1172. esta_timer_log("%s: drv=%p f=0x%x ctx=0x%x\n",
  1173. __FUNCTION__, tmr->req.drv, tmr->req.u.req.p1, tmr->req.u.req.p2);
  1174. spin_lock_irqsave(&drv->lock, flags);
  1175. list_del(&tmr->req.list);
  1176. list_add_tail(&tmr->req.list, &drv->request_q);
  1177. spin_unlock_irqrestore(&drv->lock, flags);
  1178. #ifdef DM_USE_WORKQUEUE
  1179. /* printk("TI: %s:\t%lu\n", __FUNCTION__, jiffies); */
  1180. #ifdef CONFIG_ANDROID_POWER
  1181. android_lock_suspend( &drv->timer_wake_lock );
  1182. #endif
  1183. queue_work( drv->tiwlan_wq, &drv->tw );
  1184. #else
  1185. tasklet_schedule(&drv->tl);
  1186. #endif
  1187. }
  1188. /*-----------------------------------------------------------------------------
  1189. Routine Name:
  1190. os_connectionStatus
  1191. Routine Description:
  1192. The eSTA-DK will call this API so the OS stack is aware that the
  1193. WLAN layer is ready to function.
  1194. Arguments:
  1195. cStatus = 1; WLAN in ready for network packets
  1196. cStatus = 0; WLAN in not ready for network packets
  1197. Return Value:
  1198. None
  1199. -----------------------------------------------------------------------------*/
  1200. tiINT32
  1201. os_IndicateEvent(IPC_EV_DATA* pData)
  1202. {
  1203. IPC_EVENT_PARAMS * pInParam = (IPC_EVENT_PARAMS *)pData;
  1204. tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)(pInParam->hUserParam);
  1205. /*UCHAR AuthBuf[sizeof(ULONG) + sizeof(OS_802_11_AUTHENTICATION_REQUEST)];*/
  1206. ti_nodprintf(TIWLAN_LOG_INFO, "\n os_ConnectionStatus Event 0x%08x \n", CsStatus->Event);
  1207. switch(pInParam->uEventType)
  1208. {
  1209. case IPC_EVENT_ASSOCIATED:
  1210. if (drv->netdev != NULL) {
  1211. netif_carrier_on(drv->netdev);
  1212. #if defined(CONFIG_TROUT_PWRSINK) || defined(CONFIG_HTC_PWRSINK)
  1213. queue_delayed_work(drv->tiwlan_wq, &drv->trxw, 0);
  1214. #endif
  1215. }
  1216. break;
  1217. case IPC_EVENT_DISASSOCIATED:
  1218. if (drv->netdev != NULL) {
  1219. #if defined(CONFIG_TROUT_PWRSINK) || defined(CONFIG_HTC_PWRSINK)
  1220. unsigned percent;
  1221. cancel_delayed_work_sync(&drv->trxw);
  1222. percent = ( drv->started ) ? PWRSINK_WIFI_PERCENT_BASE : 0;
  1223. #ifdef CONFIG_HTC_PWRSINK
  1224. htc_pwrsink_set(PWRSINK_WIFI, percent);
  1225. #else
  1226. trout_pwrsink_set(PWRSINK_WIFI, percent);
  1227. #endif
  1228. #endif
  1229. netif_carrier_off(drv->netdev);
  1230. }
  1231. break;
  1232. case IPC_EVENT_LINK_SPEED:
  1233. drv->adapter.LinkSpeed = (*(PULONG)pData->uBuffer * 10000) / 2;
  1234. ti_nodprintf(TIWLAN_LOG_INFO, "\n Link Speed = 0x%08x \n",drv->adapter.LinkSpeed);
  1235. break;
  1236. case IPC_EVENT_AUTH_SUCC:
  1237. /* *(PULONG)AuthBuf = os802_11StatusType_Authentication;
  1238. memcpy((PUCHAR)&AuthBuf[sizeof(ULONG)], pData->uBuffer,sizeof(OS_802_11_AUTHENTICATION_REQUEST));*/
  1239. ti_dprintf(TIWLAN_LOG_OTHER, "\n Auth Succ Event from Driver to another BSSID. \n");
  1240. break;
  1241. case IPC_EVENT_SCAN_COMPLETE:
  1242. ti_dprintf(TIWLAN_LOG_OTHER, "\n Driver Event = Scan Complete. \n");
  1243. break;
  1244. case IPC_EVENT_TIMEOUT:
  1245. ti_dprintf(TIWLAN_LOG_OTHER, "\n Driver Event = Timeout. \n");
  1246. break;
  1247. case IPC_EVENT_CCKM_START:
  1248. ti_dprintf(TIWLAN_L

Large files files are truncated, but you can click here to view the full file