1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright(c) 2007 - 2011 Realtek Corporation. */
7 #include <osdep_service.h>
10 #define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
12 #define LED_BLINK_NORMAL_INTERVAL 100
13 #define LED_BLINK_SLOWLY_INTERVAL 200
14 #define LED_BLINK_LONG_INTERVAL 400
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
22 #define LED_BLINK_NORMAL_INTERVAL_NETTRONIX 100
23 #define LED_BLINK_SLOWLY_INTERVAL_NETTRONIX 2000
25 #define LED_BLINK_SLOWLY_INTERVAL_PORNET 1000
26 #define LED_BLINK_NORMAL_INTERVAL_PORNET 100
28 #define LED_BLINK_FAST_INTERVAL_BITLAND 30
30 /* 060403, rcnjko: Customized for AzWave. */
31 #define LED_CM2_BLINK_ON_INTERVAL 250
32 #define LED_CM2_BLINK_OFF_INTERVAL 4750
34 #define LED_CM8_BLINK_INTERVAL 500 /* for QMI */
35 #define LED_CM8_BLINK_OFF_INTERVAL 3750 /* for QMI */
37 /* 080124, lanhsin: Customized for RunTop */
38 #define LED_RunTop_BLINK_INTERVAL 300
40 /* 060421, rcnjko: Customized for Sercomm Printer Server case. */
41 #define LED_CM3_BLINK_INTERVAL 1500
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,
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
70 LED_BLINK_NO_LINK = 7, /* LED is blinking during no link state. */
71 LED_BLINK_StartToBlink = 8,/* Customzied for Sercomm Printer
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 */
80 LED_BLINK_ALWAYS_ON = 16,
92 struct adapter *padapter;
94 enum LED_PIN_871x LedPin; /* Identify how to implement this
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. */
100 u8 bLedOn; /* true if LED is ON, false if LED is OFF. */
102 u8 bLedBlinkInProgress; /* true if it is blinking, false o.w.. */
104 u8 bLedWPSBlinkInProgress;
106 u32 BlinkTimes; /* Number of times to toggle led state for blinking. */
108 struct timer_list BlinkTimer; /* Timer object for led blinking. */
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. */
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)
126 #define IS_LED_BLINKING(_LED_871x) \
127 (((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress || \
128 ((struct LED_871x *)_LED_871x)->bLedScanBlinkInProgress)
130 /* LED customization. */
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
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.)*/
147 void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction);
150 /* add for led control */
151 struct LED_871x SwLed0;
152 struct LED_871x SwLed1;
153 enum LED_STRATEGY_871x LedStrategy;
155 void (*LedControlHandler)(struct adapter *padapter,
156 enum LED_CTL_MODE LedAction);
157 /* add for led control */
160 #define rtw_led_control(adapt, action) \
162 if ((adapt)->ledpriv.LedControlHandler) \
163 (adapt)->ledpriv.LedControlHandler((adapt), (action)); \
166 void BlinkTimerCallback(struct timer_list *t);
167 void BlinkWorkItemCallback(struct work_struct *work);
169 void ResetLedStatus(struct LED_871x * pLed);
171 void InitLed871x(struct adapter *padapter, struct LED_871x *pLed,
172 enum LED_PIN_871x LedPin);
174 void DeInitLed871x(struct LED_871x *pLed);
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);
181 #endif /* __RTW_LED_H_ */