iosm_ipc_flash.h 6.6 KB

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