HID: intel-ish-hid: Implement loading firmware from host feature
authorZhang Lixu <lixu.zhang@intel.com>
Mon, 6 May 2024 01:30:39 +0000 (09:30 +0800)
committerJiri Kosina <jkosina@suse.com>
Mon, 6 May 2024 21:33:54 +0000 (23:33 +0200)
commit579a267e4617d705f6c795e5e755b01f1f87eff3
tree84d2200ddbf935bf0da2a8a2deace5d2a7d0316e
parent6b2a374adfa8b58e2da2ca07245c2774fd6ea9b4
HID: intel-ish-hid: Implement loading firmware from host feature

Starting from the Lunar Lake generation, the ISH firmware has been
divided into two components for better space optimization and increased
flexibility. These components include a bootloader that is integrated
into the BIOS, and a main firmware that is stored within the operating
system's file system.

Introduce support for loading ISH main firmware from host. This feature is
applicable for Lunar Lake and later generation.

Current intel-ishtp-loader, is designed for Chrome OS based systems which
uses core boot and has different firmware loading method. For non chrome
systems the ISH firmware loading uses different method.

Key differences include:
1. The new method utilizes ISHTP capability/fixed client to enumerate the
firmware loader function. It does not require a connection or flow control,
unlike the method used in Chrome OS, which is enumerated as an ISHTP
dynamic client driver, necessitating connect/disconnect operations and flow
control.

2. The new method employs a table to describe firmware fragments, which are
sent to ISH in a single operation. Conversely, the Chrome OS method sends
firmware fragments in multiple operations within a loop, sending only one
fragment at a time.

Additionally, address potential error scenarios to ensure graceful failure
handling.
- Firmware Not Found: Triggers if request_firmware() fails, leaving ISH in
  a waiting state.
  Recovery: Re-insmod the ISH drivers to retry.

- DMA Buffer Allocation Failure: Occurs during prepare_dma_bufs(), leading
  to ISH waiting state. Allocated resources are released.
  Recovery: Re-insmod the ISH drivers to retry.

- Incorrect Firmware Image: Causes ISH to refuse loading after three failed
  attempts.
  Recovery: A platform reset is required.

Please refer to the [Documentation](Documentation/hid/intel-ish-hid.rst)
for the details on flows.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
drivers/hid/intel-ish-hid/Makefile
drivers/hid/intel-ish-hid/ishtp/hbm.c
drivers/hid/intel-ish-hid/ishtp/init.c
drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h
drivers/hid/intel-ish-hid/ishtp/loader.c [new file with mode: 0644]
drivers/hid/intel-ish-hid/ishtp/loader.h [new file with mode: 0644]