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 "drv_types.h"
17 #include "rtl8723a_hal.h"
18 #include "rtl8723a_led.h"
19 #include "usb_ops_linux.h"
20
21 /* */
22 /* LED object. */
23 /* */
24
25 /* */
26 /* Prototype of protected function. */
27 /* */
28
29 /* */
30 /* LED_819xUsb routines. */
31 /* */
32
33 /* Description: */
34 /* Turn on LED according to LedPin specified. */
SwLedOn23a(struct rtw_adapter * padapter,struct led_8723a * pLed)35 void SwLedOn23a(struct rtw_adapter *padapter, struct led_8723a *pLed)
36 {
37 u8 LedCfg = 0;
38
39 if ((padapter->bSurpriseRemoved == true) || (padapter->bDriverStopped == true))
40 return;
41 switch (pLed->LedPin) {
42 case LED_PIN_GPIO0:
43 break;
44 case LED_PIN_LED0:
45 /* SW control led0 on. */
46 rtl8723au_write8(padapter, REG_LEDCFG0,
47 (LedCfg&0xf0)|BIT(5)|BIT(6));
48 break;
49 case LED_PIN_LED1:
50 /* SW control led1 on. */
51 rtl8723au_write8(padapter, REG_LEDCFG1, (LedCfg&0x00)|BIT(6));
52 break;
53 case LED_PIN_LED2:
54 LedCfg = rtl8723au_read8(padapter, REG_LEDCFG2);
55 /* SW control led1 on. */
56 rtl8723au_write8(padapter, REG_LEDCFG2, (LedCfg&0x80)|BIT(5));
57 break;
58 default:
59 break;
60 }
61 pLed->bLedOn = true;
62 }
63
64 /* Description: */
65 /* Turn off LED according to LedPin specified. */
SwLedOff23a(struct rtw_adapter * padapter,struct led_8723a * pLed)66 void SwLedOff23a(struct rtw_adapter *padapter, struct led_8723a *pLed)
67 {
68 u8 LedCfg = 0;
69 /* struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); */
70
71 if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped))
72 goto exit;
73
74 switch (pLed->LedPin) {
75 case LED_PIN_GPIO0:
76 break;
77 case LED_PIN_LED0:
78 /* SW control led0 on. */
79 rtl8723au_write8(padapter, REG_LEDCFG0,
80 (LedCfg&0xf0)|BIT(5)|BIT(6));
81 break;
82 case LED_PIN_LED1:
83 /* SW control led1 on. */
84 rtl8723au_write8(padapter, REG_LEDCFG1,
85 (LedCfg&0x00)|BIT(5)|BIT(6));
86 break;
87 case LED_PIN_LED2:
88 LedCfg = rtl8723au_read8(padapter, REG_LEDCFG2);
89 /* SW control led1 on. */
90 rtl8723au_write8(padapter, REG_LEDCFG2,
91 (LedCfg&0x80)|BIT(3)|BIT(5));
92 break;
93 default:
94 break;
95 }
96 exit:
97 pLed->bLedOn = false;
98 }
99
100 /* Interface to manipulate LED objects. */
101
102 /* Description: */
103 /* Initialize all LED_871x objects. */
104 void
rtl8723au_InitSwLeds(struct rtw_adapter * padapter)105 rtl8723au_InitSwLeds(struct rtw_adapter *padapter)
106 {
107 struct led_priv *pledpriv = &padapter->ledpriv;
108
109 pledpriv->LedControlHandler = LedControl871x23a;
110 /* 8723as-vau wifi used led2 */
111 InitLed871x23a(padapter, &pledpriv->SwLed0, LED_PIN_LED2);
112
113 /* InitLed871x23a(padapter,&pledpriv->SwLed1, LED_PIN_LED2); */
114 }
115
116 /* Description: */
117 /* DeInitialize all LED_819xUsb objects. */
118 void
rtl8723au_DeInitSwLeds(struct rtw_adapter * padapter)119 rtl8723au_DeInitSwLeds(struct rtw_adapter *padapter)
120 {
121 struct led_priv *ledpriv = &padapter->ledpriv;
122
123 DeInitLed871x23a(&ledpriv->SwLed0);
124 }
125