| 1 |
|
| 2 |
|
| 3 |
#include <intelbasecode/debug_feature.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <spi_flash.h> |
| 6 |
|
| 7 |
#define SI_DESC_OEM_SECTION_OFFSET 0xF00 |
| 8 |
#define DEBUG_FEATURE_CTRL_OFFSET SI_DESC_OEM_SECTION_OFFSET |
| 9 |
#define DEBUG_FEATURE_CTRL_SZ 64 |
| 10 |
#define SI_DESC_REGION_SZ 4096 |
| 11 |
|
| 12 |
#define DEBUG_FEATURE_UNDEFINED 0xff |
| 13 |
struct debug_feature_cntrl { |
| 14 |
uint8_t cse_fw_update_disable; |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
uint8_t cpu_tracehub_mode; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
uint8_t pch_tracehub_mode; |
| 27 |
uint8_t reserved[61]; |
| 28 |
}; |
| 29 |
|
| 30 |
static struct debug_feature_cntrl dbg_feature_cntrl; |
| 31 |
|
| 32 |
_Static_assert(sizeof(struct debug_feature_cntrl) % 64 == 0 |
| 33 |
&& sizeof(struct debug_feature_cntrl) <= 256, |
| 34 |
"sizeof(struct debug_feature_cntrl) must be a multiple of 64 bytes and up to 256 bytes"); |
| 35 |
|
| 36 |
void debug_get_pch_cpu_tracehub_modes(uint8_t *cpu_tracehub_mode, uint8_t *pch_tracehub_mode) |
| 37 |
{ |
| 38 |
if (dbg_feature_cntrl.pch_tracehub_mode != DEBUG_FEATURE_UNDEFINED) |
| 39 |
*pch_tracehub_mode = dbg_feature_cntrl.pch_tracehub_mode; |
| 40 |
|
| 41 |
if (dbg_feature_cntrl.cpu_tracehub_mode != DEBUG_FEATURE_UNDEFINED) |
| 42 |
*cpu_tracehub_mode = dbg_feature_cntrl.cpu_tracehub_mode; |
| 43 |
|
| 44 |
printk(BIOS_DEBUG, "rt_debug: CPU Trace Hub Mode: %d PCH Trace Hub Mode: %d\n", |
| 45 |
*pch_tracehub_mode, *cpu_tracehub_mode); |
| 46 |
} |
| 47 |
|
| 48 |
bool is_debug_cse_fw_update_disable(void) |
| 49 |
{ |
| 50 |
printk(BIOS_DEBUG, "rt_debug: dbg_feature_cntrl.cse_fw_update_disable=%d\n", |
| 51 |
dbg_feature_cntrl.cse_fw_update_disable); |
| 52 |
|
| 53 |
return dbg_feature_cntrl.cse_fw_update_disable == 1; |
| 54 |
} |
| 55 |
|
| 56 |
enum cb_err dbg_feature_cntrl_init(void) |
| 57 |
{ |
| 58 |
const struct spi_flash *spi_flash_dev = boot_device_spi_flash(); |
| 59 |
|
| 60 |
if (spi_flash_dev == NULL) { |
| 61 |
printk(BIOS_ERR, "Failed to Initialize boot device SPI flash\n"); |
| 62 |
return CB_ERR; |
| 63 |
} |
| 64 |
|
| 65 |
if (spi_flash_read(spi_flash_dev, DEBUG_FEATURE_CTRL_OFFSET, |
| 66 |
DEBUG_FEATURE_CTRL_SZ, &dbg_feature_cntrl)) { |
| 67 |
printk(BIOS_ERR, "Failed to read Descriptor Region from SPI Flash\n"); |
| 68 |
return CB_ERR; |
| 69 |
} |
| 70 |
return CB_SUCCESS; |
| 71 |
} |