Commit | Line | Data |
---|---|---|
7bc88639 LF |
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 | * | |
7bc88639 LF |
14 | ******************************************************************************/ |
15 | ||
16 | #include <osdep_service.h> | |
17 | #include <drv_types.h> | |
18 | #include <rtl8188e_hal.h> | |
19 | #include <rtl8188e_led.h> | |
e73fd15e | 20 | #include <usb_ops_linux.h> |
7bc88639 LF |
21 | |
22 | /* LED object. */ | |
23 | ||
24 | /* LED_819xUsb routines. */ | |
25 | /* Description: */ | |
26 | /* Turn on LED according to LedPin specified. */ | |
27 | void SwLedOn(struct adapter *padapter, struct LED_871x *pLed) | |
28 | { | |
29 | u8 LedCfg; | |
30 | ||
31 | if (padapter->bSurpriseRemoved || padapter->bDriverStopped) | |
32 | return; | |
c7b2e995 | 33 | LedCfg = usb_read8(padapter, REG_LEDCFG2); |
9c68ed09 | 34 | usb_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0) | BIT(5) | BIT(6)); /* SW control led0 on. */ |
7bc88639 LF |
35 | pLed->bLedOn = true; |
36 | } | |
37 | ||
38 | /* Description: */ | |
39 | /* Turn off LED according to LedPin specified. */ | |
40 | void 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 | ||
c7b2e995 | 48 | LedCfg = usb_read8(padapter, REG_LEDCFG2);/* 0x4E */ |
7bc88639 | 49 | |
373b61b6 | 50 | if (pHalData->bLedOpenDrain) { |
7bc88639 | 51 | /* Open-drain arrangement for controlling the LED) */ |
373b61b6 | 52 | LedCfg &= 0x90; /* Set to software control. */ |
9c68ed09 | 53 | usb_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3))); |
c7b2e995 | 54 | LedCfg = usb_read8(padapter, REG_MAC_PINMUX_CFG); |
373b61b6 | 55 | LedCfg &= 0xFE; |
e76484d0 | 56 | usb_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg); |
373b61b6 | 57 | } else { |
9c68ed09 | 58 | usb_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3) | BIT(5) | BIT(6))); |
7bc88639 LF |
59 | } |
60 | exit: | |
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. */ | |
02d0de1f | 69 | void rtw_hal_sw_led_init(struct adapter *padapter) |
7bc88639 LF |
70 | { |
71 | struct led_priv *pledpriv = &(padapter->ledpriv); | |
74391e12 | 72 | struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); |
7bc88639 | 73 | |
74391e12 | 74 | pledpriv->bRegUseLed = true; |
d33b128e | 75 | pledpriv->LedControlHandler = LedControl8188eu; |
74391e12 | 76 | haldata->bLedOpenDrain = true; |
7bc88639 | 77 | |
373b61b6 | 78 | InitLed871x(padapter, &(pledpriv->SwLed0)); |
7bc88639 LF |
79 | } |
80 | ||
81 | /* Description: */ | |
82 | /* DeInitialize all LED_819xUsb objects. */ | |
d435335f | 83 | void rtw_hal_sw_led_deinit(struct adapter *padapter) |
7bc88639 LF |
84 | { |
85 | struct led_priv *ledpriv = &(padapter->ledpriv); | |
86 | ||
87 | DeInitLed871x(&(ledpriv->SwLed0)); | |
7bc88639 | 88 | } |