1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2009-2012 Realtek Corporation.*/
9 static void _rtl92ce_init_led(struct ieee80211_hw
*hw
,
10 struct rtl_led
*pled
, enum rtl_led_pin ledpin
)
13 pled
->ledpin
= ledpin
;
17 void rtl92ce_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
, "LedAddr:%X ledpin=%d\n",
23 REG_LEDCFG2
, pled
->ledpin
);
25 ledcfg
= rtl_read_byte(rtlpriv
, REG_LEDCFG2
);
27 switch (pled
->ledpin
) {
31 rtl_write_byte(rtlpriv
,
32 REG_LEDCFG2
, (ledcfg
& 0xf0) | BIT(5) | BIT(6));
35 rtl_write_byte(rtlpriv
, REG_LEDCFG2
, (ledcfg
& 0x0f) | BIT(5));
38 pr_err("switch case %#x not processed\n",
45 void rtl92ce_sw_led_off(struct ieee80211_hw
*hw
, struct rtl_led
*pled
)
47 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
50 RT_TRACE(rtlpriv
, COMP_LED
, DBG_LOUD
, "LedAddr:%X ledpin=%d\n",
51 REG_LEDCFG2
, pled
->ledpin
);
53 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_info("switch case %#x not processed\n", pled
->ledpin
);
78 void rtl92ce_init_sw_leds(struct ieee80211_hw
*hw
)
80 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
82 _rtl92ce_init_led(hw
, &rtlpriv
->ledctl
.sw_led0
, LED_PIN_LED0
);
83 _rtl92ce_init_led(hw
, &rtlpriv
->ledctl
.sw_led1
, LED_PIN_LED1
);
86 static void _rtl92ce_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 rtl92ce_sw_led_on(hw
, pled0
);
98 case LED_CTL_POWER_OFF
:
99 rtl92ce_sw_led_off(hw
, pled0
);
106 void rtl92ce_led_control(struct ieee80211_hw
*hw
,
107 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 RT_TRACE(rtlpriv
, COMP_LED
, DBG_LOUD
, "ledaction %d\n",
124 _rtl92ce_sw_led_control(hw
, ledaction
);