hid: intel-ish-hid: Add support for vendor customized firmware loading
Subsystems (3)
v2 cover hid: intel-ish-hid: Add support for vendor customized firmware loading
This patch series adds the capability to load vendor-specific customized firmware. The loader now constructs firmware file names based on the DMI_SYS_VENDOR, DMI_PRODUCT_NAME, and DMI_PRODUCT_SKU information in Desktop Management Interface (DMI). The loader will attempt to load the firmware files following a specific naming convention in sequence. If successful, it will skip the remaining files.
v2:
- Address the review comments from [email protected] Fix the typo and capitalization, remove unnecessary inline.
Zhang Lixu (3):
Documentation: hid: intel-ish-hid: Add vendor custom firmware loading
HID: intel-ish-hid: Use CPU generation string in driver_data
hid: intel-ish-hid: Add support for vendor customized firmware loading
Documentation/hid/intel-ish-hid.rst | 29 +++++ drivers/hid/intel-ish-hid/ipc/pci-ish.c | 10 +- drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h | 8 +- drivers/hid/intel-ish-hid/ishtp/loader.c | 121 +++++++++++++++++++- 4 files changed, 159 insertions(+), 9 deletions(-)
base-commit: 9e6869691724b12e1f43655eeedc35fade38120c
Signature · 1 line
2.34.1
PATCH v2 1/3 Documentation: hid: intel-ish-hid: Add vendor custom firmware loading
Add ISH firmware loading guidelines for vendor custom firmware.
--- Documentation/hid/intel-ish-hid.rst | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
Documentation/hid/intel-ish-hid.rst +29 -0
@@ -404,6 +404,35 @@ For more detailed information, please refer to the flow descriptions provided be | ISHTP Driver | | ISH Bootloader | +---------------+ +-----------------+ +Vendor Custom Firmware Loading +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The firmware running inside ISH can be provided by Intel or developed by vendors using the Firmware Development Kit (FDK) provided by Intel. +Intel will upstream the Intel-built firmware to the ``linux-firmware.git`` repository, located under the path ``intel/ish/``. For the Lunar Lake platform, the Intel-built ISH firmware will be named ``ish_lnlm.bin``. +Vendors who wish to upstream their custom firmware should follow these guidelines for naming their firmware files: + +- The firmware filename should use one of the following patterns: + + - ``ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}_${PRODUCT_NAME_CRC32}_${PRODUCT_SKU_CRC32}.bin`` + - ``ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}_${PRODUCT_SKU_CRC32}.bin`` + - ``ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}_${PRODUCT_NAME_CRC32}.bin`` + - ``ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}.bin`` + +- ``${intel_plat_gen}`` indicates the Intel platform generation (e.g., ``lnlm`` for Lunar Lake) and must not exceed 8 characters in length. +- ``${SYS_VENDOR_CRC32}`` is the CRC32 checksum of the ``sys_vendor`` value from the DMI field ``DMI_SYS_VENDOR``. +- ``${PRODUCT_NAME_CRC32}`` is the CRC32 checksum of the ``product_name`` value from the DMI field ``DMI_PRODUCT_NAME``. +- ``${PRODUCT_SKU_CRC32}`` is the CRC32 checksum of the ``product_sku`` value from the DMI field ``DMI_PRODUCT_SKU``. + +During system boot, the ISH Linux driver will attempt to load the firmware in the following order, prioritizing custom firmware with more precise matching patterns: + +1. ``intel/ish/ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}_${PRODUCT_NAME_CRC32}_${PRODUCT_SKU_CRC32}.bin`` +2. ``intel/ish/ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}_${PRODUCT_SKU_CRC32}.bin`` +3. ``intel/ish/ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}_${PRODUCT_NAME_CRC32}.bin`` +4. ``intel/ish/ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}.bin`` +5. ``intel/ish/ish_${intel_plat_gen}.bin`` + +The driver will load the first matching firmware and skip the rest. If no matching firmware is found, it will proceed to the next pattern in the specified order. If all searches fail, the default Intel firmware, listed last in the order above, will be loaded. + ISH Debugging -------------
Signature · 1 line
2.34.1
PATCH v2 2/3 HID: intel-ish-hid: Use CPU generation string in driver_data
In reply to Zhang LixuISH allows vendors to customize ISH firmware. To differentiate different vendors and load the correct firmware, Intel defined a firmware file name format. As part of the filename, there is a "generation" string. To load correct format the driver must know the generation name to create file name.
In the absence of any vendor specific firmware, default ISH firmware is loaded.
Currently full ISH firmware file name is stored as part of driver data. This file name already includes the generation name. For example, for Lunar Lake, the name is ish_lnlm.bin, where "lnlm" is the generation.
So instead of storing both generation name and ISH default firmware file name, just store generation name and create the default ISH firmware file name string during initialization.
No functional changes are expected.
--- drivers/hid/intel-ish-hid/ipc/pci-ish.c | 8 ++++--- drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h | 8 ++++--- drivers/hid/intel-ish-hid/ishtp/loader.c | 23 ++++++++++++++++++--- 3 files changed, 30 insertions(+), 9 deletions(-)
drivers/hid/intel-ish-hid/ipc/pci-ish.c +5 -3
@@ -28,11 +28,13 @@ enum ishtp_driver_data_index { ISHTP_DRIVER_DATA_LNL_M, }; -#define ISH_FW_FILENAME_LNL_M "intel/ish/ish_lnlm.bin" +#define ISH_FW_GEN_LNL_M "lnlm" + +#define ISH_FIRMWARE_PATH (gen) "intel/ish/ish_" gen ".bin"static struct ishtp_driver_data ishtp_driver_data[] = { [ISHTP_DRIVER_DATA_LNL_M ] = { - .fw_filename =ISH_FW_FILENAME_LNL_M , + .fw_generation =ISH_FW_GEN_LNL_M , }, };
@@ -397,4 +399,4 @@ MODULE_AUTHOR("Srinivas Pandruvada <[email protected]>");MODULE_DESCRIPTION ("Intel(R) Integrated Sensor Hub PCI Device Driver" );MODULE_LICENSE ("GPL" ); -MODULE_FIRMWARE (ISH_FW_FILENAME_LNL_M ); +MODULE_FIRMWARE (ISH_FIRMWARE_PATH (ISH_FW_GEN_LNL_M ));
drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h +5 -3
@@ -129,13 +129,15 @@ struct ishtp_hw_ops {* ISHTP device instance. It allows for the storage of data that is unique to * a particular driver or hardware variant. * -* @fw_filename: The firmware filename associated with a specific hardware +* @fw_generation: The generation name associated with a specific hardware * variant of the Intel Integrated Sensor Hub (ISH). This allows * the driver to load the correct firmware based on the device's -* hardware variant. +* hardware variant. For example, "lnlm" for the Lunar Lake-M +* platform. The generation name must not exceed 8 characters +* in length. */ struct ishtp_driver_data { -char *fw_filename; +char *fw_generation; };/**
drivers/hid/intel-ish-hid/ishtp/loader.c +20 -3
@@ -43,6 +43,7 @@#include <linux/math.h> #include <linux/module.h> #include <linux/pfn.h> +#include <linux/sprintf.h> #include <linux/string.h> #include <linux/types.h> #include <linux/wait.h>
@@ -192,6 +193,23 @@ static int prepare_dma_bufs(struct ishtp_device *dev,return 0 ; } +#define ISH_FW_FILE_DEFAULT_FMT "intel/ish/ish_%s.bin" + +#define ISH_FW_FILENAME_LEN_MAX 56 + +static int request_ish_firmware (const struct firmware **firmware_p, +struct device *dev) +{ +struct ishtp_device *ishtp =dev_get_drvdata (dev); +const char *gen; +char filename[ISH_FW_FILENAME_LEN_MAX ]; + + gen = ishtp->driver_data->fw_generation; +snprintf (filename,sizeof (filename),ISH_FW_FILE_DEFAULT_FMT , gen); + +return request_firmware (firmware_p, filename, dev); +} +/** * ishtp_loader_work() - Load the ISHTP firmware * @work: The work structure
@@ -220,7 +238,6 @@ void ishtp_loader_work(struct work_struct *work)struct loader_xfer_query query = { .header =cpu_to_le32 (query_hdr.val32), };struct loader_start start = { .header =cpu_to_le32 (start_hdr.val32), };union loader_recv_message recv_msg; -char *filename = dev->driver_data->fw_filename;const struct firmware *ish_fw;void *dma_bufs[FRAGMENT_MAX_NUM ] = {};u32 fragment_size;
@@ -228,9 +245,9 @@ void ishtp_loader_work(struct work_struct *work)int retry =ISHTP_LOADER_RETRY_TIMES ;int rv; - rv =request_firmware (&ish_fw, filename, dev->devc); + rv =request_ish_firmware (&ish_fw, dev->devc);if (rv <0 ) { -dev_err (dev->devc,"request firmware %s failed:%d\n" , filename, rv); +dev_err (dev->devc,"request ISH firmware failed:%d\n" , rv);return ; }
Signature · 1 line
2.34.1
PATCH v2 3/3 hid: intel-ish-hid: Add support for vendor customized firmware loading
In reply to Zhang LixuEnhance the firmware loader to support the loading of vendor-specific customized firmware for the Intel Integrated Sensor Hub (ISH). The loader now constructs firmware file names based on the DMI_SYS_VENDOR, DMI_PRODUCT_NAME, and DMI_PRODUCT_SKU information in Desktop Management Interface (DMI). The loader will attempt to load the firmware files following a specific naming convention in sequence. If successful, it will skip the remaining files.
For more details, please refer to Documentation/hid/intel-ish-hid.rst.
--- drivers/hid/intel-ish-hid/ipc/pci-ish.c | 2 + drivers/hid/intel-ish-hid/ishtp/loader.c | 104 ++++++++++++++++++++++- 2 files changed, 103 insertions(+), 3 deletions(-)
drivers/hid/intel-ish-hid/ipc/pci-ish.c +2 -0
@@ -31,6 +31,7 @@ enum ishtp_driver_data_index {#define ISH_FW_GEN_LNL_M "lnlm"#define ISH_FIRMWARE_PATH (gen) "intel/ish/ish_" gen ".bin" +#define ISH_FIRMWARE_PATH_ALL "intel/ish/ish_*.bin"static struct ishtp_driver_data ishtp_driver_data[] = { [ISHTP_DRIVER_DATA_LNL_M ] = {
@@ -400,3 +401,4 @@ MODULE_DESCRIPTION("Intel(R) Integrated Sensor Hub PCI Device Driver");MODULE_LICENSE ("GPL" );MODULE_FIRMWARE (ISH_FIRMWARE_PATH (ISH_FW_GEN_LNL_M )); +MODULE_FIRMWARE (ISH_FIRMWARE_PATH_ALL );
drivers/hid/intel-ish-hid/ishtp/loader.c +101 -3
130 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 7 lines · Zhang Lixu
This patch series adds the capability to load vendor-specific customized firmware. The loader now constructs firmware file names based on the
DMI_SYS_VENDOR,DMI_PRODUCT_NAME, andDMI_PRODUCT_SKUinformation in Desktop Management Interface (DMI). The loader will attempt to load the firmware files following a specific naming convention in sequence. If successful, it will skip the remaining files.
Quoted 8 lines
v2:
- Address the review comments from [email protected] Fix the typo and capitalization, remove unnecessary inline.Zhang Lixu (3):
Documentation: hid: intel-ish-hid: Add vendor custom firmware loading
HID: intel-ish-hid: Use CPU generation string indriver_data
hid: intel-ish-hid: Add support for vendor customized firmware loading
Applied to hid.git#for-6.12/intel-ish
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs