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 ******************************************************************************/
23 #include <osdep_service.h>
24 #include <drv_types.h>
26 #define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
28 #define LED_BLINK_NORMAL_INTERVAL 100
29 #define LED_BLINK_SLOWLY_INTERVAL 200
30 #define LED_BLINK_LONG_INTERVAL 400
32 #define LED_BLINK_NO_LINK_INTERVAL_ALPHA 1000
33 #define LED_BLINK_LINK_INTERVAL_ALPHA 500 /* 500 */
34 #define LED_BLINK_SCAN_INTERVAL_ALPHA 180 /* 150 */
35 #define LED_BLINK_FASTER_INTERVAL_ALPHA 50
36 #define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA 5000
38 #define LED_BLINK_NORMAL_INTERVAL_NETTRONIX 100
39 #define LED_BLINK_SLOWLY_INTERVAL_NETTRONIX 2000
41 #define LED_BLINK_SLOWLY_INTERVAL_PORNET 1000
42 #define LED_BLINK_NORMAL_INTERVAL_PORNET 100
44 #define LED_BLINK_FAST_INTERVAL_BITLAND 30
46 /* 060403, rcnjko: Customized for AzWave. */
47 #define LED_CM2_BLINK_ON_INTERVAL 250
48 #define LED_CM2_BLINK_OFF_INTERVAL 4750
50 #define LED_CM8_BLINK_INTERVAL 500 /* for QMI */
51 #define LED_CM8_BLINK_OFF_INTERVAL 3750 /* for QMI */
53 /* 080124, lanhsin: Customized for RunTop */
54 #define LED_RunTop_BLINK_INTERVAL 300
56 /* 060421, rcnjko: Customized for Sercomm Printer Server case. */
57 #define LED_CM3_BLINK_INTERVAL 1500
65 LED_CTL_SITE_SURVEY = 6,
66 LED_CTL_POWER_OFF = 7,
67 LED_CTL_START_TO_LINK = 8,
68 LED_CTL_START_WPS = 9,
69 LED_CTL_STOP_WPS = 10,
70 LED_CTL_START_WPS_BOTTON = 11, /* added for runtop */
71 LED_CTL_STOP_WPS_FAIL = 12, /* added for ALPHA */
72 LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, /* added for BELKIN */
73 LED_CTL_CONNECTION_NO_TRANSFER = 14,
82 LED_BLINK_POWER_ON = 5,
83 LED_BLINK_SCAN = 6, /* LED is blinking during scanning period,
84 * the # of times to blink is depend on time
86 LED_BLINK_NO_LINK = 7, /* LED is blinking during no link state. */
87 LED_BLINK_StartToBlink = 8,/* Customzied for Sercomm Printer
90 LED_BLINK_WPS = 10, /* LED is blinkg during WPS communication */
91 LED_BLINK_WPS_STOP = 11, /* for ALPHA */
92 LED_BLINK_WPS_STOP_OVERLAP = 12, /* for BELKIN */
93 LED_BLINK_RUNTOP = 13, /* Customized for RunTop */
96 LED_BLINK_ALWAYS_ON = 16,
108 struct adapter *padapter;
110 enum LED_PIN_871x LedPin; /* Identify how to implement this
112 enum LED_STATE_871x CurrLedState; /* Current LED state. */
113 enum LED_STATE_871x BlinkingLedState; /* Next state for blinking,
114 * either RTW_LED_ON or RTW_LED_OFF are. */
116 u8 bLedOn; /* true if LED is ON, false if LED is OFF. */
118 u8 bLedBlinkInProgress; /* true if it is blinking, false o.w.. */
120 u8 bLedWPSBlinkInProgress;
122 u32 BlinkTimes; /* Number of times to toggle led state for blinking. */
124 struct timer_list BlinkTimer; /* Timer object for led blinking. */
128 /* ALPHA, added by chiyoko, 20090106 */
129 u8 bLedNoLinkBlinkInProgress;
130 u8 bLedLinkBlinkInProgress;
131 u8 bLedStartToLinkBlinkInProgress;
132 u8 bLedScanBlinkInProgress;
133 struct work_struct BlinkWorkItem; /* Workitem used by BlinkTimer to
134 * manipulate H/W to blink LED. */
137 #define IS_LED_WPS_BLINKING(_LED_871x) \
138 (((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS || \
139 ((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS_STOP || \
140 ((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress)
142 #define IS_LED_BLINKING(_LED_871x) \
143 (((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress || \
144 ((struct LED_871x *)_LED_871x)->bLedScanBlinkInProgress)
146 /* LED customization. */
148 enum LED_STRATEGY_871x {
149 SW_LED_MODE0 = 0, /* SW control 1 LED via GPIO0. It is default option.*/
150 SW_LED_MODE1= 1, /* 2 LEDs, through LED0 and LED1. For ALPHA. */
151 SW_LED_MODE2 = 2, /* SW control 1 LED via GPIO0, customized for AzWave
153 SW_LED_MODE3 = 3, /* SW control 1 LED via GPIO0, customized for Sercomm
154 * Printer Server case. */
155 SW_LED_MODE4 = 4, /* for Edimax / Belkin */
156 SW_LED_MODE5 = 5, /* for Sercomm / Belkin */
157 SW_LED_MODE6 = 6, /* for 88CU minicard, porting from ce SW_LED_MODE7 */
158 HW_LED = 50, /* HW control 2 LEDs, LED0 and LED1 (there are 4
159 * different control modes, see MAC.CONFIG1 for details.)*/
163 void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction);
166 /* add for led control */
167 struct LED_871x SwLed0;
168 struct LED_871x SwLed1;
169 enum LED_STRATEGY_871x LedStrategy;
171 void (*LedControlHandler)(struct adapter *padapter,
172 enum LED_CTL_MODE LedAction);
173 /* add for led control */
176 #define rtw_led_control(adapt, action) \
178 if ((adapt)->ledpriv.LedControlHandler) \
179 (adapt)->ledpriv.LedControlHandler((adapt), (action)); \
182 void BlinkTimerCallback(void *data);
183 void BlinkWorkItemCallback(struct work_struct *work);
185 void ResetLedStatus(struct LED_871x * pLed);
187 void InitLed871x(struct adapter *padapter, struct LED_871x *pLed,
188 enum LED_PIN_871x LedPin);
190 void DeInitLed871x(struct LED_871x *pLed);
193 void BlinkHandler(struct LED_871x * pLed);
194 void SwLedOn(struct adapter *padapter, struct LED_871x *pLed);
195 void SwLedOff(struct adapter *padapter, struct LED_871x *pLed);
197 #endif /* __RTW_LED_H_ */