staging: r8188eu: Remove tests of kernel version
[linux-2.6-microblaze.git] / drivers / staging / r8188eu / include / rtw_led.h
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright(c) 2007 - 2011 Realtek Corporation. */
3
4 #ifndef __RTW_LED_H_
5 #define __RTW_LED_H_
6
7 #include <osdep_service.h>
8 #include <drv_types.h>
9
10 #define MSECS(t)        (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
11
12 #define LED_BLINK_NORMAL_INTERVAL               100
13 #define LED_BLINK_SLOWLY_INTERVAL               200
14 #define LED_BLINK_LONG_INTERVAL                 400
15
16 #define LED_BLINK_NO_LINK_INTERVAL_ALPHA        1000
17 #define LED_BLINK_LINK_INTERVAL_ALPHA           500     /* 500 */
18 #define LED_BLINK_SCAN_INTERVAL_ALPHA           180     /* 150 */
19 #define LED_BLINK_FASTER_INTERVAL_ALPHA         50
20 #define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA     5000
21
22 #define LED_BLINK_NORMAL_INTERVAL_NETTRONIX     100
23 #define LED_BLINK_SLOWLY_INTERVAL_NETTRONIX     2000
24
25 #define LED_BLINK_SLOWLY_INTERVAL_PORNET        1000
26 #define LED_BLINK_NORMAL_INTERVAL_PORNET        100
27
28 #define LED_BLINK_FAST_INTERVAL_BITLAND         30
29
30 /*  060403, rcnjko: Customized for AzWave. */
31 #define LED_CM2_BLINK_ON_INTERVAL               250
32 #define LED_CM2_BLINK_OFF_INTERVAL              4750
33
34 #define LED_CM8_BLINK_INTERVAL                  500     /* for QMI */
35 #define LED_CM8_BLINK_OFF_INTERVAL              3750    /* for QMI */
36
37 /*  080124, lanhsin: Customized for RunTop */
38 #define LED_RunTop_BLINK_INTERVAL               300
39
40 /*  060421, rcnjko: Customized for Sercomm Printer Server case. */
41 #define LED_CM3_BLINK_INTERVAL                  1500
42
43 enum LED_CTL_MODE {
44         LED_CTL_POWER_ON = 1,
45         LED_CTL_LINK = 2,
46         LED_CTL_NO_LINK = 3,
47         LED_CTL_TX = 4,
48         LED_CTL_RX = 5,
49         LED_CTL_SITE_SURVEY = 6,
50         LED_CTL_POWER_OFF = 7,
51         LED_CTL_START_TO_LINK = 8,
52         LED_CTL_START_WPS = 9,
53         LED_CTL_STOP_WPS = 10,
54         LED_CTL_START_WPS_BOTTON = 11, /* added for runtop */
55         LED_CTL_STOP_WPS_FAIL = 12, /* added for ALPHA */
56         LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, /* added for BELKIN */
57         LED_CTL_CONNECTION_NO_TRANSFER = 14,
58 };
59
60 enum LED_STATE_871x {
61         LED_UNKNOWN = 0,
62         RTW_LED_ON = 1,
63         RTW_LED_OFF = 2,
64         LED_BLINK_NORMAL = 3,
65         LED_BLINK_SLOWLY = 4,
66         LED_BLINK_POWER_ON = 5,
67         LED_BLINK_SCAN = 6, /*  LED is blinking during scanning period,
68                              * the # of times to blink is depend on time
69                              * for scanning. */
70         LED_BLINK_NO_LINK = 7, /*  LED is blinking during no link state. */
71         LED_BLINK_StartToBlink = 8,/*  Customzied for Sercomm Printer
72                                     * Server case */
73         LED_BLINK_TXRX = 9,
74         LED_BLINK_WPS = 10,     /*  LED is blinkg during WPS communication */
75         LED_BLINK_WPS_STOP = 11,        /* for ALPHA */
76         LED_BLINK_WPS_STOP_OVERLAP = 12,        /* for BELKIN */
77         LED_BLINK_RUNTOP = 13, /*  Customized for RunTop */
78         LED_BLINK_CAMEO = 14,
79         LED_BLINK_XAVI = 15,
80         LED_BLINK_ALWAYS_ON = 16,
81 };
82
83 enum LED_PIN_871x {
84         LED_PIN_NULL = 0,
85         LED_PIN_LED0 = 1,
86         LED_PIN_LED1 = 2,
87         LED_PIN_LED2 = 3,
88         LED_PIN_GPIO0 = 4,
89 };
90
91 struct LED_871x {
92         struct adapter *padapter;
93
94         enum LED_PIN_871x       LedPin; /* Identify how to implement this
95                                          * SW led. */
96         enum LED_STATE_871x     CurrLedState; /*  Current LED state. */
97         enum LED_STATE_871x     BlinkingLedState; /*  Next state for blinking,
98                                    * either RTW_LED_ON or RTW_LED_OFF are. */
99
100         u8 bLedOn; /*  true if LED is ON, false if LED is OFF. */
101
102         u8 bLedBlinkInProgress; /*  true if it is blinking, false o.w.. */
103
104         u8 bLedWPSBlinkInProgress;
105
106         u32 BlinkTimes; /*  Number of times to toggle led state for blinking. */
107
108         struct timer_list BlinkTimer; /*  Timer object for led blinking. */
109
110         u8 bSWLedCtrl;
111
112         /*  ALPHA, added by chiyoko, 20090106 */
113         u8 bLedNoLinkBlinkInProgress;
114         u8 bLedLinkBlinkInProgress;
115         u8 bLedStartToLinkBlinkInProgress;
116         u8 bLedScanBlinkInProgress;
117         struct work_struct BlinkWorkItem; /* Workitem used by BlinkTimer to
118                                            * manipulate H/W to blink LED. */
119 };
120
121 #define IS_LED_WPS_BLINKING(_LED_871x)                                  \
122         (((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS || \
123         ((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS_STOP || \
124         ((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress)
125
126 #define IS_LED_BLINKING(_LED_871x)                                      \
127         (((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress ||      \
128         ((struct LED_871x *)_LED_871x)->bLedScanBlinkInProgress)
129
130 /*  LED customization. */
131
132 enum LED_STRATEGY_871x {
133         SW_LED_MODE0 = 0, /* SW control 1 LED via GPIO0. It is default option.*/
134         SW_LED_MODE1= 1, /*  2 LEDs, through LED0 and LED1. For ALPHA. */
135         SW_LED_MODE2 = 2, /*  SW control 1 LED via GPIO0, customized for AzWave
136                            * 8187 minicard. */
137         SW_LED_MODE3 = 3, /*  SW control 1 LED via GPIO0, customized for Sercomm
138                            * Printer Server case. */
139         SW_LED_MODE4 = 4, /* for Edimax / Belkin */
140         SW_LED_MODE5 = 5, /* for Sercomm / Belkin */
141         SW_LED_MODE6 = 6, /* for 88CU minicard, porting from ce SW_LED_MODE7 */
142         HW_LED = 50, /*  HW control 2 LEDs, LED0 and LED1 (there are 4
143                       * different control modes, see MAC.CONFIG1 for details.)*/
144         LED_ST_NONE = 99,
145 };
146
147 void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE       LedAction);
148
149 struct led_priv{
150         /* add for led control */
151         struct LED_871x                 SwLed0;
152         struct LED_871x                 SwLed1;
153         enum LED_STRATEGY_871x  LedStrategy;
154         u8      bRegUseLed;
155         void (*LedControlHandler)(struct adapter *padapter,
156                                   enum LED_CTL_MODE LedAction);
157         /* add for led control */
158 };
159
160 #define rtw_led_control(adapt, action) \
161         do { \
162                 if ((adapt)->ledpriv.LedControlHandler) \
163                         (adapt)->ledpriv.LedControlHandler((adapt), (action)); \
164         } while (0)
165
166 void BlinkTimerCallback(struct timer_list *t);
167 void BlinkWorkItemCallback(struct work_struct *work);
168
169 void ResetLedStatus(struct LED_871x * pLed);
170
171 void InitLed871x(struct adapter *padapter, struct LED_871x *pLed,
172                  enum LED_PIN_871x LedPin);
173
174 void DeInitLed871x(struct LED_871x *pLed);
175
176 /* hal... */
177 void BlinkHandler(struct LED_871x * pLed);
178 void SwLedOn(struct adapter *padapter, struct LED_871x *pLed);
179 void SwLedOff(struct adapter *padapter, struct LED_871x *pLed);
180
181 #endif /* __RTW_LED_H_ */