1 /******************************************************************************
3 * Copyright(c) 2016 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 * 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 * Larry Finger <Larry.Finger@lwfinger.net>
24 *****************************************************************************/
31 static void _rtl8822be_init_led(struct ieee80211_hw *hw, struct rtl_led *pled,
32 enum rtl_led_pin ledpin)
35 pled->ledpin = ledpin;
39 void rtl8822be_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
41 struct rtl_priv *rtlpriv = rtl_priv(hw);
43 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n",
44 REG_LEDCFG2_8822B, pled->ledpin);
46 switch (pled->ledpin) {
54 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
55 "switch case not process\n");
61 void rtl8822be_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
63 struct rtl_priv *rtlpriv = rtl_priv(hw);
65 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n",
66 REG_LEDCFG2_8822B, pled->ledpin);
68 switch (pled->ledpin) {
77 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
78 "switch case not process\n");
84 void rtl8822be_init_sw_leds(struct ieee80211_hw *hw)
86 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
88 _rtl8822be_init_led(hw, &pcipriv->ledctl.sw_led0, LED_PIN_LED0);
89 _rtl8822be_init_led(hw, &pcipriv->ledctl.sw_led1, LED_PIN_LED1);
92 static void _rtl8822be_sw_led_control(struct ieee80211_hw *hw,
93 enum led_ctl_mode ledaction)
95 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
96 struct rtl_led *led0 = &pcipriv->ledctl.sw_led0;
99 case LED_CTL_POWER_ON:
101 case LED_CTL_NO_LINK:
102 rtl8822be_sw_led_on(hw, led0);
104 case LED_CTL_POWER_OFF:
105 rtl8822be_sw_led_off(hw, led0);
112 void rtl8822be_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction)
114 struct rtl_priv *rtlpriv = rtl_priv(hw);
115 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
117 if ((ppsc->rfoff_reason > RF_CHANGE_BY_PS) &&
118 (ledaction == LED_CTL_TX || ledaction == LED_CTL_RX ||
119 ledaction == LED_CTL_SITE_SURVEY || ledaction == LED_CTL_LINK ||
120 ledaction == LED_CTL_NO_LINK ||
121 ledaction == LED_CTL_START_TO_LINK ||
122 ledaction == LED_CTL_POWER_ON)) {
125 RT_TRACE(rtlpriv, COMP_LED, DBG_TRACE, "ledaction %d,\n", ledaction);
126 _rtl8822be_sw_led_control(hw, ledaction);