Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only
0002  *
0003  * Copyright (C) 2020-2021 Intel Corporation.
0004  */
0005 
0006 #ifndef _IOSM_IPC_FLASH_H
0007 #define _IOSM_IPC_FLASH_H
0008 
0009 /* Buffer size used to read the fls image */
0010 #define IOSM_FLS_BUF_SIZE 0x00100000
0011 /* Full erase start address */
0012 #define IOSM_ERASE_START_ADDR 0x00000000
0013 /* Erase length for NAND flash */
0014 #define IOSM_ERASE_LEN 0xFFFFFFFF
0015 /* EBL response Header size */
0016 #define IOSM_EBL_HEAD_SIZE  8
0017 /* EBL payload size */
0018 #define IOSM_EBL_W_PAYL_SIZE  2048
0019 /* Total EBL pack size */
0020 #define IOSM_EBL_W_PACK_SIZE  (IOSM_EBL_HEAD_SIZE + IOSM_EBL_W_PAYL_SIZE)
0021 /* EBL payload size */
0022 #define IOSM_EBL_DW_PAYL_SIZE  16384
0023 /* Total EBL pack size */
0024 #define IOSM_EBL_DW_PACK_SIZE  (IOSM_EBL_HEAD_SIZE + IOSM_EBL_DW_PAYL_SIZE)
0025 /* EBL name size */
0026 #define IOSM_EBL_NAME  32
0027 /* Maximum supported error types */
0028 #define IOSM_MAX_ERRORS 8
0029 /* Read size for RPSI/EBL response */
0030 #define IOSM_READ_SIZE 2
0031 /* Link establishment response ack size */
0032 #define IOSM_LER_ACK_SIZE 2
0033 /* PSI ACK len */
0034 #define IOSM_PSI_ACK 8
0035 /* SWID capability for packed swid type */
0036 #define IOSM_EXT_CAP_SWID_OOS_PACK     0x02
0037 /* EBL error response buffer */
0038 #define IOSM_EBL_RSP_BUFF 0x0041
0039 /* SWID string length */
0040 #define IOSM_SWID_STR 64
0041 /* Load EBL command size */
0042 #define IOSM_RPSI_LOAD_SIZE 0
0043 /* EBL payload checksum */
0044 #define IOSM_EBL_CKSM 0x0000FFFF
0045 /* SWID msg len and argument */
0046 #define IOSM_MSG_LEN_ARG 0
0047 /* Data to be sent to modem */
0048 #define IOSM_MDM_SEND_DATA 0x0000
0049 /* Data received from modem as part of erase check */
0050 #define IOSM_MDM_ERASE_RSP 0x0001
0051 /* Bit shift to calculate Checksum */
0052 #define IOSM_EBL_PAYL_SHIFT 16
0053 /* Flag To be set */
0054 #define IOSM_SET_FLAG 1
0055 /* Set flash erase check timeout to 100 msec */
0056 #define IOSM_FLASH_ERASE_CHECK_TIMEOUT 100
0057 /* Set flash erase check interval to 20 msec */
0058 #define IOSM_FLASH_ERASE_CHECK_INTERVAL 20
0059 /* Link establishment response ack size */
0060 #define IOSM_LER_RSP_SIZE 60
0061 
0062 /**
0063  * enum iosm_flash_package_type -   Enum for the flashing operations
0064  * @FLASH_SET_PROT_CONF:    Write EBL capabilities
0065  * @FLASH_SEC_START:        Start writing the secpack
0066  * @FLASH_SEC_END:      Validate secpack end
0067  * @FLASH_SET_ADDRESS:      Set the address for flashing
0068  * @FLASH_ERASE_START:      Start erase before flashing
0069  * @FLASH_ERASE_CHECK:      Validate the erase functionality
0070  * @FLASH_OOS_CONTROL:      Retrieve data based on oos actions
0071  * @FLASH_OOS_DATA_READ:    Read data from EBL
0072  * @FLASH_WRITE_IMAGE_RAW:  Write the raw image to flash
0073  */
0074 enum iosm_flash_package_type {
0075     FLASH_SET_PROT_CONF = 0x0086,
0076     FLASH_SEC_START = 0x0204,
0077     FLASH_SEC_END,
0078     FLASH_SET_ADDRESS = 0x0802,
0079     FLASH_ERASE_START = 0x0805,
0080     FLASH_ERASE_CHECK,
0081     FLASH_OOS_CONTROL = 0x080C,
0082     FLASH_OOS_DATA_READ = 0x080E,
0083     FLASH_WRITE_IMAGE_RAW,
0084 };
0085 
0086 /**
0087  * enum iosm_out_of_session_action -    Actions possible over the
0088  *                  OutOfSession command interface
0089  * @FLASH_OOSC_ACTION_READ:     Read data according to its type
0090  * @FLASH_OOSC_ACTION_ERASE:        Erase data according to its type
0091  */
0092 enum iosm_out_of_session_action {
0093     FLASH_OOSC_ACTION_READ = 2,
0094     FLASH_OOSC_ACTION_ERASE = 3,
0095 };
0096 
0097 /**
0098  * enum iosm_out_of_session_type -  Data types that can be handled over the
0099  *                  Out Of Session command Interface
0100  * @FLASH_OOSC_TYPE_ALL_FLASH:      The whole flash area
0101  * @FLASH_OOSC_TYPE_SWID_TABLE:     Read the swid table from the target
0102  */
0103 enum iosm_out_of_session_type {
0104     FLASH_OOSC_TYPE_ALL_FLASH = 8,
0105     FLASH_OOSC_TYPE_SWID_TABLE = 16,
0106 };
0107 
0108 /**
0109  * enum iosm_ebl_caps - EBL capability settings
0110  * @IOSM_CAP_NOT_ENHANCED:  If capability not supported
0111  * @IOSM_CAP_USE_EXT_CAP:   To be set if extended capability is set
0112  * @IOSM_EXT_CAP_ERASE_ALL: Set Erase all capability
0113  * @IOSM_EXT_CAP_COMMIT_ALL:    Set the commit all capability
0114  */
0115 enum iosm_ebl_caps {
0116     IOSM_CAP_NOT_ENHANCED = 0x00,
0117     IOSM_CAP_USE_EXT_CAP = 0x01,
0118     IOSM_EXT_CAP_ERASE_ALL = 0x08,
0119     IOSM_EXT_CAP_COMMIT_ALL = 0x20,
0120 };
0121 
0122 /**
0123  * enum iosm_ebl_rsp -  EBL response field
0124  * @EBL_CAPS_FLAG:  EBL capability flag
0125  * @EBL_SKIP_ERASE: EBL skip erase flag
0126  * @EBL_SKIP_CRC:   EBL skip wr_pack crc
0127  * @EBL_EXT_CAPS_HANDLED:   EBL extended capability handled flag
0128  * @EBL_OOS_CONFIG: EBL oos configuration
0129  * @EBL_RSP_SW_INFO_VER: EBL SW info version
0130  */
0131 enum iosm_ebl_rsp {
0132     EBL_CAPS_FLAG = 50,
0133     EBL_SKIP_ERASE = 54,
0134     EBL_SKIP_CRC = 55,
0135     EBL_EXT_CAPS_HANDLED = 57,
0136     EBL_OOS_CONFIG = 64,
0137     EBL_RSP_SW_INFO_VER = 70,
0138 };
0139 
0140 /**
0141  * enum iosm_mdm_send_recv_data - Data to send to modem
0142  * @IOSM_MDM_SEND_2:    Send 2 bytes of payload
0143  * @IOSM_MDM_SEND_4:    Send 4 bytes of payload
0144  * @IOSM_MDM_SEND_8:    Send 8 bytes of payload
0145  * @IOSM_MDM_SEND_16:   Send 16 bytes of payload
0146  */
0147 enum iosm_mdm_send_recv_data {
0148     IOSM_MDM_SEND_2 = 2,
0149     IOSM_MDM_SEND_4 = 4,
0150     IOSM_MDM_SEND_8 = 8,
0151     IOSM_MDM_SEND_16 = 16,
0152 };
0153 
0154 /**
0155  * struct iosm_ebl_one_error -  Structure containing error details
0156  * @error_class:        Error type- standard, security and text error
0157  * @error_code:         Specific error from error type
0158  */
0159 struct iosm_ebl_one_error {
0160     u16 error_class;
0161     u16 error_code;
0162 };
0163 
0164 /**
0165  * struct iosm_ebl_error- Structure with max error type supported
0166  * @error:      Array of one_error structure with max errors
0167  */
0168 struct iosm_ebl_error {
0169     struct iosm_ebl_one_error error[IOSM_MAX_ERRORS];
0170 };
0171 
0172 /**
0173  * struct iosm_swid_table - SWID table data for modem
0174  * @number_of_data_sets:    Number of swid types
0175  * @sw_id_type:         SWID type - SWID
0176  * @sw_id_val:          SWID value
0177  * @rf_engine_id_type:      RF engine ID type - RF_ENGINE_ID
0178  * @rf_engine_id_val:       RF engine ID value
0179  */
0180 struct iosm_swid_table {
0181     u32 number_of_data_sets;
0182     char sw_id_type[IOSM_EBL_NAME];
0183     u32 sw_id_val;
0184     char rf_engine_id_type[IOSM_EBL_NAME];
0185     u32 rf_engine_id_val;
0186 };
0187 
0188 /**
0189  * struct iosm_flash_msg_control - Data sent to modem
0190  * @action: Action to be performed
0191  * @type:   Type of action
0192  * @length: Length of the action
0193  * @arguments:  Argument value sent to modem
0194  */
0195 struct iosm_flash_msg_control {
0196     __le32 action;
0197     __le32 type;
0198     __le32 length;
0199     __le32 arguments;
0200 };
0201 
0202 /**
0203  * struct iosm_flash_data -  Header Data to be sent to modem
0204  * @checksum:   Checksum value calculated for the payload data
0205  * @pack_id:    Flash Action type
0206  * @msg_length: Payload length
0207  */
0208 struct iosm_flash_data {
0209     __le16  checksum;
0210     __le16  pack_id;
0211     __le32  msg_length;
0212 };
0213 
0214 int ipc_flash_boot_psi(struct iosm_devlink *ipc_devlink,
0215                const struct firmware *fw);
0216 
0217 int ipc_flash_boot_ebl(struct iosm_devlink *ipc_devlink,
0218                const struct firmware *fw);
0219 
0220 int ipc_flash_boot_set_capabilities(struct iosm_devlink *ipc_devlink,
0221                     u8 *mdm_rsp);
0222 
0223 int ipc_flash_link_establish(struct iosm_imem *ipc_imem);
0224 
0225 int ipc_flash_read_swid(struct iosm_devlink *ipc_devlink, u8 *mdm_rsp);
0226 
0227 int ipc_flash_send_fls(struct iosm_devlink *ipc_devlink,
0228                const struct firmware *fw, u8 *mdm_rsp);
0229 #endif