Path: blob/master/ALFA-W1F1/RTL8814AU/hal/rtl8814a/usb/rtl8814au_led.c
1308 views
/******************************************************************************1*2* Copyright(c) 2007 - 2017 Realtek Corporation.3*4* This program is free software; you can redistribute it and/or modify it5* under the terms of version 2 of the GNU General Public License as6* published by the Free Software Foundation.7*8* This program is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for11* more details.12*13*****************************************************************************/14#define _RTL8814AU_LED_C_1516/* #include <drv_types.h> */17#include <rtl8814a_hal.h>18#ifdef CONFIG_RTW_SW_LED1920/* ********************************************************************************21* LED object.22* ******************************************************************************** */232425/* ********************************************************************************26* Prototype of protected function.27* ******************************************************************************** */282930/* ********************************************************************************31* LED_819xUsb routines.32* ******************************************************************************** */3334/*35* Description:36* Turn on LED according to LedPin specified.37* */38static void39SwLedOn_8814AU(40PADAPTER padapter,41PLED_USB pLed42)43{44u32 LedGpioCfg;45HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);4647if (RTW_CANNOT_RUN(padapter))48return;4950LedGpioCfg = rtw_read32(padapter , REG_GPIO_PIN_CTRL_2); /* 0x60. In 8814AU, the name should be REG_GPIO_EXT_CTRL */51switch (pLed->LedPin) {52case LED_PIN_LED0:53LedGpioCfg |= (BIT16 | BIT17 | BIT21 | BIT22); /* config as gpo */54LedGpioCfg &= ~(BIT8 | BIT9 | BIT13 | BIT14); /* set gpo value */55LedGpioCfg &= ~(BIT0 | BIT1 | BIT5 | BIT6); /* set gpi value. TBD: may not need this */56rtw_write32(padapter , REG_GPIO_PIN_CTRL_2 , LedGpioCfg);57break;58default:59break;60}61pLed->bLedOn = _TRUE;62}636465/*66* Description:67* Turn off LED according to LedPin specified.68* */69static void70SwLedOff_8814AU(71PADAPTER padapter,72PLED_USB pLed73)74{75u32 LedGpioCfg;76HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);7778if (RTW_CANNOT_RUN(padapter))79return;80LedGpioCfg = rtw_read32(padapter , REG_GPIO_PIN_CTRL_2); /* 0x60. In 8814AU, the name should be REG_GPIO_EXT_CTRL */81switch (pLed->LedPin) {82case LED_PIN_LED0:83LedGpioCfg |= (BIT16 | BIT17 | BIT21 | BIT22); /* config as gpo */84LedGpioCfg |= (BIT8 | BIT9 | BIT13 | BIT14); /* set gpo output value */85rtw_write32(padapter , REG_GPIO_PIN_CTRL_2 , LedGpioCfg);86break;87default:88break;89}9091pLed->bLedOn = _FALSE;92}9394/* ********************************************************************************95* Interface to manipulate LED objects.96* ******************************************************************************** */979899/* ********************************************************************************100* Default LED behavior.101* ******************************************************************************** */102103/*104* Description:105* Initialize all LED_871x objects.106* */107void108rtl8814au_InitSwLeds(109_adapter *padapter110)111{112struct led_priv *pledpriv = adapter_to_led(padapter);113114pledpriv->LedControlHandler = LedControlUSB;115116pledpriv->SwLedOn = SwLedOn_8814AU;117pledpriv->SwLedOff = SwLedOff_8814AU;118119InitLed(padapter, &(pledpriv->SwLed0), LED_PIN_LED0);120121InitLed(padapter, &(pledpriv->SwLed1), LED_PIN_LED1);122123InitLed(padapter, &(pledpriv->SwLed2), LED_PIN_LED2);124}125126127/*128* Description:129* DeInitialize all LED_819xUsb objects.130* */131void132rtl8814au_DeInitSwLeds(133_adapter *padapter134)135{136struct led_priv *ledpriv = adapter_to_led(padapter);137138DeInitLed(&(ledpriv->SwLed0));139DeInitLed(&(ledpriv->SwLed1));140DeInitLed(&(ledpriv->SwLed2));141}142#endif143144145