diff options
Diffstat (limited to 'chip')
-rw-r--r-- | chip/g/flash.c | 12 | ||||
-rw-r--r-- | chip/g/flash_info.h | 2 | ||||
-rw-r--r-- | chip/g/upgrade_fw.c | 23 |
3 files changed, 21 insertions, 16 deletions
diff --git a/chip/g/flash.c b/chip/g/flash.c index 2029a0e438..6fd262a31d 100644 --- a/chip/g/flash.c +++ b/chip/g/flash.c @@ -451,6 +451,18 @@ int flash_physical_erase(int byte_offset, int num_bytes) return EC_SUCCESS; } + +/* Enable write access to the backup RO section. */ +void flash_open_ro_window(uint32_t offset, size_t size_b) +{ + GREG32(GLOBALSEC, FLASH_REGION6_BASE_ADDR) = + offset + CONFIG_PROGRAM_MEMORY_BASE; + GREG32(GLOBALSEC, FLASH_REGION6_SIZE) = size_b - 1; + GWRITE_FIELD(GLOBALSEC, FLASH_REGION6_CTRL, EN, 1); + GWRITE_FIELD(GLOBALSEC, FLASH_REGION6_CTRL, RD_EN, 1); + GWRITE_FIELD(GLOBALSEC, FLASH_REGION6_CTRL, WR_EN, 1); +} + #ifdef CR50_DEV static int command_erase_flash_info(int argc, char **argv) diff --git a/chip/g/flash_info.h b/chip/g/flash_info.h index b80c6889ba..9ff730b39e 100644 --- a/chip/g/flash_info.h +++ b/chip/g/flash_info.h @@ -30,4 +30,6 @@ void flash_info_write_disable(void); int flash_info_physical_write(int byte_offset, int num_bytes, const char *data); int flash_physical_info_read_word(int byte_offset, uint32_t *dst); +void flash_open_ro_window(uint32_t offset, size_t size_b); + #endif /* ! __EC_CHIP_G_FLASH_INFO_H */ diff --git a/chip/g/upgrade_fw.c b/chip/g/upgrade_fw.c index 182f1308fc..17bffe5f4c 100644 --- a/chip/g/upgrade_fw.c +++ b/chip/g/upgrade_fw.c @@ -3,21 +3,23 @@ * found in the LICENSE file. */ +#include "config.h" + #include "byteorder.h" #include "compile_time_macros.h" #include "console.h" +#include "cryptoc/sha.h" #include "dcrypto/dcrypto.h" #include "extension.h" #include "flash.h" +#include "flash_info.h" #include "hooks.h" +#include "registers.h" +#include "signed_header.h" #include "system.h" #include "system_chip.h" -#include "registers.h" #include "uart.h" - -#include "signed_header.h" #include "upgrade_fw.h" -#include "cryptoc/sha.h" #define CPRINTF(format, args...) cprintf(CC_EXTENSION, format, ## args) @@ -66,17 +68,6 @@ static void set_valid_sections(void) CONFIG_RW_SIZE; } -/* Enable write access to the backup RO section. */ -static void open_ro_window(uint32_t offset, size_t size_b) -{ - GREG32(GLOBALSEC, FLASH_REGION6_BASE_ADDR) = - offset + CONFIG_PROGRAM_MEMORY_BASE; - GREG32(GLOBALSEC, FLASH_REGION6_SIZE) = size_b - 1; - GWRITE_FIELD(GLOBALSEC, FLASH_REGION6_CTRL, EN, 1); - GWRITE_FIELD(GLOBALSEC, FLASH_REGION6_CTRL, RD_EN, 1); - GWRITE_FIELD(GLOBALSEC, FLASH_REGION6_CTRL, WR_EN, 1); -} - /* * Verify that the passed in block fits into the valid area. If it does, and * is destined to the base address of the area - erase the area contents. @@ -128,7 +119,7 @@ static uint8_t check_update_chunk(uint32_t block_offset, size_t body_size) size = valid_sections.ro_top_offset - valid_sections.ro_base_offset; /* backup RO area write access needs to be enabled. */ - open_ro_window(base, size); + flash_open_ro_window(base, size); if (flash_physical_erase(base, size) != EC_SUCCESS) { CPRINTF("%s:%d erase failure of 0x%x..+0x%x\n", __func__, __LINE__, base, size); |