1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2009-2012 Realtek Corporation.*/
9 static void _rtl92cu_init_led(struct ieee80211_hw
*hw
,
10 struct rtl_led
*pled
, enum rtl_led_pin ledpin
)
13 pled
->ledpin
= ledpin
;
17 static void rtl92cu_deinit_led(struct rtl_led
*pled
)
21 void rtl92cu_sw_led_on(struct ieee80211_hw
*hw
, struct rtl_led
*pled
)
24 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
26 rtl_dbg(rtlpriv
, COMP_LED
, DBG_LOUD
, "LedAddr:%X ledpin=%d\n",
27 REG_LEDCFG2
, pled
->ledpin
);
28 ledcfg
= rtl_read_byte(rtlpriv
, REG_LEDCFG2
);
29 switch (pled
->ledpin
) {
33 rtl_write_byte(rtlpriv
,
34 REG_LEDCFG2
, (ledcfg
& 0xf0) | BIT(5) | BIT(6));
37 rtl_write_byte(rtlpriv
, REG_LEDCFG2
, (ledcfg
& 0x0f) | BIT(5));
40 pr_err("switch case %#x not processed\n",
47 void rtl92cu_sw_led_off(struct ieee80211_hw
*hw
, struct rtl_led
*pled
)
49 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
52 rtl_dbg(rtlpriv
, COMP_LED
, DBG_LOUD
, "LedAddr:%X ledpin=%d\n",
53 REG_LEDCFG2
, pled
->ledpin
);
54 ledcfg
= rtl_read_byte(rtlpriv
, REG_LEDCFG2
);
55 switch (pled
->ledpin
) {
60 if (rtlpriv
->ledctl
.led_opendrain
)
61 rtl_write_byte(rtlpriv
, REG_LEDCFG2
,
62 (ledcfg
| BIT(1) | BIT(5) | BIT(6)));
64 rtl_write_byte(rtlpriv
, REG_LEDCFG2
,
65 (ledcfg
| BIT(3) | BIT(5) | BIT(6)));
69 rtl_write_byte(rtlpriv
, REG_LEDCFG2
, (ledcfg
| BIT(3)));
72 pr_err("switch case %#x not processed\n",
79 void rtl92cu_init_sw_leds(struct ieee80211_hw
*hw
)
81 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
83 _rtl92cu_init_led(hw
, &rtlpriv
->ledctl
.sw_led0
, LED_PIN_LED0
);
84 _rtl92cu_init_led(hw
, &rtlpriv
->ledctl
.sw_led1
, LED_PIN_LED1
);
87 void rtl92cu_deinit_sw_leds(struct ieee80211_hw
*hw
)
89 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
91 rtl92cu_deinit_led(&rtlpriv
->ledctl
.sw_led0
);
92 rtl92cu_deinit_led(&rtlpriv
->ledctl
.sw_led1
);
95 static void _rtl92cu_sw_led_control(struct ieee80211_hw
*hw
,
96 enum led_ctl_mode ledaction
)
100 void rtl92cu_led_control(struct ieee80211_hw
*hw
,
101 enum led_ctl_mode ledaction
)
103 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
104 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
106 if ((ppsc
->rfoff_reason
> RF_CHANGE_BY_PS
) &&
107 (ledaction
== LED_CTL_TX
||
108 ledaction
== LED_CTL_RX
||
109 ledaction
== LED_CTL_SITE_SURVEY
||
110 ledaction
== LED_CTL_LINK
||
111 ledaction
== LED_CTL_NO_LINK
||
112 ledaction
== LED_CTL_START_TO_LINK
||
113 ledaction
== LED_CTL_POWER_ON
)) {
116 rtl_dbg(rtlpriv
, COMP_LED
, DBG_LOUD
, "ledaction %d\n", ledaction
);
117 _rtl92cu_sw_led_control(hw
, ledaction
);