blob: d9e677ef8f84e58f962340284ce50e5b301db2e0 [file] [log] [blame]
Larry Finger7bc88632013-08-21 22:33:59 -05001/******************************************************************************
2 *
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4 *
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.
8 *
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
12 * more details.
13 *
Larry Finger7bc88632013-08-21 22:33:59 -050014 ******************************************************************************/
15
16#include <osdep_service.h>
17#include <drv_types.h>
18#include <rtl8188e_hal.h>
19#include <rtl8188e_led.h>
navin patidare73fd152014-06-11 22:51:40 +053020#include <usb_ops_linux.h>
Larry Finger7bc88632013-08-21 22:33:59 -050021
22/* LED object. */
23
24/* LED_819xUsb routines. */
25/* Description: */
26/* Turn on LED according to LedPin specified. */
27void SwLedOn(struct adapter *padapter, struct LED_871x *pLed)
28{
29 u8 LedCfg;
30
31 if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
32 return;
navin patidarc7b2e992014-06-11 22:51:36 +053033 LedCfg = usb_read8(padapter, REG_LEDCFG2);
Anish Bhatt9c68ed02015-10-18 22:51:41 -070034 usb_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0) | BIT(5) | BIT(6)); /* SW control led0 on. */
Larry Finger7bc88632013-08-21 22:33:59 -050035 pLed->bLedOn = true;
36}
37
38/* Description: */
39/* Turn off LED according to LedPin specified. */
40void SwLedOff(struct adapter *padapter, struct LED_871x *pLed)
41{
42 u8 LedCfg;
43 struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter);
44
45 if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
46 goto exit;
47
navin patidarc7b2e992014-06-11 22:51:36 +053048 LedCfg = usb_read8(padapter, REG_LEDCFG2);/* 0x4E */
Larry Finger7bc88632013-08-21 22:33:59 -050049
navin patidar373b61b2014-04-20 14:17:15 +053050 if (pHalData->bLedOpenDrain) {
Larry Finger7bc88632013-08-21 22:33:59 -050051 /* Open-drain arrangement for controlling the LED) */
navin patidar373b61b2014-04-20 14:17:15 +053052 LedCfg &= 0x90; /* Set to software control. */
Anish Bhatt9c68ed02015-10-18 22:51:41 -070053 usb_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3)));
navin patidarc7b2e992014-06-11 22:51:36 +053054 LedCfg = usb_read8(padapter, REG_MAC_PINMUX_CFG);
navin patidar373b61b2014-04-20 14:17:15 +053055 LedCfg &= 0xFE;
navin patidare76484d2014-06-11 22:51:33 +053056 usb_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg);
navin patidar373b61b2014-04-20 14:17:15 +053057 } else {
Anish Bhatt9c68ed02015-10-18 22:51:41 -070058 usb_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3) | BIT(5) | BIT(6)));
Larry Finger7bc88632013-08-21 22:33:59 -050059 }
60exit:
61 pLed->bLedOn = false;
62}
63
64/* Interface to manipulate LED objects. */
65/* Default LED behavior. */
66
67/* Description: */
68/* Initialize all LED_871x objects. */
69void rtl8188eu_InitSwLeds(struct adapter *padapter)
70{
71 struct led_priv *pledpriv = &(padapter->ledpriv);
navin patidar74391e12014-04-20 14:17:11 +053072 struct hal_data_8188e *haldata = GET_HAL_DATA(padapter);
Larry Finger7bc88632013-08-21 22:33:59 -050073
navin patidar74391e12014-04-20 14:17:11 +053074 pledpriv->bRegUseLed = true;
Larry Fingerd33b1282013-08-25 11:55:15 -050075 pledpriv->LedControlHandler = LedControl8188eu;
navin patidar74391e12014-04-20 14:17:11 +053076 haldata->bLedOpenDrain = true;
Larry Finger7bc88632013-08-21 22:33:59 -050077
navin patidar373b61b2014-04-20 14:17:15 +053078 InitLed871x(padapter, &(pledpriv->SwLed0));
Larry Finger7bc88632013-08-21 22:33:59 -050079}
80
81/* Description: */
82/* DeInitialize all LED_819xUsb objects. */
83void rtl8188eu_DeInitSwLeds(struct adapter *padapter)
84{
85 struct led_priv *ledpriv = &(padapter->ledpriv);
86
87 DeInitLed871x(&(ledpriv->SwLed0));
Larry Finger7bc88632013-08-21 22:33:59 -050088}