• 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  * 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 
21 #include <osdep_service.h>
22 #include <drv_types.h>
23 #include <rtl8188e_hal.h>
24 #include <rtl8188e_led.h>
25 #include <usb_ops_linux.h>
26 
27 /*  LED object. */
28 
29 /*  LED_819xUsb routines. */
30 /*	Description: */
31 /*		Turn on LED according to LedPin specified. */
SwLedOn(struct adapter * padapter,struct LED_871x * pLed)32 void SwLedOn(struct adapter *padapter, struct LED_871x *pLed)
33 {
34 	u8	LedCfg;
35 
36 	if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
37 		return;
38 	LedCfg = usb_read8(padapter, REG_LEDCFG2);
39 	usb_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT5|BIT6); /*  SW control led0 on. */
40 	pLed->bLedOn = true;
41 }
42 
43 /*	Description: */
44 /*		Turn off LED according to LedPin specified. */
SwLedOff(struct adapter * padapter,struct LED_871x * pLed)45 void SwLedOff(struct adapter *padapter, struct LED_871x *pLed)
46 {
47 	u8	LedCfg;
48 	struct hal_data_8188e	*pHalData = GET_HAL_DATA(padapter);
49 
50 	if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
51 		goto exit;
52 
53 	LedCfg = usb_read8(padapter, REG_LEDCFG2);/* 0x4E */
54 
55 	if (pHalData->bLedOpenDrain) {
56 			/*  Open-drain arrangement for controlling the LED) */
57 		LedCfg &= 0x90; /*  Set to software control. */
58 		usb_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3));
59 		LedCfg = usb_read8(padapter, REG_MAC_PINMUX_CFG);
60 		LedCfg &= 0xFE;
61 		usb_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg);
62 	} else {
63 		usb_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5|BIT6));
64 	}
65 exit:
66 	pLed->bLedOn = false;
67 }
68 
69 /*  Interface to manipulate LED objects. */
70 /*  Default LED behavior. */
71 
72 /*	Description: */
73 /*		Initialize all LED_871x objects. */
rtl8188eu_InitSwLeds(struct adapter * padapter)74 void rtl8188eu_InitSwLeds(struct adapter *padapter)
75 {
76 	struct led_priv *pledpriv = &(padapter->ledpriv);
77 	struct hal_data_8188e   *haldata = GET_HAL_DATA(padapter);
78 
79 	pledpriv->bRegUseLed = true;
80 	pledpriv->LedControlHandler = LedControl8188eu;
81 	haldata->bLedOpenDrain = true;
82 
83 	InitLed871x(padapter, &(pledpriv->SwLed0));
84 }
85 
86 /*	Description: */
87 /*		DeInitialize all LED_819xUsb objects. */
rtl8188eu_DeInitSwLeds(struct adapter * padapter)88 void rtl8188eu_DeInitSwLeds(struct adapter *padapter)
89 {
90 	struct led_priv	*ledpriv = &(padapter->ledpriv);
91 
92 	DeInitLed871x(&(ledpriv->SwLed0));
93 }
94