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