summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-03-14 10:53:01 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-03-28 11:16:54 -0700
commit5ea675bcecddf7fc9e94d718e22523216157e9d5 (patch)
tree087218b214ceafa02489ec26a303843e715f1d5d /chip
parent840eb397d38ba49a905955943d74b41160dfdd68 (diff)
downloadchrome-ec-5ea675bcecddf7fc9e94d718e22523216157e9d5.tar.gz
g: add flash elog support function
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. Change-Id: I8639ad437c5b90eb2d182453bd8bbdda610bdb15 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>
Diffstat (limited to 'chip')
-rw-r--r--chip/g/config_chip.h11
-rw-r--r--chip/g/flash.c19
2 files changed, 29 insertions, 1 deletions
diff --git a/chip/g/config_chip.h b/chip/g/config_chip.h
index 365154fd5b..4eaa86f53d 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;
}