1 /******************************************************************************
3 * Copyright(c) 2009-2010 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 _rtl92se_init_led(struct ieee80211_hw
*hw
,
36 struct rtl_led
*pled
, enum rtl_led_pin ledpin
)
39 pled
->ledpin
= ledpin
;
43 void rtl92se_init_sw_leds(struct ieee80211_hw
*hw
)
45 struct rtl_pci_priv
*pcipriv
= rtl_pcipriv(hw
);
46 _rtl92se_init_led(hw
, &(pcipriv
->ledctl
.sw_led0
), LED_PIN_LED0
);
47 _rtl92se_init_led(hw
, &(pcipriv
->ledctl
.sw_led1
), LED_PIN_LED1
);
50 void rtl92se_sw_led_on(struct ieee80211_hw
*hw
, struct rtl_led
*pled
)
53 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
55 RT_TRACE(rtlpriv
, COMP_LED
, DBG_LOUD
,
56 ("LedAddr:%X ledpin=%d\n", LEDCFG
, pled
->ledpin
));
58 ledcfg
= rtl_read_byte(rtlpriv
, LEDCFG
);
60 switch (pled
->ledpin
) {
64 rtl_write_byte(rtlpriv
, LEDCFG
, ledcfg
& 0xf0);
67 rtl_write_byte(rtlpriv
, LEDCFG
, ledcfg
& 0x0f);
70 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
71 ("switch case not process\n"));
77 void rtl92se_sw_led_off(struct ieee80211_hw
*hw
, struct rtl_led
*pled
)
79 struct rtl_priv
*rtlpriv
;
80 struct rtl_pci_priv
*pcipriv
= rtl_pcipriv(hw
);
83 rtlpriv
= rtl_priv(hw
);
84 if (!rtlpriv
|| rtlpriv
->max_fw_size
)
86 RT_TRACE(rtlpriv
, COMP_LED
, DBG_LOUD
,
87 ("LedAddr:%X ledpin=%d\n", LEDCFG
, pled
->ledpin
));
89 ledcfg
= rtl_read_byte(rtlpriv
, LEDCFG
);
91 switch (pled
->ledpin
) {
96 if (pcipriv
->ledctl
.led_opendrain
)
97 rtl_write_byte(rtlpriv
, LEDCFG
, (ledcfg
| BIT(1)));
99 rtl_write_byte(rtlpriv
, LEDCFG
, (ledcfg
| BIT(3)));
103 rtl_write_byte(rtlpriv
, LEDCFG
, (ledcfg
| BIT(3)));
106 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
107 ("switch case not process\n"));
113 static void _rtl92se_sw_led_control(struct ieee80211_hw
*hw
,
114 enum led_ctl_mode ledaction
)
116 struct rtl_pci_priv
*pcipriv
= rtl_pcipriv(hw
);
117 struct rtl_led
*pLed0
= &(pcipriv
->ledctl
.sw_led0
);
119 case LED_CTL_POWER_ON
:
121 case LED_CTL_NO_LINK
:
122 rtl92se_sw_led_on(hw
, pLed0
);
124 case LED_CTL_POWER_OFF
:
125 rtl92se_sw_led_off(hw
, pLed0
);
132 void rtl92se_led_control(struct ieee80211_hw
*hw
, enum led_ctl_mode ledaction
)
134 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
135 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
137 if ((ppsc
->rfoff_reason
> RF_CHANGE_BY_PS
) &&
138 (ledaction
== LED_CTL_TX
||
139 ledaction
== LED_CTL_RX
||
140 ledaction
== LED_CTL_SITE_SURVEY
||
141 ledaction
== LED_CTL_LINK
||
142 ledaction
== LED_CTL_NO_LINK
||
143 ledaction
== LED_CTL_START_TO_LINK
||
144 ledaction
== LED_CTL_POWER_ON
)) {
147 RT_TRACE(rtlpriv
, COMP_LED
, DBG_LOUD
, ("ledaction %d,\n",
150 _rtl92se_sw_led_control(hw
, ledaction
);