From patchwork Mon Apr 17 17:05:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 675022 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60593C77B7A for ; Mon, 17 Apr 2023 17:05:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229490AbjDQRFt (ORCPT ); Mon, 17 Apr 2023 13:05:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbjDQRFs (ORCPT ); Mon, 17 Apr 2023 13:05:48 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3951448B for ; Mon, 17 Apr 2023 10:05:46 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id sz19so8954127ejc.2 for ; Mon, 17 Apr 2023 10:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681751145; x=1684343145; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=WJBu1cDB2rDY4+OXJSC6bVwdAj9BGhH8dohZ1ZZQ5ug=; b=OfQOvzY9hZ9XckrRNfjM+O8UEq3Luwe/FD6aa2S1/y4lFfNcmcJ8VxYLCD4/EB1mOO cBh71VeBTy9oO2PNk+G9hhZxehVhddGsoudkgJhpOwrEcCoQ70oPWjyTb4Bh5ttva3oT IEPFDi7cZ6N6LdTtm9cyJpZnN5APoF20kV7yI7Fcs5gZ2/vJEyYvOmqgo/yB7qlV/d19 u9Q8yHbQ9STOqYszVDQZvt+kaBR32lS5R7JlR5DlHvXRKJZSPBB4v34HgEsrxFfCUdmR 2jGZzoCzrXFOLX2BXxZhTzkZQSdxXQUpInf/hYA5VWQ0Skq5yC4aPAtPcrBsUFjipuB/ Tw4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681751145; x=1684343145; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=WJBu1cDB2rDY4+OXJSC6bVwdAj9BGhH8dohZ1ZZQ5ug=; b=JwF/Br38AdwzgDg+4yj3EpkuKzas8hvRstNpzed0+Iczt9BGb8e/y0roUEh2q1KVnY lu9rFUZfNX78NcwnrGhFsiHmFkR/0KTznBhnbJ4bPcpRwy/lN9VGoW1biuO+VBQ8ODwm Nv40722bJJ1yJHo4AHj+UZqvKmpX5Sbjg9qo3s4SUWpTNl1q+mQCTNeonCBNxJU1Q4Lq jwXJNrqmKRGW0uQWp47rcKb3oI4RtBHJfVsCdmYcW1awYDSgSnDrFv/sEQESkB26Td42 vp3u770TT7JBH3QpdTjzCF9PSHziwkByPhDI3A0fZomRTKQHjlimse7UpPRA9gSakLlq cOpg== X-Gm-Message-State: AAQBX9dHl5+xqFdO04pJ+9AR+1sw2bUUbZkfbGfhFSBis6DNNoSwstUG 539m5A2HGb5XW6gwNPAckIRciKIuQiU= X-Google-Smtp-Source: AKy350Zh/G0QEYAUlP9YZocnv5ly+kdTaoKjWJ4cy95p0Lw4q6/XOfrssPNwK/OXUFpMJDPMaDvbdQ== X-Received: by 2002:a17:906:3d71:b0:94f:61b2:c991 with SMTP id r17-20020a1709063d7100b0094f61b2c991mr4246330ejf.74.1681751145204; Mon, 17 Apr 2023 10:05:45 -0700 (PDT) Received: from [192.168.1.50] ([81.196.40.55]) by smtp.gmail.com with ESMTPSA id wy6-20020a170906fe0600b0094ee88207d5sm5155806ejb.191.2023.04.17.10.05.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Apr 2023 10:05:44 -0700 (PDT) Message-ID: Date: Mon, 17 Apr 2023 20:05:43 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US To: "linux-wireless@vger.kernel.org" Cc: Jes Sorensen , Ping-Ke Shih From: Bitterblue Smith Subject: [PATCH 1/3] wifi: rtl8xxxu: Don't print the vendor/product/serial Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Most devices have a vendor name, product name, and serial number in the efuse, but it's pretty useless. It duplicates the information already printed by the USB subsystem: usb 1-4: New USB device found, idVendor=0bda, idProduct=8178, bcdDevice= 2.00 usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 usb 1-4: Product: 802.11n WLAN Adapter usb 1-4: Manufacturer: Realtek usb 1-4: SerialNumber: 00e04c000001 -> usb 1-4: Vendor: Realtek -> usb 1-4: Product: 802.11n WLAN Adapter usb 1-4: New USB device found, idVendor=0bda, idProduct=818b, bcdDevice= 2.00 usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 usb 1-4: Product: 802.11n NIC usb 1-4: Manufacturer: Realtek usb 1-4: SerialNumber: 00e04c000001 -> usb 1-4: Vendor: Realtek -> usb 1-4: Product: 802.11n NIC -> usb 1-4: Serial not available. usb 1-4: New USB device found, idVendor=0bda, idProduct=f179, bcdDevice= 0.00 usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 usb 1-4: Product: 802.11n usb 1-4: Manufacturer: Realtek usb 1-4: SerialNumber: 002E2DC0041F -> usb 1-4: Vendor: Realtek -> usb 1-4: Product: 802.11n usb 1-4: New USB device found, idVendor=0bda, idProduct=8179, bcdDevice= 0.00 usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 usb 1-4: Product: 802.11n NIC usb 1-4: Manufacturer: Realtek usb 1-4: SerialNumber: 00E04C0001 -> usb 1-4: Vendor: Realtek -> usb 1-4: Product: 802.11n NIC -> usb 1-4: Serial: 00E04C0001 Also, that data is not interpreted correctly in all cases: usb 3-1.1.2: New USB device found, idVendor=0bda, idProduct=8179, bcdDevice= 0.00 usb 3-1.1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 usb 3-1.1.2: Product: 802.11n NIC usb 3-1.1.2: Manufacturer: Realtek usb 3-1.1.2: Vendor: Realtek usb 3-1.1.2: Product: \x03802.11n NI usb 3-1.1.2: Serial: \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff Link: https://bugzilla.kernel.org/show_bug.cgi?id=217231 Signed-off-by: Bitterblue Smith Reviewed-by: Ping-Ke Shih --- .../realtek/rtl8xxxu/rtl8xxxu_8188e.c | 4 -- .../realtek/rtl8xxxu/rtl8xxxu_8188f.c | 3 -- .../realtek/rtl8xxxu/rtl8xxxu_8192c.c | 5 -- .../realtek/rtl8xxxu/rtl8xxxu_8192e.c | 54 ------------------- .../realtek/rtl8xxxu/rtl8xxxu_8723a.c | 4 -- .../realtek/rtl8xxxu/rtl8xxxu_8723b.c | 3 -- 6 files changed, 73 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c index af8436070ba7..8986783ae8fa 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c @@ -568,10 +568,6 @@ static int rtl8188eu_parse_efuse(struct rtl8xxxu_priv *priv) priv->default_crystal_cap = efuse->xtal_k & 0x3f; - dev_info(&priv->udev->dev, "Vendor: %.7s\n", efuse->vendor_name); - dev_info(&priv->udev->dev, "Product: %.11s\n", efuse->device_name); - dev_info(&priv->udev->dev, "Serial: %.11s\n", efuse->serial); - return 0; } diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c index dfb250adb168..dbdfd7787465 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c @@ -734,9 +734,6 @@ static int rtl8188fu_parse_efuse(struct rtl8xxxu_priv *priv) priv->default_crystal_cap = efuse->xtal_k & 0x3f; - dev_info(&priv->udev->dev, "Vendor: %.7s\n", efuse->vendor_name); - dev_info(&priv->udev->dev, "Product: %.7s\n", efuse->device_name); - return 0; } diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c index caeba56241fc..b30a9a513cb8 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c @@ -441,11 +441,6 @@ static int rtl8192cu_parse_efuse(struct rtl8xxxu_priv *priv) efuse->ht20_max_power_offset, sizeof(efuse->ht20_max_power_offset)); - dev_info(&priv->udev->dev, "Vendor: %.7s\n", - efuse->vendor_name); - dev_info(&priv->udev->dev, "Product: %.20s\n", - efuse->device_name); - priv->power_base = &rtl8192c_power_base; if (efuse->rf_regulatory & 0x20) { diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c index 4498748164af..fcc2926ea938 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c @@ -601,43 +601,9 @@ rtl8192e_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40) } } -static void rtl8192eu_log_next_device_info(struct rtl8xxxu_priv *priv, - char *record_name, - char *device_info, - unsigned int *record_offset) -{ - char *record = device_info + *record_offset; - - /* A record is [ total length | 0x03 | value ] */ - unsigned char l = record[0]; - - /* - * The whole device info section seems to be 80 characters, make sure - * we don't read further. - */ - if (*record_offset + l > 80) { - dev_warn(&priv->udev->dev, - "invalid record length %d while parsing \"%s\" at offset %u.\n", - l, record_name, *record_offset); - return; - } - - if (l >= 2) { - char value[80]; - - memcpy(value, &record[2], l - 2); - value[l - 2] = '\0'; - dev_info(&priv->udev->dev, "%s: %s\n", record_name, value); - *record_offset = *record_offset + l; - } else { - dev_info(&priv->udev->dev, "%s not available.\n", record_name); - } -} - static int rtl8192eu_parse_efuse(struct rtl8xxxu_priv *priv) { struct rtl8192eu_efuse *efuse = &priv->efuse_wifi.efuse8192eu; - unsigned int record_offset; int i; if (efuse->rtl_id != cpu_to_le16(0x8129)) @@ -684,26 +650,6 @@ static int rtl8192eu_parse_efuse(struct rtl8xxxu_priv *priv) priv->default_crystal_cap = priv->efuse_wifi.efuse8192eu.xtal_k & 0x3f; - /* - * device_info section seems to be laid out as records - * [ total length | 0x03 | value ] so: - * - vendor length + 2 - * - 0x03 - * - vendor string (not null terminated) - * - product length + 2 - * - 0x03 - * - product string (not null terminated) - * Then there is one or 2 0x00 on all the 4 devices I own or found - * dumped online. - * As previous version of the code handled an optional serial - * string, I now assume there may be a third record if the - * length is not 0. - */ - record_offset = 0; - rtl8192eu_log_next_device_info(priv, "Vendor", efuse->device_info, &record_offset); - rtl8192eu_log_next_device_info(priv, "Product", efuse->device_info, &record_offset); - rtl8192eu_log_next_device_info(priv, "Serial", efuse->device_info, &record_offset); - return 0; } diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c index d219be19d07f..15a30e496221 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c @@ -222,10 +222,6 @@ static int rtl8723au_parse_efuse(struct rtl8xxxu_priv *priv) priv->power_base = &rtl8723a_power_base; - dev_info(&priv->udev->dev, "Vendor: %.7s\n", - efuse->vendor_name); - dev_info(&priv->udev->dev, "Product: %.41s\n", - efuse->device_name); return 0; } diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c index c31c2b52ac77..abc56c7de6f7 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c @@ -494,9 +494,6 @@ static int rtl8723bu_parse_efuse(struct rtl8xxxu_priv *priv) priv->default_crystal_cap = priv->efuse_wifi.efuse8723bu.xtal_k & 0x3f; - dev_info(&priv->udev->dev, "Vendor: %.7s\n", efuse->vendor_name); - dev_info(&priv->udev->dev, "Product: %.41s\n", efuse->device_name); - return 0; } From patchwork Mon Apr 17 17:07:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 674488 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BEC3C77B7A for ; Mon, 17 Apr 2023 17:07:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229540AbjDQRHP (ORCPT ); Mon, 17 Apr 2023 13:07:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbjDQRHO (ORCPT ); Mon, 17 Apr 2023 13:07:14 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9758846AE for ; Mon, 17 Apr 2023 10:07:12 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id fw30so13247984ejc.5 for ; Mon, 17 Apr 2023 10:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681751231; x=1684343231; 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=mEzyh4pakPHuQ8+nKfXaL43D7FIupaCBqefoqOH9kn8=; b=qvd26ltX2D82to3/vTe2knMGvkgRfcZvSrFxX8Kl1TggmQvdlX549spN9HL8WTCuv4 UHaieeXuatKHvsC7hvJ6UYiTyrd3rwcHx3yLKOh9a/SkjgjSJmE0Ep+cbhe6GFxnaMT9 qo1jkELRXH1I133CvJSUhbnTQTxBJKSPyljVkC0I6lBdgCJ5rMG8hcERoyHkAcOTwskn wNhd7syZ9mGT81I0E4loFoiZzeSbVA8Cpig5fyGJn/0HCTnr9Q701ipPOVBXyaLx3Dw6 i3LE/L4VsiNPGLjTCCrxyar5b5vj5OH/g2crt4rc9Bgxq1vDEeJuEHUbtF8cYfx7DYVW KJ3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681751231; x=1684343231; 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=mEzyh4pakPHuQ8+nKfXaL43D7FIupaCBqefoqOH9kn8=; b=FEA1z5V9LO8MVnz6PD+olnx2ckjKy7VTKIHCr3FRQWBPMGL74WdgOP3bGVsZR4vfgY UniHturkLlrlWJhHw+IlSBRrqv9KljLpJcMoPqIJ2uJV6vNtr7U4spVktcIShzeeQ8Zz +W6cOM7p2+Bim7auW/jErgoGiCaHGEqLKkngIcQS/CA3l7MAKddtIUNWdaQa4WoMju0r AfnbyL8IZLx53zKMk/7SYlZYPGShz/9gJdkcaTAxtcoJHlEVwmohLfrTjKVH52XELBcM +HFNTzHSdOIzbh5bxVDrQL2GhIHJYXQaPntfYjCgvDwa72TU1tVZitbavH1jmrfydKRY qWHw== X-Gm-Message-State: AAQBX9flByxyH2qKuYObM+4DZU67DdlmoUAUNUIksf4UczBH6vQ/URb4 9Zj47xQQJAhov4SGYk5lxrUBQuqdAQM= X-Google-Smtp-Source: AKy350bux4drpiVsvVkPRBM5jriDmec8TQZrh4E6wrdEVWSgRJAb1Xlhlj8tpyOzFZ6sfM9j6QObyA== X-Received: by 2002:a17:906:eceb:b0:94a:5c6c:e19a with SMTP id qt11-20020a170906eceb00b0094a5c6ce19amr7533771ejb.19.1681751230977; Mon, 17 Apr 2023 10:07:10 -0700 (PDT) Received: from [192.168.1.50] ([81.196.40.55]) by smtp.gmail.com with ESMTPSA id v16-20020a1709064e9000b0094f663bced2sm2241623eju.33.2023.04.17.10.07.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Apr 2023 10:07:10 -0700 (PDT) Message-ID: <9430b841-1048-b27c-14ec-fca447dc32af@gmail.com> Date: Mon, 17 Apr 2023 20:07:09 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: [PATCH 2/3] wifi: rtl8xxxu: Add rtl8xxxu_write{8,16,32}_{set,clear} Content-Language: en-US From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Jes Sorensen , Ping-Ke Shih References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Also add rtl8xxxu_write32_mask, rtl8xxxu_write_rfreg_mask. These helper functions make it easier to modify only parts of a register by eliminating the call to the register reading function and the bit manipulations. Signed-off-by: Bitterblue Smith Reviewed-by: Ping-Ke Shih --- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 12 +++ .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 79 +++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h index 82a0290ccb29..8eafbf1cee71 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h @@ -1953,10 +1953,22 @@ u32 rtl8xxxu_read32(struct rtl8xxxu_priv *priv, u16 addr); int rtl8xxxu_write8(struct rtl8xxxu_priv *priv, u16 addr, u8 val); int rtl8xxxu_write16(struct rtl8xxxu_priv *priv, u16 addr, u16 val); int rtl8xxxu_write32(struct rtl8xxxu_priv *priv, u16 addr, u32 val); +int rtl8xxxu_write8_set(struct rtl8xxxu_priv *priv, u16 addr, u8 bits); +int rtl8xxxu_write8_clear(struct rtl8xxxu_priv *priv, u16 addr, u8 bits); +int rtl8xxxu_write16_set(struct rtl8xxxu_priv *priv, u16 addr, u16 bits); +int rtl8xxxu_write16_clear(struct rtl8xxxu_priv *priv, u16 addr, u16 bits); +int rtl8xxxu_write32_set(struct rtl8xxxu_priv *priv, u16 addr, u32 bits); +int rtl8xxxu_write32_clear(struct rtl8xxxu_priv *priv, u16 addr, u32 bits); +int rtl8xxxu_write32_mask(struct rtl8xxxu_priv *priv, u16 addr, + u32 mask, u32 val); + u32 rtl8xxxu_read_rfreg(struct rtl8xxxu_priv *priv, enum rtl8xxxu_rfpath path, u8 reg); int rtl8xxxu_write_rfreg(struct rtl8xxxu_priv *priv, enum rtl8xxxu_rfpath path, u8 reg, u32 data); +int rtl8xxxu_write_rfreg_mask(struct rtl8xxxu_priv *priv, + enum rtl8xxxu_rfpath path, u8 reg, + u32 mask, u32 val); void rtl8xxxu_save_regs(struct rtl8xxxu_priv *priv, const u32 *regs, u32 *backup, int count); void rtl8xxxu_restore_regs(struct rtl8xxxu_priv *priv, const u32 *regs, diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index 6106b47d0c37..03c0aaa9141c 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -786,6 +786,85 @@ int rtl8xxxu_write32(struct rtl8xxxu_priv *priv, u16 addr, u32 val) return ret; } +int rtl8xxxu_write8_set(struct rtl8xxxu_priv *priv, u16 addr, u8 bits) +{ + u8 val8; + + val8 = rtl8xxxu_read8(priv, addr); + val8 |= bits; + return rtl8xxxu_write8(priv, addr, val8); +} + +int rtl8xxxu_write8_clear(struct rtl8xxxu_priv *priv, u16 addr, u8 bits) +{ + u8 val8; + + val8 = rtl8xxxu_read8(priv, addr); + val8 &= ~bits; + return rtl8xxxu_write8(priv, addr, val8); +} + +int rtl8xxxu_write16_set(struct rtl8xxxu_priv *priv, u16 addr, u16 bits) +{ + u16 val16; + + val16 = rtl8xxxu_read16(priv, addr); + val16 |= bits; + return rtl8xxxu_write16(priv, addr, val16); +} + +int rtl8xxxu_write16_clear(struct rtl8xxxu_priv *priv, u16 addr, u16 bits) +{ + u16 val16; + + val16 = rtl8xxxu_read16(priv, addr); + val16 &= ~bits; + return rtl8xxxu_write16(priv, addr, val16); +} + +int rtl8xxxu_write32_set(struct rtl8xxxu_priv *priv, u16 addr, u32 bits) +{ + u32 val32; + + val32 = rtl8xxxu_read32(priv, addr); + val32 |= bits; + return rtl8xxxu_write32(priv, addr, val32); +} + +int rtl8xxxu_write32_clear(struct rtl8xxxu_priv *priv, u16 addr, u32 bits) +{ + u32 val32; + + val32 = rtl8xxxu_read32(priv, addr); + val32 &= ~bits; + return rtl8xxxu_write32(priv, addr, val32); +} + +int rtl8xxxu_write32_mask(struct rtl8xxxu_priv *priv, u16 addr, + u32 mask, u32 val) +{ + u32 orig, new, shift; + + shift = __ffs(mask); + + orig = rtl8xxxu_read32(priv, addr); + new = (orig & ~mask) | ((val << shift) & mask); + return rtl8xxxu_write32(priv, addr, new); +} + +int rtl8xxxu_write_rfreg_mask(struct rtl8xxxu_priv *priv, + enum rtl8xxxu_rfpath path, u8 reg, + u32 mask, u32 val) +{ + u32 orig, new, shift; + + shift = __ffs(mask); + + orig = rtl8xxxu_read_rfreg(priv, path, reg); + new = (orig & ~mask) | ((val << shift) & mask); + return rtl8xxxu_write_rfreg(priv, path, reg, new); +} + static int rtl8xxxu_writeN(struct rtl8xxxu_priv *priv, u16 addr, u8 *buf, u16 len) { From patchwork Mon Apr 17 17:08:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 675021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4D6BC77B76 for ; Mon, 17 Apr 2023 17:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229975AbjDQRIu (ORCPT ); Mon, 17 Apr 2023 13:08:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229800AbjDQRIt (ORCPT ); Mon, 17 Apr 2023 13:08:49 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFEBDC67A for ; Mon, 17 Apr 2023 10:08:23 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id dx24so22024646ejb.11 for ; Mon, 17 Apr 2023 10:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681751302; x=1684343302; 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=7J/Gmt+spocMRrReMmVXHsLa3nxHGax+i2VF8ucgwDw=; b=k/IyznacDhrUaTh16CNg0f3q44/7HVhdLTcDshPs6dgrzkJDoPFckMiKWSeCtMPN9N WcyskBS6/Nt6gDjW47VQMccaHc2s9JiS+mtno/x61WZpWNV5K14rJeAY60e+ttNyAXdp /nJYL2G519WAUzyFFC5WdXomZUkNmTPxw0A3eWm81w8GZofOHmSY4ioAps6qIg2iA23e qe6slFQq20HSyJXX47OVfWvML+fTfenrx6X+ZUL8fbozo6psr+Txr5BN7c/p7NB9qymZ i8D1smm1ZjC8d4U6wjO5Y0RZjbd0WQZVgsSqwzqcvtscY/cqp38XEVXQmr6MUSB+nG89 gAKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681751302; x=1684343302; 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=7J/Gmt+spocMRrReMmVXHsLa3nxHGax+i2VF8ucgwDw=; b=PkbzXODEKR3LWzYrLrNyfysal5NnH62ZXi7D268pV6+07vb/Jv+aYQNbzZsTCx+x8l TuPaLJfSj25CeMVckWZXsyRHQdF3wDXHAtXXwSIhGFNHWQl72+3u1WeGJvdyC3ofZnS9 XMOaWf2fETOk37W9hCyTlf9cpOlEAQMbBsXPlWXeagVYRHddtP6glD6BxcHaU88Q6uMB Esx95pFBIJnuFC3pz62ijTKVS/ZFDw48J4Tn8C8pIDL3UIxK79aBazCJ/YFf/gB0QBvT HN2bjNfz17nsC3pIUbqMMHbw6+Y/ckwJ5DPSRNJalR+/baifqXP3NmrXXbqT+O4In9mf PqSw== X-Gm-Message-State: AAQBX9fNnGhkrLKgGBCN2WkAYo3PvOjBHd0x7CaRn0TaWFQbyQsCsk9+ mOlF6PgQiRBKAmSNdt8qQt8el7I+OjQ= X-Google-Smtp-Source: AKy350YtAgM254g9H/SS/BQI2je5MQY8V1QHNmdPFSXTWiPMA502p96CkY8rAWFPbwZ5YIam96rYtQ== X-Received: by 2002:a17:906:9bca:b0:94e:cfd0:ed9f with SMTP id de10-20020a1709069bca00b0094ecfd0ed9fmr7570786ejc.26.1681751301831; Mon, 17 Apr 2023 10:08:21 -0700 (PDT) Received: from [192.168.1.50] ([81.196.40.55]) by smtp.gmail.com with ESMTPSA id qx11-20020a170906fccb00b0094f499257f7sm2805167ejb.151.2023.04.17.10.08.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Apr 2023 10:08:21 -0700 (PDT) Message-ID: Date: Mon, 17 Apr 2023 20:08:20 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: [PATCH 3/3] wifi: rtl8xxxu: Simplify setting the initial gain Content-Language: en-US From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Jes Sorensen , Ping-Ke Shih References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The goal of writing 0x6954341e / 0x6955341e to REG_OFDM0_XA_AGC_CORE1 appears to be setting the initial gain, which is stored in bits 0..6. Bits 7..31 are the same as what the phy init tables write. Modify only bits 0..6 so that we don't have to care about the values of the others. This way we don't have to add another "else if" for the RTL8192FU. Why we need to change the initial gain from the default 0x20 to 0x1e? Not sure. Some of the vendor drivers change it to 0x1e before scanning and then restore it to the original value after. Signed-off-by: Bitterblue Smith Reviewed-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index 03c0aaa9141c..fd8c8c6d53d6 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -7034,10 +7034,8 @@ static int rtl8xxxu_start(struct ieee80211_hw *hw) rtl8xxxu_write16(priv, REG_RXFLTMAP2, 0xffff); rtl8xxxu_write16(priv, REG_RXFLTMAP0, 0xffff); - if (priv->rtl_chip == RTL8188E) - rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, 0x6955341e); - else - rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, 0x6954341e); + rtl8xxxu_write32_mask(priv, REG_OFDM0_XA_AGC_CORE1, + OFDM0_X_AGC_CORE1_IGI_MASK, 0x1e); return ret;