diff options
author | Jett Rink <jettrink@chromium.org> | 2020-12-03 13:54:09 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-12-04 18:28:03 +0000 |
commit | b06ad2df42bd9c3c48e06df0645b526a1fc454e7 (patch) | |
tree | 43109d4e69978f6c3e6932b003ebd128eb2e7aee | |
parent | 4682423de58757a744176261390bfc3d341c046c (diff) | |
download | chrome-ec-b06ad2df42bd9c3c48e06df0645b526a1fc454e7.tar.gz |
zephyr: add CBI module to zephyr options
Shim in CBI module and necessary dependencies.
BRANCH=none
BUG=b:168032342,b:168032589
TEST=type `cbi` on volteer
Signed-off-by: Jett Rink <jettrink@chromium.org>
Change-Id: Ic08f472f8d52cd4521b78f819ea22e337cccc6f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2572736
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Queue: Simon Glass <sjg@chromium.org>
-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"); + } +} |