Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp538104pxb; Wed, 29 Sep 2021 04:44:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrqcCm6vNjV6BolnKqfv88GMnukPBenlHW9nQUVK01TjfXdMTD57T3Mw92QYFqrWVzLtk/ X-Received: by 2002:a50:bec8:: with SMTP id e8mr14313000edk.231.1632915875452; Wed, 29 Sep 2021 04:44:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632915875; cv=none; d=google.com; s=arc-20160816; b=soh+WMiuXm8KQ1n5CtjH23XaDxtbedxcPEojIBLMLc9zHfwVaM3bLGEEhOZ8MpAmsF 3gHjyAurv+VWA1TL8+Gv8gEFe64bSIyGN8lNQYkbhB6dcw3FAm1hr0NVd3H8XxDyd4rz 0HLOVidu21u/knSWbLbtVo/dDZo4RwKGNBNpng7E3AfSPoBAn7r+S9RDpB6vfLkQ2elP Tr/9oQBVuoQq7h8VJiIMcumDMgfu85yCuoG3k3oqEuUFaJArf7slnEMjOlReIm4JJp7u SAhUrL8DFQ/uYnMig+Rd/kq7TgoAoqAx6OI8DSO2wmF5LPFe0Io3mTnGtbbuCpzVVPeC dmjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:subject:cc:to:from:date :content-transfer-encoding:mime-version:sender:dkim-signature; bh=EIi/7R+B4A7qgjfMhR7sZN90W0plkrmN1FfTlJIQ8EA=; b=iZXxfn0ZnCWvz2FNcdYFNM6G/5A+lEY3KRXY0zrLnEWW6Uw2OCyoaqrPyxd0jNba4W FuInWTF1Bj0VC8OCQiTGe8p1AQVXqONxZJNNylotX+LQ8NwCc6VmIkBK2ZCdogSHQDEl u3jcuTG7USL1dDi95FS9wQOTV9ADHNoazTEtCFklT9hLRQUpVd7ltY9K2oZZ8PFkUkJg oB2loNn4N5S7/LG1Z1LEzcfqPisd58Fzfzh5wxkmNMHx7k9L9/SzXVT95IkxZ2qsLJBD Ouc1xTU9PyxAEPUaM8tiRbBuUo4YwDehQ49Ob09yLhKhbEey/1bUlZWCjsR2voBqYLJt M2kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=ZjHSTaZs; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i2si1638989ejz.559.2021.09.29.04.44.09; Wed, 29 Sep 2021 04:44:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=ZjHSTaZs; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244783AbhI2IiM (ORCPT + 99 others); Wed, 29 Sep 2021 04:38:12 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:44483 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244610AbhI2IiL (ORCPT ); Wed, 29 Sep 2021 04:38:11 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1632904587; h=Message-ID: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=EIi/7R+B4A7qgjfMhR7sZN90W0plkrmN1FfTlJIQ8EA=; b=ZjHSTaZsyqmgaNeFK53KI69z3M8d/11c+5VJDVwO1Fmpf5d0unghtUYY4I6oe59X1u0U89k0 jdLcSzBzNc4/IpxSxyDIomzVjk43sjoiAuA4wvlOdnZj4lZPgc2osbQ9et1oO3FdXIWL+uMP v1zOKknpkpHHLG7SHozR4uWnqJw= X-Mailgun-Sending-Ip: 198.61.254.9 X-Mailgun-Sid: WyI2MTA3ZSIsICJsaW51eC1ibHVldG9vdGhAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n04.prod.us-east-1.postgun.com with SMTP id 61542587713d5d6f968dc315 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 29 Sep 2021 08:36:23 GMT Sender: tjiang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 7E2DFC43460; Wed, 29 Sep 2021 08:36:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: tjiang) by smtp.codeaurora.org (Postfix) with ESMTPSA id 9A52CC4338F; Wed, 29 Sep 2021 08:36:20 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 29 Sep 2021 16:36:20 +0800 From: tjiang@codeaurora.org To: marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com Cc: linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, c-hbandi@codeaurora.org, hemantg@codeaurora.org, mka@chromium.org, rjliao@codeaurora.org, zijuhu@codeaurora.org, tjiang@codeaurora.org Subject: [PATCH v12] Bluetooth: btusb: Add support using different nvm for variant WCN6855 controller Message-ID: X-Sender: tjiang@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org the RF performance of wcn6855 soc chip from different foundries will be difference, so we should use different nvm to configure them. Signed-off-by: Tim Jiang --- drivers/bluetooth/btusb.c | 54 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index da85cc14f931..0a75c82796aa 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -3186,6 +3186,9 @@ static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev, #define QCA_DFU_TIMEOUT 3000 #define QCA_FLAG_MULTI_NVM 0x80 +#define WCN6855_2_0_RAM_VERSION_GF 0x400c1200 +#define WCN6855_2_1_RAM_VERSION_GF 0x400c1211 + struct qca_version { __le32 rom_version; __le32 patch_version; @@ -3217,6 +3220,7 @@ static const struct qca_device_info qca_devices_table[] = { { 0x00000302, 28, 4, 16 }, /* Rome 3.2 */ { 0x00130100, 40, 4, 16 }, /* WCN6855 1.0 */ { 0x00130200, 40, 4, 16 }, /* WCN6855 2.0 */ + { 0x00130201, 40, 4, 16 }, /* WCN6855 2.1 */ }; static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 request, @@ -3371,6 +3375,41 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, return err; } +static void btusb_generate_qca_nvm_name(char *fwname, + size_t max_size, + struct qca_version *ver) +{ + u32 rom_version = le32_to_cpu(ver->rom_version); + + if (((ver->flag >> 8) & 0xff) == QCA_FLAG_MULTI_NVM) { + u16 board_id = le16_to_cpu(ver->board_id); + const char *variant; + + switch (ver->ram_version) { + case WCN6855_2_0_RAM_VERSION_GF: + case WCN6855_2_1_RAM_VERSION_GF: + variant = "_gf"; + break; + default: + variant = ""; + break; + } + + /* if boardid equal 0, use default nvm without suffix */ + if (board_id == 0x0) { + snprintf(fwname, max_size, "qca/nvm_usb_%08x%s.bin", + rom_version, variant); + } else { + snprintf(fwname, max_size, "qca/nvm_usb_%08x%s_%04x.bin", + rom_version, variant, board_id); + } + } else { + snprintf(fwname, max_size, "qca/nvm_usb_%08x.bin", + rom_version); + } + +} + static int btusb_setup_qca_load_nvm(struct hci_dev *hdev, struct qca_version *ver, const struct qca_device_info *info) @@ -3379,20 +3418,7 @@ static int btusb_setup_qca_load_nvm(struct hci_dev *hdev, char fwname[64]; int err; - if (((ver->flag >> 8) & 0xff) == QCA_FLAG_MULTI_NVM) { - /* if boardid equal 0, use default nvm without surfix */ - if (le16_to_cpu(ver->board_id) == 0x0) { - snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x.bin", - le32_to_cpu(ver->rom_version)); - } else { - snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x_%04x.bin", - le32_to_cpu(ver->rom_version), - le16_to_cpu(ver->board_id)); - } - } else { - snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x.bin", - le32_to_cpu(ver->rom_version)); - } + btusb_generate_qca_nvm_name(fwname, sizeof(fwname), ver); err = request_firmware(&fw, fwname, &hdev->dev); if (err) { -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project