Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2834547rwb; Fri, 20 Jan 2023 07:58:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXuYlprX013tnWGHnRl9gQxodHAIyYYDqEtcJbBQCszvj8Y23Vu0R5TlljazcHYBhx9LtJTp X-Received: by 2002:a05:6402:138c:b0:499:b53f:1c56 with SMTP id b12-20020a056402138c00b00499b53f1c56mr14804455edv.38.1674230330701; Fri, 20 Jan 2023 07:58:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674230330; cv=none; d=google.com; s=arc-20160816; b=EOAqKzs8AnkRgPezzPH0WI9qSyBAWiYatGWIEZXWnMs9T+tQgkkUsVxs7vpO8X4kz9 bKq1QNvcf3jVZto6R7DTIF9b7wLQb5EQ2P52wYY8BluQio9s2v47NglcRY+Pwpq8JK1K jB5PwhSqIHdUixiVYRp02pNELVxsO3HSe/dNJ9L9km08pOTQjvkVkuMnqn9XYO0CKPwZ oi6jD0h7RdVnL9g87+zM6nC/wWUuWkUnS/4rjeKZ1ZGNx1hnlOSMci5ePPvw3wKNyz6S 9rLmTQqg7CGTh+i6YSPeoH7rpjYqHLBDQFfAQ+b5oSvEmMC1hSiSTtUI2w/oAefVZs1O ZEmg== 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=mbgUxd/FRuWN3nrz37DBIuagPrn/BWA4uSjLuDTkrWQ=; b=TbTHxTNw6cLDMqmiGp4J3NZKTrNnolHwdmfzll5d/11+tH/uctTpOVKgZriXD4tUZR 5bjJ6vGKPJiMFoIua//cJNq9PFUEmWK3bKmC9E/bGGx2U6ajLt3rqzhLXDtCDBqCPYhf bODbiE+zUDd6KPCGEBDvyqRkOJzqvasCBKzZuRQ1cw9hF2E/jDbxVvUEyBtivWuA3TGT 6Kd/qcNRIELOxZ8tTrcRoaxDZSXJ+naUcNxW/3KBvO/HIyxeO3yB9ETubgvZ8R5KhdDy 7RZ+bBkwDtEd965FyCXzu9KcsKJ+ziGVDuiDVDlaAGYTo1lGUx7Ar6Kj/iYiFcZtPeKZ nu2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=A+Q6KI8e; 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 g11-20020a056402180b00b0048f7f747aedsi38059725edy.226.2023.01.20.07.58.34; Fri, 20 Jan 2023 07:58:50 -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=A+Q6KI8e; 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 S231263AbjATPym (ORCPT + 63 others); Fri, 20 Jan 2023 10:54:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231642AbjATPye (ORCPT ); Fri, 20 Jan 2023 10:54:34 -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 A6C51E050D for ; Fri, 20 Jan 2023 07:54:24 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id t5so5256321wrq.1 for ; Fri, 20 Jan 2023 07:54:24 -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=mbgUxd/FRuWN3nrz37DBIuagPrn/BWA4uSjLuDTkrWQ=; b=A+Q6KI8eikgNEmDX2+f/G6ayCSXBfCh4S6WWBih+Lqba28BphKj8YlECd6IaB62Lkn KWUg385oQx4Fv6oq55LYEuEmB30XaJwidI7ga57Rermc7h+LCek2csP8lY6sLSN15vsy v+nfmC6mOwsyl/FFQcZu267NWP0nnxoJxEyHJLVOH7RMtd81t4d6lqHHL6keb0KNyPIO 428Do+axWpST4eU1n1Ma+WUdlMomO9xSY26nvqclXX9kyyGEMFt3wn/5wt91h0pFAUei 49w7Il+2YMm5o6O8iMtbkZuo2BXr1vdO78W+k0e1u7UZB7faKdbTZrI64gUOyVYEBt2H k5lQ== 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=mbgUxd/FRuWN3nrz37DBIuagPrn/BWA4uSjLuDTkrWQ=; b=g1W5i9JpRhJn9L25s3o41uDHSgw/cI4GuadKkHepb8nfTF8XWeLoICSzwTUKUrcAjQ f0SxocuTvjdwSeJ5NJSrre5s0IalFmbIajWzQBZ7/YdDdjThsImycS91rmhXfgLspOmP A80+YIK0qgmlA2i2pUqQbMKSzunQsHVbHQNiGGyigoS1GRi5hvIcp/jw6rzaK6Bytzo3 WOB1r1zr5/NKUpFy1Kp2/xY88QkeFp2G86DkqE7CnKqaqV5KrwPYA46WJj2yreZJOr75 02maDEEw0vzW1sWrhHnYKzgGDSPzEJ799B2BF2YmonAE/4x9dVZoWzEWpCYliasUBO7r citQ== X-Gm-Message-State: AFqh2kqbqS4NQxrsa+Y3FVuzTY8BwXq6idSB6DQ9qfE7A+kdpudPyzH4 OJTJi3GI+NHq6rkr/YPM/EgyddlJqWk= X-Received: by 2002:a05:6000:689:b0:2bb:b17e:789 with SMTP id bo9-20020a056000068900b002bbb17e0789mr15164784wrb.58.1674230063179; Fri, 20 Jan 2023 07:54:23 -0800 (PST) Received: from [192.168.1.50] ([79.119.240.25]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm35706506wrm.52.2023.01.20.07.54.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Jan 2023 07:54:22 -0800 (PST) Message-ID: <8f7fd5d7-5baa-b38b-ad2a-977dcd9edd81@gmail.com> Date: Fri, 20 Jan 2023 17:54:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: [PATCH v2 3/4] wifi: rtl8xxxu: Add LED control code for RTL8192EU Content-Language: en-US From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Jes Sorensen , Ping-Ke Shih References: In-Reply-To: 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 cheap "HT-WR813" from Aliexpress. Signed-off-by: Bitterblue Smith --- v2: - No change. --- .../realtek/rtl8xxxu/rtl8xxxu_8192e.c | 24 +++++++++++++++++++ .../wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c index 4a1c9bcafe31..5cfc00237f42 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c @@ -1764,6 +1764,29 @@ static s8 rtl8192e_cck_rssi(struct rtl8xxxu_priv *priv, u8 cck_agc_rpt) return rx_pwr_all; } +static int rtl8192eu_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_LEDCFG1); + + if (brightness == LED_OFF) { + ledcfg &= ~LEDCFG1_HW_LED_CONTROL; + ledcfg |= LEDCFG1_LED_DISABLE; + } else if (brightness == LED_ON) { + ledcfg &= ~(LEDCFG1_HW_LED_CONTROL | LEDCFG1_LED_DISABLE); + } else if (brightness == RTL8XXXU_HW_LED_CONTROL) { + ledcfg &= ~LEDCFG1_LED_DISABLE; + ledcfg |= LEDCFG1_HW_LED_CONTROL; + } + + rtl8xxxu_write8(priv, REG_LEDCFG1, ledcfg); + + return 0; +} + struct rtl8xxxu_fileops rtl8192eu_fops = { .identify_chip = rtl8192eu_identify_chip, .parse_efuse = rtl8192eu_parse_efuse, @@ -1788,6 +1811,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops = { .fill_txdesc = rtl8xxxu_fill_txdesc_v2, .set_crystal_cap = rtl8723a_set_crystal_cap, .cck_rssi = rtl8192e_cck_rssi, + .led_classdev_brightness_set = rtl8192eu_led_brightness_set, .writeN_block_size = 128, .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h index d510ce27b1b4..5849fa4e1566 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h @@ -147,6 +147,8 @@ #define REG_LEDCFG0 0x004c #define LEDCFG0_DPDT_SELECT BIT(23) #define REG_LEDCFG1 0x004d +#define LEDCFG1_HW_LED_CONTROL BIT(1) +#define LEDCFG1_LED_DISABLE BIT(7) #define REG_LEDCFG2 0x004e #define LEDCFG2_HW_LED_CONTROL BIT(1) #define LEDCFG2_HW_LED_ENABLE BIT(5) -- 2.39.1