From patchwork Thu Jun 11 11:45:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 11599781 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D36E1913 for ; Thu, 11 Jun 2020 11:44:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C57032081A for ; Thu, 11 Jun 2020 11:44:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727837AbgFKLo5 (ORCPT ); Thu, 11 Jun 2020 07:44:57 -0400 Received: from mga12.intel.com ([192.55.52.136]:26678 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727829AbgFKLo4 (ORCPT ); Thu, 11 Jun 2020 07:44:56 -0400 IronPort-SDR: kMpVEdw7/H/bqDiQPo75ILr2JlxYbpCjuDwoT6N6Pc7uyvu3x2dZRcqnEDfPAswf9JJF4lUuPt RCkKsWzkOVKQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2020 04:44:56 -0700 IronPort-SDR: vNQxPm7lbQ7Kbi4e+2MDNp3mpPpGOmuAsHWap/LXfnhD2d52DEkpMs/TDuQANipV+Pqb0b5eML MLolZX07r1aQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,499,1583222400"; d="scan'208";a="296562858" Received: from unknown (HELO intel-Lenovo-Legion-Y540-15IRH-PG0.iind.intel.com) ([10.224.186.95]) by fmsmga004.fm.intel.com with ESMTP; 11 Jun 2020 04:44:54 -0700 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, kiraank@gmail.com, Kiran K , Raghuram Hegde , Chethan T N , Amit K Bag Subject: [PATCH 3/4] Bluetooth: btintel: Add helper functions to parse firmware name Date: Thu, 11 Jun 2020 17:15:25 +0530 Message-Id: <20200611114526.13594-4-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200611114526.13594-1-kiran.k@intel.com> References: <20200611114526.13594-1-kiran.k@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Raghuram Hegde Define helper functions to construct firmware file name as the format of legacy differs from new generation Intel controllers Signed-off-by: Raghuram Hegde Signed-off-by: Chethan T N Signed-off-by: Kiran K Signed-off-by: Amit K Bag Reported-by: kernel test robot Reported-by: kernel test robot --- 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--.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---.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-- + * + * 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);