1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include "../wifi.h"
27#include "../pci.h"
28#include "reg.h"
29#include "led.h"
30
31static void _rtl8822be_init_led(struct ieee80211_hw *hw, struct rtl_led *pled,
32 enum rtl_led_pin ledpin)
33{
34 pled->hw = hw;
35 pled->ledpin = ledpin;
36 pled->ledon = false;
37}
38
39void rtl8822be_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
40{
41 struct rtl_priv *rtlpriv = rtl_priv(hw);
42
43 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n",
44 REG_LEDCFG2_8822B, pled->ledpin);
45
46 switch (pled->ledpin) {
47 case LED_PIN_GPIO0:
48 break;
49 case LED_PIN_LED0:
50 break;
51 case LED_PIN_LED1:
52 break;
53 default:
54 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
55 "switch case not process\n");
56 break;
57 }
58 pled->ledon = true;
59}
60
61void rtl8822be_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
62{
63 struct rtl_priv *rtlpriv = rtl_priv(hw);
64
65 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n",
66 REG_LEDCFG2_8822B, pled->ledpin);
67
68 switch (pled->ledpin) {
69 case LED_PIN_GPIO0:
70 break;
71 case LED_PIN_LED0:
72 break;
73 case LED_PIN_LED1:
74
75 break;
76 default:
77 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
78 "switch case not process\n");
79 break;
80 }
81 pled->ledon = false;
82}
83
84void rtl8822be_init_sw_leds(struct ieee80211_hw *hw)
85{
86 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
87
88 _rtl8822be_init_led(hw, &pcipriv->ledctl.sw_led0, LED_PIN_LED0);
89 _rtl8822be_init_led(hw, &pcipriv->ledctl.sw_led1, LED_PIN_LED1);
90}
91
92static void _rtl8822be_sw_led_control(struct ieee80211_hw *hw,
93 enum led_ctl_mode ledaction)
94{
95 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
96 struct rtl_led *led0 = &pcipriv->ledctl.sw_led0;
97
98 switch (ledaction) {
99 case LED_CTL_POWER_ON:
100 case LED_CTL_LINK:
101 case LED_CTL_NO_LINK:
102 rtl8822be_sw_led_on(hw, led0);
103 break;
104 case LED_CTL_POWER_OFF:
105 rtl8822be_sw_led_off(hw, led0);
106 break;
107 default:
108 break;
109 }
110}
111
112void rtl8822be_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction)
113{
114 struct rtl_priv *rtlpriv = rtl_priv(hw);
115 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
116
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)) {
123 return;
124 }
125 RT_TRACE(rtlpriv, COMP_LED, DBG_TRACE, "ledaction %d,\n", ledaction);
126 _rtl8822be_sw_led_control(hw, ledaction);
127}
128