• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  ******************************************************************************/
15 #ifndef __RTW_LED_H_
16 #define __RTW_LED_H_
17 
18 #include <osdep_service.h>
19 #include <drv_types.h>
20 
21 #define MSECS(t)        (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
22 
23 #define LED_BLINK_NORMAL_INTERVAL	100
24 #define LED_BLINK_SLOWLY_INTERVAL	200
25 #define LED_BLINK_LONG_INTERVAL	400
26 
27 #define LED_BLINK_NO_LINK_INTERVAL_ALPHA		1000
28 #define LED_BLINK_LINK_INTERVAL_ALPHA			500		/* 500 */
29 #define LED_BLINK_SCAN_INTERVAL_ALPHA		180	/* 150 */
30 #define LED_BLINK_FASTER_INTERVAL_ALPHA		50
31 #define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA	5000
32 
33 #define LED_BLINK_NORMAL_INTERVAL_NETTRONIX  100
34 #define LED_BLINK_SLOWLY_INTERVAL_NETTRONIX  2000
35 
36 #define LED_BLINK_SLOWLY_INTERVAL_PORNET 1000
37 #define LED_BLINK_NORMAL_INTERVAL_PORNET 100
38 
39 #define LED_BLINK_FAST_INTERVAL_BITLAND 30
40 
41 /*  060403, rcnjko: Customized for AzWave. */
42 #define LED_CM2_BLINK_ON_INTERVAL			250
43 #define LED_CM2_BLINK_OFF_INTERVAL		4750
44 
45 #define LED_CM8_BLINK_INTERVAL			500		/* for QMI */
46 #define LED_CM8_BLINK_OFF_INTERVAL	3750	/* for QMI */
47 
48 /*  080124, lanhsin: Customized for RunTop */
49 #define LED_RunTop_BLINK_INTERVAL			300
50 
51 /*  060421, rcnjko: Customized for Sercomm Printer Server case. */
52 #define LED_CM3_BLINK_INTERVAL				1500
53 
54 enum led_ctl_mode {
55 	LED_CTL_POWER_ON = 1,
56 	LED_CTL_LINK = 2,
57 	LED_CTL_NO_LINK = 3,
58 	LED_CTL_TX = 4,
59 	LED_CTL_RX = 5,
60 	LED_CTL_SITE_SURVEY = 6,
61 	LED_CTL_POWER_OFF = 7,
62 	LED_CTL_START_TO_LINK = 8,
63 	LED_CTL_START_WPS = 9,
64 	LED_CTL_STOP_WPS = 10,
65 	LED_CTL_START_WPS_BOTTON = 11, /* added for runtop */
66 	LED_CTL_STOP_WPS_FAIL = 12, /* added for ALPHA */
67 	LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, /* added for BELKIN */
68 	LED_CTL_CONNECTION_NO_TRANSFER = 14,
69 };
70 
71 enum led_state_872x {
72 	LED_UNKNOWN = 0,
73 	RTW_LED_ON = 1,
74 	RTW_LED_OFF = 2,
75 	LED_BLINK_NORMAL = 3,
76 	LED_BLINK_SLOWLY = 4,
77 	LED_BLINK_POWER_ON = 5,
78 	LED_BLINK_SCAN = 6, /*  LED is blinking during scanning period, the # of times to blink is depend on time for scanning. */
79 	LED_BLINK_NO_LINK = 7, /*  LED is blinking during no link state. */
80 	LED_BLINK_StartToBlink = 8,/*  Customzied for Sercomm Printer Server case */
81 	LED_BLINK_TXRX = 9,
82 	LED_BLINK_WPS = 10,	/*  LED is blinkg during WPS communication */
83 	LED_BLINK_WPS_STOP = 11,	/* for ALPHA */
84 	LED_BLINK_WPS_STOP_OVERLAP = 12,	/* for BELKIN */
85 	LED_BLINK_RUNTOP = 13, /*  Customized for RunTop */
86 	LED_BLINK_CAMEO = 14,
87 	LED_BLINK_XAVI = 15,
88 	LED_BLINK_ALWAYS_ON = 16,
89 };
90 
91 enum led_pin_8723a {
92 	LED_PIN_NULL = 0,
93 	LED_PIN_LED0 = 1,
94 	LED_PIN_LED1 = 2,
95 	LED_PIN_LED2 = 3,
96 	LED_PIN_GPIO0 = 4,
97 };
98 
99 struct led_8723a {
100 	struct rtw_adapter				*padapter;
101 
102 	enum led_pin_8723a		LedPin;	/*  Identify how to implement this SW led. */
103 	enum led_state_872x		CurrLedState; /*  Current LED state. */
104 	enum led_state_872x		BlinkingLedState; /*  Next state for blinking, either RTW_LED_ON or RTW_LED_OFF are. */
105 
106 	u8					bLedOn; /*  true if LED is ON, false if LED is OFF. */
107 
108 	u8					bLedBlinkInProgress; /*  true if it is blinking, false o.w.. */
109 
110 	u8					bLedWPSBlinkInProgress;
111 
112 	u32					BlinkTimes; /*  Number of times to toggle led state for blinking. */
113 
114 	struct timer_list			BlinkTimer; /*  Timer object for led blinking. */
115 
116 	u8					bSWLedCtrl;
117 
118 	/*  ALPHA, added by chiyoko, 20090106 */
119 	u8					bLedNoLinkBlinkInProgress;
120 	u8					bLedLinkBlinkInProgress;
121 	u8					bLedStartToLinkBlinkInProgress;
122 	u8					bLedScanBlinkInProgress;
123 
124 	struct work_struct			BlinkWorkItem; /*  Workitem used by BlinkTimer to manipulate H/W to blink LED. */
125 };
126 
127 #define IS_LED_WPS_BLINKING(_LED_871x)	(((struct led_8723a *)_LED_871x)->CurrLedState==LED_BLINK_WPS \
128 					|| ((struct led_8723a *)_LED_871x)->CurrLedState==LED_BLINK_WPS_STOP \
129 					|| ((struct led_8723a *)_LED_871x)->bLedWPSBlinkInProgress)
130 
131 #define IS_LED_BLINKING(_LED_871x)	(((struct led_8723a *)_LED_871x)->bLedWPSBlinkInProgress \
132 					||((struct led_8723a *)_LED_871x)->bLedScanBlinkInProgress)
133 
134 /*  */
135 /*  LED customization. */
136 /*  */
137 
138 enum led_strategy_8723a {
139 	SW_LED_MODE0 = 0, /*  SW control 1 LED via GPIO0. It is default option. */
140 	SW_LED_MODE1= 1, /*  2 LEDs, through LED0 and LED1. For ALPHA. */
141 	SW_LED_MODE2 = 2, /*  SW control 1 LED via GPIO0, customized for AzWave 8187 minicard. */
142 	SW_LED_MODE3 = 3, /*  SW control 1 LED via GPIO0, customized for Sercomm Printer Server case. */
143 	SW_LED_MODE4 = 4, /* for Edimax / Belkin */
144 	SW_LED_MODE5 = 5, /* for Sercomm / Belkin */
145 	SW_LED_MODE6 = 6, /* for 88CU minicard, porting from ce SW_LED_MODE7 */
146 	HW_LED = 50, /*  HW control 2 LEDs, LED0 and LED1 (there are 4 different control modes, see MAC.CONFIG1 for details.) */
147 	LED_ST_NONE = 99,
148 };
149 
150 void LedControl871x23a(struct rtw_adapter *padapter, enum led_ctl_mode LedAction);
151 
152 struct led_priv{
153 	/* add for led controll */
154 	struct led_8723a			SwLed0;
155 	struct led_8723a			SwLed1;
156 	enum led_strategy_8723a	LedStrategy;
157 	u8					bRegUseLed;
158 	void (*LedControlHandler)(struct rtw_adapter *padapter, enum led_ctl_mode LedAction);
159 	/* add for led controll */
160 };
161 
162 #define rtw_led_control(adapter, LedAction)
163 
164 void BlinkWorkItemCallback23a(struct work_struct *work);
165 
166 void ResetLedStatus23a(struct led_8723a *pLed);
167 
168 void
169 InitLed871x23a(
170 	struct rtw_adapter *padapter,
171 	struct led_8723a *pLed,
172 	enum led_pin_8723a	LedPin
173 );
174 
175 void
176 DeInitLed871x23a(struct led_8723a *pLed);
177 
178 /* hal... */
179 void BlinkHandler23a(struct led_8723a *pLed);
180 
181 #endif /* __RTW_LED_H_ */
182