Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5488837rwb; Tue, 17 Jan 2023 14:39:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXt+4zAmQTS8jd2ITTPlaYbL5rVl/wyrFo91U8klwKHcNoMr96WB5oTVM8T76MTCwsh7UOHZ X-Received: by 2002:a17:906:46d1:b0:84d:4e03:1644 with SMTP id k17-20020a17090646d100b0084d4e031644mr4455366ejs.68.1673995199303; Tue, 17 Jan 2023 14:39:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673995199; cv=none; d=google.com; s=arc-20160816; b=Ahd9Ye7fuGPfw+DNxM3/W6uZ/62HrF6/VSGEPZYLWCCbtMsJJp9clYgLBckZ/cTV2E HQCoI5J2VmOXC9Dn96TtCimLN1ItVLC+an6TzkzGA6geEJ10p2YMq2hQ7da3bOJowVG2 9/tbqFr13CUpY5QiCQfaRV1RF7wS+0KyM5h9jwbTRG0eAcsy1tDgkYmBvImHNMNI2y7+ 5JPshY26hXlaKRwvw9KnuvqUsmceacfw1EUxVHnqjJMH3fZcCUfH071CwSJM5O+gKt/q O5jWIM/VDPt43nzTHKHNj2ITnVGMDBtw1V/RHPVKhV+JhKY4KXzRzrL4lTQ+sxISUHGy gBMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=JLy1kCz5UNSqomVwOwqBMNik0CT6fDAtXmToAhAg8Uk=; b=PfYvT+ploxV6rvaUqQs56LOFti0vAxBI8V8iopYFA2nHfWFbpt3iV9i2Soh6/BpZzx xHQZJVPosy22hwK54P/M6Zx+Is+Of9Pn6SOQS7FExRyrP49Ahsqr0g4JfpZIqWe72Ur6 vkv4B0fLen9ax0FAP6aZH+eaLZBD+6riFhrSvphKbU0tk8qNthnN2eLNKMuWl5NUCIPr DzECqWiBlpr9rFBEHO73XyWI9EMWDjwgJI1pBvhmfUeOCcPlDswCbylYpxh6Qqc/BGVp FTz3g1ZQRFXuW8nm2Jj5Aec2T9lffzX6vNtsq41ptTnkj82BKeoqbkqgxRSm9gAYVx9l 8+1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KVraa78S; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs42-20020a1709072d2a00b007c170f6b32bsi4269250ejc.266.2023.01.17.14.39.40; Tue, 17 Jan 2023 14:39:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KVraa78S; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229765AbjAQW0S (ORCPT + 63 others); Tue, 17 Jan 2023 17:26:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbjAQWZv (ORCPT ); Tue, 17 Jan 2023 17:25:51 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 138727F9B7 for ; Tue, 17 Jan 2023 14:04:07 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id b5so10918679wrn.0 for ; Tue, 17 Jan 2023 14:04:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=JLy1kCz5UNSqomVwOwqBMNik0CT6fDAtXmToAhAg8Uk=; b=KVraa78SesXaCaLgojVFxs5yDr5mEaAwj4W0YjI4Pumw8mRo6QLGDI7IK0ohE4/AON EzHN9zh2r884zJg1fjfuJvDQ1s28/cYoVuFC0LTIuN67DIjcBM9gqYLbVzUY3P5aWe4w 2VNR3zqbKa04riNfQhbS+kUKShstb9sakGe+vhokXPayx4i3sCgHRiBjC80utH8m+LsK CcdpY6Xs/itu36x9xngT0O8Nkm42U2zpprvczgoaSh7UXIjkpKLcjyFKZOsG21hOTgd0 ozO232aThcZaJISwMej/MX+KKhX/A/QfdHIcKla6J6ymuoCNAqb8XGTq9x4lvX7vSDV/ PXRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JLy1kCz5UNSqomVwOwqBMNik0CT6fDAtXmToAhAg8Uk=; b=ZSbUKK0Xg00E9+QSdz4zdcWtwHBCadNo1hADq6S/4n8+arm4oJEQmhujnXUl99xObb 2p+aKPkaxFfiw5udvzQevYBrBAnPLUtHh4Cgz2DXWiDVkSwLRz8GqFgTTgwzFj7EgIWc ow7vt0MtmZGMH7xpbf8fUsvfp0QQVUrHcsY2YuNWL4JLv336Ah+7rQYz3hHQdLyuu68v tPh1EqdMleXdh1l4S6zKo2z3Rno5Fk+zkrdBx4p4gvZz+op5Zll1ljsxfWUYQ40Lh0Mb 1V1wFRhBmh6WdJFX3VbG8sQlQB5LugbKRVKQBDIeWypO9dawCPMGc7eeXvJPfp1cF9Gb 0C2A== X-Gm-Message-State: AFqh2kqmlhk+jj2nCmN5IHyOynDqppWw1PPed6R+WTH1el0SYReCh9PM FUY1W9H+r2iFwxxIc6W8YCdNAeVz2Eg= X-Received: by 2002:adf:de81:0:b0:2bd:dc5c:7e4c with SMTP id w1-20020adfde81000000b002bddc5c7e4cmr3932652wrl.15.1673993046211; Tue, 17 Jan 2023 14:04:06 -0800 (PST) Received: from [192.168.1.50] ([79.119.240.114]) by smtp.gmail.com with ESMTPSA id g11-20020a5d488b000000b002bc7e5a1171sm22869593wrq.116.2023.01.17.14.04.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Jan 2023 14:04:05 -0800 (PST) Message-ID: <77a0ec12-3711-7f21-5b99-95388f0648b1@gmail.com> Date: Wed, 18 Jan 2023 00:04:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: [PATCH 2/4] wifi: rtl8xxxu: Add LED control code for RTL8188EU Content-Language: en-US From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Jes Sorensen , Ping-Ke Shih References: <5c03ae42-a2fd-b39a-e754-f52d8528a167@gmail.com> In-Reply-To: <5c03ae42-a2fd-b39a-e754-f52d8528a167@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org By default the LED will blink when there is some activity. This was tested with a TP-Link TL-WN725N. Signed-off-by: Bitterblue Smith --- .../realtek/rtl8xxxu/rtl8xxxu_8188e.c | 25 +++++++++++++++++++ .../wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 4 +++ 2 files changed, 29 insertions(+) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c index 08f3b93ad8d0..a99ddb41cd24 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c @@ -1350,6 +1350,30 @@ static s8 rtl8188e_cck_rssi(struct rtl8xxxu_priv *priv, u8 cck_agc_rpt) return rx_pwr_all; } +static int rtl8188eu_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); + + if (brightness == LED_OFF) { + ledcfg &= ~LEDCFG2_HW_LED_CONTROL; + ledcfg |= LEDCFG2_SW_LED_CONTROL | LEDCFG2_SW_LED_DISABLE; + } else if (brightness == LED_ON) { + ledcfg &= ~(LEDCFG2_HW_LED_CONTROL | LEDCFG2_SW_LED_DISABLE); + ledcfg |= LEDCFG2_SW_LED_CONTROL; + } else if (brightness == RTL8XXXU_HW_LED_CONTROL) { + ledcfg &= ~LEDCFG2_SW_LED_DISABLE; + ledcfg |= LEDCFG2_HW_LED_CONTROL | LEDCFG2_HW_LED_ENABLE; + } + + rtl8xxxu_write8(priv, REG_LEDCFG2, ledcfg); + + return 0; +} + static void rtl8188e_set_tx_rpt_timing(struct rtl8xxxu_ra_info *ra, u8 timing) { u8 idx; @@ -1851,6 +1875,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = { .fill_txdesc = rtl8xxxu_fill_txdesc_v3, .set_crystal_cap = rtl8188f_set_crystal_cap, .cck_rssi = rtl8188e_cck_rssi, + .led_classdev_brightness_set = rtl8188eu_led_brightness_set, .writeN_block_size = 128, .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h index 5818b2378bab..d510ce27b1b4 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h @@ -148,6 +148,10 @@ #define LEDCFG0_DPDT_SELECT BIT(23) #define REG_LEDCFG1 0x004d #define REG_LEDCFG2 0x004e +#define LEDCFG2_HW_LED_CONTROL BIT(1) +#define LEDCFG2_HW_LED_ENABLE BIT(5) +#define LEDCFG2_SW_LED_DISABLE BIT(3) +#define LEDCFG2_SW_LED_CONTROL BIT(5) #define LEDCFG2_DPDT_SELECT BIT(7) #define REG_LEDCFG3 0x004f #define REG_LEDCFG REG_LEDCFG2 -- 2.38.0