1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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
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
19 ******************************************************************************/
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>
29 /* LED_819xUsb routines. */
31 /* Turn on LED according to LedPin specified. */
32 void SwLedOn(struct adapter *padapter, struct LED_871x *pLed)
36 if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
38 LedCfg = usb_read8(padapter, REG_LEDCFG2);
39 usb_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0) | BIT(5) | BIT(6)); /* SW control led0 on. */
44 /* Turn off LED according to LedPin specified. */
45 void SwLedOff(struct adapter *padapter, struct LED_871x *pLed)
48 struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter);
50 if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
53 LedCfg = usb_read8(padapter, REG_LEDCFG2);/* 0x4E */
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 | BIT(3)));
59 LedCfg = usb_read8(padapter, REG_MAC_PINMUX_CFG);
61 usb_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg);
63 usb_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3) | BIT(5) | BIT(6)));
69 /* Interface to manipulate LED objects. */
70 /* Default LED behavior. */
73 /* Initialize all LED_871x objects. */
74 void rtl8188eu_InitSwLeds(struct adapter *padapter)
76 struct led_priv *pledpriv = &(padapter->ledpriv);
77 struct hal_data_8188e *haldata = GET_HAL_DATA(padapter);
79 pledpriv->bRegUseLed = true;
80 pledpriv->LedControlHandler = LedControl8188eu;
81 haldata->bLedOpenDrain = true;
83 InitLed871x(padapter, &(pledpriv->SwLed0));
87 /* DeInitialize all LED_819xUsb objects. */
88 void rtl8188eu_DeInitSwLeds(struct adapter *padapter)
90 struct led_priv *ledpriv = &(padapter->ledpriv);
92 DeInitLed871x(&(ledpriv->SwLed0));