123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- /******************************************************************************
- *
- * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- *
- ******************************************************************************/
- #define _RTL8812AU_LED_C_
- //#include <drv_types.h>
- #include <rtl8812a_hal.h>
- //================================================================================
- // LED object.
- //================================================================================
- //================================================================================
- // Prototype of protected function.
- //================================================================================
- //================================================================================
- // LED_819xUsb routines.
- //================================================================================
- //
- // Description:
- // Turn on LED according to LedPin specified.
- //
- static void
- SwLedOn_8812AU(
- PADAPTER padapter,
- PLED_USB pLed
- )
- {
- u8 LedCfg;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
- if( (padapter->bSurpriseRemoved == _TRUE) || ( padapter->bDriverStopped == _TRUE))
- {
- return;
- }
- if( RT_GetInterfaceSelection(padapter) == INTF_SEL2_MINICARD ||
- RT_GetInterfaceSelection(padapter) == INTF_SEL3_USB_Solo ||
- RT_GetInterfaceSelection(padapter) == INTF_SEL4_USB_Combo)
- {
- LedCfg = rtw_read8(padapter, REG_LEDCFG2);
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("In SwLedON,LedAddr:%X LEDPIN=%d\n",REG_LEDCFG2, pLed->LedPin));
- switch(pLed->LedPin)
- {
- case LED_PIN_GPIO0:
- break;
- case LED_PIN_LED0:
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("In SwLedOn,LedAddr:%X LEDPIN=%d\n",REG_LEDCFG2, pLed->LedPin));
- LedCfg = rtw_read8(padapter, REG_LEDCFG2);
- rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT5|BIT6); // SW control led0 on.
- break;
- case LED_PIN_LED1:
- rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x0f)|BIT5); // SW control led1 on.
- break;
- default:
- break;
- }
- }
- else
- {
- switch(pLed->LedPin)
- {
- case LED_PIN_GPIO0:
- break;
- case LED_PIN_LED0:
- if(pHalData->AntDivCfg==0)
- {
- LedCfg = rtw_read8(padapter, REG_LEDCFG0);
- rtw_write8(padapter, REG_LEDCFG0, (LedCfg&0x70)|BIT5); // SW control led0 on.
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("SwLedOn LED0 0x%x\n", rtw_read32(padapter, REG_LEDCFG0)));
- }
- else
- {
- LedCfg = rtw_read8(padapter, REG_LEDCFG2);
- rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0xe0)|BIT7|BIT6|BIT5); // SW control led0 on.
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("SwLedOn LED0 Addr 0x%x, 0x%x\n", REG_LEDCFG2, rtw_read32(padapter, REG_LEDCFG2)));
- }
- break;
- case LED_PIN_LED1:
- LedCfg = rtw_read8(padapter, (REG_LEDCFG1));
- rtw_write8(padapter, (REG_LEDCFG1), (LedCfg&0x70)|BIT5); // SW control led1 on.
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("SwLedOn LED1 0x%x\n", rtw_read32(padapter, REG_LEDCFG1)));
- break;
- case LED_PIN_LED2:
- LedCfg = rtw_read8(padapter, (REG_LEDCFG2));
- rtw_write8(padapter, (REG_LEDCFG2), (LedCfg&0x70)|BIT5); // SW control led1 on.
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("SwLedOn LED2 0x%x\n", rtw_read32(padapter, REG_LEDCFG2)));
- break;
-
- default:
- break;
- }
- }
- pLed->bLedOn = _TRUE;
- }
- //
- // Description:
- // Turn off LED according to LedPin specified.
- //
- static void
- SwLedOff_8812AU(
- PADAPTER padapter,
- PLED_USB pLed
- )
- {
- u8 LedCfg;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
- if(padapter->bSurpriseRemoved == _TRUE)
- {
- return;
- }
- if( RT_GetInterfaceSelection(padapter) == INTF_SEL2_MINICARD ||
- RT_GetInterfaceSelection(padapter) == INTF_SEL3_USB_Solo ||
- RT_GetInterfaceSelection(padapter) == INTF_SEL4_USB_Combo)
- {
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("In SwLedOff,LedAddr:%X LEDPIN=%d\n",REG_LEDCFG2, pLed->LedPin));
- LedCfg = rtw_read8(padapter, REG_LEDCFG2);
-
- // 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:
- if(pHalData->bLedOpenDrain == _TRUE)
- {
- LedCfg &= 0x90; // Set to software control.
- rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3));
- LedCfg = rtw_read8(padapter, REG_MAC_PINMUX_CFG);
- LedCfg &= 0xFE;
- rtw_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg);
- }
- else
- {
- rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5|BIT6));
- }
- break;
- case LED_PIN_LED1:
- LedCfg &= 0x0f; // Set to software control.
- rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3));
- break;
- default:
- break;
- }
- }
- else
- {
- switch(pLed->LedPin)
- {
- case LED_PIN_GPIO0:
- break;
- case LED_PIN_LED0:
- if(pHalData->AntDivCfg==0)
- {
- LedCfg = rtw_read8(padapter, REG_LEDCFG0);
- LedCfg &= 0x70; // Set to software control.
- rtw_write8(padapter, REG_LEDCFG0, (LedCfg|BIT3|BIT5));
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("SwLedOff LED0 0x%x\n", rtw_read32(padapter, REG_LEDCFG0)));
- }
- else
- {
- LedCfg = rtw_read8(padapter, REG_LEDCFG2);
- LedCfg &= 0xe0; // Set to software control.
- if(IS_HARDWARE_TYPE_8723A(padapter))
- rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT7|BIT5));
- else
- rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT7|BIT6|BIT5));
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("SwLedOff LED0 0x%x\n", rtw_read32(padapter, REG_LEDCFG2)));
- }
- break;
- case LED_PIN_LED1:
- LedCfg = rtw_read8(padapter, REG_LEDCFG1);
- LedCfg &= 0x70; // Set to software control.
- rtw_write8(padapter, REG_LEDCFG1, (LedCfg|BIT3|BIT5));
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("SwLedOff LED1 0x%x\n", rtw_read32(padapter, REG_LEDCFG1)));
- break;
- case LED_PIN_LED2:
- LedCfg = rtw_read8(padapter, REG_LEDCFG2);
- LedCfg &= 0x70; // Set to software control.
- rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5));
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("SwLedOff LED1 0x%x\n", rtw_read32(padapter, REG_LEDCFG2)));
- break;
- default:
- break;
- }
- }
- pLed->bLedOn = _FALSE;
- }
- //
- // Description:
- // Turn on LED according to LedPin specified.
- //
- static void
- SwLedOn_8821AU(
- PADAPTER Adapter,
- PLED_USB pLed
- )
- {
- u8 LedCfg;
- if( (Adapter->bSurpriseRemoved == _TRUE) || ( Adapter->bDriverStopped == _TRUE))
- {
- return;
- }
- if( RT_GetInterfaceSelection(Adapter) == INTF_SEL2_MINICARD ||
- RT_GetInterfaceSelection(Adapter) == INTF_SEL3_USB_Solo ||
- RT_GetInterfaceSelection(Adapter) == INTF_SEL4_USB_Combo)
- {
- LedCfg = rtw_read8(Adapter, REG_LEDCFG2);
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("In SwLedON,LedAddr:%X LEDPIN=%d\n",REG_LEDCFG2, pLed->LedPin));
- switch(pLed->LedPin)
- {
- case LED_PIN_GPIO0:
- break;
- case LED_PIN_LED0:
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("In SwLedOn,LedAddr:%X LEDPIN=%d\n",REG_LEDCFG2, pLed->LedPin));
- LedCfg = rtw_read8(Adapter, REG_LEDCFG2);
- rtw_write8(Adapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT5|BIT6); // SW control led0 on.
- break;
- case LED_PIN_LED1:
- rtw_write8(Adapter, REG_LEDCFG2, (LedCfg&0x0f)|BIT5); // SW control led1 on.
- break;
- default:
- break;
- }
- }
- else
- {
- switch(pLed->LedPin)
- {
- case LED_PIN_GPIO0:
- break;
- case LED_PIN_LED0:
- case LED_PIN_LED1:
- case LED_PIN_LED2:
- if(IS_HARDWARE_TYPE_8821U(Adapter))
- {
- LedCfg = rtw_read8(Adapter, REG_LEDCFG2);
- rtw_write8(Adapter, REG_LEDCFG2, ((LedCfg&0x20) & (~BIT3))|BIT5); // SW control led0 on.
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("8821 SwLedOn LED2 0x%x\n", rtw_read32(Adapter, REG_LEDCFG0)));
- }
- break;
- default:
- break;
- }
- }
- pLed->bLedOn = _TRUE;
- }
- //
- // Description:
- // Turn off LED according to LedPin specified.
- //
- static void
- SwLedOff_8821AU(
- PADAPTER Adapter,
- PLED_USB pLed
- )
- {
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- u8 LedCfg;
- if(Adapter->bSurpriseRemoved == _TRUE)
- {
- return;
- }
- if( RT_GetInterfaceSelection(Adapter) == INTF_SEL2_MINICARD ||
- RT_GetInterfaceSelection(Adapter) == INTF_SEL3_USB_Solo ||
- RT_GetInterfaceSelection(Adapter) == INTF_SEL4_USB_Combo)
- {
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("In SwLedOff,LedAddr:%X LEDPIN=%d\n",REG_LEDCFG2, pLed->LedPin));
- LedCfg = rtw_read8(Adapter, REG_LEDCFG2);
-
- // 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:
- if(pHalData->bLedOpenDrain == _TRUE)
- {
- LedCfg &= 0x90; // Set to software control.
- rtw_write8(Adapter, REG_LEDCFG2, (LedCfg|BIT3));
- LedCfg = rtw_read8(Adapter, REG_MAC_PINMUX_CFG);
- LedCfg &= 0xFE;
- rtw_write8(Adapter, REG_MAC_PINMUX_CFG, LedCfg);
- }
- else
- {
- rtw_write8(Adapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5|BIT6));
- }
- break;
- case LED_PIN_LED1:
- LedCfg &= 0x0f; // Set to software control.
- rtw_write8(Adapter, REG_LEDCFG2, (LedCfg|BIT3));
- break;
- default:
- break;
- }
- }
- else
- {
- switch(pLed->LedPin)
- {
- case LED_PIN_GPIO0:
- break;
- case LED_PIN_LED0:
- case LED_PIN_LED1:
- case LED_PIN_LED2:
- if(IS_HARDWARE_TYPE_8821U(Adapter))
- {
- LedCfg = rtw_read8(Adapter, REG_LEDCFG2);
- LedCfg &= 0x20; // Set to software control.
- rtw_write8(Adapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5));
- RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("8821 SwLedOff LED2 0x%x\n", rtw_read32(Adapter, REG_LEDCFG0)));
- }
- break;
- default:
- break;
- }
- }
-
- pLed->bLedOn = _FALSE;
- }
- //================================================================================
- // Interface to manipulate LED objects.
- //================================================================================
- //================================================================================
- // Default LED behavior.
- //================================================================================
- //
- // Description:
- // Initialize all LED_871x objects.
- //
- void
- rtl8812au_InitSwLeds(
- _adapter *padapter
- )
- {
- struct led_priv *pledpriv = &(padapter->ledpriv);
- pledpriv->LedControlHandler = LedControlUSB;
- if(IS_HARDWARE_TYPE_8812(padapter)) {
- pledpriv->SwLedOn = SwLedOn_8812AU;
- pledpriv->SwLedOff = SwLedOff_8812AU;
- } else {
- pledpriv->SwLedOn = SwLedOn_8821AU;
- pledpriv->SwLedOff = SwLedOff_8821AU;
- }
- InitLed(padapter, &(pledpriv->SwLed0), LED_PIN_LED0);
- InitLed(padapter, &(pledpriv->SwLed1), LED_PIN_LED1);
- InitLed(padapter, &(pledpriv->SwLed2), LED_PIN_LED2);
- }
- //
- // Description:
- // DeInitialize all LED_819xUsb objects.
- //
- void
- rtl8812au_DeInitSwLeds(
- _adapter *padapter
- )
- {
- struct led_priv *ledpriv = &(padapter->ledpriv);
- DeInitLed( &(ledpriv->SwLed0) );
- DeInitLed( &(ledpriv->SwLed1) );
- DeInitLed( &(ledpriv->SwLed2) );
- }
|