hal_com_led.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 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. *
  19. ******************************************************************************/
  20. #ifndef __HAL_COMMON_LED_H_
  21. #define __HAL_COMMON_LED_H_
  22. #define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
  23. //================================================================================
  24. // LED Behavior Constant.
  25. //================================================================================
  26. // Default LED behavior.
  27. //
  28. #define LED_BLINK_NORMAL_INTERVAL 100
  29. #define LED_BLINK_SLOWLY_INTERVAL 200
  30. #define LED_BLINK_LONG_INTERVAL 400
  31. #define LED_INITIAL_INTERVAL 1800
  32. // LED Customerization
  33. //NETTRONIX
  34. #define LED_BLINK_NORMAL_INTERVAL_NETTRONIX 100
  35. #define LED_BLINK_SLOWLY_INTERVAL_NETTRONIX 2000
  36. //PORNET
  37. #define LED_BLINK_SLOWLY_INTERVAL_PORNET 1000
  38. #define LED_BLINK_NORMAL_INTERVAL_PORNET 100
  39. #define LED_BLINK_FAST_INTERVAL_BITLAND 30
  40. //AzWave.
  41. #define LED_CM2_BLINK_ON_INTERVAL 250
  42. #define LED_CM2_BLINK_OFF_INTERVAL 4750
  43. #define LED_CM8_BLINK_OFF_INTERVAL 3750 //for QMI
  44. //RunTop
  45. #define LED_RunTop_BLINK_INTERVAL 300
  46. //ALPHA
  47. #define LED_BLINK_NO_LINK_INTERVAL_ALPHA 1000
  48. #define LED_BLINK_NO_LINK_INTERVAL_ALPHA_500MS 500 //add by ylb 20121012 for customer led for alpha
  49. #define LED_BLINK_LINK_INTERVAL_ALPHA 500 //500
  50. #define LED_BLINK_SCAN_INTERVAL_ALPHA 180 //150
  51. #define LED_BLINK_FASTER_INTERVAL_ALPHA 50
  52. #define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA 5000
  53. // 111122 by hpfan: Customized for Xavi
  54. #define LED_CM11_BLINK_INTERVAL 300
  55. #define LED_CM11_LINK_ON_INTERVEL 3000
  56. //Netgear
  57. #define LED_BLINK_LINK_INTERVAL_NETGEAR 500
  58. #define LED_BLINK_LINK_SLOWLY_INTERVAL_NETGEAR 1000
  59. #define LED_WPS_BLINK_OFF_INTERVAL_NETGEAR 100
  60. #define LED_WPS_BLINK_ON_INTERVAL_NETGEAR 500
  61. //Belkin AC950
  62. #define LED_BLINK_LINK_INTERVAL_ON_BELKIN 200
  63. #define LED_BLINK_LINK_INTERVAL_OFF_BELKIN 100
  64. #define LED_BLINK_ERROR_INTERVAL_BELKIN 100
  65. //by chiyokolin for Azurewave
  66. #define LED_CM12_BLINK_INTERVAL_5Mbps 160
  67. #define LED_CM12_BLINK_INTERVAL_10Mbps 80
  68. #define LED_CM12_BLINK_INTERVAL_20Mbps 50
  69. #define LED_CM12_BLINK_INTERVAL_40Mbps 40
  70. #define LED_CM12_BLINK_INTERVAL_80Mbps 30
  71. #define LED_CM12_BLINK_INTERVAL_MAXMbps 25
  72. //================================================================================
  73. // LED object.
  74. //================================================================================
  75. typedef enum _LED_CTL_MODE{
  76. LED_CTL_POWER_ON = 1,
  77. LED_CTL_LINK = 2,
  78. LED_CTL_NO_LINK = 3,
  79. LED_CTL_TX = 4,
  80. LED_CTL_RX = 5,
  81. LED_CTL_SITE_SURVEY = 6,
  82. LED_CTL_POWER_OFF = 7,
  83. LED_CTL_START_TO_LINK = 8,
  84. LED_CTL_START_WPS = 9,
  85. LED_CTL_STOP_WPS = 10,
  86. LED_CTL_START_WPS_BOTTON = 11, //added for runtop
  87. LED_CTL_STOP_WPS_FAIL = 12, //added for ALPHA
  88. LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, //added for BELKIN
  89. LED_CTL_CONNECTION_NO_TRANSFER = 14,
  90. }LED_CTL_MODE;
  91. typedef enum _LED_STATE{
  92. LED_UNKNOWN = 0,
  93. RTW_LED_ON = 1,
  94. RTW_LED_OFF = 2,
  95. LED_BLINK_NORMAL = 3,
  96. LED_BLINK_SLOWLY = 4,
  97. LED_BLINK_POWER_ON = 5,
  98. LED_BLINK_SCAN = 6, // LED is blinking during scanning period, the # of times to blink is depend on time for scanning.
  99. LED_BLINK_NO_LINK = 7, // LED is blinking during no link state.
  100. LED_BLINK_StartToBlink = 8, // Customzied for Sercomm Printer Server case
  101. LED_BLINK_TXRX = 9,
  102. LED_BLINK_WPS = 10, // LED is blinkg during WPS communication
  103. LED_BLINK_WPS_STOP = 11, //for ALPHA
  104. LED_BLINK_WPS_STOP_OVERLAP = 12, //for BELKIN
  105. LED_BLINK_RUNTOP = 13, // Customized for RunTop
  106. LED_BLINK_CAMEO = 14,
  107. LED_BLINK_XAVI = 15,
  108. LED_BLINK_ALWAYS_ON = 16,
  109. LED_BLINK_LINK_IN_PROCESS = 17, //Customized for Belkin AC950
  110. LED_BLINK_AUTH_ERROR = 18, //Customized for Belkin AC950
  111. LED_BLINK_Azurewave_5Mbps = 19,
  112. LED_BLINK_Azurewave_10Mbps = 20,
  113. LED_BLINK_Azurewave_20Mbps = 21,
  114. LED_BLINK_Azurewave_40Mbps = 22,
  115. LED_BLINK_Azurewave_80Mbps = 23,
  116. LED_BLINK_Azurewave_MAXMbps = 24,
  117. }LED_STATE;
  118. typedef enum _LED_PIN{
  119. LED_PIN_GPIO0,
  120. LED_PIN_LED0,
  121. LED_PIN_LED1,
  122. LED_PIN_LED2
  123. }LED_PIN;
  124. //================================================================================
  125. // PCIE LED Definition.
  126. //================================================================================
  127. #ifdef CONFIG_PCI_HCI
  128. typedef enum _LED_STRATEGY_PCIE{
  129. SW_LED_MODE0, // SW control 1 LED via GPIO0. It is default option.
  130. SW_LED_MODE1, // SW control for PCI Express
  131. SW_LED_MODE2, // SW control for Cameo.
  132. SW_LED_MODE3, // SW contorl for RunTop.
  133. SW_LED_MODE4, // SW control for Netcore
  134. SW_LED_MODE5, //added by vivi, for led new mode, DLINK
  135. SW_LED_MODE6, //added by vivi, for led new mode, PRONET
  136. SW_LED_MODE7, //added by chiyokolin, for Lenovo, PCI Express Minicard Spec Rev.1.2 spec
  137. SW_LED_MODE8, //added by chiyokolin, for QMI
  138. SW_LED_MODE9, //added by chiyokolin, for BITLAND-LENOVO, PCI Express Minicard Spec Rev.1.1
  139. SW_LED_MODE10, //added by chiyokolin, for Edimax-ASUS
  140. SW_LED_MODE11, //added by hpfan, for Xavi
  141. SW_LED_MODE12, //added by chiyokolin, for Azurewave
  142. HW_LED, // HW control 2 LEDs, LED0 and LED1 (there are 4 different control modes)
  143. }LED_STRATEGY_PCIE, *PLED_STRATEGY_PCIE;
  144. typedef struct _LED_PCIE{
  145. PADAPTER padapter;
  146. LED_PIN LedPin; // Identify how to implement this SW led.
  147. LED_STATE CurrLedState; // Current LED state.
  148. BOOLEAN bLedOn; // TRUE if LED is ON, FALSE if LED is OFF.
  149. BOOLEAN bLedBlinkInProgress; // TRUE if it is blinking, FALSE o.w..
  150. BOOLEAN bLedWPSBlinkInProgress; // TRUE if it is blinking, FALSE o.w..
  151. BOOLEAN bLedSlowBlinkInProgress;//added by vivi, for led new mode
  152. u32 BlinkTimes; // Number of times to toggle led state for blinking.
  153. LED_STATE BlinkingLedState; // Next state for blinking, either LED_ON or LED_OFF are.
  154. _timer BlinkTimer; // Timer object for led blinking.
  155. } LED_PCIE, *PLED_PCIE;
  156. typedef struct _LED_PCIE LED_DATA, *PLED_DATA;
  157. typedef enum _LED_STRATEGY_PCIE LED_STRATEGY, *PLED_STRATEGY;
  158. VOID
  159. LedControlPCIE(
  160. IN PADAPTER Adapter,
  161. IN LED_CTL_MODE LedAction
  162. );
  163. VOID
  164. gen_RefreshLedState(
  165. IN PADAPTER Adapter);
  166. //================================================================================
  167. // USB LED Definition.
  168. //================================================================================
  169. #elif defined(CONFIG_USB_HCI)
  170. #define IS_LED_WPS_BLINKING(_LED_USB) (((PLED_USB)_LED_USB)->CurrLedState==LED_BLINK_WPS \
  171. || ((PLED_USB)_LED_USB)->CurrLedState==LED_BLINK_WPS_STOP \
  172. || ((PLED_USB)_LED_USB)->bLedWPSBlinkInProgress)
  173. #define IS_LED_BLINKING(_LED_USB) (((PLED_USB)_LED_USB)->bLedWPSBlinkInProgress \
  174. ||((PLED_USB)_LED_USB)->bLedScanBlinkInProgress)
  175. typedef enum _LED_STRATEGY_USB{
  176. SW_LED_MODE0, // SW control 1 LED via GPIO0. It is default option.
  177. SW_LED_MODE1, // 2 LEDs, through LED0 and LED1. For ALPHA.
  178. SW_LED_MODE2, // SW control 1 LED via GPIO0, customized for AzWave 8187 minicard.
  179. SW_LED_MODE3, // SW control 1 LED via GPIO0, customized for Sercomm Printer Server case.
  180. SW_LED_MODE4, //for Edimax / Belkin
  181. SW_LED_MODE5, //for Sercomm / Belkin
  182. SW_LED_MODE6, //for 88CU minicard, porting from ce SW_LED_MODE7
  183. SW_LED_MODE7, //for Netgear special requirement
  184. SW_LED_MODE8, //for LC
  185. SW_LED_MODE9, //for Belkin AC950
  186. SW_LED_MODE10, //for Netgear A6200V2
  187. SW_LED_MODE11, //for Edimax / ASUS
  188. SW_LED_MODE12, //for WNC/NEC
  189. SW_LED_MODE13, //for Netgear A6100, 8811Au
  190. HW_LED, // HW control 2 LEDs, LED0 and LED1 (there are 4 different control modes, see MAC.CONFIG1 for details.)
  191. }LED_STRATEGY_USB, *PLED_STRATEGY_USB;
  192. typedef struct _LED_USB{
  193. PADAPTER padapter;
  194. LED_PIN LedPin; // Identify how to implement this SW led.
  195. LED_STATE CurrLedState; // Current LED state.
  196. BOOLEAN bLedOn; // TRUE if LED is ON, FALSE if LED is OFF.
  197. BOOLEAN bSWLedCtrl;
  198. BOOLEAN bLedBlinkInProgress; // TRUE if it is blinking, FALSE o.w..
  199. // ALPHA, added by chiyoko, 20090106
  200. BOOLEAN bLedNoLinkBlinkInProgress;
  201. BOOLEAN bLedLinkBlinkInProgress;
  202. BOOLEAN bLedStartToLinkBlinkInProgress;
  203. BOOLEAN bLedScanBlinkInProgress;
  204. BOOLEAN bLedWPSBlinkInProgress;
  205. u32 BlinkTimes; // Number of times to toggle led state for blinking.
  206. u8 BlinkCounter; //Added for turn off overlap led after blinking a while, by page, 20120821
  207. LED_STATE BlinkingLedState; // Next state for blinking, either LED_ON or LED_OFF are.
  208. _timer BlinkTimer; // Timer object for led blinking.
  209. _workitem BlinkWorkItem; // Workitem used by BlinkTimer to manipulate H/W to blink LED.
  210. } LED_USB, *PLED_USB;
  211. typedef struct _LED_USB LED_DATA, *PLED_DATA;
  212. typedef enum _LED_STRATEGY_USB LED_STRATEGY, *PLED_STRATEGY;
  213. VOID
  214. LedControlUSB(
  215. IN PADAPTER Adapter,
  216. IN LED_CTL_MODE LedAction
  217. );
  218. //================================================================================
  219. // SDIO LED Definition.
  220. //================================================================================
  221. #elif defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
  222. #define IS_LED_WPS_BLINKING(_LED_SDIO) (((PLED_SDIO)_LED_SDIO)->CurrLedState==LED_BLINK_WPS \
  223. || ((PLED_SDIO)_LED_SDIO)->CurrLedState==LED_BLINK_WPS_STOP \
  224. || ((PLED_SDIO)_LED_SDIO)->bLedWPSBlinkInProgress)
  225. #define IS_LED_BLINKING(_LED_SDIO) (((PLED_SDIO)_LED_SDIO)->bLedWPSBlinkInProgress \
  226. ||((PLED_SDIO)_LED_SDIO)->bLedScanBlinkInProgress)
  227. typedef enum _LED_STRATEGY_SDIO{
  228. SW_LED_MODE0, // SW control 1 LED via GPIO0. It is default option.
  229. SW_LED_MODE1, // 2 LEDs, through LED0 and LED1. For ALPHA.
  230. SW_LED_MODE2, // SW control 1 LED via GPIO0, customized for AzWave 8187 minicard.
  231. SW_LED_MODE3, // SW control 1 LED via GPIO0, customized for Sercomm Printer Server case.
  232. SW_LED_MODE4, //for Edimax / Belkin
  233. SW_LED_MODE5, //for Sercomm / Belkin
  234. SW_LED_MODE6, //for 88CU minicard, porting from ce SW_LED_MODE7
  235. HW_LED, // HW control 2 LEDs, LED0 and LED1 (there are 4 different control modes, see MAC.CONFIG1 for details.)
  236. }LED_STRATEGY_SDIO, *PLED_STRATEGY_SDIO;
  237. typedef struct _LED_SDIO{
  238. PADAPTER padapter;
  239. LED_PIN LedPin; // Identify how to implement this SW led.
  240. LED_STATE CurrLedState; // Current LED state.
  241. BOOLEAN bLedOn; // TRUE if LED is ON, FALSE if LED is OFF.
  242. BOOLEAN bSWLedCtrl;
  243. BOOLEAN bLedBlinkInProgress; // TRUE if it is blinking, FALSE o.w..
  244. // ALPHA, added by chiyoko, 20090106
  245. BOOLEAN bLedNoLinkBlinkInProgress;
  246. BOOLEAN bLedLinkBlinkInProgress;
  247. BOOLEAN bLedStartToLinkBlinkInProgress;
  248. BOOLEAN bLedScanBlinkInProgress;
  249. BOOLEAN bLedWPSBlinkInProgress;
  250. u32 BlinkTimes; // Number of times to toggle led state for blinking.
  251. LED_STATE BlinkingLedState; // Next state for blinking, either LED_ON or LED_OFF are.
  252. _timer BlinkTimer; // Timer object for led blinking.
  253. _workitem BlinkWorkItem; // Workitem used by BlinkTimer to manipulate H/W to blink LED.
  254. } LED_SDIO, *PLED_SDIO;
  255. typedef struct _LED_SDIO LED_DATA, *PLED_DATA;
  256. typedef enum _LED_STRATEGY_SDIO LED_STRATEGY, *PLED_STRATEGY;
  257. VOID
  258. LedControlSDIO(
  259. IN PADAPTER Adapter,
  260. IN LED_CTL_MODE LedAction
  261. );
  262. #endif
  263. struct led_priv{
  264. /* add for led controll */
  265. LED_DATA SwLed0;
  266. LED_DATA SwLed1;
  267. LED_DATA SwLed2;
  268. LED_STRATEGY LedStrategy;
  269. u8 bRegUseLed;
  270. void (*LedControlHandler)(_adapter *padapter, LED_CTL_MODE LedAction);
  271. void (*SwLedOn)(_adapter *padapter, PLED_DATA pLed);
  272. void (*SwLedOff)(_adapter *padapter, PLED_DATA pLed);
  273. /* add for led controll */
  274. };
  275. #ifdef CONFIG_SW_LED
  276. void rtw_led_control(_adapter *adapter, LED_CTL_MODE LedAction);
  277. #else //CONFIG_SW_LED
  278. #define rtw_led_control(adapter, LedAction)
  279. #endif //CONFIG_SW_LED
  280. #define SwLedOn(adapter, pLed) \
  281. do { \
  282. if((adapter)->ledpriv.SwLedOn) \
  283. (adapter)->ledpriv.SwLedOn((adapter), (pLed)); \
  284. } while(0)
  285. #define SwLedOff(adapter, pLed) \
  286. do { \
  287. if((adapter)->ledpriv.SwLedOff) \
  288. (adapter)->ledpriv.SwLedOff((adapter), (pLed)); \
  289. } while(0)
  290. void BlinkTimerCallback(void *data);
  291. void BlinkWorkItemCallback(_workitem *work);
  292. void ResetLedStatus(PLED_DATA pLed);
  293. void
  294. InitLed(
  295. _adapter *padapter,
  296. PLED_DATA pLed,
  297. LED_PIN LedPin
  298. );
  299. void
  300. DeInitLed(
  301. PLED_DATA pLed
  302. );
  303. //hal...
  304. extern void BlinkHandler(PLED_DATA pLed);
  305. #endif //__RTW_LED_H_