Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp437607pxt; Thu, 12 Aug 2021 01:53:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz69GMUeZgYW1sJlkNaKHr12ficw05vlXXd8C+fFkKGC21uus40DCDgss2TuG/6yggJC+N8 X-Received: by 2002:a17:906:1901:: with SMTP id a1mr2642906eje.129.1628758386370; Thu, 12 Aug 2021 01:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628758386; cv=none; d=google.com; s=arc-20160816; b=e7AW3G4gM8P6JHLA9goyf19OHJCfyKEUXjnAO4TSzFui4shKKGIFkFyKobrMP5iKvt W2eSOAvvzQpz5HyPrGGqWIdq7ciHTJdOULN2CaAzEjt1o3ActfgqIdYak8SIr3dRc+Rf cOyqS5v8HbIC1q6X2QK1Usr6ts5lMaiXQ3Vy/wfRr2Dswu0Vao1YOO4gvs3HhaX9sDlj DmgAjLKgnhTe196un0iJUQY6y5TRe0Seh6/q2dV/Yz2NhmSyTPolVUIwB5m+3bMCXb3v OjYcA4vL2EsHcyKmqz/DMBkAaFXDC+7DGxa5GaUzrTT3o7DvJnnsIJ0HfMJ4Fo6hlMI9 JnMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:dmarc-filter :sender:dkim-signature; bh=Ya9+Ha0SGv8ND1/LQ97Qs9nz9/yO8+sXj545J9GZXEQ=; b=qed1NyucNjesyekUEdas9jcm4pdWCkaaQDGMsHkO79SbtG98HFtNu5TbbhWi7ZeW6c 9S7yjPQuxVZ+V30GHYknB8m/x1vWCN3I51n5ncKm1Qa9jkLqx8J9p+8aXREMeszH4+gf 01oeXYqyE5Yssddxcs0+1BMNyWEvZ1km30GdItAImQjvF1VMHE+Q4LIGcR5D23X05KP4 9zOlPrUFPrj/LoUbXC3EuARFug7K+lv1barD3/y2huiYkLad0B0S9ABVn/cXy3nSh9B3 MvHCY2sy+ufkXPYptBelQl0ehyIfTlPbTC7uxr/69jIg1yN7vL0G/C75ZnGbi5krmEUD urNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b="C9Dod/6Q"; 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 9si182066ejy.65.2021.08.12.01.52.27; Thu, 12 Aug 2021 01:53:06 -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="C9Dod/6Q"; 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 S235131AbhHLIvR (ORCPT + 99 others); Thu, 12 Aug 2021 04:51:17 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:40922 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234605AbhHLIvP (ORCPT ); Thu, 12 Aug 2021 04:51:15 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1628758251; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=Ya9+Ha0SGv8ND1/LQ97Qs9nz9/yO8+sXj545J9GZXEQ=; b=C9Dod/6Qz7pTvGUEvhUmb3R0NlUnHbPM8XjOnhJ1nA2mR0zg0XCDJqFr8trZ1Srn/jM1Rqiv OZ87krJVf+zd+3/SP/vuHVkJ1RdF4lKFdLhUq7SZdAlqsKjsC7+bC6AL1gL43heZParqMN5X J/1i8Nwxpas6aeweUwrTMQOxTO4= X-Mailgun-Sending-Ip: 69.72.43.7 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-n06.prod.us-east-1.postgun.com with SMTP id 6114e0d176c3a9a17204dd70 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 12 Aug 2021 08:50:25 GMT Sender: zijuhu=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 86A29C43460; Thu, 12 Aug 2021 08:50:24 +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,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from zijuhu-gv.qualcomm.com (unknown [180.166.53.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: zijuhu) by smtp.codeaurora.org (Postfix) with ESMTPSA id C2263C433F1; Thu, 12 Aug 2021 08:50:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C2263C433F1 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=zijuhu@codeaurora.org From: Zijun Hu 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 v3] Bluetooth: btusb: Add support different nvm to distinguish different factory for WCN6855 controller Date: Thu, 12 Aug 2021 16:50:16 +0800 Message-Id: <1628758216-3201-1-git-send-email-zijuhu@codeaurora.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Tim Jiang we have different factory to produce wcn6855 soc chip, so we should use different nvm file with suffix to distinguish them. Signed-off-by: Tim Jiang --- drivers/bluetooth/btusb.c | 60 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index b1a05bb9f4bf..d7b4e0f1c3e3 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -4013,6 +4013,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; @@ -4044,6 +4047,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, @@ -4198,6 +4202,39 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, return err; } +static int btusb_setup_qca_form_nvm_name(char **fwname, + int max_size, + struct qca_version *ver, + char *factory) +{ + /* if boardid equal 0, use default nvm without suffix */ + switch (le16_to_cpu(ver->board_id)) { + case 0x0: + /* we add suffix factory to distinguish with different factory. */ + if (factory != NULL) { + snprintf(*fwname, max_size, "qca/nvm_usb_%08x_%s.bin", + le32_to_cpu(ver->rom_version), + factory); + } else { + snprintf(*fwname, max_size, "qca/nvm_usb_%08x.bin", + le32_to_cpu(ver->rom_version)); + } + break; + default: + if (factory != NULL) { + snprintf(*fwname, max_size, "qca/nvm_usb_%08x_%s_%04x.bin", + le32_to_cpu(ver->rom_version), + factory, + le16_to_cpu(ver->board_id)); + } else { + snprintf(*fwname, max_size, "qca/nvm_usb_%08x_%04x.bin", + le32_to_cpu(ver->rom_version), + le16_to_cpu(ver->board_id)); + } + break; + } +} + static int btusb_setup_qca_load_nvm(struct hci_dev *hdev, struct qca_version *ver, const struct qca_device_info *info) @@ -4206,19 +4243,24 @@ 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) { + switch (ver->ram_version) { + case WCN6855_2_0_RAM_VERSION_GF: + case WCN6855_2_1_RAM_VERSION_GF: + if (((ver->flag >> 8) & 0xff) == QCA_FLAG_MULTI_NVM) { + btusb_setup_qca_form_nvm_name(&fwname, sizeof(fwname), ver, "gf"); + } else { snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x.bin", le32_to_cpu(ver->rom_version)); + } + break; + default: + if (((ver->flag >> 8) & 0xff) == QCA_FLAG_MULTI_NVM) { + btusb_setup_qca_form_nvm_name(&fwname, sizeof(fwname), ver, NULL); } else { - snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x_%04x.bin", - le32_to_cpu(ver->rom_version), - le16_to_cpu(ver->board_id)); + snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x.bin", + le32_to_cpu(ver->rom_version)); } - } else { - snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x.bin", - le32_to_cpu(ver->rom_version)); + break; } err = request_firmware(&fw, fwname, &hdev->dev); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project