diff options
Diffstat (limited to 'zephyr')
-rw-r--r-- | zephyr/CMakeLists.txt | 1 | ||||
-rw-r--r-- | zephyr/Kconfig | 8 | ||||
-rw-r--r-- | zephyr/shim/src/util.c | 31 |
3 files changed, 40 insertions, 0 deletions
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index c1a11633e6..b6ee807afc 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -35,6 +35,7 @@ zephyr_include_directories_ifdef( add_subdirectory_ifdef(CONFIG_PLATFORM_EC "shim") zephyr_sources_ifdef(CONFIG_PLATFORM_EC "${PLATFORM_EC}/common/base32.c") +zephyr_sources_ifdef(CONFIG_PLATFORM_EC_CBI "${PLATFORM_EC}/common/cbi.c") zephyr_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ "${PLATFORM_EC}/common/chipset.c") zephyr_sources_ifdef(CONFIG_PLATFORM_EC_ESPI "${PLATFORM_EC}/common/espi.c") diff --git a/zephyr/Kconfig b/zephyr/Kconfig index d99aa52d21..1d5dd67fe3 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -187,4 +187,12 @@ config PLATFORM_EC_POWER_BUTTON commands in platform/ec. This requires a GPIO named GPIO_POWER_BUTTON_L in gpio_map.h. +config PLATFORM_EC_CBI + bool "Enable the CBI EEPROM module" + depends on PLATFORM_EC_I2C + help + Enables various CBI accessors and host and console commands. One must + specify both I2C_PORT_EEPROM and I2C_ADDR_EEPROM_FLAGS to the CBI + EEPROM's i2c port and 7-bit i2c address. + endif # PLATFORM_EC diff --git a/zephyr/shim/src/util.c b/zephyr/shim/src/util.c index 98e61f9c73..8585d21f54 100644 --- a/zephyr/shim/src/util.c +++ b/zephyr/shim/src/util.c @@ -9,6 +9,7 @@ #define HIDE_EC_STDLIB #include "common.h" +#include "console.h" #include "util.h" /* Int and Long are same size, just forward to existing Long implementation */ @@ -99,3 +100,33 @@ unsigned long long int strtoull(const char *nptr, char **endptr, int base) return result; } BUILD_ASSERT(sizeof(unsigned long long int) == sizeof(uint64_t)); + +void hexdump(const uint8_t *data, int len) +{ + /* + * NOTE: Could be replaced with LOG_HEXDUMP_INF(data, len, "CBI RAW"); + * if we enabled CONFIG_LOG=y in future. + */ + int i, j; + + if (!data || !len) + return; + + for (i = 0; i < len; i += 16) { + /* Left column (Hex) */ + for (j = i; j < i + 16; j++) { + if (j < len) + ccprintf(" %02x", data[j]); + else + ccprintf(" "); + } + /* Right column (ASCII) */ + ccprintf(" |"); + for (j = i; j < i + 16; j++) { + int c = j < len ? data[j] : ' '; + + ccprintf("%c", isprint(c) ? c : '.'); + } + ccprintf("|\n"); + } +} |