Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5433266pxu; Thu, 22 Oct 2020 02:04:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcWtAuWmZO3zHkiwpx4IBlwk95CknYVZGSVt8h6uQ/JjCKygT84ogd0FiBgxldyXuLJadv X-Received: by 2002:a17:907:2090:: with SMTP id pv16mr1255620ejb.506.1603357485259; Thu, 22 Oct 2020 02:04:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603357485; cv=none; d=google.com; s=arc-20160816; b=G5oFEEUXGC+BLg8v+bOl1uWRuZ/qSl+m0oE10gk5tM9JBgS6AJJTKzGM2GeMtfx5Hr /7MWN+mnFxX2hEWnqkX/lyPVLhyYs3UHWdW8KibMUDMhI6E521ungriRA2XJOholf62N qmHL5rAECtZj2Ug32FkUliSMd56Ss3MLrES6PuBJLDpZj3J5NNG1dh8sEqa1x/sJ5d9o sUFSDuR9Zk0WKpkqixxaPbjO+PLBIIKUsBPFbQsNvmhf4KRz4yBU6zsDdgn4RRqd0+vs QF4vp/vzGwjqwMqoEaaVrnlBNeMsYSmgznj5qa2q8SbdROi9WVscGrTr2GvdV/PoPZaX r93g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=wiNgrnZtCuvQcb5zEd4xakXVaM2f+04392e0eDjTsuY=; b=Saj0Sk9AstXGJh4u24JF4GNhHs+r414IcM+dtZ2HNskGxEHOxuaUpSxS/RbKWhRzyd 6UYxwHaZrpNf8x0AjzwWnG1d32HfvyWBiTPsC+KLGXZvpQz04RyREu7sfr6ydJCL0keN yv5Z5s61C09dxMr2li62xf+oXYlU83akOCKrqwByQ9JRkVeeDkpz3ioGrmMofIkAfV4g 64qrjCcb0yPNVatn3c3guCGiahzw/fy1PsIF9NLwHUtGZfOfKGYBrhdTISRjF9zAFsEM DjBw/gN9bhvkqehzHr5K3HHlJapsSj00ikIqBiTZwtLcPh9WHY8ngNqQIlapUvX7qGNF WHAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="U/uHaqjv"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si702572edu.343.2020.10.22.02.04.21; Thu, 22 Oct 2020 02:04:45 -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=@gmail.com header.s=20161025 header.b="U/uHaqjv"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2894829AbgJVITQ (ORCPT + 99 others); Thu, 22 Oct 2020 04:19:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2443979AbgJVITP (ORCPT ); Thu, 22 Oct 2020 04:19:15 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3167FC0613CE for ; Thu, 22 Oct 2020 01:19:14 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id t22so549243plr.9 for ; Thu, 22 Oct 2020 01:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wiNgrnZtCuvQcb5zEd4xakXVaM2f+04392e0eDjTsuY=; b=U/uHaqjvtQ5GugBE0/xgJv0UnnDKE24y/giRqg6kYooOXfTj80ZIUmj/EwlymUBKi/ 59fUBl2qscvvb3UhmbudDuSXF69ZxmFDg9Js7KOnggHRu0rribzitnVp+ovmkd6IzPGp tbDDiKKmA+fWraRMO3LDqNzTP6jMbWUaii7yB4jMhuqYFvUOpsyTBaM6QfEswK9RLZYm kYoRDwrW9L7hrpEeCG5ifCYqang3KGbSAu6oorIlHzAiHEZIgkkG9ud4kSWJOij0xNtP 7w4qtwLfMc8ARUtZkU7UtuK+bumCE1isJXNU5RPP+UluHTQZKOk9W0MzpFtL5ky5FChX 7Z+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wiNgrnZtCuvQcb5zEd4xakXVaM2f+04392e0eDjTsuY=; b=KsdVkv91U49RWsr6c+MjbUSW8XSLYYLyEjsJtXFEOhwBpBwhaLeg5gflcR++wByuot KND2ePmUPES8PIHF8iz1vJ9hnFPrZudsoQixSNwT7BFSUZLloHVrC/sKhC1HFbnSTPsg V7SCKfySXdJ6EZeQlMuOFoxNZ39Xak8o+4DyBEIHoh66nbhpu52PRsxyFzZxPrSS8Q+6 sJPdMm15cl2zCbw9uAtJgMaB4Pvx7NedjoioyW8DhAEDzMuDa7uA0cGmQgZW228/mlWy kWnk2JYsdDGqANDg11mmVnElZ4pqlL8nDbvuI+izmdAk0x5h7cs2vWk6Zeg6iRVTimO3 qhsQ== X-Gm-Message-State: AOAM530lqNeOnnySKWAZGyn/63QSPe6HS7Vr8SR6HA8yFPYtgnlPewWi fFwdm+oHRDdl4RusLAderMpDsFpgE+8ixl+8 X-Received: by 2002:a17:902:5581:b029:d5:ff8e:18e5 with SMTP id g1-20020a1709025581b02900d5ff8e18e5mr1442718pli.36.1603354753485; Thu, 22 Oct 2020 01:19:13 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([134.134.137.79]) by smtp.gmail.com with ESMTPSA id j5sm1179514pjb.56.2020.10.22.01.19.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2020 01:19:13 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: chethan.tumkur.narayan@intel.com, ravishankar.srivatsa@intel.com, kiran.k@intel.com, Sathish Narasimman Subject: [PATCH 2/3] Bluetooth: btintel: Introducing new btintel read version Date: Thu, 22 Oct 2020 13:54:34 +0530 Message-Id: <20201022082435.31831-3-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201022082435.31831-1-sathish.narasimman@intel.com> References: <20201022082435.31831-1-sathish.narasimman@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org The new btintel read version supports the latest intel read version command and also supports the TLV structure parsing. It still handles the legacy read version Signed-off-by: Sathish Narasimman --- drivers/bluetooth/btintel.c | 51 +++++++++++++++++++++++++++++++++++++ drivers/bluetooth/btintel.h | 15 +++++++++++ 2 files changed, 66 insertions(+) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index cc8e6c4e3205..ddd3c4bbdd6f 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -476,6 +476,57 @@ static void btintel_parse_tlv(struct sk_buff *skb, } } +int btintel_read_version_new(struct hci_dev *hdev, struct btintel_version *ver) +{ + struct sk_buff *skb; + struct intel_version *version = &ver->ver; + const u8 param[1] = { 0xFF }; + + skb = __hci_cmd_sync(hdev, 0xfc05, 1, param, HCI_CMD_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "Reading Intel version info failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + + if (skb->data[0]) { + bt_dev_err(hdev, "Intel Read Version command failed (%02x)", + skb->data[0]); + kfree_skb(skb); + return -EIO; + } + + /* The new Intel read version is backward compatible for Thp and CcP + * type cards. when the controller is in bootloader mode the controller + * response remains same as old intel_read version. For ThP/CcP cards + * TLV stucture supports only during the Operation Mode. The best way + * to differentiate the read_version response is to check the length + * parameter and first byte of the payload, which is a fixed value. + * After the status parameter if the payload starts with 0x37(This is + * a fixed value) and length of the payload is 10 then it is identified + * as legacy struct intel_version. In the latest firmweare the support + * of TLV structure is added during Operational Firmware. + */ + if (skb->len == sizeof(*version) && skb->data[1] == 0x37) { + memcpy(version, skb->data, sizeof(*version)); + ver->tlv_format = false; + goto finish; + } + + /* Consume Command Complete Status field */ + skb_pull(skb, 1); + + ver->tlv_format = true; + + bt_dev_info(hdev, "Parsing TLV Supported intel read version"); + btintel_parse_tlv(skb, &ver->ver_tlv); + +finish: + kfree_skb(skb); + return 0; +} +EXPORT_SYMBOL_GPL(btintel_read_version_new); + int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *version) { struct sk_buff *skb; diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index 09346ae308eb..08406ef935a3 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -132,6 +132,14 @@ struct intel_debug_features { __u8 page1[16]; } __packed; +struct btintel_version { + bool tlv_format; + union { + struct intel_version ver; /*Legacy Intel read version*/ + struct intel_version_tlv ver_tlv; + }; +}; + #if IS_ENABLED(CONFIG_BT_INTEL) int btintel_check_bdaddr(struct hci_dev *hdev); @@ -151,6 +159,7 @@ int btintel_set_event_mask(struct hci_dev *hdev, bool debug); int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug); int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver); int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *ver); +int btintel_read_version_new(struct hci_dev *hdev, struct btintel_version *ver); struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read, u16 opcode_write); @@ -248,6 +257,12 @@ static inline int btintel_read_version_tlv(struct hci_dev *hdev, return -EOPNOTSUPP; } +static inline int btintel_read_version_new(struct hci_dev *hdev, + struct btintel_version *ver) +{ + return -EOPNOTSUPP; +} + static inline struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read, u16 opcode_write) -- 2.17.1