Added for supporting larger embedded controller flash.
Showing the changes to include/linux (1 of 1 file). Show all
Unified · Split
| @@ -1138,6 +1138,7 @@ struct ec_response_get_features { · 1137 unmodified lines | |||
| 1138 | 1138 | ||
| 1139 | /* Get flash info */ | 1139 | /* Get flash info */ |
| 1140 | #define EC_CMD_FLASH_INFO 0x0010 | 1140 | #define EC_CMD_FLASH_INFO 0x0010 |
| 1141 | #define EC_VER_FLASH_INFO 2 | ||
| 1141 | 1142 | ||
| 1142 | /** | 1143 | /** |
| 1143 | * struct ec_response_flash_info - Response to the flash info command. | 1144 | * struct ec_response_flash_info - Response to the flash info command. |
| @@ -1164,6 +1165,15 @@ struct ec_response_flash_info { · 20 unmodified lines | |||
| 1164 | */ | 1165 | */ |
| 1165 | #define EC_FLASH_INFO_ERASE_TO_0 BIT(0) | 1166 | #define EC_FLASH_INFO_ERASE_TO_0 BIT(0) |
| 1166 | 1167 | ||
| 1168 | /* | ||
| 1169 | * Flash must be selected for read/write/erase operations to succeed. This may | ||
| 1170 | * be necessary on a chip where write/erase can be corrupted by other board | ||
| 1171 | * activity, or where the chip needs to enable some sort of programming voltage, | ||
| 1172 | * or where the read/write/erase operations require cleanly suspending other | ||
| 1173 | * chip functionality. | ||
| 1174 | */ | ||
| 1175 | #define EC_FLASH_INFO_SELECT_REQUIRED BIT(1) | ||
| 1176 | |||
| 1167 | /** | 1177 | /** |
| 1168 | * struct ec_response_flash_info_1 - Response to the flash info v1 command. | 1178 | * struct ec_response_flash_info_1 - Response to the flash info v1 command. |
| 1169 | * @flash_size: Usable flash size in bytes. | 1179 | * @flash_size: Usable flash size in bytes. |
| @@ -1186,6 +1196,12 @@ struct ec_response_flash_info { · 16 unmodified lines | |||
| 1186 | * gcc anonymous structs don't seem to get along with the __packed directive; | 1196 | * gcc anonymous structs don't seem to get along with the __packed directive; |
| 1187 | * if they did we'd define the version 0 structure as a sub-structure of this | 1197 | * if they did we'd define the version 0 structure as a sub-structure of this |
| 1188 | * one. | 1198 | * one. |
| 1199 | * | ||
| 1200 | * Version 2 supports flash banks of different sizes: | ||
| 1201 | * The caller specified the number of banks it has preallocated | ||
| 1202 | * (num_banks_desc) | ||
| 1203 | * The EC returns the number of banks describing the flash memory. | ||
| 1204 | * It adds banks descriptions up to num_banks_desc. | ||
| 1189 | */ | 1205 | */ |
| 1190 | struct ec_response_flash_info_1 { | 1206 | struct ec_response_flash_info_1 { |
| 1191 | /* Version 0 fields; see above for description */ | 1207 | /* Version 0 fields; see above for description */ |
| @@ -1199,6 +1215,42 @@ struct ec_response_flash_info_1 { · 7 unmodified lines | |||
| 1199 | uint32_t flags; | 1215 | uint32_t flags; |
| 1200 | } __ec_align4; | 1216 | } __ec_align4; |
| 1201 | 1217 | ||
| 1218 | struct ec_params_flash_info_2 { | ||
| 1219 | /* Number of banks to describe */ | ||
| 1220 | uint16_t num_banks_desc; | ||
| 1221 | /* Reserved; set 0; ignore on read */ | ||
| 1222 | uint8_t reserved[2]; | ||
| 1223 | } __ec_align4; | ||
| 1224 | |||
| 1225 | struct ec_flash_bank { | ||
| 1226 | /* Number of sector is in this bank. */ | ||
| 1227 | uint16_t count; | ||
| 1228 | /* Size in power of 2 of each sector (8 --> 256 bytes) */ | ||
| 1229 | uint8_t size_exp; | ||
| 1230 | /* Minimal write size for the sectors in this bank */ | ||
| 1231 | uint8_t write_size_exp; | ||
| 1232 | /* Erase size for the sectors in this bank */ | ||
| 1233 | uint8_t erase_size_exp; | ||
| 1234 | /* Size for write protection, usually identical to erase size. */ | ||
| 1235 | uint8_t protect_size_exp; | ||
| 1236 | /* Reserved; set 0; ignore on read */ | ||
| 1237 | uint8_t reserved[2]; | ||
| 1238 | }; | ||
| 1239 | |||
| 1240 | struct ec_response_flash_info_2 { | ||
| 1241 | /* Total flash in the EC. */ | ||
| 1242 | uint32_t flash_size; | ||
| 1243 | /* Flags; see EC_FLASH_INFO_* */ | ||
| 1244 | uint32_t flags; | ||
| 1245 | /* Maximum size to use to send data to write to the EC. */ | ||
| 1246 | uint32_t write_ideal_size; | ||
| 1247 | /* Number of banks present in the EC. */ | ||
| 1248 | uint16_t num_banks_total; | ||
| 1249 | /* Number of banks described in banks array. */ | ||
| 1250 | uint16_t num_banks_desc; | ||
| 1251 | struct ec_flash_bank banks[0]; | ||
| 1252 | } __ec_align4; | ||
| 1253 | |||
| 1202 | /* | 1254 | /* |
| 1203 | * Read flash | 1255 | * Read flash |
| 1204 | * | 1256 | * |
| @@ -1238,7 +1290,7 @@ struct ec_params_flash_write { · 33 unmodified lines | |||
| 1238 | #define EC_CMD_FLASH_ERASE 0x0013 | 1290 | #define EC_CMD_FLASH_ERASE 0x0013 |
| 1239 | 1291 | ||
| 1240 | /** | 1292 | /** |
| 1241 | * struct ec_params_flash_erase - Parameters for the flash erase command. | 1293 | * struct ec_params_flash_erase - Parameters for the flash erase command, v0. |
| 1242 | * @offset: Byte offset to erase. | 1294 | * @offset: Byte offset to erase. |
| 1243 | * @size: Size to erase in bytes. | 1295 | * @size: Size to erase in bytes. |
| 1244 | */ | 1296 | */ |
| @@ -1247,6 +1299,43 @@ struct ec_params_flash_erase { · 2 unmodified lines | |||
| 1247 | uint32_t size; | 1299 | uint32_t size; |
| 1248 | } __ec_align4; | 1300 | } __ec_align4; |
| 1249 | 1301 | ||
| 1302 | /* | ||
| 1303 | * v1 add async erase: | ||
| 1304 | * subcommands can returns: | ||
| 1305 | * EC_RES_SUCCESS : erased (see ERASE_SECTOR_ASYNC case below). | ||
| 1306 | * EC_RES_INVALID_PARAM : offset/size are not aligned on a erase boundary. | ||
| 1307 | * EC_RES_ERROR : other errors. | ||
| 1308 | * EC_RES_BUSY : an existing erase operation is in progress. | ||
| 1309 | * EC_RES_ACCESS_DENIED: Trying to erase running image. | ||
| 1310 | * | ||
| 1311 | * When ERASE_SECTOR_ASYNC returns EC_RES_SUCCESS, the operation is just | ||
| 1312 | * properly queued. The user must call ERASE_GET_RESULT subcommand to get | ||
| 1313 | * the proper result. | ||
| 1314 | * When ERASE_GET_RESULT returns EC_RES_BUSY, the caller must wait and send | ||
| 1315 | * ERASE_GET_RESULT again to get the result of ERASE_SECTOR_ASYNC. | ||
| 1316 | * ERASE_GET_RESULT command may timeout on EC where flash access is not | ||
| 1317 | * permitted while erasing. (For instance, STM32F4). | ||
| 1318 | */ | ||
| 1319 | enum ec_flash_erase_cmd { | ||
| 1320 | FLASH_ERASE_SECTOR, /* Erase and wait for result */ | ||
| 1321 | FLASH_ERASE_SECTOR_ASYNC, /* Erase and return immediately. */ | ||
| 1322 | FLASH_ERASE_GET_RESULT, /* Ask for last erase result */ | ||
| 1323 | }; | ||
| 1324 | |||
| 1325 | /** | ||
| 1326 | * struct ec_params_flash_erase_v1 - Parameters for the flash erase command, v1. | ||
| 1327 | * @cmd: One of ec_flash_erase_cmd. | ||
| 1328 | * @reserved: Pad byte; currently always contains 0. | ||
| 1329 | * @flag: No flags defined yet; set to 0. | ||
| 1330 | * @params: Same as v0 parameters. | ||
| 1331 | */ | ||
| 1332 | struct ec_params_flash_erase_v1 { | ||
| 1333 | uint8_t cmd; | ||
| 1334 | uint8_t reserved; | ||
| 1335 | uint16_t flag; | ||
| 1336 | struct ec_params_flash_erase params; | ||
| 1337 | } __ec_align4; | ||
| 1338 | |||
| 1250 | /* | 1339 | /* |
| 1251 | * Get/set flash protection. | 1340 | * Get/set flash protection. |
| 1252 | * | 1341 | * |
| @@ -1282,6 +1371,15 @@ struct ec_params_flash_erase { · 29 unmodified lines | |||
| 1282 | #define EC_FLASH_PROTECT_ERROR_INCONSISTENT BIT(5) | 1371 | #define EC_FLASH_PROTECT_ERROR_INCONSISTENT BIT(5) |
| 1283 | /* Entire flash code protected when the EC boots */ | 1372 | /* Entire flash code protected when the EC boots */ |
| 1284 | #define EC_FLASH_PROTECT_ALL_AT_BOOT BIT(6) | 1373 | #define EC_FLASH_PROTECT_ALL_AT_BOOT BIT(6) |
| 1374 | /* RW flash code protected when the EC boots */ | ||
| 1375 | #define EC_FLASH_PROTECT_RW_AT_BOOT BIT(7) | ||
| 1376 | /* RW flash code protected now. */ | ||
| 1377 | #define EC_FLASH_PROTECT_RW_NOW BIT(8) | ||
| 1378 | /* Rollback information flash region protected when the EC boots */ | ||
| 1379 | #define EC_FLASH_PROTECT_ROLLBACK_AT_BOOT BIT(9) | ||
| 1380 | /* Rollback information flash region protected now */ | ||
| 1381 | #define EC_FLASH_PROTECT_ROLLBACK_NOW BIT(10) | ||
| 1382 | |||
| 1285 | 1383 | ||
| 1286 | /** | 1384 | /** |
| 1287 | * struct ec_params_flash_protect - Parameters for the flash protect command. | 1385 | * struct ec_params_flash_protect - Parameters for the flash protect command. |
| @@ -1320,16 +1418,31 @@ struct ec_response_flash_protect { · 32 unmodified lines | |||
| 1320 | enum ec_flash_region { | 1418 | enum ec_flash_region { |
| 1321 | /* Region which holds read-only EC image */ | 1419 | /* Region which holds read-only EC image */ |
| 1322 | EC_FLASH_REGION_RO = 0, | 1420 | EC_FLASH_REGION_RO = 0, |
| 1323 | /* Region which holds rewritable EC image */ | 1421 | /* |
| 1324 | EC_FLASH_REGION_RW, | 1422 | * Region which holds active RW image. 'Active' is different from |
| 1423 | * 'running'. Active means 'scheduled-to-run'. Since RO image always | ||
| 1424 | * scheduled to run, active/non-active applies only to RW images (for | ||
| 1425 | * the same reason 'update' applies only to RW images. It's a state of | ||
| 1426 | * an image on a flash. Running image can be RO, RW_A, RW_B but active | ||
| 1427 | * image can only be RW_A or RW_B. In recovery mode, an active RW image | ||
| 1428 | * doesn't enter 'running' state but it's still active on a flash. | ||
| 1429 | */ | ||
| 1430 | EC_FLASH_REGION_ACTIVE, | ||
| 1325 | /* | 1431 | /* |
| 1326 | * Region which should be write-protected in the factory (a superset of | 1432 | * Region which should be write-protected in the factory (a superset of |
| 1327 | * EC_FLASH_REGION_RO) | 1433 | * EC_FLASH_REGION_RO) |
| 1328 | */ | 1434 | */ |
| 1329 | EC_FLASH_REGION_WP_RO, | 1435 | EC_FLASH_REGION_WP_RO, |
| 1436 | /* Region which holds updatable (non-active) RW image */ | ||
| 1437 | EC_FLASH_REGION_UPDATE, | ||
| 1330 | /* Number of regions */ | 1438 | /* Number of regions */ |
| 1331 | EC_FLASH_REGION_COUNT, | 1439 | EC_FLASH_REGION_COUNT, |
| 1332 | }; | 1440 | }; |
| 1441 | /* | ||
| 1442 | * 'RW' is vague if there are multiple RW images; we mean the active one, | ||
| 1443 | * so the old constant is deprecated. | ||
| 1444 | */ | ||
| 1445 | #define EC_FLASH_REGION_RW EC_FLASH_REGION_ACTIVE | ||
| 1333 | 1446 | ||
| 1334 | /** | 1447 | /** |
| 1335 | * struct ec_params_flash_region_info - Parameters for the flash region info | 1448 | * struct ec_params_flash_region_info - Parameters for the flash region info |
| @@ -1364,6 +1477,37 @@ struct ec_response_vbnvcontext { · 28 unmodified lines | |||
| 1364 | uint8_t block[EC_VBNV_BLOCK_SIZE]; | 1477 | uint8_t block[EC_VBNV_BLOCK_SIZE]; |
| 1365 | } __ec_align4; | 1478 | } __ec_align4; |
| 1366 | 1479 | ||
| 1480 | |||
| 1481 | /* Get SPI flash information */ | ||
| 1482 | #define EC_CMD_FLASH_SPI_INFO 0x0018 | ||
| 1483 | |||
| 1484 | struct ec_response_flash_spi_info { | ||
| 1485 | /* JEDEC info from command 0x9F (manufacturer, memory type, size) */ | ||
| 1486 | uint8_t jedec[3]; | ||
| 1487 | |||
| 1488 | /* Pad byte; currently always contains 0 */ | ||
| 1489 | uint8_t reserved0; | ||
| 1490 | |||
| 1491 | /* Manufacturer / device ID from command 0x90 */ | ||
| 1492 | uint8_t mfr_dev_id[2]; | ||
| 1493 | |||
| 1494 | /* Status registers from command 0x05 and 0x35 */ | ||
| 1495 | uint8_t sr1, sr2; | ||
| 1496 | } __ec_align1; | ||
| 1497 | |||
| 1498 | |||
| 1499 | /* Select flash during flash operations */ | ||
| 1500 | #define EC_CMD_FLASH_SELECT 0x0019 | ||
| 1501 | |||
| 1502 | /** | ||
| 1503 | * struct ec_params_flash_select - Parameters for the flash select command. | ||
| 1504 | * @select: 1 to select flash, 0 to deselect flash | ||
| 1505 | */ | ||
| 1506 | struct ec_params_flash_select { | ||
| 1507 | uint8_t select; | ||
| 1508 | } __ec_align4; | ||
| 1509 | |||
| 1510 | |||
| 1367 | /*****************************************************************************/ | 1511 | /*****************************************************************************/ |
| 1368 | /* PWM commands */ | 1512 | /* PWM commands */ |
| 1369 | 1513 | ||