Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2305244rwr; Fri, 21 Apr 2023 07:13:25 -0700 (PDT) X-Google-Smtp-Source: AKy350Zia4ppcozoGfXmXFqr7A6mrvMpF90ROR7lWTFSSnnemR7ZvABlKCX+UBDm3J+0nVClZuV/ X-Received: by 2002:a05:6a20:394c:b0:f2:2654:2b60 with SMTP id r12-20020a056a20394c00b000f226542b60mr4497931pzg.6.1682086405024; Fri, 21 Apr 2023 07:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682086405; cv=none; d=google.com; s=arc-20160816; b=gGU7QENdPzZuv9M1XSJJNpvjneGHObRBz1cY5wMdf10bK5uZDxOzZ0Y0jja2/SxzjS brQtuqMHt8ujfC361gXYsBqGXa5TQ65nnHN5yh5K6v8yOQsw3k1i91ahbEcSFp2hJSJb yBrF9Aksl6tyK9wn1SAjXsrKpDQD8XrAb6mBeI6irit/d8aVrzM0hx1+e8xWktvu0LbX ovn9iU9uixzbL4SyokrIpGC8fL1RJ/0BrGokNFx3svnjo0kOmMK8TzwezrsFY3Wgv14j j3DqzmD9tIsaFOHivQQwOhFv5ygEKnvxu87nBUbPupr87PL3iJ/mE/TBpX76uvBBuqzs mv/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=L+ingdxVlBAhx25mIHmohRsrlSprqOSnQvcGnUxqFXU=; b=bjEXofC8ibuV3SOFkO/sfzIEm04Q+ptJEmKF0e2DLiHjMIupioV+mf5e/VCZllUlyX /pOASHxZzVhu/DdEFctWoUqqDdTPmvE9RGTFk0XrBCWVlVuN2sD5c83YRiv09ctyOMcV VfaVVuuYsICglhuTuvTSly3NUIJHTnAhy4b1Wsl1ycw0C9/nW5V3ZWPq6C9Ho0xIdFfn iCPjaX1EZ8WZIbKHz3Ucrhi8D3uz5hVdQKzp6rZLJYBEn7G/rmoyqq5YgDDD/egHZe5C 8DdG53e9NN5MZS/c0lKVxrbDSjcBTR/3qyafpqfcv62awchOAIfvvJTjuxu+aUzwc7Xg 2Ebw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fairphone.com header.s=fair header.b=K7QrebmC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fairphone.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x71-20020a63864a000000b005215235fbd9si4852502pgd.38.2023.04.21.07.13.05; Fri, 21 Apr 2023 07:13:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@fairphone.com header.s=fair header.b=K7QrebmC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fairphone.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232594AbjDUOLy (ORCPT + 99 others); Fri, 21 Apr 2023 10:11:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232360AbjDUOLv (ORCPT ); Fri, 21 Apr 2023 10:11:51 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43CDA1259E for ; Fri, 21 Apr 2023 07:11:45 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-94e53ef6815so235966766b.1 for ; Fri, 21 Apr 2023 07:11:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fairphone.com; s=fair; t=1682086304; x=1684678304; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=L+ingdxVlBAhx25mIHmohRsrlSprqOSnQvcGnUxqFXU=; b=K7QrebmCX4fOWCWQ+IN56eGYHw2eCyT52m+HN56/5dQf+TwupwcfBoj6ORZLog0nno VlpAEcKOcF1iv0a8wW6mhOupvnSXzv4+/hLin/GL6MbhdD+9KfeIWrDD2zabw6Ewl4DC lqpNJ3IWgWaxhH/QMqzKeB2+UsPhT00dLiBprlLlJqZelnD90pTg7yj7ibmB4ILLUkak kzEFxMh6i8+xFZc9U/mQoACKz26bNYF/+0afIcGmc6ZNBigVYyM7/oxx79+uo2DfZl4z VE1eMeY7FK57OQ7e6FDH2BMCP1+bUE7OsY07DfJeOPUFiqe9FlGJd+sbuN2/bQX8caW4 QasQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682086304; x=1684678304; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L+ingdxVlBAhx25mIHmohRsrlSprqOSnQvcGnUxqFXU=; b=NpkhFjiyWtaK52ieWY0l5R5BYXTHGC620eQlJCUV1G4MN0MTJZgFhGVaSzQ+cUjh4z DUYdHC5tICQA4dpTKod3ZF4CYneo2X2EpoZXnJmfPZtQEjiWDXRbKOY/rkIUujONqyIp nm+eXmJdHhwOXsLcGsD5ZPdAk2nz+sVpYptGS4C3Q5Y97woYodMdL63Tiy1LIXcrRXOi f8Fo3awV3Ij1a/UZO73g9g1Tuw7Sz9s/KkXDKLt4pSzuuZLp0alGin4AfBosxKbVFX17 4olLN7+7wENkXmC0zgO73nrTk8x1L/Z627VgI6OzKd2f/9qpwPmnSeXXHfDAKbn1JhJy 6zOQ== X-Gm-Message-State: AAQBX9eHXFY+324MArpNEaplEtGl00iRMvcdRZXWawXgBv2K5d+uNL0s mHaSC19rPpUA+SiIKIW8nMpT5g== X-Received: by 2002:a17:906:7e45:b0:94f:5079:ade2 with SMTP id z5-20020a1709067e4500b0094f5079ade2mr2473933ejr.62.1682086303670; Fri, 21 Apr 2023 07:11:43 -0700 (PDT) Received: from [172.16.220.31] (144-178-202-138.static.ef-service.nl. [144.178.202.138]) by smtp.gmail.com with ESMTPSA id mb20-20020a170906eb1400b0094f432f2429sm2104299ejb.109.2023.04.21.07.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:11:43 -0700 (PDT) From: Luca Weiss Date: Fri, 21 Apr 2023 16:11:39 +0200 Subject: [PATCH RFC 2/4] Bluetooth: btqca: Add WCN3988 support MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230421-fp4-bluetooth-v1-2-0430e3a7e0a2@fairphone.com> References: <20230421-fp4-bluetooth-v1-0-0430e3a7e0a2@fairphone.com> In-Reply-To: <20230421-fp4-bluetooth-v1-0-0430e3a7e0a2@fairphone.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Balakrishna Godavarthi , Rocky Liao , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , Andy Gross , Bjorn Andersson , Konrad Dybcio Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org, Luca Weiss X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for the Bluetooth chip codenamed APACHE which is part of WCN3988. The firmware for this chip has a slightly different naming scheme compared to most others. For ROM Version 0x0200 we need to use apbtfw10.tlv + apnv10.bin and for ROM version 0x201 apbtfw11.tlv + apnv11.bin Signed-off-by: Luca Weiss --- drivers/bluetooth/btqca.c | 13 +++++++++++-- drivers/bluetooth/btqca.h | 12 ++++++++++-- drivers/bluetooth/hci_qca.c | 12 ++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c index fd0941fe8608..3ee1ef88a640 100644 --- a/drivers/bluetooth/btqca.c +++ b/drivers/bluetooth/btqca.c @@ -594,14 +594,20 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, /* Firmware files to download are based on ROM version. * ROM version is derived from last two bytes of soc_ver. */ - rom_ver = ((soc_ver & 0x00000f00) >> 0x04) | (soc_ver & 0x0000000f); + if (soc_type == QCA_WCN3988) + rom_ver = ((soc_ver & 0x00000f00) >> 0x05) | (soc_ver & 0x0000000f); + else + rom_ver = ((soc_ver & 0x00000f00) >> 0x04) | (soc_ver & 0x0000000f); if (soc_type == QCA_WCN6750) qca_send_patch_config_cmd(hdev); /* Download rampatch file */ config.type = TLV_TYPE_PATCH; - if (qca_is_wcn399x(soc_type)) { + if (soc_type == QCA_WCN3988) { + snprintf(config.fwname, sizeof(config.fwname), + "qca/apbtfw%02x.tlv", rom_ver); + } else if (qca_is_wcn399x(soc_type)) { snprintf(config.fwname, sizeof(config.fwname), "qca/crbtfw%02x.tlv", rom_ver); } else if (soc_type == QCA_QCA6390) { @@ -636,6 +642,9 @@ 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 (soc_type == QCA_WCN3988) + snprintf(config.fwname, sizeof(config.fwname), + "qca/apnv%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), diff --git a/drivers/bluetooth/btqca.h b/drivers/bluetooth/btqca.h index b884095bcd9d..fc6cf314eb0e 100644 --- a/drivers/bluetooth/btqca.h +++ b/drivers/bluetooth/btqca.h @@ -142,6 +142,7 @@ enum qca_btsoc_type { QCA_INVALID = -1, QCA_AR3002, QCA_ROME, + QCA_WCN3988, QCA_WCN3990, QCA_WCN3998, QCA_WCN3991, @@ -162,8 +163,15 @@ int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); int qca_send_pre_shutdown_cmd(struct hci_dev *hdev); static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type) { - return soc_type == QCA_WCN3990 || soc_type == QCA_WCN3991 || - soc_type == QCA_WCN3998; + switch (soc_type) { + case QCA_WCN3988: + case QCA_WCN3990: + case QCA_WCN3991: + case QCA_WCN3998: + return true; + default: + return false; + } } static inline bool qca_is_wcn6750(enum qca_btsoc_type soc_type) { diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 1597797ff169..96b837410a6b 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -1835,6 +1835,17 @@ static const struct hci_uart_proto qca_proto = { .dequeue = qca_dequeue, }; +static const struct qca_device_data qca_soc_data_wcn3988 __maybe_unused = { + .soc_type = QCA_WCN3988, + .vregs = (struct qca_vreg []) { + { "vddio", 15000 }, + { "vddxo", 80000 }, + { "vddrf", 300000 }, + { "vddch0", 450000 }, + }, + .num_vregs = 4, +}; + static const struct qca_device_data qca_soc_data_wcn3990 __maybe_unused = { .soc_type = QCA_WCN3990, .vregs = (struct qca_vreg []) { @@ -2359,6 +2370,7 @@ static const struct of_device_id qca_bluetooth_of_match[] = { { .compatible = "qcom,qca6174-bt" }, { .compatible = "qcom,qca6390-bt", .data = &qca_soc_data_qca6390}, { .compatible = "qcom,qca9377-bt" }, + { .compatible = "qcom,wcn3988-bt", .data = &qca_soc_data_wcn3988}, { .compatible = "qcom,wcn3990-bt", .data = &qca_soc_data_wcn3990}, { .compatible = "qcom,wcn3991-bt", .data = &qca_soc_data_wcn3991}, { .compatible = "qcom,wcn3998-bt", .data = &qca_soc_data_wcn3998}, -- 2.40.0