Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / drivers / staging / rtl8712 / rtl871x_led.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2010 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  * Modifications for inclusion into the Linux staging tree are
19  * Copyright(c) 2010 Larry Finger. All rights reserved.
20  *
21  * Contact information:
22  * WLAN FAE <wlanfae@realtek.com>
23  * Larry Finger <Larry.Finger@lwfinger.net>
24  *
25  ******************************************************************************/
26 #ifndef __RTL8712_LED_H
27 #define __RTL8712_LED_H
28
29 #include "osdep_service.h"
30 #include "drv_types.h"
31
32 /*===========================================================================
33  * LED customization.
34  *===========================================================================
35  */
36 enum LED_CTL_MODE {
37         LED_CTL_POWER_ON = 1,
38         LED_CTL_LINK = 2,
39         LED_CTL_NO_LINK = 3,
40         LED_CTL_TX = 4,
41         LED_CTL_RX = 5,
42         LED_CTL_SITE_SURVEY = 6,
43         LED_CTL_POWER_OFF = 7,
44         LED_CTL_START_TO_LINK = 8,
45         LED_CTL_START_WPS = 9,
46         LED_CTL_STOP_WPS = 10,
47         LED_CTL_START_WPS_BOTTON = 11,
48         LED_CTL_STOP_WPS_FAIL = 12,
49         LED_CTL_STOP_WPS_FAIL_OVERLAP = 13,
50 };
51
52 #define IS_LED_WPS_BLINKING(_LED_871x)  \
53         (((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS \
54         || ((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS_STOP \
55         || ((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress)
56
57 #define IS_LED_BLINKING(_LED_871x)      \
58                 (((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress \
59                 || ((struct LED_871x *)_LED_871x)->bLedScanBlinkInProgress)
60
61 enum LED_PIN_871x {
62         LED_PIN_GPIO0,
63         LED_PIN_LED0,
64         LED_PIN_LED1
65 };
66
67 /*===========================================================================
68  * LED customization.
69  *===========================================================================
70  */
71 enum LED_STRATEGY_871x {
72         SW_LED_MODE0, /* SW control 1 LED via GPIO0. It is default option. */
73         SW_LED_MODE1, /* 2 LEDs, through LED0 and LED1. For ALPHA. */
74         SW_LED_MODE2, /* SW control 1 LED via GPIO0,
75                        * custom for AzWave 8187 minicard. */
76         SW_LED_MODE3, /* SW control 1 LED via GPIO0,
77                        *  customized for Sercomm Printer Server case.*/
78         SW_LED_MODE4, /*for Edimax / Belkin*/
79         SW_LED_MODE5, /*for Sercomm / Belkin*/
80         SW_LED_MODE6, /*for WNC / Corega*/
81         HW_LED, /* HW control 2 LEDs, LED0 and LED1 (there are 4 different
82                  * control modes, see MAC.CONFIG1 for details.)*/
83 };
84
85 struct LED_871x {
86         struct _adapter         *padapter;
87         enum LED_PIN_871x       LedPin; /* Implementation for this SW led. */
88         u32                     CurrLedState; /* Current LED state. */
89         u8                      bLedOn; /* true if LED is ON */
90         u8                      bSWLedCtrl;
91         u8                      bLedBlinkInProgress; /*true if blinking */
92         u8                      bLedNoLinkBlinkInProgress;
93         u8                      bLedLinkBlinkInProgress;
94         u8                      bLedStartToLinkBlinkInProgress;
95         u8                      bLedScanBlinkInProgress;
96         u8                      bLedWPSBlinkInProgress;
97         u32                     BlinkTimes; /* No. times to toggle for blink.*/
98         u32                     BlinkingLedState; /* Next state for blinking,
99                                                    * either LED_ON or OFF.*/
100
101         struct timer_list       BlinkTimer; /* Timer object for led blinking.*/
102         struct work_struct      BlinkWorkItem; /* Workitem used by BlinkTimer */
103 };
104
105 struct led_priv {
106         /* add for led control */
107         struct LED_871x         SwLed0;
108         struct LED_871x         SwLed1;
109         enum LED_STRATEGY_871x  LedStrategy;
110         u8                      bRegUseLed;
111         void (*LedControlHandler)(struct _adapter *padapter,
112                                   enum LED_CTL_MODE LedAction);
113         /* add for led control */
114 };
115
116 /*===========================================================================
117  * Interface to manipulate LED objects.
118  *===========================================================================*/
119 void r8712_InitSwLeds(struct _adapter *padapter);
120 void r8712_DeInitSwLeds(struct _adapter *padapter);
121 void LedControl871x(struct _adapter *padapter, enum LED_CTL_MODE LedAction);
122
123 #endif
124