• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
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  *
14  ******************************************************************************/
15 
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>
21 
22 /*  LED object. */
23 
24 /*  LED_819xUsb routines. */
25 /*	Description: */
26 /*		Turn on LED according to LedPin specified. */
SwLedOn(struct adapter * padapter,struct LED_871x * pLed)27 void SwLedOn(struct adapter *padapter, struct LED_871x *pLed)
28 {
29 	u8	LedCfg;
30 
31 	if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
32 		return;
33 	LedCfg = usb_read8(padapter, REG_LEDCFG2);
34 	usb_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0) | BIT(5) | BIT(6)); /*  SW control led0 on. */
35 	pLed->bLedOn = true;
36 }
37 
38 /*	Description: */
39 /*		Turn off LED according to LedPin specified. */
SwLedOff(struct adapter * padapter,struct LED_871x * pLed)40 void SwLedOff(struct adapter *padapter, struct LED_871x *pLed)
41 {
42 	u8	LedCfg;
43 
44 	if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
45 		goto exit;
46 
47 	LedCfg = usb_read8(padapter, REG_LEDCFG2);/* 0x4E */
48 
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);
54 		LedCfg &= 0xFE;
55 		usb_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg);
56 	} else {
57 		usb_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3) | BIT(5) | BIT(6)));
58 	}
59 exit:
60 	pLed->bLedOn = false;
61 }
62 
63 /*  Interface to manipulate LED objects. */
64 /*  Default LED behavior. */
65 
66 /*	Description: */
67 /*		Initialize all LED_871x objects. */
rtw_hal_sw_led_init(struct adapter * padapter)68 void rtw_hal_sw_led_init(struct adapter *padapter)
69 {
70 	struct led_priv *pledpriv = &(padapter->ledpriv);
71 
72 	pledpriv->bRegUseLed = true;
73 	pledpriv->LedControlHandler = LedControl8188eu;
74 	padapter->HalData->bLedOpenDrain = true;
75 
76 	InitLed871x(padapter, &(pledpriv->SwLed0));
77 }
78 
79 /*	Description: */
80 /*		DeInitialize all LED_819xUsb objects. */
rtw_hal_sw_led_deinit(struct adapter * padapter)81 void rtw_hal_sw_led_deinit(struct adapter *padapter)
82 {
83 	struct led_priv	*ledpriv = &(padapter->ledpriv);
84 
85 	DeInitLed871x(&(ledpriv->SwLed0));
86 }
87