Merge commit 'v2.6.33-rc5' into secretlab/test-devicetree
[pandora-kernel.git] / drivers / staging / rt2860 / rtmp_timer.h
1 /*
2  *************************************************************************
3  * Ralink Tech Inc.
4  * 5F., No.36, Taiyuan St., Jhubei City,
5  * Hsinchu County 302,
6  * Taiwan, R.O.C.
7  *
8  * (c) Copyright 2002-2007, Ralink Technology, Inc.
9  *
10  * This program is free software; you can redistribute it and/or modify  *
11  * it under the terms of the GNU General Public License as published by  *
12  * the Free Software Foundation; either version 2 of the License, or     *
13  * (at your option) any later version.                                   *
14  *                                                                       *
15  * This program is distributed in the hope that it will be useful,       *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
18  * GNU General Public License for more details.                          *
19  *                                                                       *
20  * You should have received a copy of the GNU General Public License     *
21  * along with this program; if not, write to the                         *
22  * Free Software Foundation, Inc.,                                       *
23  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
24  *                                                                       *
25  *************************************************************************
26
27     Module Name:
28         rtmp_timer.h
29
30     Abstract:
31         Ralink Wireless Driver timer related data structures and delcarations
32
33     Revision History:
34         Who           When                What
35         --------    ----------      ----------------------------------------------
36         Name          Date                 Modification logs
37         Shiang Tu    Aug-28-2008        init version
38
39 */
40
41 #ifndef __RTMP_TIMER_H__
42 #define  __RTMP_TIMER_H__
43
44 #include "rtmp_os.h"
45
46 #define DECLARE_TIMER_FUNCTION(_func)                   \
47         void rtmp_timer_##_func(unsigned long data)
48
49 #define GET_TIMER_FUNCTION(_func)                               \
50         rtmp_timer_##_func
51
52 /* ----------------- Timer Related MARCO ---------------*/
53 /* In some os or chipset, we have a lot of timer functions and will read/write register, */
54 /*   it's not allowed in Linux USB sub-system to do it ( because of sleep issue when */
55 /*  submit to ctrl pipe). So we need a wrapper function to take care it. */
56
57 #ifdef RTMP_TIMER_TASK_SUPPORT
58 typedef void(*RTMP_TIMER_TASK_HANDLE) (void *SystemSpecific1,
59                                        void *FunctionContext,
60                                        void *SystemSpecific2,
61                                        void *SystemSpecific3);
62 #endif /* RTMP_TIMER_TASK_SUPPORT // */
63
64 struct rt_ralink_timer {
65         struct timer_list TimerObj;     /* Ndis Timer object */
66         BOOLEAN Valid;          /* Set to True when call RTMPInitTimer */
67         BOOLEAN State;          /* True if timer cancelled */
68         BOOLEAN PeriodicType;   /* True if timer is periodic timer */
69         BOOLEAN Repeat;         /* True if periodic timer */
70         unsigned long TimerValue;       /* Timer value in milliseconds */
71         unsigned long cookie;           /* os specific object */
72 #ifdef RTMP_TIMER_TASK_SUPPORT
73         RTMP_TIMER_TASK_HANDLE handle;
74         void *pAd;
75 #endif                          /* RTMP_TIMER_TASK_SUPPORT // */
76 };
77
78 #ifdef RTMP_TIMER_TASK_SUPPORT
79 struct rt_rtmp_timer_task_entry {
80         struct rt_ralink_timer *pRaTimer;
81         struct rt_rtmp_timer_task_entry *pNext;
82 };
83
84 #define TIMER_QUEUE_SIZE_MAX    128
85 struct rt_rtmp_timer_task_queue {
86         unsigned int status;
87         unsigned char *pTimerQPoll;
88         struct rt_rtmp_timer_task_entry *pQPollFreeList;
89         struct rt_rtmp_timer_task_entry *pQHead;
90         struct rt_rtmp_timer_task_entry *pQTail;
91 };
92
93 #define BUILD_TIMER_FUNCTION(_func)                                                                             \
94 void rtmp_timer_##_func(unsigned long data)                                                                             \
95 {                                                                                                                                                       \
96         struct rt_ralink_timer *_pTimer = (struct rt_ralink_timer *)data;                               \
97         struct rt_rtmp_timer_task_entry *_pQNode;                                                                               \
98         struct rt_rtmp_adapter *_pAd;                                                                                   \
99                                                                                                                                                         \
100         _pTimer->handle = _func;                                                                                                        \
101         _pAd = (struct rt_rtmp_adapter *)_pTimer->pAd;                                                                          \
102         _pQNode = RtmpTimerQInsert(_pAd, _pTimer);                                                              \
103         if ((_pQNode == NULL) && (_pAd->TimerQ.status & RTMP_TASK_CAN_DO_INSERT))       \
104                 RTMP_OS_Add_Timer(&_pTimer->TimerObj, OS_HZ);                                                   \
105 }
106 #else
107 #define BUILD_TIMER_FUNCTION(_func)                                                                             \
108 void rtmp_timer_##_func(unsigned long data)                                                                             \
109 {                                                                                                                                                       \
110         struct rt_ralink_timer *pTimer = (struct rt_ralink_timer *)data;                                \
111                                                                                                                                                         \
112         _func(NULL, (void *)pTimer->cookie, NULL, pTimer);                                                      \
113         if (pTimer->Repeat)                                                                                                             \
114                 RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue);                       \
115 }
116 #endif /* RTMP_TIMER_TASK_SUPPORT // */
117
118 DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
119 DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
120 DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
121 DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
122 DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
123 #ifdef RTMP_MAC_USB
124 DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
125 #endif /* RTMP_MAC_USB // */
126
127 DECLARE_TIMER_FUNCTION(BeaconTimeout);
128 DECLARE_TIMER_FUNCTION(ScanTimeout);
129 DECLARE_TIMER_FUNCTION(AuthTimeout);
130 DECLARE_TIMER_FUNCTION(AssocTimeout);
131 DECLARE_TIMER_FUNCTION(ReassocTimeout);
132 DECLARE_TIMER_FUNCTION(DisassocTimeout);
133 DECLARE_TIMER_FUNCTION(LinkDownExec);
134 DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
135 DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
136 DECLARE_TIMER_FUNCTION(PsPollWakeExec);
137 DECLARE_TIMER_FUNCTION(RadioOnExec);
138
139 #ifdef RTMP_MAC_USB
140 DECLARE_TIMER_FUNCTION(RtmpUsbStaAsicForceWakeupTimeout);
141 #endif /* RTMP_MAC_USB // */
142
143 #if defined(AP_LED) || defined(STA_LED)
144 DECLARE_TIMER_FUNCTION(LedCtrlMain);
145 #endif
146
147 #endif /* __RTMP_TIMER_H__ // */