1 /******************************************************************************
3 * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved.
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 * The full GNU General Public License is included in this distribution in the
15 * file called LICENSE.
17 * Contact Information:
18 * wlanfae <wlanfae@realtek.com>
19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20 * Hsinchu 300, Taiwan.
22 *****************************************************************************/
29 static void _rtl92cu_init_led(struct ieee80211_hw
*hw
,
30 struct rtl_led
*pled
, enum rtl_led_pin ledpin
)
33 pled
->ledpin
= ledpin
;
37 static void _rtl92cu_deInit_led(struct rtl_led
*pled
)
41 void rtl92cu_sw_led_on(struct ieee80211_hw
*hw
, struct rtl_led
*pled
)
44 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
46 RT_TRACE(rtlpriv
, COMP_LED
, DBG_LOUD
, "LedAddr:%X ledpin=%d\n",
47 REG_LEDCFG2
, pled
->ledpin
);
48 ledcfg
= rtl_read_byte(rtlpriv
, REG_LEDCFG2
);
49 switch (pled
->ledpin
) {
53 rtl_write_byte(rtlpriv
,
54 REG_LEDCFG2
, (ledcfg
& 0xf0) | BIT(5) | BIT(6));
57 rtl_write_byte(rtlpriv
, REG_LEDCFG2
, (ledcfg
& 0x0f) | BIT(5));
60 pr_err("switch case %#x not processed\n",
67 void rtl92cu_sw_led_off(struct ieee80211_hw
*hw
, struct rtl_led
*pled
)
69 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
72 RT_TRACE(rtlpriv
, COMP_LED
, DBG_LOUD
, "LedAddr:%X ledpin=%d\n",
73 REG_LEDCFG2
, pled
->ledpin
);
74 ledcfg
= rtl_read_byte(rtlpriv
, REG_LEDCFG2
);
75 switch (pled
->ledpin
) {
80 if (rtlpriv
->ledctl
.led_opendrain
)
81 rtl_write_byte(rtlpriv
, REG_LEDCFG2
,
82 (ledcfg
| BIT(1) | BIT(5) | BIT(6)));
84 rtl_write_byte(rtlpriv
, REG_LEDCFG2
,
85 (ledcfg
| BIT(3) | BIT(5) | BIT(6)));
89 rtl_write_byte(rtlpriv
, REG_LEDCFG2
, (ledcfg
| BIT(3)));
92 pr_err("switch case %#x not processed\n",
99 void rtl92cu_init_sw_leds(struct ieee80211_hw
*hw
)
101 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
103 _rtl92cu_init_led(hw
, &rtlpriv
->ledctl
.sw_led0
, LED_PIN_LED0
);
104 _rtl92cu_init_led(hw
, &rtlpriv
->ledctl
.sw_led1
, LED_PIN_LED1
);
107 void rtl92cu_deinit_sw_leds(struct ieee80211_hw
*hw
)
109 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
111 _rtl92cu_deInit_led(&rtlpriv
->ledctl
.sw_led0
);
112 _rtl92cu_deInit_led(&rtlpriv
->ledctl
.sw_led1
);
115 static void _rtl92cu_sw_led_control(struct ieee80211_hw
*hw
,
116 enum led_ctl_mode ledaction
)
120 void rtl92cu_led_control(struct ieee80211_hw
*hw
,
121 enum led_ctl_mode ledaction
)
123 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
124 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
126 if ((ppsc
->rfoff_reason
> RF_CHANGE_BY_PS
) &&
127 (ledaction
== LED_CTL_TX
||
128 ledaction
== LED_CTL_RX
||
129 ledaction
== LED_CTL_SITE_SURVEY
||
130 ledaction
== LED_CTL_LINK
||
131 ledaction
== LED_CTL_NO_LINK
||
132 ledaction
== LED_CTL_START_TO_LINK
||
133 ledaction
== LED_CTL_POWER_ON
)) {
136 RT_TRACE(rtlpriv
, COMP_LED
, DBG_LOUD
, "ledaction %d\n", ledaction
);
137 _rtl92cu_sw_led_control(hw
, ledaction
);