Skip to content

Commit 6413615

Browse files
lixuzhaJiri Kosina
authored andcommitted
HID: intel-ish-hid: Use CPU generation string in driver_data
ISH 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. Signed-off-by: Zhang Lixu <[email protected]> Acked-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 87de161 commit 6413615

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

drivers/hid/intel-ish-hid/ipc/pci-ish.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ enum ishtp_driver_data_index {
2828
ISHTP_DRIVER_DATA_LNL_M,
2929
};
3030

31-
#define ISH_FW_FILENAME_LNL_M "intel/ish/ish_lnlm.bin"
31+
#define ISH_FW_GEN_LNL_M "lnlm"
32+
33+
#define ISH_FIRMWARE_PATH(gen) "intel/ish/ish_" gen ".bin"
3234

3335
static struct ishtp_driver_data ishtp_driver_data[] = {
3436
[ISHTP_DRIVER_DATA_LNL_M] = {
35-
.fw_filename = ISH_FW_FILENAME_LNL_M,
37+
.fw_generation = ISH_FW_GEN_LNL_M,
3638
},
3739
};
3840

@@ -397,4 +399,4 @@ MODULE_AUTHOR("Srinivas Pandruvada <[email protected]>");
397399
MODULE_DESCRIPTION("Intel(R) Integrated Sensor Hub PCI Device Driver");
398400
MODULE_LICENSE("GPL");
399401

400-
MODULE_FIRMWARE(ISH_FW_FILENAME_LNL_M);
402+
MODULE_FIRMWARE(ISH_FIRMWARE_PATH(ISH_FW_GEN_LNL_M));

drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,15 @@ struct ishtp_hw_ops {
129129
* ISHTP device instance. It allows for the storage of data that is unique to
130130
* a particular driver or hardware variant.
131131
*
132-
* @fw_filename: The firmware filename associated with a specific hardware
132+
* @fw_generation: The generation name associated with a specific hardware
133133
* variant of the Intel Integrated Sensor Hub (ISH). This allows
134134
* the driver to load the correct firmware based on the device's
135-
* hardware variant.
135+
* hardware variant. For example, "lnlm" for the Lunar Lake-M
136+
* platform. The generation name must not exceed 8 characters
137+
* in length.
136138
*/
137139
struct ishtp_driver_data {
138-
char *fw_filename;
140+
char *fw_generation;
139141
};
140142

141143
/**

drivers/hid/intel-ish-hid/ishtp/loader.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <linux/math.h>
4444
#include <linux/module.h>
4545
#include <linux/pfn.h>
46+
#include <linux/sprintf.h>
4647
#include <linux/string.h>
4748
#include <linux/types.h>
4849
#include <linux/wait.h>
@@ -192,6 +193,23 @@ static int prepare_dma_bufs(struct ishtp_device *dev,
192193
return 0;
193194
}
194195

196+
#define ISH_FW_FILE_DEFAULT_FMT "intel/ish/ish_%s.bin"
197+
198+
#define ISH_FW_FILENAME_LEN_MAX 56
199+
200+
static int request_ish_firmware(const struct firmware **firmware_p,
201+
struct device *dev)
202+
{
203+
struct ishtp_device *ishtp = dev_get_drvdata(dev);
204+
const char *gen;
205+
char filename[ISH_FW_FILENAME_LEN_MAX];
206+
207+
gen = ishtp->driver_data->fw_generation;
208+
snprintf(filename, sizeof(filename), ISH_FW_FILE_DEFAULT_FMT, gen);
209+
210+
return request_firmware(firmware_p, filename, dev);
211+
}
212+
195213
/**
196214
* ishtp_loader_work() - Load the ISHTP firmware
197215
* @work: The work structure
@@ -220,17 +238,16 @@ void ishtp_loader_work(struct work_struct *work)
220238
struct loader_xfer_query query = { .header = cpu_to_le32(query_hdr.val32), };
221239
struct loader_start start = { .header = cpu_to_le32(start_hdr.val32), };
222240
union loader_recv_message recv_msg;
223-
char *filename = dev->driver_data->fw_filename;
224241
const struct firmware *ish_fw;
225242
void *dma_bufs[FRAGMENT_MAX_NUM] = {};
226243
u32 fragment_size;
227244
u32 fragment_count;
228245
int retry = ISHTP_LOADER_RETRY_TIMES;
229246
int rv;
230247

231-
rv = request_firmware(&ish_fw, filename, dev->devc);
248+
rv = request_ish_firmware(&ish_fw, dev->devc);
232249
if (rv < 0) {
233-
dev_err(dev->devc, "request firmware %s failed:%d\n", filename, rv);
250+
dev_err(dev->devc, "request ISH firmware failed:%d\n", rv);
234251
return;
235252
}
236253

0 commit comments

Comments
 (0)