1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2009-2012 Realtek Corporation.*/
9 static void _rtl92se_init_led(struct ieee80211_hw
*hw
,
10 struct rtl_led
*pled
, enum rtl_led_pin ledpin
)
13 pled
->ledpin
= ledpin
;
17 void rtl92se_init_sw_leds(struct ieee80211_hw
*hw
)
19 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
21 _rtl92se_init_led(hw
, &rtlpriv
->ledctl
.sw_led0
, LED_PIN_LED0
);
22 _rtl92se_init_led(hw
, &rtlpriv
->ledctl
.sw_led1
, LED_PIN_LED1
);
25 void rtl92se_sw_led_on(struct ieee80211_hw
*hw
, struct rtl_led
*pled
)
28 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
30 rtl_dbg(rtlpriv
, COMP_LED
, DBG_LOUD
, "LedAddr:%X ledpin=%d\n",
31 LEDCFG
, pled
->ledpin
);
33 ledcfg
= rtl_read_byte(rtlpriv
, LEDCFG
);
35 switch (pled
->ledpin
) {
39 rtl_write_byte(rtlpriv
, LEDCFG
, ledcfg
& 0xf0);
42 rtl_write_byte(rtlpriv
, LEDCFG
, ledcfg
& 0x0f);
45 pr_err("switch case %#x not processed\n",
52 void rtl92se_sw_led_off(struct ieee80211_hw
*hw
, struct rtl_led
*pled
)
54 struct rtl_priv
*rtlpriv
;
57 rtlpriv
= rtl_priv(hw
);
58 if (!rtlpriv
|| rtlpriv
->max_fw_size
)
60 rtl_dbg(rtlpriv
, COMP_LED
, DBG_LOUD
, "LedAddr:%X ledpin=%d\n",
61 LEDCFG
, pled
->ledpin
);
63 ledcfg
= rtl_read_byte(rtlpriv
, LEDCFG
);
65 switch (pled
->ledpin
) {
70 if (rtlpriv
->ledctl
.led_opendrain
)
71 rtl_write_byte(rtlpriv
, LEDCFG
, (ledcfg
| BIT(1)));
73 rtl_write_byte(rtlpriv
, LEDCFG
, (ledcfg
| BIT(3)));
77 rtl_write_byte(rtlpriv
, LEDCFG
, (ledcfg
| BIT(3)));
80 pr_err("switch case %#x not processed\n",
87 static void _rtl92se_sw_led_control(struct ieee80211_hw
*hw
,
88 enum led_ctl_mode ledaction
)
90 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
91 struct rtl_led
*pled0
= &rtlpriv
->ledctl
.sw_led0
;
94 case LED_CTL_POWER_ON
:
97 rtl92se_sw_led_on(hw
, pled0
);
99 case LED_CTL_POWER_OFF
:
100 rtl92se_sw_led_off(hw
, pled0
);
107 void rtl92se_led_control(struct ieee80211_hw
*hw
, enum led_ctl_mode ledaction
)
109 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
110 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
112 if ((ppsc
->rfoff_reason
> RF_CHANGE_BY_PS
) &&
113 (ledaction
== LED_CTL_TX
||
114 ledaction
== LED_CTL_RX
||
115 ledaction
== LED_CTL_SITE_SURVEY
||
116 ledaction
== LED_CTL_LINK
||
117 ledaction
== LED_CTL_NO_LINK
||
118 ledaction
== LED_CTL_START_TO_LINK
||
119 ledaction
== LED_CTL_POWER_ON
)) {
122 rtl_dbg(rtlpriv
, COMP_LED
, DBG_LOUD
, "ledaction %d\n", ledaction
);
124 _rtl92se_sw_led_control(hw
, ledaction
);