Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 3 | #include <intelbasecode/debug_feature.h> |
| 4 | #include <console/console.h> |
Sridhar Siricilla | 574f3c8 | 2022-04-21 10:33:51 +0530 | [diff] [blame] | 5 | #include <spi_flash.h> |
Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 6 | |
| 7 | #define SI_DESC_OEM_SECTION_OFFSET 0xF00 |
| 8 | #define PRE_MEM_FEATURE_CTRL_OFFSET SI_DESC_OEM_SECTION_OFFSET |
| 9 | #define PRE_MEM_FEATURE_CTRL_SZ 64 |
| 10 | #define SI_DESC_REGION_SZ 4096 |
| 11 | |
| 12 | struct pre_mem_ft { |
Sridhar Siricilla | 0aa1ac4 | 2022-03-09 20:35:32 +0530 | [diff] [blame] | 13 | uint8_t cse_fw_update_disable; /* Byte location: 0xF00 */ |
| 14 | uint8_t reserved[63]; |
Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 15 | }; |
| 16 | |
| 17 | static struct pre_mem_ft pre_mem_debug; |
| 18 | |
| 19 | _Static_assert(sizeof(struct pre_mem_ft) % 64 == 0 && sizeof(struct pre_mem_ft) <= 256, |
| 20 | "sizeof(struct pre_mem_ft) must be a multiple of 64 bytes and up to 256 bytes"); |
| 21 | |
Sridhar Siricilla | 0aa1ac4 | 2022-03-09 20:35:32 +0530 | [diff] [blame] | 22 | bool is_debug_cse_fw_update_disable(void) |
| 23 | { |
| 24 | printk(BIOS_DEBUG, "rt_debug: pre_mem_debug.cse_fw_update_disable=%d\n", |
| 25 | pre_mem_debug.cse_fw_update_disable); |
| 26 | |
| 27 | return pre_mem_debug.cse_fw_update_disable == 1; |
| 28 | } |
| 29 | |
Sridhar Siricilla | b4de261 | 2022-04-28 14:36:38 +0530 | [diff] [blame^] | 30 | enum cb_err pre_mem_debug_init(void) |
Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 31 | { |
Sridhar Siricilla | 574f3c8 | 2022-04-21 10:33:51 +0530 | [diff] [blame] | 32 | if (spi_flash_read(boot_device_spi_flash(), PRE_MEM_FEATURE_CTRL_OFFSET, |
| 33 | PRE_MEM_FEATURE_CTRL_SZ, &pre_mem_debug)) { |
Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 34 | printk(BIOS_ERR, "Failed to read Descriptor Region from SPI Flash\n"); |
Sridhar Siricilla | b4de261 | 2022-04-28 14:36:38 +0530 | [diff] [blame^] | 35 | return CB_ERR; |
Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 36 | } |
Sridhar Siricilla | b4de261 | 2022-04-28 14:36:38 +0530 | [diff] [blame^] | 37 | return CB_SUCCESS; |
Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 38 | } |