1 /******************************************************************************
3 * Copyright(c) 2009-2012 Realtek Corporation.
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.
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
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
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
21 * Contact Information:
22 * wlanfae <wlanfae@realtek.com>
23 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
24 * Hsinchu 300, Taiwan.
26 * Larry Finger <Larry.Finger@lwfinger.net>
28 *****************************************************************************/
35 static void _rtl8723e_init_led(struct ieee80211_hw
*hw
,
36 struct rtl_led
*pled
, enum rtl_led_pin ledpin
)
39 pled
->ledpin
= ledpin
;
43 void rtl8723e_sw_led_on(struct ieee80211_hw
*hw
, struct rtl_led
*pled
)
46 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
48 RT_TRACE(rtlpriv
, COMP_LED
, DBG_LOUD
,
49 "LedAddr:%X ledpin=%d\n", REG_LEDCFG2
, pled
->ledpin
);
51 switch (pled
->ledpin
) {
55 ledcfg
= rtl_read_byte(rtlpriv
, REG_LEDCFG2
);
57 rtl_write_byte(rtlpriv
,
58 REG_LEDCFG2
, (ledcfg
& 0xf0) | BIT(5));
61 ledcfg
= rtl_read_byte(rtlpriv
, REG_LEDCFG1
);
62 rtl_write_byte(rtlpriv
, REG_LEDCFG1
, ledcfg
& 0x10);
65 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
66 "switch case not process\n");
72 void rtl8723e_sw_led_off(struct ieee80211_hw
*hw
, struct rtl_led
*pled
)
74 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
75 struct rtl_pci_priv
*pcipriv
= rtl_pcipriv(hw
);
78 RT_TRACE(rtlpriv
, COMP_LED
, DBG_LOUD
,
79 "LedAddr:%X ledpin=%d\n", REG_LEDCFG2
, pled
->ledpin
);
81 ledcfg
= rtl_read_byte(rtlpriv
, REG_LEDCFG2
);
83 switch (pled
->ledpin
) {
88 if (pcipriv
->ledctl
.led_opendrain
) {
89 ledcfg
&= 0x90; /* Set to software control. */
90 rtl_write_byte(rtlpriv
, REG_LEDCFG2
, (ledcfg
|BIT(3)));
91 ledcfg
= rtl_read_byte(rtlpriv
, REG_MAC_PINMUX_CFG
);
93 rtl_write_byte(rtlpriv
, REG_MAC_PINMUX_CFG
, ledcfg
);
96 rtl_write_byte(rtlpriv
, REG_LEDCFG2
,
97 (ledcfg
| BIT(3) | BIT(5)));
101 ledcfg
= rtl_read_byte(rtlpriv
, REG_LEDCFG1
);
102 ledcfg
&= 0x10; /* Set to software control. */
103 rtl_write_byte(rtlpriv
, REG_LEDCFG1
, ledcfg
|BIT(3));
107 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
108 "switch case not process\n");
114 void rtl8723e_init_sw_leds(struct ieee80211_hw
*hw
)
116 struct rtl_pci_priv
*pcipriv
= rtl_pcipriv(hw
);
117 _rtl8723e_init_led(hw
, &pcipriv
->ledctl
.sw_led0
, LED_PIN_LED0
);
118 _rtl8723e_init_led(hw
, &pcipriv
->ledctl
.sw_led1
, LED_PIN_LED1
);
121 static void _rtl8723e_sw_led_control(struct ieee80211_hw
*hw
,
122 enum led_ctl_mode ledaction
)
124 struct rtl_pci_priv
*pcipriv
= rtl_pcipriv(hw
);
125 struct rtl_led
*pLed0
= &(pcipriv
->ledctl
.sw_led0
);
127 case LED_CTL_POWER_ON
:
129 case LED_CTL_NO_LINK
:
130 rtl8723e_sw_led_on(hw
, pLed0
);
132 case LED_CTL_POWER_OFF
:
133 rtl8723e_sw_led_off(hw
, pLed0
);
140 void rtl8723e_led_control(struct ieee80211_hw
*hw
,
141 enum led_ctl_mode ledaction
)
143 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
144 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
146 if ((ppsc
->rfoff_reason
> RF_CHANGE_BY_PS
) &&
147 (ledaction
== LED_CTL_TX
||
148 ledaction
== LED_CTL_RX
||
149 ledaction
== LED_CTL_SITE_SURVEY
||
150 ledaction
== LED_CTL_LINK
||
151 ledaction
== LED_CTL_NO_LINK
||
152 ledaction
== LED_CTL_START_TO_LINK
||
153 ledaction
== LED_CTL_POWER_ON
)) {
156 RT_TRACE(rtlpriv
, COMP_LED
, DBG_LOUD
, "ledaction %d,\n",
158 _rtl8723e_sw_led_control(hw
, ledaction
);