1*b5573474SM Chetan Kumar /* SPDX-License-Identifier: GPL-2.0-only 2*b5573474SM Chetan Kumar * 3*b5573474SM Chetan Kumar * Copyright (C) 2020-2021 Intel Corporation. 4*b5573474SM Chetan Kumar */ 5*b5573474SM Chetan Kumar 6*b5573474SM Chetan Kumar #ifndef _IOSM_IPC_FLASH_H 7*b5573474SM Chetan Kumar #define _IOSM_IPC_FLASH_H 8*b5573474SM Chetan Kumar 9*b5573474SM Chetan Kumar /* Buffer size used to read the fls image */ 10*b5573474SM Chetan Kumar #define IOSM_FLS_BUF_SIZE 0x00100000 11*b5573474SM Chetan Kumar /* Full erase start address */ 12*b5573474SM Chetan Kumar #define IOSM_ERASE_START_ADDR 0x00000000 13*b5573474SM Chetan Kumar /* Erase length for NAND flash */ 14*b5573474SM Chetan Kumar #define IOSM_ERASE_LEN 0xFFFFFFFF 15*b5573474SM Chetan Kumar /* EBL response Header size */ 16*b5573474SM Chetan Kumar #define IOSM_EBL_HEAD_SIZE 8 17*b5573474SM Chetan Kumar /* EBL payload size */ 18*b5573474SM Chetan Kumar #define IOSM_EBL_W_PAYL_SIZE 2048 19*b5573474SM Chetan Kumar /* Total EBL pack size */ 20*b5573474SM Chetan Kumar #define IOSM_EBL_W_PACK_SIZE (IOSM_EBL_HEAD_SIZE + IOSM_EBL_W_PAYL_SIZE) 21*b5573474SM Chetan Kumar /* EBL payload size */ 22*b5573474SM Chetan Kumar #define IOSM_EBL_DW_PAYL_SIZE 16384 23*b5573474SM Chetan Kumar /* Total EBL pack size */ 24*b5573474SM Chetan Kumar #define IOSM_EBL_DW_PACK_SIZE (IOSM_EBL_HEAD_SIZE + IOSM_EBL_DW_PAYL_SIZE) 25*b5573474SM Chetan Kumar /* EBL name size */ 26*b5573474SM Chetan Kumar #define IOSM_EBL_NAME 32 27*b5573474SM Chetan Kumar /* Maximum supported error types */ 28*b5573474SM Chetan Kumar #define IOSM_MAX_ERRORS 8 29*b5573474SM Chetan Kumar /* Read size for RPSI/EBL response */ 30*b5573474SM Chetan Kumar #define IOSM_READ_SIZE 2 31*b5573474SM Chetan Kumar /* Link establishment response ack size */ 32*b5573474SM Chetan Kumar #define IOSM_LER_ACK_SIZE 2 33*b5573474SM Chetan Kumar /* PSI ACK len */ 34*b5573474SM Chetan Kumar #define IOSM_PSI_ACK 8 35*b5573474SM Chetan Kumar /* SWID capability for packed swid type */ 36*b5573474SM Chetan Kumar #define IOSM_EXT_CAP_SWID_OOS_PACK 0x02 37*b5573474SM Chetan Kumar /* EBL error response buffer */ 38*b5573474SM Chetan Kumar #define IOSM_EBL_RSP_BUFF 0x0041 39*b5573474SM Chetan Kumar /* SWID string length */ 40*b5573474SM Chetan Kumar #define IOSM_SWID_STR 64 41*b5573474SM Chetan Kumar /* Load EBL command size */ 42*b5573474SM Chetan Kumar #define IOSM_RPSI_LOAD_SIZE 0 43*b5573474SM Chetan Kumar /* EBL payload checksum */ 44*b5573474SM Chetan Kumar #define IOSM_EBL_CKSM 0x0000FFFF 45*b5573474SM Chetan Kumar /* SWID msg len and argument */ 46*b5573474SM Chetan Kumar #define IOSM_MSG_LEN_ARG 0 47*b5573474SM Chetan Kumar /* Data to be sent to modem */ 48*b5573474SM Chetan Kumar #define IOSM_MDM_SEND_DATA 0x0000 49*b5573474SM Chetan Kumar /* Data received from modem as part of erase check */ 50*b5573474SM Chetan Kumar #define IOSM_MDM_ERASE_RSP 0x0001 51*b5573474SM Chetan Kumar /* Bit shift to calculate Checksum */ 52*b5573474SM Chetan Kumar #define IOSM_EBL_PAYL_SHIFT 16 53*b5573474SM Chetan Kumar /* Flag To be set */ 54*b5573474SM Chetan Kumar #define IOSM_SET_FLAG 1 55*b5573474SM Chetan Kumar /* Set flash erase check timeout to 100 msec */ 56*b5573474SM Chetan Kumar #define IOSM_FLASH_ERASE_CHECK_TIMEOUT 100 57*b5573474SM Chetan Kumar /* Set flash erase check interval to 20 msec */ 58*b5573474SM Chetan Kumar #define IOSM_FLASH_ERASE_CHECK_INTERVAL 20 59*b5573474SM Chetan Kumar /* Link establishment response ack size */ 60*b5573474SM Chetan Kumar #define IOSM_LER_RSP_SIZE 60 61*b5573474SM Chetan Kumar 62*b5573474SM Chetan Kumar /** 63*b5573474SM Chetan Kumar * enum iosm_flash_package_type - Enum for the flashing operations 64*b5573474SM Chetan Kumar * @FLASH_SET_PROT_CONF: Write EBL capabilities 65*b5573474SM Chetan Kumar * @FLASH_SEC_START: Start writing the secpack 66*b5573474SM Chetan Kumar * @FLASH_SEC_END: Validate secpack end 67*b5573474SM Chetan Kumar * @FLASH_SET_ADDRESS: Set the address for flashing 68*b5573474SM Chetan Kumar * @FLASH_ERASE_START: Start erase before flashing 69*b5573474SM Chetan Kumar * @FLASH_ERASE_CHECK: Validate the erase functionality 70*b5573474SM Chetan Kumar * @FLASH_OOS_CONTROL: Retrieve data based on oos actions 71*b5573474SM Chetan Kumar * @FLASH_OOS_DATA_READ: Read data from EBL 72*b5573474SM Chetan Kumar * @FLASH_WRITE_IMAGE_RAW: Write the raw image to flash 73*b5573474SM Chetan Kumar */ 74*b5573474SM Chetan Kumar enum iosm_flash_package_type { 75*b5573474SM Chetan Kumar FLASH_SET_PROT_CONF = 0x0086, 76*b5573474SM Chetan Kumar FLASH_SEC_START = 0x0204, 77*b5573474SM Chetan Kumar FLASH_SEC_END, 78*b5573474SM Chetan Kumar FLASH_SET_ADDRESS = 0x0802, 79*b5573474SM Chetan Kumar FLASH_ERASE_START = 0x0805, 80*b5573474SM Chetan Kumar FLASH_ERASE_CHECK, 81*b5573474SM Chetan Kumar FLASH_OOS_CONTROL = 0x080C, 82*b5573474SM Chetan Kumar FLASH_OOS_DATA_READ = 0x080E, 83*b5573474SM Chetan Kumar FLASH_WRITE_IMAGE_RAW, 84*b5573474SM Chetan Kumar }; 85*b5573474SM Chetan Kumar 86*b5573474SM Chetan Kumar /** 87*b5573474SM Chetan Kumar * enum iosm_out_of_session_action - Actions possible over the 88*b5573474SM Chetan Kumar * OutOfSession command interface 89*b5573474SM Chetan Kumar * @FLASH_OOSC_ACTION_READ: Read data according to its type 90*b5573474SM Chetan Kumar * @FLASH_OOSC_ACTION_ERASE: Erase data according to its type 91*b5573474SM Chetan Kumar */ 92*b5573474SM Chetan Kumar enum iosm_out_of_session_action { 93*b5573474SM Chetan Kumar FLASH_OOSC_ACTION_READ = 2, 94*b5573474SM Chetan Kumar FLASH_OOSC_ACTION_ERASE = 3, 95*b5573474SM Chetan Kumar }; 96*b5573474SM Chetan Kumar 97*b5573474SM Chetan Kumar /** 98*b5573474SM Chetan Kumar * enum iosm_out_of_session_type - Data types that can be handled over the 99*b5573474SM Chetan Kumar * Out Of Session command Interface 100*b5573474SM Chetan Kumar * @FLASH_OOSC_TYPE_ALL_FLASH: The whole flash area 101*b5573474SM Chetan Kumar * @FLASH_OOSC_TYPE_SWID_TABLE: Read the swid table from the target 102*b5573474SM Chetan Kumar */ 103*b5573474SM Chetan Kumar enum iosm_out_of_session_type { 104*b5573474SM Chetan Kumar FLASH_OOSC_TYPE_ALL_FLASH = 8, 105*b5573474SM Chetan Kumar FLASH_OOSC_TYPE_SWID_TABLE = 16, 106*b5573474SM Chetan Kumar }; 107*b5573474SM Chetan Kumar 108*b5573474SM Chetan Kumar /** 109*b5573474SM Chetan Kumar * enum iosm_ebl_caps - EBL capability settings 110*b5573474SM Chetan Kumar * @IOSM_CAP_NOT_ENHANCED: If capability not supported 111*b5573474SM Chetan Kumar * @IOSM_CAP_USE_EXT_CAP: To be set if extended capability is set 112*b5573474SM Chetan Kumar * @IOSM_EXT_CAP_ERASE_ALL: Set Erase all capability 113*b5573474SM Chetan Kumar * @IOSM_EXT_CAP_COMMIT_ALL: Set the commit all capability 114*b5573474SM Chetan Kumar */ 115*b5573474SM Chetan Kumar enum iosm_ebl_caps { 116*b5573474SM Chetan Kumar IOSM_CAP_NOT_ENHANCED = 0x00, 117*b5573474SM Chetan Kumar IOSM_CAP_USE_EXT_CAP = 0x01, 118*b5573474SM Chetan Kumar IOSM_EXT_CAP_ERASE_ALL = 0x08, 119*b5573474SM Chetan Kumar IOSM_EXT_CAP_COMMIT_ALL = 0x20, 120*b5573474SM Chetan Kumar }; 121*b5573474SM Chetan Kumar 122*b5573474SM Chetan Kumar /** 123*b5573474SM Chetan Kumar * enum iosm_ebl_rsp - EBL response field 124*b5573474SM Chetan Kumar * @EBL_CAPS_FLAG: EBL capability flag 125*b5573474SM Chetan Kumar * @EBL_SKIP_ERASE: EBL skip erase flag 126*b5573474SM Chetan Kumar * @EBL_SKIP_CRC: EBL skip wr_pack crc 127*b5573474SM Chetan Kumar * @EBL_EXT_CAPS_HANDLED: EBL extended capability handled flag 128*b5573474SM Chetan Kumar * @EBL_OOS_CONFIG: EBL oos configuration 129*b5573474SM Chetan Kumar * @EBL_RSP_SW_INFO_VER: EBL SW info version 130*b5573474SM Chetan Kumar */ 131*b5573474SM Chetan Kumar enum iosm_ebl_rsp { 132*b5573474SM Chetan Kumar EBL_CAPS_FLAG = 50, 133*b5573474SM Chetan Kumar EBL_SKIP_ERASE = 54, 134*b5573474SM Chetan Kumar EBL_SKIP_CRC = 55, 135*b5573474SM Chetan Kumar EBL_EXT_CAPS_HANDLED = 57, 136*b5573474SM Chetan Kumar EBL_OOS_CONFIG = 64, 137*b5573474SM Chetan Kumar EBL_RSP_SW_INFO_VER = 70, 138*b5573474SM Chetan Kumar }; 139*b5573474SM Chetan Kumar 140*b5573474SM Chetan Kumar /** 141*b5573474SM Chetan Kumar * enum iosm_mdm_send_recv_data - Data to send to modem 142*b5573474SM Chetan Kumar * @IOSM_MDM_SEND_2: Send 2 bytes of payload 143*b5573474SM Chetan Kumar * @IOSM_MDM_SEND_4: Send 4 bytes of payload 144*b5573474SM Chetan Kumar * @IOSM_MDM_SEND_8: Send 8 bytes of payload 145*b5573474SM Chetan Kumar * @IOSM_MDM_SEND_16: Send 16 bytes of payload 146*b5573474SM Chetan Kumar */ 147*b5573474SM Chetan Kumar enum iosm_mdm_send_recv_data { 148*b5573474SM Chetan Kumar IOSM_MDM_SEND_2 = 2, 149*b5573474SM Chetan Kumar IOSM_MDM_SEND_4 = 4, 150*b5573474SM Chetan Kumar IOSM_MDM_SEND_8 = 8, 151*b5573474SM Chetan Kumar IOSM_MDM_SEND_16 = 16, 152*b5573474SM Chetan Kumar }; 153*b5573474SM Chetan Kumar 154*b5573474SM Chetan Kumar /** 155*b5573474SM Chetan Kumar * struct iosm_ebl_one_error - Structure containing error details 156*b5573474SM Chetan Kumar * @error_class: Error type- standard, security and text error 157*b5573474SM Chetan Kumar * @error_code: Specific error from error type 158*b5573474SM Chetan Kumar */ 159*b5573474SM Chetan Kumar struct iosm_ebl_one_error { 160*b5573474SM Chetan Kumar u16 error_class; 161*b5573474SM Chetan Kumar u16 error_code; 162*b5573474SM Chetan Kumar }; 163*b5573474SM Chetan Kumar 164*b5573474SM Chetan Kumar /** 165*b5573474SM Chetan Kumar * struct iosm_ebl_error- Structure with max error type supported 166*b5573474SM Chetan Kumar * @error: Array of one_error structure with max errors 167*b5573474SM Chetan Kumar */ 168*b5573474SM Chetan Kumar struct iosm_ebl_error { 169*b5573474SM Chetan Kumar struct iosm_ebl_one_error error[IOSM_MAX_ERRORS]; 170*b5573474SM Chetan Kumar }; 171*b5573474SM Chetan Kumar 172*b5573474SM Chetan Kumar /** 173*b5573474SM Chetan Kumar * struct iosm_swid_table - SWID table data for modem 174*b5573474SM Chetan Kumar * @number_of_data_sets: Number of swid types 175*b5573474SM Chetan Kumar * @sw_id_type: SWID type - SWID 176*b5573474SM Chetan Kumar * @sw_id_val: SWID value 177*b5573474SM Chetan Kumar * @rf_engine_id_type: RF engine ID type - RF_ENGINE_ID 178*b5573474SM Chetan Kumar * @rf_engine_id_val: RF engine ID value 179*b5573474SM Chetan Kumar */ 180*b5573474SM Chetan Kumar struct iosm_swid_table { 181*b5573474SM Chetan Kumar u32 number_of_data_sets; 182*b5573474SM Chetan Kumar char sw_id_type[IOSM_EBL_NAME]; 183*b5573474SM Chetan Kumar u32 sw_id_val; 184*b5573474SM Chetan Kumar char rf_engine_id_type[IOSM_EBL_NAME]; 185*b5573474SM Chetan Kumar u32 rf_engine_id_val; 186*b5573474SM Chetan Kumar }; 187*b5573474SM Chetan Kumar 188*b5573474SM Chetan Kumar /** 189*b5573474SM Chetan Kumar * struct iosm_flash_msg_control - Data sent to modem 190*b5573474SM Chetan Kumar * @action: Action to be performed 191*b5573474SM Chetan Kumar * @type: Type of action 192*b5573474SM Chetan Kumar * @length: Length of the action 193*b5573474SM Chetan Kumar * @arguments: Argument value sent to modem 194*b5573474SM Chetan Kumar */ 195*b5573474SM Chetan Kumar struct iosm_flash_msg_control { 196*b5573474SM Chetan Kumar __le32 action; 197*b5573474SM Chetan Kumar __le32 type; 198*b5573474SM Chetan Kumar __le32 length; 199*b5573474SM Chetan Kumar __le32 arguments; 200*b5573474SM Chetan Kumar }; 201*b5573474SM Chetan Kumar 202*b5573474SM Chetan Kumar /** 203*b5573474SM Chetan Kumar * struct iosm_flash_data - Header Data to be sent to modem 204*b5573474SM Chetan Kumar * @checksum: Checksum value calculated for the payload data 205*b5573474SM Chetan Kumar * @pack_id: Flash Action type 206*b5573474SM Chetan Kumar * @msg_length: Payload length 207*b5573474SM Chetan Kumar */ 208*b5573474SM Chetan Kumar struct iosm_flash_data { 209*b5573474SM Chetan Kumar __le16 checksum; 210*b5573474SM Chetan Kumar __le16 pack_id; 211*b5573474SM Chetan Kumar __le32 msg_length; 212*b5573474SM Chetan Kumar }; 213*b5573474SM Chetan Kumar 214*b5573474SM Chetan Kumar int ipc_flash_boot_psi(struct iosm_devlink *ipc_devlink, 215*b5573474SM Chetan Kumar const struct firmware *fw); 216*b5573474SM Chetan Kumar 217*b5573474SM Chetan Kumar int ipc_flash_boot_ebl(struct iosm_devlink *ipc_devlink, 218*b5573474SM Chetan Kumar const struct firmware *fw); 219*b5573474SM Chetan Kumar 220*b5573474SM Chetan Kumar int ipc_flash_boot_set_capabilities(struct iosm_devlink *ipc_devlink, 221*b5573474SM Chetan Kumar u8 *mdm_rsp); 222*b5573474SM Chetan Kumar 223*b5573474SM Chetan Kumar int ipc_flash_link_establish(struct iosm_imem *ipc_imem); 224*b5573474SM Chetan Kumar 225*b5573474SM Chetan Kumar int ipc_flash_read_swid(struct iosm_devlink *ipc_devlink, u8 *mdm_rsp); 226*b5573474SM Chetan Kumar 227*b5573474SM Chetan Kumar int ipc_flash_send_fls(struct iosm_devlink *ipc_devlink, 228*b5573474SM Chetan Kumar const struct firmware *fw, u8 *mdm_rsp); 229*b5573474SM Chetan Kumar #endif 230