1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
3 *
4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5 *
6 ******************************************************************************/
7
8 #include <osdep_service.h>
9 #include <drv_types.h>
10 #include <rtl8188e_hal.h>
11 #include <usb_ops_linux.h>
12
13 /* LED object. */
14
15 /* LED_819xUsb routines. */
16 /* Description: */
17 /* Turn on LED according to LedPin specified. */
SwLedOn(struct adapter * padapter,struct LED_871x * pLed)18 void SwLedOn(struct adapter *padapter, struct LED_871x *pLed)
19 {
20 u8 LedCfg;
21
22 if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
23 return;
24 LedCfg = usb_read8(padapter, REG_LEDCFG2);
25 usb_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0) | BIT(5) | BIT(6)); /* SW control led0 on. */
26 pLed->bLedOn = true;
27 }
28
29 /* Description: */
30 /* Turn off LED according to LedPin specified. */
SwLedOff(struct adapter * padapter,struct LED_871x * pLed)31 void SwLedOff(struct adapter *padapter, struct LED_871x *pLed)
32 {
33 u8 LedCfg;
34
35 if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
36 goto exit;
37
38 LedCfg = usb_read8(padapter, REG_LEDCFG2);/* 0x4E */
39
40 /* Open-drain arrangement for controlling the LED) */
41 LedCfg &= 0x90; /* Set to software control. */
42 usb_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3)));
43 LedCfg = usb_read8(padapter, REG_MAC_PINMUX_CFG);
44 LedCfg &= 0xFE;
45 usb_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg);
46 exit:
47 pLed->bLedOn = false;
48 }
49
50 /* Interface to manipulate LED objects. */
51 /* Default LED behavior. */
52
53 /* Description: */
54 /* Initialize all LED_871x objects. */
rtw_hal_sw_led_init(struct adapter * padapter)55 void rtw_hal_sw_led_init(struct adapter *padapter)
56 {
57 struct led_priv *pledpriv = &(padapter->ledpriv);
58
59 InitLed871x(padapter, &(pledpriv->SwLed0));
60 }
61
62 /* Description: */
63 /* DeInitialize all LED_819xUsb objects. */
rtw_hal_sw_led_deinit(struct adapter * padapter)64 void rtw_hal_sw_led_deinit(struct adapter *padapter)
65 {
66 struct led_priv *ledpriv = &(padapter->ledpriv);
67
68 DeInitLed871x(&(ledpriv->SwLed0));
69 }
70