1 /******************************************************************************
2 *
3 * Copyright(c) 2015 - 2016 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 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 *
19 ******************************************************************************/
20
21 #include <drv_types.h> /* PADAPTER */
22 #include <hal_data.h> /* PHAL_DATA_TYPE */
23 #include <hal_com_led.h> /* PLED_PCIE */
24
25
26 /*
27 *==============================================================================
28 * Prototype of protected function.
29 *==============================================================================
30 */
31
32 /*
33 *==============================================================================
34 * LED_819xUsb routines.
35 *==============================================================================
36 */
37
38 /*
39 * Description:
40 * Turn on LED according to LedPin specified.
41 */
SwLedOn_8822be(PADAPTER adapter,PLED_PCIE pLed)42 static void SwLedOn_8822be(PADAPTER adapter, PLED_PCIE pLed)
43 {
44 #if 0
45 u16 LedReg = REG_LEDCFG0;
46 u8 LedCfg = 0;
47 struct led_priv *ledpriv = &(adapter->ledpriv);
48
49 if (RTW_CANNOT_RUN(adapter))
50 return;
51
52 switch (pLed->LedPin) {
53 case LED_PIN_LED0:
54 if (ledpriv->LedStrategy == SW_LED_MODE10)
55 LedReg = REG_LEDCFG0;
56 else
57 LedReg = REG_LEDCFG1;
58 break;
59
60 case LED_PIN_LED1:
61 LedReg = REG_LEDCFG2;
62 break;
63
64 case LED_PIN_GPIO0:
65 default:
66 break;
67 }
68
69 LedCfg = rtw_read8(adapter, LedReg);
70 LedCfg |= BIT5; /* Set 0x4c[21] */
71
72 /* Clear 0x4c[23:22] and 0x4c[19:16] */
73 LedCfg &= ~(BIT7 | BIT6 | BIT3 | BIT2 | BIT1 | BIT0);
74
75 /* SW control led0 on. */
76 rtw_write8(adapter, LedReg, LedCfg);
77 pLed->bLedOn = _TRUE;
78 #else
79 RTW_INFO("%s(%d)TODO LED\n", __func__, __LINE__);
80 #endif
81 }
82
83
84 /*
85 * Description:
86 * Turn off LED according to LedPin specified.
87 */
SwLedOff_8822be(PADAPTER adapter,PLED_PCIE pLed)88 static void SwLedOff_8822be(PADAPTER adapter, PLED_PCIE pLed)
89 {
90 #if 0
91 u16 LedReg = REG_LEDCFG0;
92 PHAL_DATA_TYPE hal = GET_HAL_DATA(adapter);
93 struct led_priv *ledpriv = &adapter->ledpriv;
94
95 if (RTW_CANNOT_RUN(adapter))
96 return;
97
98 switch (pLed->LedPin) {
99 case LED_PIN_LED0:
100 if (ledpriv->LedStrategy == SW_LED_MODE10)
101 LedReg = REG_LEDCFG0;
102 else
103 LedReg = REG_LEDCFG1;
104 break;
105
106 case LED_PIN_LED1:
107 LedReg = REG_LEDCFG2;
108 break;
109
110 case LED_PIN_GPIO0:
111 default:
112 break;
113 }
114
115 /* Open-drain arrangement for controlling the LED */
116 if (hal->bLedOpenDrain == _TRUE) {
117 u8 LedCfg = rtw_read8(adapter, LedReg);
118
119 LedCfg &= 0xd0; /* Set to software control. */
120 rtw_write8(adapter, LedReg, (LedCfg | BIT3));
121
122 /* Open-drain arrangement */
123 LedCfg = rtw_read8(adapter, REG_MAC_PINMUX_CFG);
124 LedCfg &= 0xFE;/* Set GPIO[8] to input mode */
125 rtw_write8(adapter, REG_MAC_PINMUX_CFG, LedCfg);
126
127 } else
128 rtw_write8(adapter, LedReg, 0x28);
129
130 pLed->bLedOn = _FALSE;
131 #else
132 RTW_INFO("%s(%d)TODO LED\n", __func__, __LINE__);
133 #endif
134 }
135
136 /*
137 * Description:
138 * Initialize all LED_871x objects.
139 */
rtl8822be_InitSwLeds(PADAPTER adapter)140 void rtl8822be_InitSwLeds(PADAPTER adapter)
141 {
142 struct led_priv *pledpriv = &adapter->ledpriv;
143
144 pledpriv->LedControlHandler = LedControlPCIE;
145
146 pledpriv->SwLedOn = SwLedOn_8822be;
147 pledpriv->SwLedOff = SwLedOff_8822be;
148
149 InitLed(adapter, &pledpriv->SwLed0, LED_PIN_LED0);
150 InitLed(adapter, &pledpriv->SwLed1, LED_PIN_LED1);
151 }
152
153
154 /*
155 * Description:
156 * DeInitialize all LED_819xUsb objects.
157 */
rtl8822be_DeInitSwLeds(PADAPTER adapter)158 void rtl8822be_DeInitSwLeds(PADAPTER adapter)
159 {
160 struct led_priv *ledpriv = &adapter->ledpriv;
161
162 DeInitLed(&ledpriv->SwLed0);
163 DeInitLed(&ledpriv->SwLed1);
164 }
165