Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2363925rdb; Mon, 11 Sep 2023 22:10:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGxPaf2K4hBRDh76sSzB8qZAU89I/9a1k5At1WZiN74U/M/YV5miGQOQZy7JUuHCjyCkidy X-Received: by 2002:a17:902:e811:b0:1bc:3908:14d with SMTP id u17-20020a170902e81100b001bc3908014dmr1842516plg.2.1694495456923; Mon, 11 Sep 2023 22:10:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694495456; cv=none; d=google.com; s=arc-20160816; b=SUQUMg6ZeT6EihHJ+hVmI7RPH3nKZdhbTsPC97LwrBs8ehXzqbC1tzhw1rv644VtWO eYtkQmB1CZdjDoumZAQnZPYk0JTc6GJTX/ZZ3t6H1B58fTMRF3pxItec+wCV8mxvRIkW kz7TJTdB9TRdQjvsEipFIS3Ss3AouGAXxAyLmeCHZePbOdeBsVMt/5wh5V/rw2WxeDVG eji6/M2h6AUSIBbXxaAe9Yc6USsLOU0PolxNMpgkzVE9FnPW0YWW+9UHQmHN37EO1r37 OzisJn0D+QZr/3nyiS9St6qykMN6XsuNFTBhBSieOLibxYKUBhP9OphXVKRvoaw9tVLN Tpvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1zwpOpIh4oXz95LntC63YJlhaKyBb/bVMEz2LsKNzrA=; fh=J1pr4AOqu67CAyp13hCn4Wn9exqjbuYJy+yu82/MJc4=; b=Khkoss4uDLU4E91NTmzI1GXBJlBYduH/UygCpvzc7IQlUPvEZWP+9m3TWYcrIwkPtU Q4JM9q1Q9xzDjdYKxsvAlyLwr/53YGGnKZRiCHfwaCF3fefnSp0EZjznTbxOd6grVGe2 IeEfufnTL2H33aTBxKEHcb4N0AzgpNCBHNwNQaqNarp0cDHjkr1cw4fNUaUet5mZNZzE CkTSe5XhuHNk/Jisz3qTLWewvGi/rcy7jt8l5FlyC1RsEIG+WiZFRES3H2HN6vKtQVFo nNmC3uK3WLk+UqBZFImwyrMpIkgDzoLIlZomzP2ylLE+ADBhj6FpoDWRbhirWcG5VQWT 2RPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=jt3o8o5J; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id p11-20020a170902eacb00b001b89b77ce99si7379104pld.458.2023.09.11.22.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 22:10:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=jt3o8o5J; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id BB59880CE7D4; Mon, 11 Sep 2023 21:58:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230343AbjILE6P (ORCPT + 55 others); Tue, 12 Sep 2023 00:58:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230344AbjILE6C (ORCPT ); Tue, 12 Sep 2023 00:58:02 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F3AF4ECF; Mon, 11 Sep 2023 21:54:49 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-68fdd5c1bbbso712450b3a.1; Mon, 11 Sep 2023 21:54:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694494488; x=1695099288; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1zwpOpIh4oXz95LntC63YJlhaKyBb/bVMEz2LsKNzrA=; b=jt3o8o5JrSYRQ2I1wxUh+c3uT8iBUMP50psqWb4lDImGa0eUQnXUKGm3SUvsIywcJA 9q+X021jNaf6FSeboSDowtOjgHEAA5AFbeuVRJKMXKsTGOuRlrNSAmqPEdWemTVsoGI+ 9e+jtRexMuekQbFldUmCRMsVmaQQ4wWsEVQVsiWJmEGU5YI3Cw+0ERFks23g7folHF3b Un005ffcQbJqawYY8tlnctPjAVu9K8fgxfyxUlSTioEWBHw6yM9RgE8lqkmUmK/kCiJP Ykh6muragvU0PqkoEH3ImiB7YQK7Y5Fw6RlMOZcLjj6TloG4rIDkA6w2Sc6V+2rDJW7D Os0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694494488; x=1695099288; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1zwpOpIh4oXz95LntC63YJlhaKyBb/bVMEz2LsKNzrA=; b=sDpkY7Pu9uH5O7iOSpdItdBa0NP/25BrNtr+2xnWwxs/Y4fiHPvOx4fZVfGGqiiazO QMNjZlXoKU8InSos26/b5T4fzkPDrU98CVwksGu8S8jBmsH06ddIDKLMY4H3Nbh6mtI1 AGVlbzheBf5spju/AZAKwNZLM7IlUHOeYmnvSH6SE6ijO4ySHZXpViDfNyCZwO3DKDwg 6ylOtARArCXuKISdPUah6dvHA2CvKOXOLSlmdAs/ay4pmpDOmI6c0IjDktTuMPr2d1AZ aTV2OdZAD1ZLC7CVUSY3GpXPOxXH2qhNAwAm4BHzwuKKhjfwvk8OVaFIsT7JfvJomdy3 m8dw== X-Gm-Message-State: AOJu0Yx0AqaoEtCo5vI+RDEk728VAQFmU5nvXQvZZKKrQSW/BfstxCv0 VHp8bwwYssLsg82yDRbSNM0= X-Received: by 2002:a05:6a21:6d9f:b0:151:35ad:f331 with SMTP id wl31-20020a056a216d9f00b0015135adf331mr2062786pzb.14.1694494488100; Mon, 11 Sep 2023 21:54:48 -0700 (PDT) Received: from localhost.localdomain (220-133-92-232.hinet-ip.hinet.net. [220.133.92.232]) by smtp.googlemail.com with ESMTPSA id cw22-20020a056a00451600b0068fc6570874sm2671543pfb.9.2023.09.11.21.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 21:54:47 -0700 (PDT) From: Zenm Chen To: zenmchen@gmail.com Cc: Jes.Sorensen@gmail.com, kvalo@kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, pkshih@realtek.com, rtl8821cerfe2@gmail.com Subject: RE: [PATCH] wifi: rtl8xxxu: fix LED control code of RTL8192FU Date: Tue, 12 Sep 2023 12:54:39 +0800 Message-ID: <20230912045443.9821-1-zenmchen@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230910002038.56362-1-zenmchen@gmail.com> References: <20230910002038.56362-1-zenmchen@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 11 Sep 2023 21:58:22 -0700 (PDT) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Ping-Ke Shih wrote: > > > > > -----Original Message----- > > From: Zenm Chen > > Sent: Sunday, September 10, 2023 8:21 AM > > To: Jes.Sorensen@gmail.com > > Cc: kvalo@kernel.org; linux-wireless@vger.kernel.org; linux-kernel@vger.kernel.org; > > rtl8821cerfe2@gmail.com; Ping-Ke Shih ; Zenm Chen > > Subject: [PATCH] wifi: rtl8xxxu: fix LED control code of RTL8192FU > > > > ASUS USB-N13 C1 is a wifi adapter based on a RTL8192FU chip and its LED > > doesn't blink with the rtl8xxxu driver. This patch fix this via writing > > the correct value to the register "REG_LEDCFG0". > > > > This was tested with these two wifi adapters: > > ASUS USB-N13 C1 (vid=0x0b05, pid=0x18f1, rfe_type=0x1) > > MERCURY MW310UH (vid=0x0bda, pid=0xf192, rfe_type=0x5) > > Did you ever try Linux vendor driver for software and hardware LED? > Seemingly, the vendor driver is different from yours, but I'm pretty > sure which one is correct because I don't have a RTL8192FU stick. > > > > > Signed-off-by: Zenm Chen > > --- > > .../realtek/rtl8xxxu/rtl8xxxu_8192f.c | 24 ++++++++----------- > > 1 file changed, 10 insertions(+), 14 deletions(-) > > > > diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192f.c > > b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192f.c > > index 28e93835e05a..ab6d4e4e228e 100644 > > --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192f.c > > +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192f.c > > @@ -2014,26 +2014,22 @@ static int rtl8192fu_led_brightness_set(struct led_classdev *led_cdev, > > struct rtl8xxxu_priv *priv = container_of(led_cdev, > > struct rtl8xxxu_priv, > > led_cdev); > > - u16 ledcfg; > > + u32 ledcfg; > > > > /* Values obtained by observing the USB traffic from the Windows driver. */ > > rtl8xxxu_write32(priv, REG_SW_GPIO_SHARE_CTRL_0, 0x20080); > > rtl8xxxu_write32(priv, REG_SW_GPIO_SHARE_CTRL_1, 0x1b0000); > > > > - ledcfg = rtl8xxxu_read16(priv, REG_LEDCFG0); > > - > > - if (brightness == LED_OFF) { > > - /* Value obtained like above. */ > > - ledcfg = BIT(1) | BIT(7); > > - } else if (brightness == LED_ON) { > > - /* Value obtained like above. */ > > - ledcfg = BIT(1) | BIT(7) | BIT(11); > > - } else if (brightness == RTL8XXXU_HW_LED_CONTROL) { > > - /* Value obtained by brute force. */ > > - ledcfg = BIT(8) | BIT(9); > > - } > > The definitions are used by this driver: > > #define BIT_LED2EN BIT(21) > #define BIT_LED1SV BIT(11) // the same definition with BIT_LED0SV > #define BIT_LED1CM GENMASK(10, 8) // use the same value of BIT_LED0CM > #define BIT_LED0SV BIT(3) > #define BIT_LED0CM GENMASK(2, 0) > #define LED_MODE_TX_OR_RX_EVENTS 3 > #define LED_MODE_SW_CTRL 0 > > > > + /* Enable LED0 GPIO and turn LED0/LED1 off. */ > > + ledcfg = (rtl8xxxu_read32(priv, REG_LEDCFG0) | BIT(21)) & ~0xffff; > > Split this statement into multiple lines and use definitions I provide above. > > > + > > + /* Values obtained by brute force. */ > > + if (brightness == LED_ON) > > + ledcfg |= BIT(3) | BIT(11); > > + else if (brightness == RTL8XXXU_HW_LED_CONTROL) > > + ledcfg |= BIT(0) | BIT(1) | BIT(8) | BIT(9); > > > > - rtl8xxxu_write16(priv, REG_LEDCFG0, ledcfg); > > + rtl8xxxu_write32(priv, REG_LEDCFG0, ledcfg); > > > > return 0; > > } > > -- > > 2.42.0 > Thanks for the help and suggestions, I will make these changes. :)