Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp418887pxb; Thu, 19 Nov 2020 04:51:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJy2FZjV7MXxjrOmKh5G2w2e7KLEgRukrUnEnQPNhIKQvERBtlCqlkYUQN220lAvZTQULwon X-Received: by 2002:a05:6402:1818:: with SMTP id g24mr12010169edy.313.1605790311002; Thu, 19 Nov 2020 04:51:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605790310; cv=none; d=google.com; s=arc-20160816; b=iNn3la04zWdCiJs4KAWz4ojoAs5z1tF0TM+HFC9RAD7bspO6RFIcKlP4ZeV4v0qo01 gUMMFI0g5VJPd4upqzQiuByI8U8MBvJ4ekZzJ+J3jpfyiCQPImsfdA8DiJ9V8MdGjF9p YZylIYmyfnS+dNJUgnYlSD67isQ+uPkGJUgdYRIyETyHfyYWp2Rm1vqhX32Y5FcmY4Lk gWpvjmt1MEZbYAhjaWMWONk2nhYGfjvPxabR2a41OoFN54wzHTjp28ktaleYJOLePShC q9mcofiKKisg5fqJqRI8CHnSMuY05GansS6zqkewPBHXEiBu9DAffvPVPuusfbbedQ/9 bn/A== 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:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :sender:dkim-signature; bh=IaxDyN0zVVfn696/u90QGUG+9uOUlx4Eok4grDksNsc=; b=KqaMuBYnUFjlgKz/LGF8PI+kRfGjS0D846eH4GQKNjm2fAeQMgW/9QVJxv65qGWHmS kwmaWHAeaRwb2oamgQsTUBRLgcIrI8xgSaW1Kb0lXbrO8RKJ552+X932kM9/g7MKqAXC iDYGvUxUF7F9pj9kjnDxNvmipg52li3novnUK6iX4Cfz1Yn6A/O1wcoxd5A7Bd6kflq6 IvUkKimCtlxcrkKAoUUOdXaY7RvH4Fw4BcEHzubW8O5C6rty/l3FiTVG+QV0vNOJuqg/ z3oUQ9j0bjaayIDnrUdORHW9mx7wdI6q6WpXtZCXIj9mn7+2wbjJYwhVKs3NGvqAyn/G WTEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=HECavPM6; 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 u92si1063104edc.306.2020.11.19.04.51.10; Thu, 19 Nov 2020 04:51:50 -0800 (PST) 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=HECavPM6; 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 S1726848AbgKSMuS (ORCPT + 99 others); Thu, 19 Nov 2020 07:50:18 -0500 Received: from z5.mailgun.us ([104.130.96.5]:59798 "EHLO z5.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727401AbgKSMuR (ORCPT ); Thu, 19 Nov 2020 07:50:17 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1605790216; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=IaxDyN0zVVfn696/u90QGUG+9uOUlx4Eok4grDksNsc=; b=HECavPM6XfpINcTn/kebOfKZaxZXibVbNUz5jIyH6APH76LoJgo2gZ/g246+VtI3Y4sQkd6m QGRQ4DVFxPI1vBnJnDI4peT5N4cY4VmHETp2b6DX741Z9/69PegW8M05e/NC3BXKlCNIR8B8 G5Y53pFj/q9ZpeSJa8co55FqhBA= X-Mailgun-Sending-Ip: 104.130.96.5 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-n02.prod.us-west-2.postgun.com with SMTP id 5fb66a04e714ea65012c2f63 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 19 Nov 2020 12:50:12 GMT Sender: gubbaven=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 33B58C43461; Thu, 19 Nov 2020 12:50:12 +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: gubbaven) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8FDA8C43460; Thu, 19 Nov 2020 12:50:11 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 19 Nov 2020 18:20:11 +0530 From: gubbaven@codeaurora.org To: Matthias Kaehlcke Cc: marcel@holtmann.org, johan.hedberg@gmail.com, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, rjliao@codeaurora.org, hbandi@codeaurora.org, abhishekpandit@chromium.org Subject: Re: [PATCH v1] Bluetooth: Use NVM files based on SoC ID for WCN3991 In-Reply-To: <20200916180229.GA3560556@google.com> References: <1600184605-31611-1-git-send-email-gubbaven@codeaurora.org> <20200916180229.GA3560556@google.com> Message-ID: <7d9a95bc2b1c11487662c8b4c0ffa29f@codeaurora.org> X-Sender: gubbaven@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Matthias, On 2020-09-16 23:32, Matthias Kaehlcke wrote: > Hi Venkata, > > I agree with Marcel that the version magic is confusing ... > > On Tue, Sep 15, 2020 at 09:13:25PM +0530, Venkata Lakshmi Narayana > Gubba wrote: >> This change will allow to use different NVM file based >> on WCN3991 BT SoC ID.Need to use different NVM file based on >> fab location for WCN3991 BT SoC. >> >> Signed-off-by: Venkata Lakshmi Narayana Gubba >> >> --- >> drivers/bluetooth/btqca.c | 41 >> +++++++++++++++++++++++++---------------- >> drivers/bluetooth/btqca.h | 13 ++++++++----- >> drivers/bluetooth/hci_qca.c | 11 +++++------ >> 3 files changed, 38 insertions(+), 27 deletions(-) >> >> diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c >> index ce9dcff..a7e72f1 100644 >> --- a/drivers/bluetooth/btqca.c >> +++ b/drivers/bluetooth/btqca.c >> @@ -14,12 +14,11 @@ >> >> #define VERSION "0.1" >> >> -int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, >> +int qca_read_soc_version(struct hci_dev *hdev, struct >> qca_btsoc_version *ver, >> enum qca_btsoc_type soc_type) >> { >> struct sk_buff *skb; >> struct edl_event_hdr *edl; >> - struct qca_btsoc_version *ver; >> char cmd; >> int err = 0; >> u8 event_type = HCI_EV_VENDOR; >> @@ -70,9 +69,9 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 >> *soc_version, >> } >> >> if (soc_type >= QCA_WCN3991) >> - memmove(&edl->data, &edl->data[1], sizeof(*ver)); >> - >> - ver = (struct qca_btsoc_version *)(edl->data); >> + memcpy(ver, &edl->data[1], sizeof(*ver)); >> + else >> + memcpy(ver, &edl->data, sizeof(*ver)); >> >> bt_dev_info(hdev, "QCA Product ID :0x%08x", >> le32_to_cpu(ver->product_id)); >> @@ -83,13 +82,7 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 >> *soc_version, >> bt_dev_info(hdev, "QCA Patch Version:0x%08x", >> le16_to_cpu(ver->patch_ver)); >> >> - /* QCA chipset version can be decided by patch and SoC >> - * version, combination with upper 2 bytes from SoC >> - * and lower 2 bytes from patch will be used. >> - */ >> - *soc_version = (le32_to_cpu(ver->soc_id) << 16) | >> - (le16_to_cpu(ver->rom_ver) & 0x0000ffff); >> - if (*soc_version == 0) >> + if (le32_to_cpu(ver->soc_id) == 0 || le16_to_cpu(ver->rom_ver) == 0) >> err = -EILSEQ; >> >> out: >> @@ -446,15 +439,25 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, >> const bdaddr_t *bdaddr) >> EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome); >> >> int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, >> - enum qca_btsoc_type soc_type, u32 soc_ver, >> + enum qca_btsoc_type soc_type, struct qca_btsoc_version ver, >> const char *firmware_name) >> { >> struct qca_fw_config config; >> int err; >> u8 rom_ver = 0; >> + u32 soc_ver; >> >> bt_dev_dbg(hdev, "QCA setup on UART"); >> >> + /* QCA chipset version can be decided by patch and SoC >> + * version, combination with upper 2 bytes from SoC >> + * and lower 2 bytes from patch will be used. >> + */ >> + soc_ver = (le32_to_cpu(ver.soc_id) << 16) | >> + (le16_to_cpu(ver.rom_ver) & 0x0000ffff); >> + > > Can we at least do the leN_to_cpu conversions in qca_read_soc_version() > as previously to make this less clunky? > > And/or define a macro to extract 'soc_ver' to unclunkify this further. > [Venkata]: I will define a macro to extract soc_ver and will update in next patchset. >> + bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver); >> + >> config.user_baud_rate = baudrate; >> >> /* Download rampatch file */ >> @@ -491,9 +494,15 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t >> baudrate, >> if (firmware_name) >> snprintf(config.fwname, sizeof(config.fwname), >> "qca/%s", firmware_name); >> - else if (qca_is_wcn399x(soc_type)) >> - snprintf(config.fwname, sizeof(config.fwname), >> - "qca/crnv%02x.bin", rom_ver); >> + else if (qca_is_wcn399x(soc_type)) { >> + if (ver.soc_id == QCA_WCN3991_SOC_ID) { >> + snprintf(config.fwname, sizeof(config.fwname), >> + "qca/crnv%02xu.bin", rom_ver); >> + } else { >> + snprintf(config.fwname, sizeof(config.fwname), >> + "qca/crnv%02x.bin", rom_ver); >> + } >> + } >> else if (soc_type == QCA_QCA6390) >> snprintf(config.fwname, sizeof(config.fwname), >> "qca/htnv%02x.bin", rom_ver); >> diff --git a/drivers/bluetooth/btqca.h b/drivers/bluetooth/btqca.h >> index d81b74c..d01a9f5 100644 >> --- a/drivers/bluetooth/btqca.h >> +++ b/drivers/bluetooth/btqca.h >> @@ -34,6 +34,8 @@ >> #define QCA_HCI_CC_OPCODE 0xFC00 >> #define QCA_HCI_CC_SUCCESS 0x00 >> >> +#define QCA_WCN3991_SOC_ID (0x40014320) > > The QCA_ prefix seems a bit verbose, given that this is a QCA driver > and > WCN3991 uniquely identifies the chip. Having the prefix just needlessly > clutters conditions, I suggest to just call it SOC_ID_WCN3991.