diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2019-03-14 10:53:01 -0700 |
---|---|---|
committer | Vadim Bendebury <vbendeb@chromium.org> | 2019-09-21 19:11:19 -0700 |
commit | aaf08ad4988f86c5f3b1f7a6d34757e9a6dd2217 (patch) | |
tree | 79377b96f80e5c6b96b3d68a34946b920b77d272 | |
parent | 3e89209bcb083ba73727ae2c8c5bbaa27bd82699 (diff) | |
download | chrome-ec-aaf08ad4988f86c5f3b1f7a6d34757e9a6dd2217.tar.gz |
g: add flash elog support function (take two)
Cr50 flash layout does not use space in the top of RO_B section, this
is a good location for the flash log, as it can not be easily used for
the code or RO data of the main Cr50 application.
BRANCH=cr50, cr50-mp
BUG=b:63760920
TEST=with the rest of the stack of patches applied was able to add and
retrieve flash log messages on Cr50.
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1525144
Reviewed-by: Namyoon Woo <namyoon@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
(cherry picked from commit 5ea675bcecddf7fc9e94d718e22523216157e9d5)
Change-Id: I0ab6b3b53c0854b368dcdecccd6d1a407ad8e983
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1644043
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
(cherry picked from commit 1af519a59ae93af6980a2ce2a4971986aa3e17ec)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1705364
(cherry picked from commit 3ec8ae525b85f0634377d35f99cab3dd552c084c)
-rw-r--r-- | chip/g/config_chip.h | 11 | ||||
-rw-r--r-- | chip/g/flash.c | 19 |
2 files changed, 29 insertions, 1 deletions
diff --git a/chip/g/config_chip.h b/chip/g/config_chip.h index de61f9f4a5..3cc286637b 100644 --- a/chip/g/config_chip.h +++ b/chip/g/config_chip.h @@ -147,4 +147,13 @@ /* Number of I2C ports */ #define I2C_PORT_COUNT 2 -#endif /* __CROS_EC_CONFIG_CHIP_H */ +#define CONFIG_FLASH_LOG_SPACE CONFIG_FLASH_BANK_SIZE + +/* + * Flash log occupies space in the top of RO_B section, its counterpart in + * RO_A is occupied by the certs. + */ +#define CONFIG_FLASH_LOG_BASE \ + (CONFIG_PROGRAM_MEMORY_BASE + CHIP_RO_B_MEM_OFF + CONFIG_RO_SIZE - \ + CONFIG_FLASH_LOG_SPACE) +#endif /* __CROS_EC_CONFIG_CHIP_H */ diff --git a/chip/g/flash.c b/chip/g/flash.c index fdb962bf00..8012a34430 100644 --- a/chip/g/flash.c +++ b/chip/g/flash.c @@ -43,6 +43,7 @@ #include "cryptoc/util.h" #include "flash.h" #include "flash_config.h" +#include "flash_log.h" #include "flash_info.h" #include "registers.h" #include "shared_mem.h" @@ -55,6 +56,13 @@ /* Mutex to prevent concurrent accesses to flash engine. */ static struct mutex flash_mtx; +#ifdef CONFIG_FLASH_LOG +static void flash_log_space_control(int enable) +{ + GWRITE_FIELD(GLOBALSEC, FLASH_REGION7_CTRL, WR_EN, !!enable); +} +#endif + int flash_pre_init(void) { struct g_flash_region regions[4]; @@ -85,6 +93,17 @@ int flash_pre_init(void) REG32(reg_base) = regions[i].reg_perms; } +#ifdef CONFIG_FLASH_LOG + /* + * Allow access to flash elog space and register the access control + * function. + */ + GREG32(GLOBALSEC, FLASH_REGION7_BASE_ADDR) = CONFIG_FLASH_LOG_BASE; + GREG32(GLOBALSEC, FLASH_REGION7_SIZE) = CONFIG_FLASH_LOG_SPACE - 1; + GWRITE_FIELD(GLOBALSEC, FLASH_REGION7_CTRL, EN, 1); + GWRITE_FIELD(GLOBALSEC, FLASH_REGION7_CTRL, RD_EN, 1); + flash_log_register_flash_control_callback(flash_log_space_control); +#endif return EC_SUCCESS; } |