2015-08-18 19:03:09 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2019-11-09 10:12:08 +00:00
|
|
|
* Copyright(c) 2012 - 2017 Realtek Corporation.
|
|
|
|
*
|
2015-08-18 19:03:09 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
2019-11-09 10:12:08 +00:00
|
|
|
*****************************************************************************/
|
2015-08-18 19:03:09 +00:00
|
|
|
#define _RTL8192E_LED_C_
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* #include <drv_types.h> */
|
2015-08-18 19:03:09 +00:00
|
|
|
#include <rtl8192e_hal.h>
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTW_SW_LED
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* ********************************************************************************
|
|
|
|
* LED object.
|
|
|
|
* ******************************************************************************** */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* ********************************************************************************
|
|
|
|
* Prototype of protected function.
|
|
|
|
* ******************************************************************************** */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* ********************************************************************************
|
|
|
|
* LED_819xUsb routines.
|
|
|
|
* ******************************************************************************** */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/*
|
|
|
|
* Description:
|
|
|
|
* Turn on LED according to LedPin specified.
|
|
|
|
* */
|
2015-08-18 19:03:09 +00:00
|
|
|
static void
|
|
|
|
SwLedOn_8192EU(
|
2019-11-09 10:12:08 +00:00
|
|
|
PADAPTER padapter,
|
2015-08-18 19:03:09 +00:00
|
|
|
PLED_USB pLed
|
|
|
|
)
|
|
|
|
{
|
|
|
|
u8 LedCfg;
|
|
|
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
if (RTW_CANNOT_RUN(padapter))
|
2015-08-18 19:03:09 +00:00
|
|
|
return;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (RT_GetInterfaceSelection(padapter) == INTF_SEL2_MINICARD ||
|
|
|
|
RT_GetInterfaceSelection(padapter) == INTF_SEL3_USB_Solo ||
|
|
|
|
RT_GetInterfaceSelection(padapter) == INTF_SEL4_USB_Combo) {
|
2015-08-18 19:03:09 +00:00
|
|
|
LedCfg = rtw_read8(padapter, REG_LEDCFG2);
|
2019-11-09 10:12:08 +00:00
|
|
|
switch (pLed->LedPin) {
|
|
|
|
case LED_PIN_GPIO0:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LED_PIN_LED0:
|
|
|
|
LedCfg = rtw_read8(padapter, REG_LEDCFG0);
|
|
|
|
rtw_write8(padapter, REG_LEDCFG1, (LedCfg & ~BIT7)); /* SW control led1 on. */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LED_PIN_LED1:
|
|
|
|
phy_set_mac_reg(padapter, 0x64, BIT1, 0);
|
|
|
|
phy_set_mac_reg(padapter, 0x4C, BIT15, 0);
|
|
|
|
phy_set_mac_reg(padapter, 0x4C, BIT10 | BIT9 | BIT8, 0);
|
|
|
|
phy_set_mac_reg(padapter, 0x4C, BIT11, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
} else {
|
|
|
|
switch (pLed->LedPin) {
|
|
|
|
case LED_PIN_GPIO0:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LED_PIN_LED0: /* 8192EU don't have LED0, so we jump this case to set LED1 */
|
|
|
|
LedCfg = rtw_read8(padapter, (REG_LEDCFG1));
|
|
|
|
rtw_write8(padapter, (REG_LEDCFG1), (LedCfg & ~BIT7)); /* SW control led1 on. */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LED_PIN_LED1:
|
|
|
|
phy_set_mac_reg(padapter, 0x64, BIT1, 0);
|
|
|
|
phy_set_mac_reg(padapter, 0x4C, BIT15, 0);
|
|
|
|
phy_set_mac_reg(padapter, 0x4C, BIT10 | BIT9 | BIT8, 0);
|
|
|
|
phy_set_mac_reg(padapter, 0x4C, BIT11, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LED_PIN_LED2:
|
|
|
|
LedCfg = rtw_read8(padapter, (REG_LEDCFG2));
|
|
|
|
rtw_write8(padapter, (REG_LEDCFG2), (LedCfg & ~BIT7)); /* SW control led1 on. */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pLed->bLedOn = _TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/*
|
|
|
|
* Description:
|
|
|
|
* Turn off LED according to LedPin specified.
|
|
|
|
* */
|
2015-08-18 19:03:09 +00:00
|
|
|
static void
|
|
|
|
SwLedOff_8192EU(
|
2019-11-09 10:12:08 +00:00
|
|
|
PADAPTER padapter,
|
2015-08-18 19:03:09 +00:00
|
|
|
PLED_USB pLed
|
|
|
|
)
|
|
|
|
{
|
|
|
|
u8 LedCfg;
|
|
|
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
if (RTW_CANNOT_RUN(padapter))
|
2015-08-18 19:03:09 +00:00
|
|
|
return;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (RT_GetInterfaceSelection(padapter) == INTF_SEL2_MINICARD ||
|
|
|
|
RT_GetInterfaceSelection(padapter) == INTF_SEL3_USB_Solo ||
|
|
|
|
RT_GetInterfaceSelection(padapter) == INTF_SEL4_USB_Combo) {
|
2015-08-18 19:03:09 +00:00
|
|
|
LedCfg = rtw_read8(padapter, REG_LEDCFG2);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
/* 2009/10/23 MH Issau eed to move the LED GPIO from bit 0 to bit3. */
|
|
|
|
/* 2009/10/26 MH Issau if tyhe device is 8c DID is 0x8176, we need to enable bit6 to */
|
|
|
|
/* enable GPIO8 for controlling LED. */
|
|
|
|
/* 2010/07/02 Supprt Open-drain arrangement for controlling the LED. Added by Roger. */
|
|
|
|
/* */
|
|
|
|
switch (pLed->LedPin) {
|
|
|
|
|
|
|
|
case LED_PIN_GPIO0:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LED_PIN_LED0: /* 8192EU don't have LED0, so we jump this case to set LED1 */
|
|
|
|
LedCfg = rtw_read8(padapter, REG_LEDCFG1);
|
|
|
|
rtw_write8(padapter, REG_LEDCFG1, LedCfg | BIT7);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LED_PIN_LED1:
|
|
|
|
phy_set_mac_reg(padapter, 0x64, BIT1, 0);
|
|
|
|
phy_set_mac_reg(padapter, 0x4C, BIT15, 0);
|
|
|
|
phy_set_mac_reg(padapter, 0x4C, BIT10 | BIT9 | BIT8, 0);
|
|
|
|
phy_set_mac_reg(padapter, 0x4C, BIT11, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
} else {
|
|
|
|
switch (pLed->LedPin) {
|
|
|
|
case LED_PIN_GPIO0:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LED_PIN_LED0: /* 8192EU don't have LED0, so we jump this case to set LED1 */
|
|
|
|
LedCfg = rtw_read8(padapter, REG_LEDCFG1);
|
|
|
|
rtw_write8(padapter, REG_LEDCFG1, LedCfg | BIT7);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LED_PIN_LED1:
|
|
|
|
phy_set_mac_reg(padapter, 0x64, BIT1, 0);
|
|
|
|
phy_set_mac_reg(padapter, 0x4C, BIT15, 0);
|
|
|
|
phy_set_mac_reg(padapter, 0x4C, BIT10 | BIT9 | BIT8, 0);
|
|
|
|
phy_set_mac_reg(padapter, 0x4C, BIT11, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LED_PIN_LED2:
|
|
|
|
LedCfg = rtw_read8(padapter, REG_LEDCFG2);
|
|
|
|
rtw_write8(padapter, REG_LEDCFG2, LedCfg | BIT7);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pLed->bLedOn = _FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* ********************************************************************************
|
|
|
|
* Interface to manipulate LED objects.
|
|
|
|
* ******************************************************************************** */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* ********************************************************************************
|
|
|
|
* Default LED behavior.
|
|
|
|
* ******************************************************************************** */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/*
|
|
|
|
* Description:
|
|
|
|
* Initialize all LED_871x objects.
|
|
|
|
* */
|
2015-08-18 19:03:09 +00:00
|
|
|
void
|
|
|
|
rtl8192eu_InitSwLeds(
|
|
|
|
_adapter *padapter
|
2019-11-09 10:12:08 +00:00
|
|
|
)
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
struct led_priv *pledpriv = adapter_to_led(padapter);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
pledpriv->LedControlHandler = LedControlUSB;
|
|
|
|
|
|
|
|
pledpriv->SwLedOn = SwLedOn_8192EU;
|
|
|
|
pledpriv->SwLedOff = SwLedOff_8192EU;
|
|
|
|
|
|
|
|
InitLed(padapter, &(pledpriv->SwLed0), LED_PIN_LED0);
|
|
|
|
|
|
|
|
InitLed(padapter, &(pledpriv->SwLed1), LED_PIN_LED1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/*
|
|
|
|
* Description:
|
|
|
|
* DeInitialize all LED_819xUsb objects.
|
|
|
|
* */
|
2015-08-18 19:03:09 +00:00
|
|
|
void
|
|
|
|
rtl8192eu_DeInitSwLeds(
|
|
|
|
_adapter *padapter
|
2019-11-09 10:12:08 +00:00
|
|
|
)
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
struct led_priv *ledpriv = adapter_to_led(padapter);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
DeInitLed(&(ledpriv->SwLed0));
|
|
|
|
DeInitLed(&(ledpriv->SwLed1));
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|