1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2009-2014 Realtek Corporation.*/
9 static void _rtl92ee_init_led(struct ieee80211_hw
*hw
,
10 struct rtl_led
*pled
, enum rtl_led_pin ledpin
)
13 pled
->ledpin
= ledpin
;
17 void rtl92ee_sw_led_on(struct ieee80211_hw
*hw
, struct rtl_led
*pled
)
20 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
22 RT_TRACE(rtlpriv
, COMP_LED
, DBG_LOUD
,
23 "LedAddr:%X ledpin=%d\n", REG_LEDCFG2
, pled
->ledpin
);
25 switch (pled
->ledpin
) {
29 ledcfg
= rtl_read_dword(rtlpriv
, REG_GPIO_PIN_CTRL
);
34 rtl_write_dword(rtlpriv
, REG_GPIO_PIN_CTRL
, ledcfg
);
41 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_LOUD
,
42 "switch case %#x not processed\n", pled
->ledpin
);
48 void rtl92ee_sw_led_off(struct ieee80211_hw
*hw
, struct rtl_led
*pled
)
50 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
53 RT_TRACE(rtlpriv
, COMP_LED
, DBG_LOUD
,
54 "LedAddr:%X ledpin=%d\n", REG_LEDCFG2
, pled
->ledpin
);
56 switch (pled
->ledpin
) {
61 ledcfg
= rtl_read_dword(rtlpriv
, REG_GPIO_PIN_CTRL
);
64 rtl_write_dword(rtlpriv
, REG_GPIO_PIN_CTRL
, ledcfg
);
71 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_LOUD
,
72 "switch case %#x not processed\n", pled
->ledpin
);
78 void rtl92ee_init_sw_leds(struct ieee80211_hw
*hw
)
80 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
82 _rtl92ee_init_led(hw
, &rtlpriv
->ledctl
.sw_led0
, LED_PIN_LED0
);
83 _rtl92ee_init_led(hw
, &rtlpriv
->ledctl
.sw_led1
, LED_PIN_LED1
);
86 static void _rtl92ee_sw_led_control(struct ieee80211_hw
*hw
,
87 enum led_ctl_mode ledaction
)
89 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
90 struct rtl_led
*pled0
= &rtlpriv
->ledctl
.sw_led0
;
93 case LED_CTL_POWER_ON
:
96 rtl92ee_sw_led_on(hw
, pled0
);
98 case LED_CTL_POWER_OFF
:
99 rtl92ee_sw_led_off(hw
, pled0
);
106 void rtl92ee_led_control(struct ieee80211_hw
*hw
, enum led_ctl_mode ledaction
)
108 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
109 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
111 if ((ppsc
->rfoff_reason
> RF_CHANGE_BY_PS
) &&
112 (ledaction
== LED_CTL_TX
||
113 ledaction
== LED_CTL_RX
||
114 ledaction
== LED_CTL_SITE_SURVEY
||
115 ledaction
== LED_CTL_LINK
||
116 ledaction
== LED_CTL_NO_LINK
||
117 ledaction
== LED_CTL_START_TO_LINK
||
118 ledaction
== LED_CTL_POWER_ON
)) {
121 RT_TRACE(rtlpriv
, COMP_LED
, DBG_TRACE
, "ledaction %d,\n", ledaction
);
122 _rtl92ee_sw_led_control(hw
, ledaction
);