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 */ 77 SW_LED_MODE3, /* SW control 1 LED via GPIO0, 78 * customized for Sercomm Printer Server case. 79 */ 80 SW_LED_MODE4, /*for Edimax / Belkin*/ 81 SW_LED_MODE5, /*for Sercomm / Belkin*/ 82 SW_LED_MODE6, /*for WNC / Corega*/ 83 HW_LED, /* HW control 2 LEDs, LED0 and LED1 (there are 4 different 84 * control modes, see MAC.CONFIG1 for details.) 85 */ 86 }; 87 88 struct LED_871x { 89 struct _adapter *padapter; 90 enum LED_PIN_871x LedPin; /* Implementation for this SW led. */ 91 u32 CurrLedState; /* Current LED state. */ 92 u8 bLedOn; /* true if LED is ON */ 93 u8 bSWLedCtrl; 94 u8 bLedBlinkInProgress; /*true if blinking */ 95 u8 bLedNoLinkBlinkInProgress; 96 u8 bLedLinkBlinkInProgress; 97 u8 bLedStartToLinkBlinkInProgress; 98 u8 bLedScanBlinkInProgress; 99 u8 bLedWPSBlinkInProgress; 100 u32 BlinkTimes; /* No. times to toggle for blink.*/ 101 u32 BlinkingLedState; /* Next state for blinking, 102 * either LED_ON or OFF. 103 */ 104 105 struct timer_list BlinkTimer; /* Timer object for led blinking.*/ 106 struct work_struct BlinkWorkItem; /* Workitem used by BlinkTimer */ 107 }; 108 109 struct led_priv { 110 /* add for led control */ 111 struct LED_871x SwLed0; 112 struct LED_871x SwLed1; 113 enum LED_STRATEGY_871x LedStrategy; 114 u8 bRegUseLed; 115 void (*LedControlHandler)(struct _adapter *padapter, 116 enum LED_CTL_MODE LedAction); 117 /* add for led control */ 118 }; 119 120 /*=========================================================================== 121 * Interface to manipulate LED objects. 122 *=========================================================================== 123 */ 124 void r8712_InitSwLeds(struct _adapter *padapter); 125 void r8712_DeInitSwLeds(struct _adapter *padapter); 126 void LedControl871x(struct _adapter *padapter, enum LED_CTL_MODE LedAction); 127 128 #endif 129 130