wifi: renew patch drivers/net/wireless
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rtl8192cu / include / rtw_led.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4  *                                        
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __RTW_LED_H_
21 #define __RTW_LED_H_
22
23 #include <drv_conf.h>
24 #include <osdep_service.h>
25 #include <drv_types.h>
26
27 #define MSECS(t)        (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
28
29 typedef enum _LED_CTL_MODE{
30         LED_CTL_POWER_ON = 1,
31         LED_CTL_LINK = 2,
32         LED_CTL_NO_LINK = 3,
33         LED_CTL_TX = 4,
34         LED_CTL_RX = 5,
35         LED_CTL_SITE_SURVEY = 6,
36         LED_CTL_POWER_OFF = 7,
37         LED_CTL_START_TO_LINK = 8,
38         LED_CTL_START_WPS = 9,
39         LED_CTL_STOP_WPS = 10,
40         LED_CTL_START_WPS_BOTTON = 11, //added for runtop
41         LED_CTL_STOP_WPS_FAIL = 12, //added for ALPHA   
42          LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, //added for BELKIN
43 }LED_CTL_MODE;
44
45
46 #if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI)
47 //================================================================================
48 // LED object.
49 //================================================================================
50
51 typedef enum _LED_STATE_871x{
52         LED_UNKNOWN = 0,
53         RTW_LED_ON = 1,
54         RTW_LED_OFF = 2,
55         LED_BLINK_NORMAL = 3,
56         LED_BLINK_SLOWLY = 4,
57         LED_POWER_ON_BLINK = 5,
58         LED_SCAN_BLINK = 6, // LED is blinking during scanning period, the # of times to blink is depend on time for scanning.
59         LED_NO_LINK_BLINK = 7, // LED is blinking during no link state.
60         LED_BLINK_StartToBlink = 8,// Customzied for Sercomm Printer Server case
61         LED_BLINK_WPS = 9,      // LED is blinkg during WPS communication       
62         LED_TXRX_BLINK = 10,
63         LED_BLINK_WPS_STOP = 11,        //for ALPHA     
64         LED_BLINK_WPS_STOP_OVERLAP = 12,        //for BELKIN
65 }LED_STATE_871x;
66
67 #define IS_LED_WPS_BLINKING(_LED_871x)  (((PLED_871x)_LED_871x)->CurrLedState==LED_BLINK_WPS \
68                                         || ((PLED_871x)_LED_871x)->CurrLedState==LED_BLINK_WPS_STOP \
69                                         || ((PLED_871x)_LED_871x)->bLedWPSBlinkInProgress)
70
71 #define IS_LED_BLINKING(_LED_871x)      (((PLED_871x)_LED_871x)->bLedWPSBlinkInProgress \
72                                         ||((PLED_871x)_LED_871x)->bLedScanBlinkInProgress)
73
74 typedef enum _LED_PIN_871x{
75         LED_PIN_GPIO0,
76         LED_PIN_LED0,
77         LED_PIN_LED1
78 }LED_PIN_871x;
79
80 typedef struct _LED_871x{
81         _adapter                                *padapter;
82         LED_PIN_871x            LedPin; // Identify how to implement this SW led.
83         LED_STATE_871x          CurrLedState; // Current LED state.
84         u8                                      bLedOn; // true if LED is ON, false if LED is OFF.
85
86         u8                                      bSWLedCtrl;
87
88         u8                                      bLedBlinkInProgress; // true if it is blinking, false o.w..
89         // ALPHA, added by chiyoko, 20090106
90         u8                                      bLedNoLinkBlinkInProgress;
91         u8                                      bLedLinkBlinkInProgress;
92         u8                                      bLedStartToLinkBlinkInProgress;
93         u8                                      bLedScanBlinkInProgress;
94         u8                                      bLedWPSBlinkInProgress;
95         
96         u32                                     BlinkTimes; // Number of times to toggle led state for blinking.
97         LED_STATE_871x          BlinkingLedState; // Next state for blinking, either RTW_LED_ON or RTW_LED_OFF are.
98
99         _timer                          BlinkTimer; // Timer object for led blinking.
100 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)|| defined PLATFORM_FREEBSD
101         _workitem                       BlinkWorkItem; // Workitem used by BlinkTimer to manipulate H/W to blink LED.
102 #endif
103 } LED_871x, *PLED_871x;
104
105
106 //================================================================================
107 // LED customization.
108 //================================================================================
109
110 typedef enum _LED_STRATEGY_871x{
111         SW_LED_MODE0, // SW control 1 LED via GPIO0. It is default option.
112         SW_LED_MODE1, // 2 LEDs, through LED0 and LED1. For ALPHA.
113         SW_LED_MODE2, // SW control 1 LED via GPIO0, customized for AzWave 8187 minicard.
114         SW_LED_MODE3, // SW control 1 LED via GPIO0, customized for Sercomm Printer Server case.
115         SW_LED_MODE4, //for Edimax / Belkin
116         SW_LED_MODE5, //for Sercomm / Belkin
117         SW_LED_MODE6, //for 88CU minicard, porting from ce SW_LED_MODE7
118         HW_LED, // HW control 2 LEDs, LED0 and LED1 (there are 4 different control modes, see MAC.CONFIG1 for details.)
119 }LED_STRATEGY_871x, *PLED_STRATEGY_871x;
120 #endif //CONFIG_USB_HCI
121
122 #ifdef CONFIG_PCI_HCI
123 //================================================================================
124 // LED object.
125 //================================================================================
126
127 typedef enum _LED_STATE_871x{
128         LED_UNKNOWN = 0,
129         RTW_LED_ON = 1,
130         RTW_LED_OFF = 2,
131         LED_BLINK_NORMAL = 3,
132         LED_BLINK_SLOWLY = 4,
133         LED_POWER_ON_BLINK = 5,
134         LED_SCAN_BLINK = 6, // LED is blinking during scanning period, the # of times to blink is depend on time for scanning.
135         LED_NO_LINK_BLINK = 7, // LED is blinking during no link state.
136         LED_BLINK_StartToBlink = 8, 
137         LED_BLINK_TXRX = 9,
138         LED_BLINK_RUNTOP = 10, // Customized for RunTop
139         LED_BLINK_CAMEO = 11,
140 }LED_STATE_871x;
141
142 typedef enum _LED_PIN_871x{
143         LED_PIN_GPIO0,
144         LED_PIN_LED0,
145         LED_PIN_LED1,
146         LED_PIN_LED2
147 }LED_PIN_871x;
148
149 typedef struct _LED_871x{
150         _adapter                                *padapter;
151
152         LED_PIN_871x            LedPin; // Identify how to implement this SW led.
153
154         LED_STATE_871x          CurrLedState; // Current LED state.
155         u8                                      bLedOn; // TRUE if LED is ON, FALSE if LED is OFF.
156
157         u8                                      bLedBlinkInProgress; // TRUE if it is blinking, FALSE o.w..
158         u8                                      bLedWPSBlinkInProgress; // TRUE if it is blinking, FALSE o.w..
159
160         u8                                      bLedSlowBlinkInProgress;//added by vivi, for led new mode
161         u32                                     BlinkTimes; // Number of times to toggle led state for blinking.
162         LED_STATE_871x          BlinkingLedState; // Next state for blinking, either RTW_LED_ON or RTW_LED_OFF are.
163
164         _timer                          BlinkTimer; // Timer object for led blinking.
165         
166         u8                                      bLedLinkBlinkInProgress;
167         u8                                      bLedNoLinkBlinkInProgress;
168         u8                                      bLedScanBlinkInProgress;
169 } LED_871x, *PLED_871x;
170
171
172 //================================================================================
173 // LED customization.
174 //================================================================================
175
176 typedef enum _LED_STRATEGY_871x{
177         SW_LED_MODE0, // SW control 1 LED via GPIO0. It is default option.
178         SW_LED_MODE1, // SW control for PCI Express
179         SW_LED_MODE2, // SW control for Cameo.
180         SW_LED_MODE3, // SW contorl for RunTop.
181         SW_LED_MODE4, // SW control for Netcore
182         SW_LED_MODE5, //added by vivi, for led new mode, DLINK
183         SW_LED_MODE6, //added by vivi, for led new mode, PRONET
184         SW_LED_MODE7, //added by chiyokolin, for Lenovo, PCI Express Minicard Spec Rev.1.2 spec
185         SW_LED_MODE8, //added by chiyokolin, for QMI
186         SW_LED_MODE9, //added by chiyokolin, for BITLAND, PCI Express Minicard Spec Rev.1.1 
187         SW_LED_MODE10, //added by chiyokolin, for Edimax-ASUS
188         HW_LED, // HW control 2 LEDs, LED0 and LED1 (there are 4 different control modes)
189 }LED_STRATEGY_871x, *PLED_STRATEGY_871x;
190
191 #define LED_CM8_BLINK_INTERVAL          500     //for QMI
192 #endif //CONFIG_PCI_HCI
193
194 struct led_priv{
195         /* add for led controll */
196         LED_871x                        SwLed0;
197         LED_871x                        SwLed1;
198         LED_STRATEGY_871x       LedStrategy;
199         u8                                      bRegUseLed;
200         void (*LedControlHandler)(_adapter *padapter, LED_CTL_MODE LedAction);
201         /* add for led controll */
202 };
203
204 #ifdef CONFIG_SW_LED
205 #define rtw_led_control(adapter, LedAction) \
206         do { \
207                 if((adapter)->ledpriv.LedControlHandler) \
208                         (adapter)->ledpriv.LedControlHandler((adapter), (LedAction)); \
209         } while(0)
210 #else //CONFIG_SW_LED
211 #define rtw_led_control(adapter, LedAction)
212 #endif //CONFIG_SW_LED
213
214 extern void BlinkHandler(PLED_871x       pLed);
215
216 #endif //__RTW_LED_H_
217