[PATCH 3/4] Bluetooth: btintel: Add helper functions to parse firmware name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Raghuram Hegde <raghuram.hegde@xxxxxxxxx>

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@xxxxxxxxx>
Signed-off-by: Chethan T N <chethan.tumkur.narayan@xxxxxxxxx>
Signed-off-by: Kiran K <kiran.k@xxxxxxxxx>
Signed-off-by: Amit K Bag <amit.k.bag@xxxxxxxxx>
---
 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




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux