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 |
Sridhar Siricilla | 0448177 | 2022-06-15 22:44:06 +0530 | [diff] [blame^] | 8 | #define DEBUG_FEATURE_CTRL_OFFSET SI_DESC_OEM_SECTION_OFFSET |
| 9 | #define DEBUG_FEATURE_CTRL_SZ 64 |
Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 10 | #define SI_DESC_REGION_SZ 4096 |
| 11 | |
Sridhar Siricilla | 0448177 | 2022-06-15 22:44:06 +0530 | [diff] [blame^] | 12 | struct debug_feature_cntrl { |
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 | |
Sridhar Siricilla | 0448177 | 2022-06-15 22:44:06 +0530 | [diff] [blame^] | 17 | static struct debug_feature_cntrl dbg_feature_cntrl; |
Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 18 | |
Sridhar Siricilla | 0448177 | 2022-06-15 22:44:06 +0530 | [diff] [blame^] | 19 | _Static_assert(sizeof(struct debug_feature_cntrl) % 64 == 0 |
| 20 | && sizeof(struct debug_feature_cntrl) <= 256, |
| 21 | "sizeof(struct debug_feature_cntrl) must be a multiple of 64 bytes and up to 256 bytes"); |
Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 22 | |
Sridhar Siricilla | 0aa1ac4 | 2022-03-09 20:35:32 +0530 | [diff] [blame] | 23 | bool is_debug_cse_fw_update_disable(void) |
| 24 | { |
Sridhar Siricilla | 0448177 | 2022-06-15 22:44:06 +0530 | [diff] [blame^] | 25 | printk(BIOS_DEBUG, "rt_debug: dbg_feature_cntrl.cse_fw_update_disable=%d\n", |
| 26 | dbg_feature_cntrl.cse_fw_update_disable); |
Sridhar Siricilla | 0aa1ac4 | 2022-03-09 20:35:32 +0530 | [diff] [blame] | 27 | |
Sridhar Siricilla | 0448177 | 2022-06-15 22:44:06 +0530 | [diff] [blame^] | 28 | return dbg_feature_cntrl.cse_fw_update_disable == 1; |
Sridhar Siricilla | 0aa1ac4 | 2022-03-09 20:35:32 +0530 | [diff] [blame] | 29 | } |
| 30 | |
Sridhar Siricilla | 0448177 | 2022-06-15 22:44:06 +0530 | [diff] [blame^] | 31 | enum cb_err dbg_feature_cntrl_init(void) |
Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 32 | { |
Sridhar Siricilla | 0448177 | 2022-06-15 22:44:06 +0530 | [diff] [blame^] | 33 | if (spi_flash_read(boot_device_spi_flash(), DEBUG_FEATURE_CTRL_OFFSET, |
| 34 | DEBUG_FEATURE_CTRL_SZ, &dbg_feature_cntrl)) { |
Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 35 | printk(BIOS_ERR, "Failed to read Descriptor Region from SPI Flash\n"); |
Sridhar Siricilla | b4de261 | 2022-04-28 14:36:38 +0530 | [diff] [blame] | 36 | return CB_ERR; |
Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 37 | } |
Sridhar Siricilla | b4de261 | 2022-04-28 14:36:38 +0530 | [diff] [blame] | 38 | return CB_SUCCESS; |
Sridhar Siricilla | 2c2706c | 2022-01-25 00:15:17 +0530 | [diff] [blame] | 39 | } |