162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci====================
462306a36Sopenharmony_ciiosm devlink support
562306a36Sopenharmony_ci====================
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciThis document describes the devlink features implemented by the ``iosm``
862306a36Sopenharmony_cidevice driver.
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciParameters
1162306a36Sopenharmony_ci==========
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciThe ``iosm`` driver implements the following driver-specific parameters.
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci.. list-table:: Driver-specific parameters implemented
1662306a36Sopenharmony_ci   :widths: 5 5 5 85
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci   * - Name
1962306a36Sopenharmony_ci     - Type
2062306a36Sopenharmony_ci     - Mode
2162306a36Sopenharmony_ci     - Description
2262306a36Sopenharmony_ci   * - ``erase_full_flash``
2362306a36Sopenharmony_ci     - u8
2462306a36Sopenharmony_ci     - runtime
2562306a36Sopenharmony_ci     - erase_full_flash parameter is used to check if full erase is required for
2662306a36Sopenharmony_ci       the device during firmware flashing.
2762306a36Sopenharmony_ci       If set, Full nand erase command will be sent to the device. By default,
2862306a36Sopenharmony_ci       only conditional erase support is enabled.
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ciFlash Update
3262306a36Sopenharmony_ci============
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ciThe ``iosm`` driver implements support for flash update using the
3562306a36Sopenharmony_ci``devlink-flash`` interface.
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ciIt supports updating the device flash using a combined flash image which contains
3862306a36Sopenharmony_cithe Bootloader images and other modem software images.
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ciThe driver uses DEVLINK_SUPPORT_FLASH_UPDATE_COMPONENT to identify type of
4162306a36Sopenharmony_cifirmware image that need to be flashed as requested by user space application.
4262306a36Sopenharmony_ciSupported firmware image types.
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci.. list-table:: Firmware Image types
4562306a36Sopenharmony_ci    :widths: 15 85
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci    * - Name
4862306a36Sopenharmony_ci      - Description
4962306a36Sopenharmony_ci    * - ``PSI RAM``
5062306a36Sopenharmony_ci      - Primary Signed Image
5162306a36Sopenharmony_ci    * - ``EBL``
5262306a36Sopenharmony_ci      - External Bootloader
5362306a36Sopenharmony_ci    * - ``FLS``
5462306a36Sopenharmony_ci      - Modem Software Image
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ciPSI RAM and EBL are the RAM images which are injected to the device when the
5762306a36Sopenharmony_cidevice is in BOOT ROM stage. Once this is successful, the actual modem firmware
5862306a36Sopenharmony_ciimage is flashed to the device. The modem software image contains multiple files
5962306a36Sopenharmony_cieach having one secure bin file and at least one Loadmap/Region file. For flashing
6062306a36Sopenharmony_cithese files, appropriate commands are sent to the modem device along with the
6162306a36Sopenharmony_cidata required for flashing. The data like region count and address of each region
6262306a36Sopenharmony_cihas to be passed to the driver using the devlink param command.
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ciIf the device has to be fully erased before firmware flashing, user application
6562306a36Sopenharmony_cineed to set the erase_full_flash parameter using devlink param command.
6662306a36Sopenharmony_ciBy default, conditional erase feature is supported.
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ciFlash Commands:
6962306a36Sopenharmony_ci===============
7062306a36Sopenharmony_ci1) When modem is in Boot ROM stage, user can use below command to inject PSI RAM
7162306a36Sopenharmony_ciimage using devlink flash command.
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci$ devlink dev flash pci/0000:02:00.0 file <PSI_RAM_File_name>
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci2) If user want to do a full erase, below command need to be issued to set the
7662306a36Sopenharmony_cierase full flash param (To be set only if full erase required).
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci$ devlink dev param set pci/0000:02:00.0 name erase_full_flash value true cmode runtime
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci3) Inject EBL after the modem is in PSI stage.
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci$ devlink dev flash pci/0000:02:00.0 file <EBL_File_name>
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci4) Once EBL is injected successfully, then the actual firmware flashing takes
8562306a36Sopenharmony_ciplace. Below is the sequence of commands used for each of the firmware images.
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_cia) Flash secure bin file.
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci$ devlink dev flash pci/0000:02:00.0 file <Secure_bin_file_name>
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_cib) Flashing the Loadmap/Region file
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci$ devlink dev flash pci/0000:02:00.0 file <Load_map_file_name>
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ciRegions
9662306a36Sopenharmony_ci=======
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ciThe ``iosm`` driver supports dumping the coredump logs.
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ciIn case a firmware encounters an exception, a snapshot will be taken by the
10162306a36Sopenharmony_cidriver. Following regions are accessed for device internal data.
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci.. list-table:: Regions implemented
10462306a36Sopenharmony_ci    :widths: 15 85
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci    * - Name
10762306a36Sopenharmony_ci      - Description
10862306a36Sopenharmony_ci    * - ``report.json``
10962306a36Sopenharmony_ci      - The summary of exception details logged as part of this region.
11062306a36Sopenharmony_ci    * - ``coredump.fcd``
11162306a36Sopenharmony_ci      - This region contains the details related to the exception occurred in the
11262306a36Sopenharmony_ci        device (RAM dump).
11362306a36Sopenharmony_ci    * - ``cdd.log``
11462306a36Sopenharmony_ci      - This region contains the logs related to the modem CDD driver.
11562306a36Sopenharmony_ci    * - ``eeprom.bin``
11662306a36Sopenharmony_ci      - This region contains the eeprom logs.
11762306a36Sopenharmony_ci    * - ``bootcore_trace.bin``
11862306a36Sopenharmony_ci      -  This region contains the current instance of bootloader logs.
11962306a36Sopenharmony_ci    * - ``bootcore_prev_trace.bin``
12062306a36Sopenharmony_ci      - This region contains the previous instance of bootloader logs.
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ciRegion commands
12462306a36Sopenharmony_ci===============
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci$ devlink region show
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci$ devlink region new pci/0000:02:00.0/report.json
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci$ devlink region dump pci/0000:02:00.0/report.json snapshot 0
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci$ devlink region del pci/0000:02:00.0/report.json snapshot 0
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci$ devlink region new pci/0000:02:00.0/coredump.fcd
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci$ devlink region dump pci/0000:02:00.0/coredump.fcd snapshot 1
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci$ devlink region del pci/0000:02:00.0/coredump.fcd snapshot 1
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci$ devlink region new pci/0000:02:00.0/cdd.log
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci$ devlink region dump pci/0000:02:00.0/cdd.log snapshot 2
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci$ devlink region del pci/0000:02:00.0/cdd.log snapshot 2
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci$ devlink region new pci/0000:02:00.0/eeprom.bin
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci$ devlink region dump pci/0000:02:00.0/eeprom.bin snapshot 3
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci$ devlink region del pci/0000:02:00.0/eeprom.bin snapshot 3
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ci$ devlink region new pci/0000:02:00.0/bootcore_trace.bin
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ci$ devlink region dump pci/0000:02:00.0/bootcore_trace.bin snapshot 4
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci$ devlink region del pci/0000:02:00.0/bootcore_trace.bin snapshot 4
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci$ devlink region new pci/0000:02:00.0/bootcore_prev_trace.bin
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ci$ devlink region dump pci/0000:02:00.0/bootcore_prev_trace.bin snapshot 5
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci$ devlink region del pci/0000:02:00.0/bootcore_prev_trace.bin snapshot 5
163