diff options
Diffstat (limited to 'src/soc/intel/fsp_baytrail/nvm.c')
-rw-r--r-- | src/soc/intel/fsp_baytrail/nvm.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/soc/intel/fsp_baytrail/nvm.c b/src/soc/intel/fsp_baytrail/nvm.c index d1e5223996..02244636f8 100644 --- a/src/soc/intel/fsp_baytrail/nvm.c +++ b/src/soc/intel/fsp_baytrail/nvm.c @@ -47,6 +47,15 @@ static int nvm_init(void) return 0; } +/* Convert memory mapped pointer to flash offset. */ +static inline uint32_t to_flash_offset(void *p) +{ +#ifndef CONFIG_ROM_SIZE +#error CONFIG_ROM_SIZE must be set. +#endif + return CONFIG_ROM_SIZE + (uintptr_t)p; +} + int nvm_is_erased(const void *start, size_t size) { const uint8_t *cur = start; @@ -65,7 +74,7 @@ int nvm_erase(void *start, size_t size) { if (nvm_init() < 0) return -1; - flash->erase(flash, to_flash_offset(flash, start), size); + flash->erase(flash, to_flash_offset(start), size); return 0; } @@ -74,6 +83,6 @@ int nvm_write(void *start, const void *data, size_t size) { if (nvm_init() < 0) return -1; - flash->write(flash, to_flash_offset(flash, start), size, data); + flash->write(flash, to_flash_offset(start), size, data); return 0; } |