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 ******************************************************************************/
16 #include <osdep_service.h>
17 #include <drv_types.h>
18 #include <rtl8188e_hal.h>
19 #include <rtl8188e_led.h>
20 #include <usb_ops_linux.h>
24 /* LED_819xUsb routines. */
26 /* Turn on LED according to LedPin specified. */
27 void SwLedOn(struct adapter *padapter, struct LED_871x *pLed)
31 if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
33 LedCfg = usb_read8(padapter, REG_LEDCFG2);
34 usb_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0) | BIT(5) | BIT(6)); /* SW control led0 on. */
39 /* Turn off LED according to LedPin specified. */
40 void SwLedOff(struct adapter *padapter, struct LED_871x *pLed)
44 if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
47 LedCfg = usb_read8(padapter, REG_LEDCFG2);/* 0x4E */
49 if (padapter->HalData->bLedOpenDrain) {
50 /* Open-drain arrangement for controlling the LED) */
51 LedCfg &= 0x90; /* Set to software control. */
52 usb_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3)));
53 LedCfg = usb_read8(padapter, REG_MAC_PINMUX_CFG);
55 usb_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg);
57 usb_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3) | BIT(5) | BIT(6)));
63 /* Interface to manipulate LED objects. */
64 /* Default LED behavior. */
67 /* Initialize all LED_871x objects. */
68 void rtw_hal_sw_led_init(struct adapter *padapter)
70 struct led_priv *pledpriv = &(padapter->ledpriv);
72 pledpriv->bRegUseLed = true;
73 pledpriv->LedControlHandler = LedControl8188eu;
74 padapter->HalData->bLedOpenDrain = true;
76 InitLed871x(padapter, &(pledpriv->SwLed0));
80 /* DeInitialize all LED_819xUsb objects. */
81 void rtw_hal_sw_led_deinit(struct adapter *padapter)
83 struct led_priv *ledpriv = &(padapter->ledpriv);
85 DeInitLed871x(&(ledpriv->SwLed0));