Message ID | 6a0698cc-9389-414f-b172-7046bec01b3e@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Ping-Ke Shih |
Headers | show |
Series | wifi: rtl8xxxu: Add LED control code for RTL8723BU | expand |
Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote: > Tested with EDUP EP-N8568. Please describe the LED modes you have tested. Send v2 or paste description here, I can add them during being merged. > > Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com> Reviewed-by: Ping-Ke Shih <pkshih@realtek.com> > --- > .../realtek/rtl8xxxu/rtl8xxxu_8723b.c | 23 +++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c > b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c > index 9640c841d20a..c677a47ed46d 100644 > --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c > +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c > @@ -1701,6 +1701,28 @@ static s8 rtl8723b_cck_rssi(struct rtl8xxxu_priv *priv, struct rtl8723au_phy_sta > return rx_pwr_all; > } > > +static int rtl8723bu_led_brightness_set(struct led_classdev *led_cdev, > + enum led_brightness brightness) > +{ > + struct rtl8xxxu_priv *priv = container_of(led_cdev, > + struct rtl8xxxu_priv, > + led_cdev); > + u8 ledcfg = rtl8xxxu_read8(priv, REG_LEDCFG2); > + ledcfg &= LEDCFG2_DPDT_SELECT; > + > + if (brightness == LED_OFF) { > + ledcfg |= LEDCFG2_SW_LED_CONTROL | LEDCFG2_SW_LED_DISABLE; > + } else if (brightness == LED_ON) { > + ledcfg |= LEDCFG2_SW_LED_CONTROL; > + } else if (brightness == RTL8XXXU_HW_LED_CONTROL) { > + ledcfg |= LEDCFG2_HW_LED_CONTROL | LEDCFG2_HW_LED_ENABLE; > + } > + > + rtl8xxxu_write8(priv, REG_LEDCFG2, ledcfg); > + > + return 0; > +} > + > struct rtl8xxxu_fileops rtl8723bu_fops = { > .identify_chip = rtl8723bu_identify_chip, > .parse_efuse = rtl8723bu_parse_efuse, > @@ -1731,6 +1753,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = { > .fill_txdesc = rtl8xxxu_fill_txdesc_v2, > .set_crystal_cap = rtl8723a_set_crystal_cap, > .cck_rssi = rtl8723b_cck_rssi, > + .led_classdev_brightness_set = rtl8723bu_led_brightness_set, > .writeN_block_size = 1024, > .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), > .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), > -- > 2.44.0
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c index 9640c841d20a..c677a47ed46d 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c @@ -1701,6 +1701,28 @@ static s8 rtl8723b_cck_rssi(struct rtl8xxxu_priv *priv, struct rtl8723au_phy_sta return rx_pwr_all; } +static int rtl8723bu_led_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + struct rtl8xxxu_priv *priv = container_of(led_cdev, + struct rtl8xxxu_priv, + led_cdev); + u8 ledcfg = rtl8xxxu_read8(priv, REG_LEDCFG2); + ledcfg &= LEDCFG2_DPDT_SELECT; + + if (brightness == LED_OFF) { + ledcfg |= LEDCFG2_SW_LED_CONTROL | LEDCFG2_SW_LED_DISABLE; + } else if (brightness == LED_ON) { + ledcfg |= LEDCFG2_SW_LED_CONTROL; + } else if (brightness == RTL8XXXU_HW_LED_CONTROL) { + ledcfg |= LEDCFG2_HW_LED_CONTROL | LEDCFG2_HW_LED_ENABLE; + } + + rtl8xxxu_write8(priv, REG_LEDCFG2, ledcfg); + + return 0; +} + struct rtl8xxxu_fileops rtl8723bu_fops = { .identify_chip = rtl8723bu_identify_chip, .parse_efuse = rtl8723bu_parse_efuse, @@ -1731,6 +1753,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = { .fill_txdesc = rtl8xxxu_fill_txdesc_v2, .set_crystal_cap = rtl8723a_set_crystal_cap, .cck_rssi = rtl8723b_cck_rssi, + .led_classdev_brightness_set = rtl8723bu_led_brightness_set, .writeN_block_size = 1024, .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24),
Tested with EDUP EP-N8568. Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com> --- .../realtek/rtl8xxxu/rtl8xxxu_8723b.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+)