All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kiran K <kiran.k@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: ravishankar.srivatsa@intel.com, kiraank@gmail.com,
	Kiran K <kiran.k@intel.com>,
	Raghuram Hegde <raghuram.hegde@intel.com>,
	Chethan T N <chethan.tumkur.narayan@intel.com>,
	Amit K Bag <amit.k.bag@intel.com>
Subject: [PATCH 3/4] Bluetooth: btintel: Add helper functions to parse firmware name
Date: Thu, 11 Jun 2020 17:15:25 +0530	[thread overview]
Message-ID: <20200611114526.13594-4-kiran.k@intel.com> (raw)
In-Reply-To: <20200611114526.13594-1-kiran.k@intel.com>

From: Raghuram Hegde <raghuram.hegde@intel.com>

Define helper functions to construct firmware file name as the format of
legacy differs from new generation Intel controllers

Signed-off-by: Raghuram Hegde <raghuram.hegde@intel.com>
Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
Signed-off-by: Kiran K <kiran.k@intel.com>
Signed-off-by: Amit K Bag <amit.k.bag@intel.com>
---
 drivers/bluetooth/btintel.c | 75 +++++++++++++++++++++++++++++++++++++
 drivers/bluetooth/btintel.h |  6 +++
 2 files changed, 81 insertions(+)

diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c
index 0139857f6a2c..ae60527e1abd 100644
--- a/drivers/bluetooth/btintel.c
+++ b/drivers/bluetooth/btintel.c
@@ -382,6 +382,81 @@ int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug)
 }
 EXPORT_SYMBOL_GPL(btintel_set_event_mask_mfg);
 
+bool btintel_get_fw_name(struct intel_version *ver,
+			 struct intel_boot_params *params,
+			 char *fw_name, size_t len,
+			 const char *suffix)
+{
+	/* This is for legacy HCI_Intel_Read_Version command.
+	 *
+	 * With this Intel bootloader only the hardware variant and device
+	 * revision information are used to select the right firmware for SfP
+	 * and WsP.
+	 *
+	 * The firmware filename is ibt-<hw_variant>-<dev_revid>.sfi.
+	 *
+	 * Currently the supported hardware variants are:
+	 *   11 (0x0b) for iBT3.0 (LnP/SfP)
+	 *   12 (0x0c) for iBT3.5 (WsP)
+	 *
+	 * For ThP/JfP and for future SKU's, the FW name varies based on HW
+	 * variant, HW revision and FW revision, as these are dependent on CNVi
+	 * and RF Combination.
+	 *
+	 *   17 (0x11) for iBT3.5 (JfP)
+	 *   18 (0x12) for iBT3.5 (ThP)
+	 *
+	 * The firmware file name for these will be
+	 * ibt-<hw_variant>-<hw_revision>-<fw_revision>.sfi.
+	 *
+	 */
+
+	switch (ver->hw_variant) {
+	case 0x0b:	/* SfP */
+	case 0x0c:	/* WsP */
+		snprintf(fw_name, len, "intel/ibt-%u-%u.%s",
+			 le16_to_cpu(ver->hw_variant),
+			 le16_to_cpu(params->dev_revid),
+			 suffix);
+		break;
+	case 0x11:	/* JfP */
+	case 0x12:	/* ThP */
+	case 0x13:	/* HrP */
+	case 0x14:	/* CcP */
+		snprintf(fw_name, len, "intel/ibt-%u-%u-%u.%s",
+			 le16_to_cpu(ver->hw_variant),
+			 le16_to_cpu(ver->hw_revision),
+			 le16_to_cpu(ver->fw_revision),
+			 suffix);
+		break;
+	default:
+		return false;
+	}
+	return true;
+}
+EXPORT_SYMBOL_GPL(btintel_get_fw_name);
+
+void btintel_get_fw_name_tlv(struct intel_version_tlv *ver,
+			     char *fw_name, size_t len,
+			     const char *suffix)
+{
+	/* This is for legacy HCI_Intel_Read_Version command.
+	 * The firmware file name for these will be
+	 * ibt-<cnvi_top type+cnvi_top step>-<cnvr_top type+cnvr_top step>
+	 *
+	 * Currently the supported hardware variants are:
+	 * iBT4.2 23 (0x17) for TyP
+	 * iBT4.2 24 (0x18) for Solar
+	 */
+	snprintf(fw_name, len, "intel/ibt-%04x-%04x.%s",
+		 INTEL_CNVX_TOP_PACK_SWAB(INTEL_CNVX_TOP_TYPE(ver->cnvi_top),
+		 INTEL_CNVX_TOP_STEP(ver->cnvi_top)),
+		 INTEL_CNVX_TOP_PACK_SWAB(INTEL_CNVX_TOP_TYPE(ver->cnvr_top),
+		 INTEL_CNVX_TOP_STEP(ver->cnvr_top)),
+		 suffix);
+}
+EXPORT_SYMBOL_GPL(btintel_get_fw_name_tlv);
+
 int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver)
 {
 	struct sk_buff *skb;
diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h
index 32b2cd887bdd..fa4b1b801b13 100644
--- a/drivers/bluetooth/btintel.h
+++ b/drivers/bluetooth/btintel.h
@@ -106,6 +106,12 @@ struct intel_debug_features {
 	__u8    page1[16];
 } __packed;
 
+#define INTEL_CNVX_TOP_TYPE_MASK	0x00000fff
+#define INTEL_CNVX_TOP_STEP_MASK	0x0f000000
+#define INTEL_CNVX_TOP_TYPE(cnvx_top)	((cnvx_top) & INTEL_CNVX_TOP_TYPE_MASK)
+#define INTEL_CNVX_TOP_STEP(cnvx_top)	(((cnvx_top) & INTEL_CNVX_TOP_STEP_MASK) >> 24)
+#define INTEL_CNVX_TOP_PACK_SWAB(t, s)	__swab16(((__u16)(((t) << 4) | (s))))
+
 #if IS_ENABLED(CONFIG_BT_INTEL)
 
 int btintel_check_bdaddr(struct hci_dev *hdev);
-- 
2.17.1


  parent reply	other threads:[~2020-06-11 11:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-11 11:45 [PATCH 0/4] Add support for new generation Intel controllers Kiran K
2020-06-11 11:45 ` [PATCH 1/4] Bluetooth: btintel: Define tlv structure to enable firmware download Kiran K
2020-06-11 11:45 ` [PATCH 2/4] Bluetooth: btintel: Add helper functions to dump boot/firmware info Kiran K
2020-06-12  1:00   ` kernel test robot
2020-06-12  8:05   ` kernel test robot
2020-06-12  8:05     ` kernel test robot
2020-06-11 11:45 ` Kiran K [this message]
2020-06-11 20:25   ` [PATCH 3/4] Bluetooth: btintel: Add helper functions to parse firmware name kernel test robot
2020-06-11 20:25     ` kernel test robot
2020-06-12  9:42   ` kernel test robot
2020-06-12  9:42     ` kernel test robot
2020-06-11 11:45 ` [PATCH 4/4] Bluetooth: btintel: Add helper function to help controller type Kiran K
2020-06-12 11:26   ` kernel test robot
2020-06-12 11:26     ` kernel test robot
2020-07-02 13:25 ` [PATCH 0/4] Add support for new generation Intel controllers K, Kiran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200611114526.13594-4-kiran.k@intel.com \
    --to=kiran.k@intel.com \
    --cc=amit.k.bag@intel.com \
    --cc=chethan.tumkur.narayan@intel.com \
    --cc=kiraank@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=raghuram.hegde@intel.com \
    --cc=ravishankar.srivatsa@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.