1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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
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
19 ******************************************************************************/
24 #include <osdep_service.h>
25 #include <drv_types.h>
27 #define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
29 typedef enum _LED_CTL_MODE{
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
46 #if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI)
47 //================================================================================
49 //================================================================================
51 typedef enum _LED_STATE_871x{
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
63 LED_BLINK_WPS_STOP = 11, //for ALPHA
64 LED_BLINK_WPS_STOP_OVERLAP = 12, //for BELKIN
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)
71 #define IS_LED_BLINKING(_LED_871x) (((PLED_871x)_LED_871x)->bLedWPSBlinkInProgress \
72 ||((PLED_871x)_LED_871x)->bLedScanBlinkInProgress)
74 typedef enum _LED_PIN_871x{
80 typedef struct _LED_871x{
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.
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;
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.
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.
103 } LED_871x, *PLED_871x;
106 //================================================================================
107 // LED customization.
108 //================================================================================
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
122 #ifdef CONFIG_PCI_HCI
123 //================================================================================
125 //================================================================================
127 typedef enum _LED_STATE_871x{
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,
138 LED_BLINK_RUNTOP = 10, // Customized for RunTop
139 LED_BLINK_CAMEO = 11,
142 typedef enum _LED_PIN_871x{
149 typedef struct _LED_871x{
152 LED_PIN_871x LedPin; // Identify how to implement this SW led.
154 LED_STATE_871x CurrLedState; // Current LED state.
155 u8 bLedOn; // TRUE if LED is ON, FALSE if LED is OFF.
157 u8 bLedBlinkInProgress; // TRUE if it is blinking, FALSE o.w..
158 u8 bLedWPSBlinkInProgress; // TRUE if it is blinking, FALSE o.w..
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.
164 _timer BlinkTimer; // Timer object for led blinking.
166 u8 bLedLinkBlinkInProgress;
167 u8 bLedNoLinkBlinkInProgress;
168 u8 bLedScanBlinkInProgress;
169 } LED_871x, *PLED_871x;
172 //================================================================================
173 // LED customization.
174 //================================================================================
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;
191 #define LED_CM8_BLINK_INTERVAL 500 //for QMI
192 #endif //CONFIG_PCI_HCI
195 /* add for led controll */
198 LED_STRATEGY_871x LedStrategy;
200 void (*LedControlHandler)(_adapter *padapter, LED_CTL_MODE LedAction);
201 /* add for led controll */
205 #define rtw_led_control(adapter, LedAction) \
207 if((adapter)->ledpriv.LedControlHandler) \
208 (adapter)->ledpriv.LedControlHandler((adapter), (LedAction)); \
210 #else //CONFIG_SW_LED
211 #define rtw_led_control(adapter, LedAction)
212 #endif //CONFIG_SW_LED
214 extern void BlinkHandler(PLED_871x pLed);
216 #endif //__RTW_LED_H_